ember-promise-modals 4.1.0 → 5.0.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 +10 -33
- package/addon-main.cjs +4 -0
- package/dist/_app_/components/epm-modal-container.js +1 -0
- package/dist/_app_/components/epm-modal.js +1 -0
- package/dist/_app_/helpers/open-modal.js +1 -0
- package/dist/_app_/services/modals.js +1 -0
- package/{addon/styles/ember-promise-modals.css → dist/components/epm-modal-container.css} +17 -15
- package/dist/components/epm-modal-container.js +14 -0
- package/dist/components/epm-modal-container.js.map +1 -0
- package/{addon/components/modal.js → dist/components/epm-modal.js} +26 -48
- package/dist/components/epm-modal.js.map +1 -0
- package/{addon → dist}/helpers/open-modal.js +13 -12
- package/dist/helpers/open-modal.js.map +1 -0
- package/{addon → dist}/modal.js +10 -34
- package/dist/modal.js.map +1 -0
- package/{addon → dist}/services/modals.js +7 -34
- package/dist/services/modals.js.map +1 -0
- package/{addon-test-support → dist/test-support}/index.js +4 -7
- package/dist/test-support/index.js.map +1 -0
- package/package.json +49 -78
- package/.prettierignore +0 -27
- package/.release-it.js +0 -20
- package/CHANGELOG.md +0 -224
- package/DEPRECATIONS.md +0 -91
- package/MIGRATION.md +0 -80
- package/addon/components/modal-container.js +0 -11
- package/addon/templates/components/modal-container.hbs +0 -12
- package/addon/templates/components/modal.hbs +0 -6
- package/app/components/epm-modal-container.js +0 -1
- package/app/components/epm-modal.js +0 -1
- package/app/helpers/open-modal.js +0 -1
- package/app/services/modals.js +0 -1
- package/config/environment.js +0 -5
- package/index.js +0 -45
- package/pnpm-lock.yaml +0 -13232
- package/renovate.json +0 -29
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<p align="center"><img src="./
|
|
1
|
+
<p align="center"><img src="./packages/test-app/public/ember-promise-modals-logo.svg" role="presentation" alt="" width="600" height="400" /></p>
|
|
2
2
|
|
|
3
3
|
# ember-promise-modals
|
|
4
4
|
|
|
@@ -10,9 +10,9 @@ The better way to handle modals in your Ember.js apps.
|
|
|
10
10
|
|
|
11
11
|
## Compatibility
|
|
12
12
|
|
|
13
|
-
- Ember.js v3.
|
|
14
|
-
- Ember CLI v3.
|
|
15
|
-
- Node.js
|
|
13
|
+
- Ember.js v3.28 or above
|
|
14
|
+
- Ember CLI v3.28 or above
|
|
15
|
+
- Node.js v16 or above
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
@@ -193,37 +193,11 @@ The CSS animations which are applied by the custom CSS class _must_ end in
|
|
|
193
193
|
Examples for custom animations and how to apply them can be found in the addon's
|
|
194
194
|
dummy application.
|
|
195
195
|
|
|
196
|
-
See [the application.js controller](./
|
|
196
|
+
See [the application.js controller](./packages/test-app/app/controllers/application.js)
|
|
197
197
|
for how the modals are opened in your JavaScript actions and look at
|
|
198
|
-
[app.css](./
|
|
198
|
+
[app.css](./packages/test-app/app/styles/app.css) for the style definition of these
|
|
199
199
|
custom animations.
|
|
200
200
|
|
|
201
|
-
### CSS Variables
|
|
202
|
-
|
|
203
|
-
⚠️ This functionality will be removed in 5.0.0, checkout the [DEPRECATIONS.md]('https://github.com/mainmatter/ember-promise-modals/blob/main/DEPRECATIONS.md#postcss-process) guide.
|
|
204
|
-
|
|
205
|
-
The addons CSS is run through PostCSS by default, which will create static
|
|
206
|
-
fallbacks for all custom properties using their defaults.
|
|
207
|
-
|
|
208
|
-
If your application uses PostCSS by itself, you can set `excludeCSS` to `true`
|
|
209
|
-
inside your `ember-cli-build.js`:
|
|
210
|
-
|
|
211
|
-
```js
|
|
212
|
-
let app = new EmberAddon(defaults, {
|
|
213
|
-
// Add options here
|
|
214
|
-
'ember-promise-modals': {
|
|
215
|
-
excludeCSS: true,
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Done that, you can use [postcss-import](https://github.com/postcss/postcss-import)
|
|
221
|
-
to import the uncompiled addon styles in your projects `app/styles/app.css`:
|
|
222
|
-
|
|
223
|
-
```css
|
|
224
|
-
@import 'ember-promise-modals';
|
|
225
|
-
```
|
|
226
|
-
|
|
227
201
|
## Accessibility
|
|
228
202
|
|
|
229
203
|
User can press the <kbd>Esc</kbd> key to close the modal.
|
|
@@ -309,7 +283,10 @@ module('Application | ...', function (hooks) {
|
|
|
309
283
|
|
|
310
284
|
## Migration guide
|
|
311
285
|
|
|
312
|
-
See the [Migration](MIGRATION.md) guide for details
|
|
286
|
+
See the [Migration](MIGRATION.md) guide for details:
|
|
287
|
+
|
|
288
|
+
- From 0.x.x to 1.x.x about the replacement of ember-animated powered animations with CSS-based animations.
|
|
289
|
+
- From v4.x.x to v5.x.x about the removal of the PostCSS process.
|
|
313
290
|
|
|
314
291
|
## Contributing
|
|
315
292
|
|
package/addon-main.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "ember-promise-modals/components/epm-modal-container";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "ember-promise-modals/components/epm-modal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "ember-promise-modals/helpers/open-modal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "ember-promise-modals/services/modals";
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
@layer ember-promise-modals {
|
|
2
|
+
:root {
|
|
3
|
+
/* The named -duration and -delay variables will be lowered to near zero when using the setupPromiseModals test helper */
|
|
4
|
+
--epm-animation-backdrop-in-duration: 0.3s;
|
|
5
|
+
--epm-animation-backdrop-out-duration: 0.18s;
|
|
6
|
+
--epm-animation-modal-in-duration: 0.3s;
|
|
7
|
+
--epm-animation-modal-out-duration: 0.18s;
|
|
8
|
+
--epm-animation-backdrop-in-delay: 0s;
|
|
9
|
+
--epm-animation-backdrop-out-delay: 0s;
|
|
10
|
+
--epm-animation-modal-in-delay: 0s;
|
|
11
|
+
--epm-animation-modal-out-delay: 0s;
|
|
12
|
+
--epm-animation-backdrop-in: var(--epm-animation-backdrop-in-duration) ease var(--epm-animation-backdrop-in-delay) forwards epm-backdrop-in;
|
|
13
|
+
--epm-animation-backdrop-out: var(--epm-animation-backdrop-out-duration) ease var(--epm-animation-backdrop-out-delay) forwards epm-backdrop-out;
|
|
14
|
+
--epm-animation-modal-in: var(--epm-animation-modal-in-duration) ease-out var(--epm-animation-modal-in-delay) forwards epm-modal-in;
|
|
15
|
+
--epm-animation-modal-out: var(--epm-animation-modal-out-duration) ease-out var(--epm-animation-modal-out-delay) forwards epm-modal-out;
|
|
16
|
+
--epm-backdrop-background: #2d3748CD;
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Component, { setComponentTemplate } from '@ember/component';
|
|
2
|
+
import { inject } from '@ember/service';
|
|
3
|
+
import './epm-modal-container.css';
|
|
4
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
|
+
|
|
6
|
+
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
|
+
|
|
8
|
+
var epmModalContainer = setComponentTemplate(TEMPLATE, Component.extend({
|
|
9
|
+
tagName: '',
|
|
10
|
+
modals: inject()
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
export { epmModalContainer as default };
|
|
14
|
+
//# sourceMappingURL=epm-modal-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epm-modal-container.js","sources":["../../src/components/epm-modal-container.hbs","../../src/components/epm-modal-container.js"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default 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}}\")","import Component from '@ember/component';\nimport { inject as service } from '@ember/service';\n\nimport './epm-modal-container.css';\n\nexport default Component.extend({\n tagName: '',\n\n modals: service(),\n});\n"],"names":["setComponentTemplate","TEMPLATE","Component","extend","tagName","modals","service"],"mappings":";;;;;AACA,eAAe,kBAAkB,CAAC,iXAAiX;;ACInZ,wBAAAA,oBAAA,CAAAC,QAAA,EAAeC,SAAS,CAACC,MAAM,CAAC;AAC9BC,EAAAA,OAAO,EAAE,EAAE;EAEXC,MAAM,EAAEC,MAAO,EAAC;AAClB,CAAC,CAAC,CAAA;;;;"}
|
|
@@ -1,98 +1,83 @@
|
|
|
1
|
-
import Component from '@ember/component';
|
|
1
|
+
import Component, { setComponentTemplate } from '@ember/component';
|
|
2
2
|
import { set } from '@ember/object';
|
|
3
3
|
import { readOnly } from '@ember/object/computed';
|
|
4
4
|
import { guidFor } from '@ember/object/internals';
|
|
5
|
-
import { inject
|
|
6
|
-
|
|
5
|
+
import { inject } from '@ember/service';
|
|
7
6
|
import { createFocusTrap } from 'focus-trap';
|
|
7
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default Component.extend({
|
|
12
|
-
layout,
|
|
9
|
+
var TEMPLATE = precompileTemplate("{{!-- template-lint-disable no-action --}}\n<div id={{this.modalElementId}} class=\"epm-modal {{this.optionsClassName}} {{this.animatingClass}}\">\n {{#let (component (ensure-safe-component @modal._componentClass) data=@modal._data close=(action \"close\")) as |ModalComponent|}}\n <ModalComponent />\n {{/let}}\n</div>");
|
|
13
10
|
|
|
11
|
+
var epmModal = setComponentTemplate(TEMPLATE, Component.extend({
|
|
14
12
|
tagName: '',
|
|
15
13
|
outAnimationClass: 'epm-out',
|
|
16
14
|
animatingClass: '',
|
|
17
|
-
|
|
18
|
-
modals: service(),
|
|
19
|
-
|
|
15
|
+
modals: inject(),
|
|
20
16
|
optionsClassName: readOnly('modal._options.className'),
|
|
21
|
-
|
|
22
17
|
modalElementId: null,
|
|
23
18
|
focusTrapOptions: null,
|
|
24
19
|
_animationEnd: null,
|
|
25
|
-
|
|
26
20
|
init() {
|
|
27
21
|
this._super(...arguments);
|
|
28
|
-
|
|
29
22
|
set(this, 'modalElementId', guidFor(this));
|
|
30
|
-
|
|
31
23
|
this.modal._componentInstance = this;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
let {
|
|
25
|
+
focusTrapOptions: globalFocusTrapOptions
|
|
26
|
+
} = this.modals;
|
|
27
|
+
let {
|
|
28
|
+
focusTrapOptions: localFocusTrapOptions
|
|
29
|
+
} = this.modal._options;
|
|
36
30
|
if (localFocusTrapOptions !== null) {
|
|
37
31
|
this.focusTrapOptions = localFocusTrapOptions || globalFocusTrapOptions;
|
|
38
32
|
}
|
|
39
33
|
},
|
|
40
|
-
|
|
41
34
|
didInsertElement() {
|
|
42
35
|
this._super(...arguments);
|
|
43
|
-
|
|
44
36
|
this._addFocusTrap();
|
|
45
37
|
this._addAnimationListeners();
|
|
46
38
|
|
|
47
39
|
// animating in starts when the element is added to the DOM. Inform the service about it.
|
|
48
40
|
this.modals._onModalAnimationStart();
|
|
49
41
|
},
|
|
50
|
-
|
|
51
42
|
willDestroyElement() {
|
|
52
43
|
this.destroyModal();
|
|
53
|
-
|
|
54
44
|
this._super(...arguments);
|
|
55
45
|
},
|
|
56
|
-
|
|
57
46
|
_getElement() {
|
|
58
47
|
return document.getElementById(this.modalElementId);
|
|
59
48
|
},
|
|
60
|
-
|
|
61
49
|
_addFocusTrap() {
|
|
62
50
|
let element = this._getElement();
|
|
63
|
-
|
|
64
51
|
if (!this.focusTrapOptions) {
|
|
65
52
|
return;
|
|
66
53
|
}
|
|
67
|
-
|
|
68
54
|
let options = {
|
|
69
55
|
...this.focusTrapOptions,
|
|
70
56
|
fallbackFocus: element,
|
|
71
57
|
onDeactivate: (...args) => {
|
|
72
58
|
this.focusTrapOptions.onDeactivate?.(...args);
|
|
73
|
-
|
|
74
59
|
if (this.isDestroyed || this.isDestroying) {
|
|
75
60
|
return;
|
|
76
61
|
}
|
|
77
|
-
|
|
78
62
|
this.closeModal();
|
|
79
|
-
}
|
|
63
|
+
}
|
|
80
64
|
};
|
|
81
|
-
|
|
82
65
|
this.focusTrap = createFocusTrap(element, options);
|
|
83
66
|
this.focusTrap.activate();
|
|
84
67
|
},
|
|
85
|
-
|
|
86
68
|
_removeFocusTrap(onDeactivate = this.focusTrapOptions?.onDeactivate) {
|
|
87
69
|
if (!this.focusTrap) {
|
|
88
70
|
return;
|
|
89
71
|
}
|
|
90
|
-
|
|
91
|
-
|
|
72
|
+
this.focusTrap.deactivate({
|
|
73
|
+
onDeactivate
|
|
74
|
+
});
|
|
92
75
|
},
|
|
93
|
-
|
|
94
76
|
_addAnimationListeners() {
|
|
95
|
-
this._animationEnd = ({
|
|
77
|
+
this._animationEnd = ({
|
|
78
|
+
target,
|
|
79
|
+
animationName
|
|
80
|
+
}) => {
|
|
96
81
|
// ignore animations bubbling up
|
|
97
82
|
if (target !== this._getElement()) {
|
|
98
83
|
return;
|
|
@@ -100,32 +85,26 @@ export default Component.extend({
|
|
|
100
85
|
|
|
101
86
|
// An animation has ended, inform the modals service
|
|
102
87
|
this.modals._onModalAnimationEnd();
|
|
103
|
-
|
|
104
88
|
let isOutAnimation = animationName.substring(animationName.length - 4) === '-out';
|
|
105
89
|
if (isOutAnimation) {
|
|
106
90
|
this.modal._remove();
|
|
107
91
|
}
|
|
108
92
|
};
|
|
109
|
-
|
|
110
93
|
let element = this._getElement();
|
|
111
94
|
if (element) {
|
|
112
95
|
element.addEventListener('animationend', this._animationEnd);
|
|
113
96
|
}
|
|
114
97
|
},
|
|
115
|
-
|
|
116
98
|
_removeAnimationListeners() {
|
|
117
99
|
if (!this._animationEnd) {
|
|
118
100
|
return;
|
|
119
101
|
}
|
|
120
|
-
|
|
121
102
|
let element = this._getElement();
|
|
122
103
|
if (element) {
|
|
123
104
|
element.removeEventListener('animationend', this._animationEnd);
|
|
124
105
|
}
|
|
125
|
-
|
|
126
106
|
this._animationEnd = null;
|
|
127
107
|
},
|
|
128
|
-
|
|
129
108
|
destroyModal() {
|
|
130
109
|
// Remove the focus trap without triggering the optional onDeactivate() hook
|
|
131
110
|
this._removeFocusTrap(null);
|
|
@@ -136,26 +115,25 @@ export default Component.extend({
|
|
|
136
115
|
// make sure that we remove the modal, also resolving the test waiter
|
|
137
116
|
this.modal._remove();
|
|
138
117
|
},
|
|
139
|
-
|
|
140
118
|
closeModal(result) {
|
|
141
119
|
if (this.animatingClass !== '') {
|
|
142
120
|
return;
|
|
143
121
|
}
|
|
144
|
-
|
|
145
122
|
this.modals._onModalAnimationStart();
|
|
146
123
|
|
|
147
124
|
// This triggers the out animation, which in turn will remove the modal after it completes
|
|
148
125
|
set(this, 'animatingClass', this.outAnimationClass);
|
|
149
|
-
|
|
150
126
|
this.modal._resolve(result);
|
|
151
127
|
},
|
|
152
|
-
|
|
153
128
|
actions: {
|
|
154
129
|
close(result) {
|
|
155
130
|
this.closeModal(result);
|
|
156
131
|
|
|
157
132
|
// Remove the focus trap, triggering the onDeactivate() hook
|
|
158
133
|
this._removeFocusTrap();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
|
|
138
|
+
export { epmModal as default };
|
|
139
|
+
//# sourceMappingURL=epm-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epm-modal.js","sources":["../../src/components/epm-modal.hbs","../../src/components/epm-modal.js"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!-- template-lint-disable no-action --}}\\n<div id={{this.modalElementId}} class=\\\"epm-modal {{this.optionsClassName}} {{this.animatingClass}}\\\">\\n {{#let (component (ensure-safe-component @modal._componentClass) data=@modal._data close=(action \\\"close\\\")) as |ModalComponent|}}\\n <ModalComponent />\\n {{/let}}\\n</div>\")","import Component from '@ember/component';\nimport { set } from '@ember/object';\nimport { readOnly } from '@ember/object/computed';\nimport { guidFor } from '@ember/object/internals';\nimport { inject as service } from '@ember/service';\n\nimport { createFocusTrap } from 'focus-trap';\n\nexport default Component.extend({\n tagName: '',\n outAnimationClass: 'epm-out',\n animatingClass: '',\n\n modals: service(),\n\n optionsClassName: readOnly('modal._options.className'),\n\n modalElementId: null,\n focusTrapOptions: null,\n _animationEnd: null,\n\n init() {\n this._super(...arguments);\n\n set(this, 'modalElementId', guidFor(this));\n\n this.modal._componentInstance = this;\n\n let { focusTrapOptions: globalFocusTrapOptions } = this.modals;\n let { focusTrapOptions: localFocusTrapOptions } = this.modal._options;\n\n if (localFocusTrapOptions !== null) {\n this.focusTrapOptions = localFocusTrapOptions || globalFocusTrapOptions;\n }\n },\n\n didInsertElement() {\n this._super(...arguments);\n\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\n willDestroyElement() {\n this.destroyModal();\n\n this._super(...arguments);\n },\n\n _getElement() {\n return document.getElementById(this.modalElementId);\n },\n\n _addFocusTrap() {\n let element = this._getElement();\n\n if (!this.focusTrapOptions) {\n return;\n }\n\n let options = {\n ...this.focusTrapOptions,\n fallbackFocus: 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(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._getElement()) {\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.modal._remove();\n }\n };\n\n let element = this._getElement();\n if (element) {\n element.addEventListener('animationend', this._animationEnd);\n }\n },\n\n _removeAnimationListeners() {\n if (!this._animationEnd) {\n return;\n }\n\n let element = this._getElement();\n if (element) {\n 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.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 set(this, 'animatingClass', this.outAnimationClass);\n\n this.modal._resolve(result);\n },\n\n actions: {\n close(result) {\n this.closeModal(result);\n\n // Remove the focus trap, triggering the onDeactivate() hook\n this._removeFocusTrap();\n },\n },\n});\n"],"names":["setComponentTemplate","TEMPLATE","Component","extend","tagName","outAnimationClass","animatingClass","modals","service","optionsClassName","readOnly","modalElementId","focusTrapOptions","_animationEnd","init","_super","arguments","set","guidFor","modal","_componentInstance","globalFocusTrapOptions","localFocusTrapOptions","_options","didInsertElement","_addFocusTrap","_addAnimationListeners","_onModalAnimationStart","willDestroyElement","destroyModal","_getElement","document","getElementById","element","options","fallbackFocus","onDeactivate","args","isDestroyed","isDestroying","closeModal","focusTrap","createFocusTrap","activate","_removeFocusTrap","deactivate","target","animationName","_onModalAnimationEnd","isOutAnimation","substring","length","_remove","addEventListener","_removeAnimationListeners","removeEventListener","result","_resolve","actions","close"],"mappings":";;;;;;;;AACA,eAAe,kBAAkB,CAAC,sUAAsU;;ACOxW,eAAAA,oBAAA,CAAAC,QAAA,EAAeC,SAAS,CAACC,MAAM,CAAC;AAC9BC,EAAAA,OAAO,EAAE,EAAE;AACXC,EAAAA,iBAAiB,EAAE,SAAS;AAC5BC,EAAAA,cAAc,EAAE,EAAE;EAElBC,MAAM,EAAEC,MAAO,EAAE;AAEjBC,EAAAA,gBAAgB,EAAEC,QAAQ,CAAC,0BAA0B,CAAC;AAEtDC,EAAAA,cAAc,EAAE,IAAI;AACpBC,EAAAA,gBAAgB,EAAE,IAAI;AACtBC,EAAAA,aAAa,EAAE,IAAI;AAEnBC,EAAAA,IAAIA,GAAG;AACL,IAAA,IAAI,CAACC,MAAM,CAAC,GAAGC,SAAS,CAAC,CAAA;IAEzBC,GAAG,CAAC,IAAI,EAAE,gBAAgB,EAAEC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;AAE1C,IAAA,IAAI,CAACC,KAAK,CAACC,kBAAkB,GAAG,IAAI,CAAA;IAEpC,IAAI;AAAER,MAAAA,gBAAgB,EAAES,sBAAAA;KAAwB,GAAG,IAAI,CAACd,MAAM,CAAA;IAC9D,IAAI;AAAEK,MAAAA,gBAAgB,EAAEU,qBAAAA;AAAsB,KAAC,GAAG,IAAI,CAACH,KAAK,CAACI,QAAQ,CAAA;IAErE,IAAID,qBAAqB,KAAK,IAAI,EAAE;AAClC,MAAA,IAAI,CAACV,gBAAgB,GAAGU,qBAAqB,IAAID,sBAAsB,CAAA;AACzE,KAAA;GACD;AAED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AEDgB,EAAAA,YAAYA,GAAG;AACb;AACA,IAAA,IAAI,CAACe,gBAAgB,CAAC,IAAI,CAAC,CAAA;;AAE3B;IACA,IAAI,CAACU,yBAAyB,EAAE,CAAA;;AAEhC;AACA,IAAA,IAAI,CAACnC,KAAK,CAACiC,OAAO,EAAE,CAAA;GACrB;EAEDZ,UAAUA,CAACgB,MAAM,EAAE;AACjB,IAAA,IAAI,IAAI,CAAClD,cAAc,KAAK,EAAE,EAAE;AAC9B,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,IAAI,CAACC,MAAM,CAACoB,sBAAsB,EAAE,CAAA;;AAEpC;IACAV,GAAG,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAACZ,iBAAiB,CAAC,CAAA;AAEnD,IAAA,IAAI,CAACc,KAAK,CAACsC,QAAQ,CAACD,MAAM,CAAC,CAAA;GAC5B;AAEDE,EAAAA,OAAO,EAAE;IACPC,KAAKA,CAACH,MAAM,EAAE;AACZ,MAAA,IAAI,CAAChB,UAAU,CAACgB,MAAM,CAAC,CAAA;;AAEvB;MACA,IAAI,CAACZ,gBAAgB,EAAE,CAAA;AACzB,KAAA;AACF,GAAA;AACF,CAAC,CAAC,CAAA;;;;"}
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import Helper from '@ember/component/helper';
|
|
2
|
-
import { inject
|
|
3
|
-
|
|
4
|
-
export default class OpenModalHelper extends Helper {
|
|
5
|
-
@service modals;
|
|
2
|
+
import { inject } from '@ember/service';
|
|
3
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
6
4
|
|
|
5
|
+
class OpenModalHelper extends Helper {
|
|
6
|
+
static {
|
|
7
|
+
g(this.prototype, "modals", [inject]);
|
|
8
|
+
}
|
|
9
|
+
#modals = (i(this, "modals"), void 0);
|
|
7
10
|
modal = null;
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
compute([modalComponent, data, options], {
|
|
12
|
+
close
|
|
13
|
+
}) {
|
|
10
14
|
this.showModal(modalComponent, data, options, close);
|
|
11
15
|
}
|
|
12
|
-
|
|
13
16
|
async showModal(modalComponent, data, options, close) {
|
|
14
17
|
this.modal = this.modals.open(modalComponent, data, options);
|
|
15
|
-
|
|
16
18
|
let success = await this.modal;
|
|
17
|
-
|
|
18
19
|
this.modal = null;
|
|
19
|
-
|
|
20
20
|
if (close) {
|
|
21
21
|
close(success);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
hideModal() {
|
|
26
25
|
this.modal?.close();
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
willDestroy() {
|
|
30
28
|
this.hideModal();
|
|
31
29
|
super.willDestroy(...arguments);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
32
|
+
|
|
33
|
+
export { OpenModalHelper as default };
|
|
34
|
+
//# sourceMappingURL=open-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-modal.js","sources":["../../src/helpers/open-modal.js"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport { inject as service } from '@ember/service';\n\nexport default class OpenModalHelper extends Helper {\n @service modals;\n\n modal = null;\n\n compute([modalComponent, data, options], { close }) {\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 if (close) {\n close(success);\n }\n }\n\n hideModal() {\n this.modal?.close();\n }\n\n willDestroy() {\n this.hideModal();\n super.willDestroy(...arguments);\n }\n}\n"],"names":["OpenModalHelper","Helper","g","this","prototype","service","i","void 0","modal","compute","modalComponent","data","options","close","showModal","modals","open","success","hideModal","willDestroy","arguments"],"mappings":";;;;AAGe,MAAMA,eAAe,SAASC,MAAM,CAAC;AAAA,EAAA;AAAAC,IAAAA,CAAA,CAAAC,IAAA,CAAAC,SAAA,aACjDC,MAAO,CAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAAA,OAAA,IAAAC,CAAA,CAAAH,IAAA,aAAAI,KAAA,CAAA,EAAA;AAERC,EAAAA,KAAK,GAAG,IAAI,CAAA;EAEZC,OAAOA,CAAC,CAACC,cAAc,EAAEC,IAAI,EAAEC,OAAO,CAAC,EAAE;AAAEC,IAAAA,KAAAA;AAAM,GAAC,EAAE;IAClD,IAAI,CAACC,SAAS,CAACJ,cAAc,EAAEC,IAAI,EAAEC,OAAO,EAAEC,KAAK,CAAC,CAAA;AACtD,GAAA;EAEA,MAAMC,SAASA,CAACJ,cAAc,EAAEC,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAE;AACpD,IAAA,IAAI,CAACL,KAAK,GAAG,IAAI,CAACO,MAAM,CAACC,IAAI,CAACN,cAAc,EAAEC,IAAI,EAAEC,OAAO,CAAC,CAAA;AAE5D,IAAA,IAAIK,OAAO,GAAG,MAAM,IAAI,CAACT,KAAK,CAAA;IAE9B,IAAI,CAACA,KAAK,GAAG,IAAI,CAAA;AAEjB,IAAA,IAAIK,KAAK,EAAE;MACTA,KAAK,CAACI,OAAO,CAAC,CAAA;AAChB,KAAA;AACF,GAAA;AAEAC,EAAAA,SAASA,GAAG;AACV,IAAA,IAAI,CAACV,KAAK,EAAEK,KAAK,EAAE,CAAA;AACrB,GAAA;AAEAM,EAAAA,WAAWA,GAAG;IACZ,IAAI,CAACD,SAAS,EAAE,CAAA;AAChB,IAAA,KAAK,CAACC,WAAW,CAAC,GAAGC,SAAS,CAAC,CAAA;AACjC,GAAA;AACF;;;;"}
|
package/{addon → dist}/modal.js
RENAMED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
// eslint-disable-next-line ember/no-computed-properties-in-native-classes
|
|
2
1
|
import { computed, set } from '@ember/object';
|
|
3
2
|
import { waitForPromise } from '@ember/test-waiters';
|
|
4
|
-
|
|
5
3
|
import { defer } from 'rsvp';
|
|
4
|
+
import { n } from 'decorator-transforms/runtime';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @property {Function} [onAnimationModalOutEnd]
|
|
10
|
-
* @property {String} [className] - CSS class name passed to the modal element
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @class Modal
|
|
15
|
-
* @param {Service} service
|
|
16
|
-
* @param {String} componentClass
|
|
17
|
-
* @param {any} data
|
|
18
|
-
* @param {ModalOptions} options
|
|
19
|
-
* @method close - closes the modal
|
|
20
|
-
* @method then - resolves when the modal is closed
|
|
21
|
-
*/
|
|
22
|
-
export default class Modal {
|
|
6
|
+
// eslint-disable-next-line ember/no-computed-properties-in-native-classes
|
|
7
|
+
class Modal {
|
|
23
8
|
constructor(service, componentClass, data, options = {}) {
|
|
24
9
|
this._service = service;
|
|
25
10
|
this._componentClass = componentClass;
|
|
@@ -27,68 +12,59 @@ export default class Modal {
|
|
|
27
12
|
this._options = {
|
|
28
13
|
className: '',
|
|
29
14
|
onAnimationModalOutEnd: undefined,
|
|
30
|
-
...options
|
|
15
|
+
...options
|
|
31
16
|
};
|
|
32
17
|
this._result = undefined;
|
|
33
18
|
this._deferred = defer();
|
|
34
19
|
this._deferredOutAnimation = undefined;
|
|
35
20
|
this._componentInstance = undefined;
|
|
36
21
|
}
|
|
37
|
-
|
|
38
22
|
get result() {
|
|
39
23
|
return this._result;
|
|
40
24
|
}
|
|
41
|
-
|
|
42
|
-
@computed('_deferredOutAnimation')
|
|
43
25
|
get isClosing() {
|
|
44
26
|
return Boolean(this._deferredOutAnimation);
|
|
45
27
|
}
|
|
46
|
-
|
|
28
|
+
static {
|
|
29
|
+
n(this.prototype, "isClosing", [computed('_deferredOutAnimation')]);
|
|
30
|
+
}
|
|
47
31
|
close(result) {
|
|
48
32
|
if (this._componentInstance) {
|
|
49
33
|
this._componentInstance.closeModal(result);
|
|
50
34
|
}
|
|
51
35
|
}
|
|
52
|
-
|
|
53
36
|
then(onFulfilled, onRejected) {
|
|
54
37
|
return this._deferred.promise.then(onFulfilled, onRejected);
|
|
55
38
|
}
|
|
56
|
-
|
|
57
39
|
_destroy() {
|
|
58
40
|
if (!this._componentInstance) {
|
|
59
41
|
return;
|
|
60
42
|
}
|
|
61
|
-
|
|
62
43
|
this._componentInstance.destroyModal();
|
|
63
44
|
}
|
|
64
|
-
|
|
65
45
|
_resolve(result) {
|
|
66
46
|
if (this._deferredOutAnimation) {
|
|
67
47
|
return;
|
|
68
48
|
}
|
|
69
|
-
|
|
70
49
|
set(this, '_deferredOutAnimation', defer());
|
|
71
50
|
if (this._options.onAnimationModalOutEnd) {
|
|
72
51
|
this._deferredOutAnimation.promise.then(() => this._options.onAnimationModalOutEnd()).catch(() => {});
|
|
73
52
|
}
|
|
74
|
-
|
|
75
53
|
this._result = result;
|
|
76
54
|
this._deferred.resolve(result);
|
|
77
|
-
|
|
78
55
|
waitForPromise(this._deferredOutAnimation.promise);
|
|
79
56
|
}
|
|
80
|
-
|
|
81
57
|
_remove() {
|
|
82
58
|
this._service._stack.removeObject(this);
|
|
83
|
-
|
|
84
59
|
if (this._service._stack.length === 0) {
|
|
85
60
|
this._service._onLastModalRemoved();
|
|
86
61
|
}
|
|
87
|
-
|
|
88
62
|
this._componentInstance = undefined;
|
|
89
|
-
|
|
90
63
|
if (this._deferredOutAnimation) {
|
|
91
64
|
this._deferredOutAnimation.resolve();
|
|
92
65
|
}
|
|
93
66
|
}
|
|
94
67
|
}
|
|
68
|
+
|
|
69
|
+
export { Modal as default };
|
|
70
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../src/modal.js"],"sourcesContent":["// eslint-disable-next-line ember/no-computed-properties-in-native-classes\nimport { computed, set } from '@ember/object';\nimport { waitForPromise } from '@ember/test-waiters';\n\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 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._deferredOutAnimation = undefined;\n this._componentInstance = undefined;\n }\n\n get result() {\n return this._result;\n }\n\n @computed('_deferredOutAnimation')\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 set(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 this._service._stack.removeObject(this);\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","constructor","service","componentClass","data","options","_service","_componentClass","_data","_options","className","onAnimationModalOutEnd","undefined","_result","_deferred","defer","_deferredOutAnimation","_componentInstance","result","isClosing","Boolean","n","this","prototype","computed","close","closeModal","then","onFulfilled","onRejected","promise","_destroy","destroyModal","_resolve","set","catch","resolve","waitForPromise","_remove","_stack","removeObject","length","_onLastModalRemoved"],"mappings":";;;;;AAAA;AAqBe,MAAMA,KAAK,CAAC;EACzBC,WAAWA,CAACC,OAAO,EAAEC,cAAc,EAAEC,IAAI,EAAEC,OAAO,GAAG,EAAE,EAAE;IACvD,IAAI,CAACC,QA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xC,GAAA;EAEAC,QAAQA,CAACf,MAAM,EAAE;IACf,IAAI,IAAI,CAACF,qBAAqB,EAAE;AAC9B,MAAA,OAAA;AACF,KAAA;IAEAkB,GAAG,CAAC,IAAI,EAAE,uBAAuB,EAAEnB,KAAK,EAAE,CAAC,CAAA;AAC3C,IAAA,IAAI,IAAI,CAACN,QAAQ,CAACE,sBAAsB,EAAE;MACxC,IAAI,CAACK,qBAAqB,CAACc,OAAO,CAACH,IAAI,CAAC,MAAM,IAAI,CAAClB,QAAQ,CAACE,sBAAsB,EAAE,CAAC,CAACwB,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;AACvG,KAAA;IAEA,IAAI,CAACtB,OAAO,GAAGK,MAAM,CAAA;AACrB,IAAA,IAAI,CAACJ,SAAS,CAACsB,OAAO,CAAClB,MAAM,CAAC,CAAA;AAE9BmB,IAAAA,cAAc,CAAC,IAAI,CAACrB,qBAAqB,CAACc,OAAO,CAAC,CAAA;AACpD,GAAA;AAEAQ,EAAAA,OAAOA,GAAG;IACR,IAAI,CAAChC,QAAQ,CAACiC,MAAM,CAACC,YAAY,CAAC,IAAI,CAAC,CAAA;IAEvC,IAAI,IAAI,CAAClC,QAAQ,CAACiC,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;AACrC,MAAA,IAAI,CAACnC,QAAQ,CAACoC,mBAAmB,EAAE,CAAA;AACrC,KAAA;IAEA,IAAI,CAACzB,kBAAkB,GAAGL,SAAS,CAAA;IAEnC,IAAI,IAAI,CAACI,qBAAqB,EAAE;AAC9B,MAAA,IAAI,CAACA,qBAAqB,CAACoB,OAAO,EAAE,CAAA;AACtC,KAAA;AACF,GAAA;AACF;;;;"}
|
|
@@ -1,39 +1,31 @@
|
|
|
1
1
|
import { A } from '@ember/array';
|
|
2
|
-
import { deprecate } from '@ember/debug';
|
|
3
2
|
import { computed } from '@ember/object';
|
|
4
3
|
import { alias } from '@ember/object/computed';
|
|
5
4
|
import Service from '@ember/service';
|
|
5
|
+
import Modal from '../modal.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default Service.extend({
|
|
7
|
+
var modals = Service.extend({
|
|
10
8
|
count: computed('_stack.@each.isClosing', function () {
|
|
11
9
|
return this._stack.filter(modal => !modal.isClosing).length;
|
|
12
10
|
}),
|
|
13
11
|
top: alias('_stack.lastObject'),
|
|
14
|
-
|
|
15
12
|
focusTrapOptions: undefined,
|
|
16
|
-
|
|
17
13
|
init() {
|
|
18
14
|
this._super(...arguments);
|
|
19
15
|
this._stack = A([]);
|
|
20
|
-
|
|
21
16
|
if (this.focusTrapOptions !== null) {
|
|
22
17
|
this.focusTrapOptions = {
|
|
23
18
|
...(this.focusTrapOptions ?? {}),
|
|
24
|
-
clickOutsideDeactivates: this.focusTrapOptions?.clickOutsideDeactivates ?? true
|
|
19
|
+
clickOutsideDeactivates: this.focusTrapOptions?.clickOutsideDeactivates ?? true
|
|
25
20
|
};
|
|
26
21
|
}
|
|
27
22
|
},
|
|
28
|
-
|
|
29
23
|
willDestroy() {
|
|
30
24
|
this._onLastModalRemoved();
|
|
31
25
|
this._onModalAnimationEnd();
|
|
32
26
|
this._destroyModals();
|
|
33
|
-
|
|
34
27
|
this._super(...arguments);
|
|
35
28
|
},
|
|
36
|
-
|
|
37
29
|
/**
|
|
38
30
|
* @param {*} componentClass component class
|
|
39
31
|
* @param {*} data passed to the component template
|
|
@@ -41,50 +33,31 @@ export default Service.extend({
|
|
|
41
33
|
* @returns {Modal}
|
|
42
34
|
*/
|
|
43
35
|
open(componentClass, data, options) {
|
|
44
|
-
deprecate(
|
|
45
|
-
`Ember Promise Modals: For extended compatibility with Embroider and its tree-shaking ability, you need to import and pass in the component class of the modal component you want to display instead of "${componentClass}".`,
|
|
46
|
-
typeof componentClass !== 'string',
|
|
47
|
-
{
|
|
48
|
-
id: 'ember-promise-modals.modals-from-string',
|
|
49
|
-
until: '5.0.0',
|
|
50
|
-
for: 'ember-promise-modals',
|
|
51
|
-
since: {
|
|
52
|
-
enabled: '3.1.0',
|
|
53
|
-
},
|
|
54
|
-
url: 'https://github.com/mainmatter/ember-promise-modals/blob/main/DEPRECATIONS.md#ember-promise-modalsmodals-from-string',
|
|
55
|
-
},
|
|
56
|
-
);
|
|
57
|
-
|
|
58
36
|
let modal = new Modal(this, componentClass, data, options);
|
|
59
|
-
|
|
60
37
|
this._stack.pushObject(modal);
|
|
61
|
-
|
|
62
38
|
if (this._stack.length === 1) {
|
|
63
39
|
this._onFirstModalAdded();
|
|
64
40
|
}
|
|
65
|
-
|
|
66
41
|
return modal;
|
|
67
42
|
},
|
|
68
|
-
|
|
69
43
|
_destroyModals() {
|
|
70
44
|
this._stack.forEach(modal => {
|
|
71
45
|
modal._destroy();
|
|
72
46
|
});
|
|
73
47
|
},
|
|
74
|
-
|
|
75
48
|
_onFirstModalAdded() {
|
|
76
49
|
document.body.classList.add('epm-scrolling-disabled');
|
|
77
50
|
},
|
|
78
|
-
|
|
79
51
|
_onLastModalRemoved() {
|
|
80
52
|
document.body.classList.remove('epm-scrolling-disabled');
|
|
81
53
|
},
|
|
82
|
-
|
|
83
54
|
_onModalAnimationStart() {
|
|
84
55
|
document.body.classList.add('epm-animating');
|
|
85
56
|
},
|
|
86
|
-
|
|
87
57
|
_onModalAnimationEnd() {
|
|
88
58
|
document.body.classList.remove('epm-animating');
|
|
89
|
-
}
|
|
59
|
+
}
|
|
90
60
|
});
|
|
61
|
+
|
|
62
|
+
export { modals as default };
|
|
63
|
+
//# sourceMappingURL=modals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modals.js","sources":["../../src/services/modals.js"],"sourcesContent":["import { A } from '@ember/array';\nimport { computed } from '@ember/object';\nimport { alias } from '@ember/object/computed';\nimport Service from '@ember/service';\n\nimport Modal from '../modal';\n\nexport default Service.extend({\n count: computed('_stack.@each.isClosing', function () {\n return this._stack.filter(modal => !modal.isClosing).length;\n }),\n top: alias('_stack.lastObject'),\n\n focusTrapOptions: undefined,\n\n init() {\n this._super(...arguments);\n this._stack = A([]);\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 this._super(...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.pushObject(modal);\n\n if (this._stack.length === 1) {\n this._onFirstModalAdded();\n }\n\n return modal;\n },\n\n _destroyModals() {\n this._stack.forEach(modal => {\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":["Service","extend","count","computed","_stack","filter","modal","isClosing","length","top","alias","focusTrapOptions","undefined","init","_super","arguments","A","clickOutsideDeactivates","willDestroy","_onLastModalRemoved","_onModalAnimationEnd","_destroyModals","open","componentClass","data","options","Modal","pushObject","_onFirstModalAdded","forEach","_destroy","document","body","classList","add","remove","_onModalAnimationStart"],"mappings":";;;;;;AAOA,aAAeA,OAAO,CAACC,MAAM,CAAC;AAC5BC,EAAAA,KAAK,EAAEC,QAAQ,CAAC,wBAAwB,EAAE,YAAY;AACpD,IAAA,OAAO,IAAI,CAACC,MAAM,CAACC,MAAM,CAACC,KAAK,IAAI,CAACA,KAAK,CAACC,SAAS,CAAC,CAACC,MAAM,CAAA;AAC7D,GAAC,CAAC;AACFC,EAAAA,GAAG,EAAEC,KAAK,CAAC,mBAAmB,CAAC;AAE/BC,EAAAA,gBAAgB,EAAEC,S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