ember-promise-modals 4.1.0 → 5.0.1
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 +9 -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 +21 -0
- package/dist/components/epm-modal-container.js.map +1 -0
- package/dist/components/epm-modal.js +147 -0
- package/dist/components/epm-modal.js.map +1 -0
- package/{addon → dist}/helpers/open-modal.js +14 -12
- package/dist/helpers/open-modal.js.map +1 -0
- package/{addon → dist}/modal.js +11 -34
- package/dist/modal.js.map +1 -0
- package/{addon → dist}/services/modals.js +8 -34
- package/dist/services/modals.js.map +1 -0
- package/{addon-test-support → dist/test-support}/index.js +5 -7
- package/dist/test-support/index.js.map +1 -0
- package/package.json +61 -86
- 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/components/modal.js +0 -161
- 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,8 @@ The better way to handle modals in your Ember.js apps.
|
|
|
10
10
|
|
|
11
11
|
## Compatibility
|
|
12
12
|
|
|
13
|
-
- Ember.js v3.
|
|
14
|
-
-
|
|
15
|
-
- Node.js v12, v14 or above
|
|
13
|
+
- Ember.js v3.28 or above
|
|
14
|
+
- Embroider or ember-auto-import v2
|
|
16
15
|
|
|
17
16
|
## Installation
|
|
18
17
|
|
|
@@ -193,37 +192,11 @@ The CSS animations which are applied by the custom CSS class _must_ end in
|
|
|
193
192
|
Examples for custom animations and how to apply them can be found in the addon's
|
|
194
193
|
dummy application.
|
|
195
194
|
|
|
196
|
-
See [the application.js controller](./
|
|
195
|
+
See [the application.js controller](./packages/test-app/app/controllers/application.js)
|
|
197
196
|
for how the modals are opened in your JavaScript actions and look at
|
|
198
|
-
[app.css](./
|
|
197
|
+
[app.css](./packages/test-app/app/styles/app.css) for the style definition of these
|
|
199
198
|
custom animations.
|
|
200
199
|
|
|
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
200
|
## Accessibility
|
|
228
201
|
|
|
229
202
|
User can press the <kbd>Esc</kbd> key to close the modal.
|
|
@@ -309,7 +282,10 @@ module('Application | ...', function (hooks) {
|
|
|
309
282
|
|
|
310
283
|
## Migration guide
|
|
311
284
|
|
|
312
|
-
See the [Migration](MIGRATION.md) guide for details
|
|
285
|
+
See the [Migration](MIGRATION.md) guide for details:
|
|
286
|
+
|
|
287
|
+
- From 0.x.x to 1.x.x about the replacement of ember-animated powered animations with CSS-based animations.
|
|
288
|
+
- From v4.x.x to v5.x.x about the removal of the PostCSS process.
|
|
313
289
|
|
|
314
290
|
## Contributing
|
|
315
291
|
|
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,21 @@
|
|
|
1
|
+
import "./epm-modal-container.css"
|
|
2
|
+
import { inject } from '@ember/service';
|
|
3
|
+
import Component from '@glimmer/component';
|
|
4
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
6
|
+
import { setComponentTemplate } from '@ember/component';
|
|
7
|
+
|
|
8
|
+
;
|
|
9
|
+
|
|
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}}");
|
|
11
|
+
|
|
12
|
+
class EpmModalContainer extends Component {
|
|
13
|
+
static {
|
|
14
|
+
g(this.prototype, "modals", [inject]);
|
|
15
|
+
}
|
|
16
|
+
#modals = (i(this, "modals"), void 0);
|
|
17
|
+
}
|
|
18
|
+
setComponentTemplate(TEMPLATE, EpmModalContainer);
|
|
19
|
+
|
|
20
|
+
export { EpmModalContainer as default };
|
|
21
|
+
//# sourceMappingURL=epm-modal-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epm-modal-container.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { inject } from '@ember/service';
|
|
4
|
+
import Component from '@glimmer/component';
|
|
5
|
+
import { tracked } from '@glimmer/tracking';
|
|
6
|
+
import { modifier } from 'ember-modifier';
|
|
7
|
+
import { createFocusTrap } from 'focus-trap';
|
|
8
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
9
|
+
import { g, i, n } from 'decorator-transforms/runtime';
|
|
10
|
+
import { setComponentTemplate } from '@ember/component';
|
|
11
|
+
|
|
12
|
+
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>");
|
|
13
|
+
|
|
14
|
+
class EpmModal extends Component {
|
|
15
|
+
static {
|
|
16
|
+
g(this.prototype, "modals", [inject]);
|
|
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() {
|
|
32
|
+
let {
|
|
33
|
+
focusTrapOptions: globalFocusTrapOptions
|
|
34
|
+
} = this.modals;
|
|
35
|
+
let {
|
|
36
|
+
focusTrapOptions: localFocusTrapOptions
|
|
37
|
+
} = this.args.modal._options;
|
|
38
|
+
if (localFocusTrapOptions !== undefined) {
|
|
39
|
+
return localFocusTrapOptions;
|
|
40
|
+
}
|
|
41
|
+
return globalFocusTrapOptions;
|
|
42
|
+
}
|
|
43
|
+
setup = modifier(element => {
|
|
44
|
+
this.element = element;
|
|
45
|
+
this._addFocusTrap();
|
|
46
|
+
this._addAnimationListeners();
|
|
47
|
+
|
|
48
|
+
// animating in starts when the element is added to the DOM. Inform the service about it.
|
|
49
|
+
this.modals._onModalAnimationStart();
|
|
50
|
+
return () => {
|
|
51
|
+
this.destroyModal();
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
this.args.modal._componentInstance = this;
|
|
57
|
+
}
|
|
58
|
+
_addFocusTrap() {
|
|
59
|
+
if (!this.focusTrapOptions) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let options = {
|
|
63
|
+
...this.focusTrapOptions,
|
|
64
|
+
fallbackFocus: this.element,
|
|
65
|
+
onDeactivate: (...args) => {
|
|
66
|
+
this.focusTrapOptions.onDeactivate?.(...args);
|
|
67
|
+
if (this.isDestroyed || this.isDestroying) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.closeModal();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
this.focusTrap = createFocusTrap(this.element, options);
|
|
74
|
+
this.focusTrap.activate();
|
|
75
|
+
}
|
|
76
|
+
_removeFocusTrap(onDeactivate = this.focusTrapOptions?.onDeactivate) {
|
|
77
|
+
if (!this.focusTrap) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.focusTrap.deactivate({
|
|
81
|
+
onDeactivate
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
_addAnimationListeners() {
|
|
85
|
+
this._animationEnd = ({
|
|
86
|
+
target,
|
|
87
|
+
animationName
|
|
88
|
+
}) => {
|
|
89
|
+
// ignore animations bubbling up
|
|
90
|
+
if (target !== this.element) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// An animation has ended, inform the modals service
|
|
95
|
+
this.modals._onModalAnimationEnd();
|
|
96
|
+
let isOutAnimation = animationName.substring(animationName.length - 4) === '-out';
|
|
97
|
+
if (isOutAnimation) {
|
|
98
|
+
this.args.modal._remove();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
if (this.element) {
|
|
102
|
+
this.element.addEventListener('animationend', this._animationEnd);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_removeAnimationListeners() {
|
|
106
|
+
if (!this._animationEnd) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (this.element) {
|
|
110
|
+
this.element.removeEventListener('animationend', this._animationEnd);
|
|
111
|
+
}
|
|
112
|
+
this._animationEnd = null;
|
|
113
|
+
}
|
|
114
|
+
destroyModal() {
|
|
115
|
+
// Remove the focus trap without triggering the optional onDeactivate() hook
|
|
116
|
+
this._removeFocusTrap(null);
|
|
117
|
+
|
|
118
|
+
// Remove the animation listeners
|
|
119
|
+
this._removeAnimationListeners();
|
|
120
|
+
|
|
121
|
+
// make sure that we remove the modal, also resolving the test waiter
|
|
122
|
+
this.args.modal._remove();
|
|
123
|
+
}
|
|
124
|
+
closeModal(result) {
|
|
125
|
+
if (this.animatingClass !== '') {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
this.modals._onModalAnimationStart();
|
|
129
|
+
|
|
130
|
+
// This triggers the out animation, which in turn will remove the modal after it completes
|
|
131
|
+
this.animatingClass = this.outAnimationClass;
|
|
132
|
+
this.args.modal._resolve(result);
|
|
133
|
+
}
|
|
134
|
+
close(result) {
|
|
135
|
+
this.closeModal(result);
|
|
136
|
+
|
|
137
|
+
// Remove the focus trap, triggering the onDeactivate() hook
|
|
138
|
+
this._removeFocusTrap();
|
|
139
|
+
}
|
|
140
|
+
static {
|
|
141
|
+
n(this.prototype, "close", [action]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
setComponentTemplate(TEMPLATE, EpmModal);
|
|
145
|
+
|
|
146
|
+
export { EpmModal as default };
|
|
147
|
+
//# sourceMappingURL=epm-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epm-modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
import Helper from '@ember/component/helper';
|
|
2
|
-
import { inject as service } from '@ember/service';
|
|
3
1
|
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import Helper from '@ember/component/helper';
|
|
3
|
+
import { inject } from '@ember/service';
|
|
4
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
6
5
|
|
|
6
|
+
class OpenModalHelper extends Helper {
|
|
7
|
+
static {
|
|
8
|
+
g(this.prototype, "modals", [inject]);
|
|
9
|
+
}
|
|
10
|
+
#modals = (i(this, "modals"), void 0);
|
|
7
11
|
modal = null;
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
compute([modalComponent, data, options], {
|
|
13
|
+
close
|
|
14
|
+
}) {
|
|
10
15
|
this.showModal(modalComponent, data, options, close);
|
|
11
16
|
}
|
|
12
|
-
|
|
13
17
|
async showModal(modalComponent, data, options, close) {
|
|
14
18
|
this.modal = this.modals.open(modalComponent, data, options);
|
|
15
|
-
|
|
16
19
|
let success = await this.modal;
|
|
17
|
-
|
|
18
20
|
this.modal = null;
|
|
19
|
-
|
|
20
21
|
if (close) {
|
|
21
22
|
close(success);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
|
|
25
25
|
hideModal() {
|
|
26
26
|
this.modal?.close();
|
|
27
27
|
}
|
|
28
|
-
|
|
29
28
|
willDestroy() {
|
|
30
29
|
this.hideModal();
|
|
31
30
|
super.willDestroy(...arguments);
|
|
32
31
|
}
|
|
33
32
|
}
|
|
33
|
+
|
|
34
|
+
export { OpenModalHelper as default };
|
|
35
|
+
//# sourceMappingURL=open-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/{addon → dist}/modal.js
RENAMED
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { computed, set } from '@ember/object';
|
|
3
3
|
import { waitForPromise } from '@ember/test-waiters';
|
|
4
|
-
|
|
5
4
|
import { defer } from 'rsvp';
|
|
5
|
+
import { n } from 'decorator-transforms/runtime';
|
|
6
6
|
|
|
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 {
|
|
7
|
+
// eslint-disable-next-line ember/no-computed-properties-in-native-classes
|
|
8
|
+
class Modal {
|
|
23
9
|
constructor(service, componentClass, data, options = {}) {
|
|
24
10
|
this._service = service;
|
|
25
11
|
this._componentClass = componentClass;
|
|
@@ -27,68 +13,59 @@ export default class Modal {
|
|
|
27
13
|
this._options = {
|
|
28
14
|
className: '',
|
|
29
15
|
onAnimationModalOutEnd: undefined,
|
|
30
|
-
...options
|
|
16
|
+
...options
|
|
31
17
|
};
|
|
32
18
|
this._result = undefined;
|
|
33
19
|
this._deferred = defer();
|
|
34
20
|
this._deferredOutAnimation = undefined;
|
|
35
21
|
this._componentInstance = undefined;
|
|
36
22
|
}
|
|
37
|
-
|
|
38
23
|
get result() {
|
|
39
24
|
return this._result;
|
|
40
25
|
}
|
|
41
|
-
|
|
42
|
-
@computed('_deferredOutAnimation')
|
|
43
26
|
get isClosing() {
|
|
44
27
|
return Boolean(this._deferredOutAnimation);
|
|
45
28
|
}
|
|
46
|
-
|
|
29
|
+
static {
|
|
30
|
+
n(this.prototype, "isClosing", [computed('_deferredOutAnimation')]);
|
|
31
|
+
}
|
|
47
32
|
close(result) {
|
|
48
33
|
if (this._componentInstance) {
|
|
49
34
|
this._componentInstance.closeModal(result);
|
|
50
35
|
}
|
|
51
36
|
}
|
|
52
|
-
|
|
53
37
|
then(onFulfilled, onRejected) {
|
|
54
38
|
return this._deferred.promise.then(onFulfilled, onRejected);
|
|
55
39
|
}
|
|
56
|
-
|
|
57
40
|
_destroy() {
|
|
58
41
|
if (!this._componentInstance) {
|
|
59
42
|
return;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
this._componentInstance.destroyModal();
|
|
63
45
|
}
|
|
64
|
-
|
|
65
46
|
_resolve(result) {
|
|
66
47
|
if (this._deferredOutAnimation) {
|
|
67
48
|
return;
|
|
68
49
|
}
|
|
69
|
-
|
|
70
50
|
set(this, '_deferredOutAnimation', defer());
|
|
71
51
|
if (this._options.onAnimationModalOutEnd) {
|
|
72
52
|
this._deferredOutAnimation.promise.then(() => this._options.onAnimationModalOutEnd()).catch(() => {});
|
|
73
53
|
}
|
|
74
|
-
|
|
75
54
|
this._result = result;
|
|
76
55
|
this._deferred.resolve(result);
|
|
77
|
-
|
|
78
56
|
waitForPromise(this._deferredOutAnimation.promise);
|
|
79
57
|
}
|
|
80
|
-
|
|
81
58
|
_remove() {
|
|
82
59
|
this._service._stack.removeObject(this);
|
|
83
|
-
|
|
84
60
|
if (this._service._stack.length === 0) {
|
|
85
61
|
this._service._onLastModalRemoved();
|
|
86
62
|
}
|
|
87
|
-
|
|
88
63
|
this._componentInstance = undefined;
|
|
89
|
-
|
|
90
64
|
if (this._deferredOutAnimation) {
|
|
91
65
|
this._deferredOutAnimation.resolve();
|
|
92
66
|
}
|
|
93
67
|
}
|
|
94
68
|
}
|
|
69
|
+
|
|
70
|
+
export { Modal as default };
|
|
71
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,39 +1,32 @@
|
|
|
1
|
+
|
|
1
2
|
import { A } from '@ember/array';
|
|
2
|
-
import { deprecate } from '@ember/debug';
|
|
3
3
|
import { computed } from '@ember/object';
|
|
4
4
|
import { alias } from '@ember/object/computed';
|
|
5
5
|
import Service from '@ember/service';
|
|
6
|
+
import Modal from '../modal.js';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default Service.extend({
|
|
8
|
+
var modals = Service.extend({
|
|
10
9
|
count: computed('_stack.@each.isClosing', function () {
|
|
11
10
|
return this._stack.filter(modal => !modal.isClosing).length;
|
|
12
11
|
}),
|
|
13
12
|
top: alias('_stack.lastObject'),
|
|
14
|
-
|
|
15
13
|
focusTrapOptions: undefined,
|
|
16
|
-
|
|
17
14
|
init() {
|
|
18
15
|
this._super(...arguments);
|
|
19
16
|
this._stack = A([]);
|
|
20
|
-
|
|
21
17
|
if (this.focusTrapOptions !== null) {
|
|
22
18
|
this.focusTrapOptions = {
|
|
23
19
|
...(this.focusTrapOptions ?? {}),
|
|
24
|
-
clickOutsideDeactivates: this.focusTrapOptions?.clickOutsideDeactivates ?? true
|
|
20
|
+
clickOutsideDeactivates: this.focusTrapOptions?.clickOutsideDeactivates ?? true
|
|
25
21
|
};
|
|
26
22
|
}
|
|
27
23
|
},
|
|
28
|
-
|
|
29
24
|
willDestroy() {
|
|
30
25
|
this._onLastModalRemoved();
|
|
31
26
|
this._onModalAnimationEnd();
|
|
32
27
|
this._destroyModals();
|
|
33
|
-
|
|
34
28
|
this._super(...arguments);
|
|
35
29
|
},
|
|
36
|
-
|
|
37
30
|
/**
|
|
38
31
|
* @param {*} componentClass component class
|
|
39
32
|
* @param {*} data passed to the component template
|
|
@@ -41,50 +34,31 @@ export default Service.extend({
|
|
|
41
34
|
* @returns {Modal}
|
|
42
35
|
*/
|
|
43
36
|
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
37
|
let modal = new Modal(this, componentClass, data, options);
|
|
59
|
-
|
|
60
38
|
this._stack.pushObject(modal);
|
|
61
|
-
|
|
62
39
|
if (this._stack.length === 1) {
|
|
63
40
|
this._onFirstModalAdded();
|
|
64
41
|
}
|
|
65
|
-
|
|
66
42
|
return modal;
|
|
67
43
|
},
|
|
68
|
-
|
|
69
44
|
_destroyModals() {
|
|
70
45
|
this._stack.forEach(modal => {
|
|
71
46
|
modal._destroy();
|
|
72
47
|
});
|
|
73
48
|
},
|
|
74
|
-
|
|
75
49
|
_onFirstModalAdded() {
|
|
76
50
|
document.body.classList.add('epm-scrolling-disabled');
|
|
77
51
|
},
|
|
78
|
-
|
|
79
52
|
_onLastModalRemoved() {
|
|
80
53
|
document.body.classList.remove('epm-scrolling-disabled');
|
|
81
54
|
},
|
|
82
|
-
|
|
83
55
|
_onModalAnimationStart() {
|
|
84
56
|
document.body.classList.add('epm-animating');
|
|
85
57
|
},
|
|
86
|
-
|
|
87
58
|
_onModalAnimationEnd() {
|
|
88
59
|
document.body.classList.remove('epm-animating');
|
|
89
|
-
}
|
|
60
|
+
}
|
|
90
61
|
});
|
|
62
|
+
|
|
63
|
+
export { modals as default };
|
|
64
|
+
//# sourceMappingURL=modals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modals.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
|
|
1
2
|
import { settled } from '@ember/test-helpers';
|
|
2
3
|
|
|
3
4
|
function setMinimum(propertyName) {
|
|
4
5
|
document.documentElement.style.setProperty(propertyName, '0.001s');
|
|
5
6
|
}
|
|
6
|
-
|
|
7
7
|
function unsetMinimum(propertyName) {
|
|
8
8
|
document.documentElement.style.removeProperty(propertyName);
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
export function setupPromiseModals(hooks) {
|
|
10
|
+
function setupPromiseModals(hooks) {
|
|
12
11
|
hooks.beforeEach(function () {
|
|
13
12
|
setMinimum('--epm-animation-backdrop-in-duration');
|
|
14
13
|
setMinimum('--epm-animation-backdrop-out-duration');
|
|
@@ -18,18 +17,14 @@ export function setupPromiseModals(hooks) {
|
|
|
18
17
|
setMinimum('--epm-animation-modal-out-duration');
|
|
19
18
|
setMinimum('--epm-animation-modal-in-delay');
|
|
20
19
|
setMinimum('--epm-animation-modal-out-delay');
|
|
21
|
-
|
|
22
20
|
this.modals = this.owner.lookup('service:modals');
|
|
23
21
|
});
|
|
24
|
-
|
|
25
22
|
hooks.afterEach(async function () {
|
|
26
23
|
// be sure to close all modals after a test
|
|
27
24
|
if (this.modals) {
|
|
28
25
|
this.modals._destroyModals();
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
delete this.modals;
|
|
32
|
-
|
|
33
28
|
unsetMinimum('--epm-animation-backdrop-in-duration');
|
|
34
29
|
unsetMinimum('--epm-animation-backdrop-out-duration');
|
|
35
30
|
unsetMinimum('--epm-animation-backdrop-in-delay');
|
|
@@ -43,3 +38,6 @@ export function setupPromiseModals(hooks) {
|
|
|
43
38
|
await settled();
|
|
44
39
|
});
|
|
45
40
|
}
|
|
41
|
+
|
|
42
|
+
export { setupPromiseModals };
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|