ember-promise-modals 5.0.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 +1 -2
- package/dist/components/epm-modal-container.js +14 -7
- package/dist/components/epm-modal-container.js.map +1 -1
- package/dist/components/epm-modal.js +68 -60
- package/dist/components/epm-modal.js.map +1 -1
- package/dist/helpers/open-modal.js +1 -0
- package/dist/helpers/open-modal.js.map +1 -1
- package/dist/modal.js +1 -0
- package/dist/modal.js.map +1 -1
- package/dist/services/modals.js +1 -0
- package/dist/services/modals.js.map +1 -1
- package/dist/test-support/index.js +1 -0
- package/dist/test-support/index.js.map +1 -1
- package/package.json +26 -22
package/README.md
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./epm-modal-container.css"
|
|
2
2
|
import { inject } from '@ember/service';
|
|
3
|
-
import '
|
|
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
|
+
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);
|
|
12
19
|
|
|
13
|
-
export {
|
|
20
|
+
export { EpmModalContainer as default };
|
|
14
21
|
//# 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
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { readOnly } from '@ember/object/computed';
|
|
4
|
-
import { guidFor } from '@ember/object/internals';
|
|
1
|
+
|
|
2
|
+
import { action } from '@ember/object';
|
|
5
3
|
import { inject } from '@ember/service';
|
|
4
|
+
import Component from '@glimmer/component';
|
|
5
|
+
import { tracked } from '@glimmer/tracking';
|
|
6
|
+
import { modifier } from 'ember-modifier';
|
|
6
7
|
import { createFocusTrap } from 'focus-trap';
|
|
7
8
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
9
|
+
import { g, i, n } from 'decorator-transforms/runtime';
|
|
10
|
+
import { setComponentTemplate } from '@ember/component';
|
|
8
11
|
|
|
9
|
-
var TEMPLATE = precompileTemplate("
|
|
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>");
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
modals
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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() {
|
|
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":[
|
|
1
|
+
{"version":3,"file":"epm-modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-modal.js","sources":[
|
|
1
|
+
{"version":3,"file":"open-modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/modal.js
CHANGED
package/dist/modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":[
|
|
1
|
+
{"version":3,"file":"modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/services/modals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modals.js","sources":[
|
|
1
|
+
{"version":3,"file":"modals.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-promise-modals",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "The better way to handle modals in your Ember.js apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -36,37 +36,41 @@
|
|
|
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"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "7.
|
|
45
|
-
"@babel/eslint-parser": "7.
|
|
46
|
-
"@babel/plugin-proposal-decorators": "7.
|
|
47
|
-
"@babel/plugin-transform-class-properties": "7.
|
|
48
|
-
"@
|
|
46
|
+
"@babel/core": "7.28.0",
|
|
47
|
+
"@babel/eslint-parser": "7.28.0",
|
|
48
|
+
"@babel/plugin-proposal-decorators": "7.28.0",
|
|
49
|
+
"@babel/plugin-transform-class-properties": "7.27.1",
|
|
50
|
+
"@ember/test-helpers": "5.2.2",
|
|
51
|
+
"@embroider/addon-dev": "8.1.0",
|
|
52
|
+
"@glimmer/component": "1.1.2",
|
|
49
53
|
"@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.
|
|
54
|
+
"ember-template-lint": "7.9.1",
|
|
55
|
+
"eslint": "8.57.1",
|
|
56
|
+
"eslint-config-prettier": "9.1.0",
|
|
57
|
+
"eslint-plugin-ember": "12.6.0",
|
|
58
|
+
"eslint-plugin-import-helpers": "2.0.1",
|
|
59
|
+
"eslint-plugin-n": "17.21.0",
|
|
60
|
+
"eslint-plugin-prettier": "5.5.1",
|
|
61
|
+
"eslint-plugin-promise": "6.6.0",
|
|
58
62
|
"eslint-plugin-qunit": "7.3.4",
|
|
59
63
|
"npm-run-all": "4.1.5",
|
|
60
|
-
"prettier": "
|
|
61
|
-
"rollup": "4.
|
|
64
|
+
"prettier": "3.6.2",
|
|
65
|
+
"rollup": "4.45.1",
|
|
62
66
|
"rollup-plugin-copy": "3.5.0",
|
|
63
|
-
"webpack": "5.
|
|
67
|
+
"webpack": "5.100.2"
|
|
64
68
|
},
|
|
65
69
|
"peerDependencies": {
|
|
66
|
-
"@ember/test-helpers": "^3.0.0"
|
|
70
|
+
"@ember/test-helpers": "^3.0.0 || ^5.0.0"
|
|
67
71
|
},
|
|
68
72
|
"engines": {
|
|
69
|
-
"node": ">=
|
|
73
|
+
"node": ">= 18.*"
|
|
70
74
|
},
|
|
71
75
|
"ember": {
|
|
72
76
|
"edition": "octane"
|