ember-promise-modals 4.0.0 → 4.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/CHANGELOG.md +19 -0
- package/DEPRECATIONS.md +91 -0
- package/README.md +19 -27
- package/addon/modal.js +3 -3
- package/addon/services/modals.js +18 -3
- package/addon/templates/components/modal.hbs +1 -1
- package/package.json +22 -21
- package/pnpm-lock.yaml +3069 -4072
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
|
|
7
|
+
## v4.1.0 (2024-02-01)
|
|
8
|
+
|
|
9
|
+
#### :rocket: Enhancement
|
|
10
|
+
* [#894](https://github.com/mainmatter/ember-promise-modals/pull/894) Deprecate opening a modal from string ([@BlueCutOfficial](https://github.com/BlueCutOfficial))
|
|
11
|
+
|
|
12
|
+
#### :memo: Documentation
|
|
13
|
+
* [#908](https://github.com/mainmatter/ember-promise-modals/pull/908) docs(DEPRECATIONS)/ Adjust the line about deprecated node ([@BlueCutOfficial](https://github.com/BlueCutOfficial))
|
|
14
|
+
* [#897](https://github.com/mainmatter/ember-promise-modals/pull/897) Communicate about all the major changes planned for the v2 addon ([@BlueCutOfficial](https://github.com/BlueCutOfficial))
|
|
15
|
+
|
|
16
|
+
#### :house: Internal
|
|
17
|
+
* [#907](https://github.com/mainmatter/ember-promise-modals/pull/907) Internal fix/ re-add node 14 to the list of supported engines ([@BlueCutOfficial](https://github.com/BlueCutOfficial))
|
|
18
|
+
* [#858](https://github.com/mainmatter/ember-promise-modals/pull/858) Fix CI tests for beta/canary channels ([@zeppelin](https://github.com/zeppelin))
|
|
19
|
+
|
|
20
|
+
#### Committers: 3
|
|
21
|
+
- Gabor Babicz ([@zeppelin](https://github.com/zeppelin))
|
|
22
|
+
- Marco Otte-Witte ([@marcoow](https://github.com/marcoow))
|
|
23
|
+
- Marine Dunstetter ([@BlueCutOfficial](https://github.com/BlueCutOfficial))
|
|
24
|
+
|
|
6
25
|
## v4.0.0 (2023-06-01)
|
|
7
26
|
|
|
8
27
|
#### :boom: Breaking Change
|
package/DEPRECATIONS.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Deprecations
|
|
2
|
+
|
|
3
|
+
ember-promise-modals 5.0.0 will be a [v2 addon](https://github.com/embroider-build/embroider/blob/main/README.md#for-addon-authors) compatible with Embroider ecosystem. This document describes what functionalities will no longer exist in the coming major release.
|
|
4
|
+
|
|
5
|
+
## ember-promise-modals.modals-from-string
|
|
6
|
+
|
|
7
|
+
_Added in 4.1.0, functionality to be removed in 5.0.0_
|
|
8
|
+
|
|
9
|
+
The new Embroider build system prefers static imports when dynamically invoking components. To resolve this deprecation, you need to replace the path to the modal component with an imported component class:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
// before
|
|
13
|
+
export class ApplicationController extends Controller {
|
|
14
|
+
@service modals;
|
|
15
|
+
|
|
16
|
+
@action
|
|
17
|
+
async show() {
|
|
18
|
+
await this.modals.open('my-modal');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// after
|
|
23
|
+
import MyModal from 'my-app/components/my-modal';
|
|
24
|
+
|
|
25
|
+
export class ApplicationController extends Controller {
|
|
26
|
+
@service modals;
|
|
27
|
+
|
|
28
|
+
@action
|
|
29
|
+
async show() {
|
|
30
|
+
await this.modals.open(MyModal);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> Caution: old-style components that have their template in `app/templates/components` instead of co-located next to their Javascript in `app/components` can't work correctly when discovered via their component class, because there's no way to locate the template. They should either port to being co-located (which is a simple mechanical transformation and highly recommended) or should import their own template and set it as layout as was traditional in addons before co-location was available.
|
|
36
|
+
|
|
37
|
+
-- [Replacing Component Helper.md](https://github.com/embroider-build/embroider/blob/main/docs/replacing-component-helper.md#when-youre-invoking-a-component-youve-been-given)
|
|
38
|
+
|
|
39
|
+
## PostCSS process
|
|
40
|
+
|
|
41
|
+
Currently, the addon's CSS is run through PostCSS by default, which will create static
|
|
42
|
+
fallbacks for all custom properties using their defaults. It also provides the option `excludeCSS` so you can import the uncompiled addon styles in your project's `app/styles/app.css` and run your own PostCSS using `postcss-import`:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
// before
|
|
46
|
+
let app = new EmberApp(defaults, {
|
|
47
|
+
'ember-promise-modals': {
|
|
48
|
+
excludeCSS: true,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return maybeEmbroider(app);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This functionality no longer stands in Embroider world because [v2 addons are static](https://github.com/embroider-build/embroider/blob/HEAD/docs/spec.md). When installed in your app, they don't do anything at build-time.
|
|
56
|
+
|
|
57
|
+
As most browsers have been supporting CSS variables for several years, the v2 addon will no longer process the CSS and the components will import the non-processed styles. However, if you still need the static fallbacks `postcss-preset-env` used to generate, you can re-implement the functionality on the app side with a [Webpack config](https://webpack.js.org/loaders/postcss-loader/). For instance:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
let app = new EmberApp(defaults, {});
|
|
61
|
+
|
|
62
|
+
return maybeEmbroider(app, {
|
|
63
|
+
packagerOptions: {
|
|
64
|
+
webpackConfig: {
|
|
65
|
+
module: {
|
|
66
|
+
rules: [
|
|
67
|
+
{
|
|
68
|
+
test: /\.css$/i,
|
|
69
|
+
use: [
|
|
70
|
+
{
|
|
71
|
+
loader: 'postcss-loader',
|
|
72
|
+
options: {
|
|
73
|
+
postcssOptions: {
|
|
74
|
+
plugins: [['postcss-preset-env', { stage: 3 }]],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Ember < 3.28 & node < 16 support
|
|
88
|
+
|
|
89
|
+
The v2 addon will no longer support Ember versions lower than 3.28.
|
|
90
|
+
|
|
91
|
+
Additionally, it will have dependencies such as `ember-cli-babel@8.2.0` that require node 16, so node 12 and node 14 will be removed from the supported engines.
|
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
The better way to handle modals in your Ember.js apps.
|
|
6
6
|
|
|
7
|
+
> [!NOTE]
|
|
8
|
+
> ember-promise-modals was written and is maintained by [Mainmatter](https://mainmatter.com) and contributors.
|
|
9
|
+
> We offer consulting, training, and team augmentation for Ember.js – check out our [website](https://mainmatter.com/ember-consulting/) to learn more!
|
|
10
|
+
|
|
7
11
|
## Compatibility
|
|
8
12
|
|
|
9
13
|
- Ember.js v3.4 or above
|
|
@@ -24,17 +28,18 @@ To use EPM in your project, add the target for the modals to your `application.h
|
|
|
24
28
|
<EpmModalContainer />
|
|
25
29
|
```
|
|
26
30
|
|
|
27
|
-
Then you can
|
|
31
|
+
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.
|
|
28
32
|
|
|
29
33
|
```js
|
|
30
34
|
import { inject as service } from '@ember/service';
|
|
35
|
+
import ConfirmationModal from 'my-app/components/confirmation-modal';
|
|
31
36
|
|
|
32
37
|
export default class extends Component {
|
|
33
38
|
@service modals;
|
|
34
39
|
|
|
35
40
|
@action
|
|
36
41
|
async handleOpenModal() {
|
|
37
|
-
let modal = this.modals.open(
|
|
42
|
+
let modal = this.modals.open(ConfirmationModal);
|
|
38
43
|
|
|
39
44
|
// the instance acts as a promise that resolves with anything passed to the @close function
|
|
40
45
|
modal.then(results => {
|
|
@@ -56,28 +61,12 @@ export default class extends Component {
|
|
|
56
61
|
</button>
|
|
57
62
|
```
|
|
58
63
|
|
|
59
|
-
### Embroider Optimized Apps
|
|
60
|
-
|
|
61
|
-
If your application uses [Embroider](https://github.com/embroider-build/embroider), you need to pass the component class to the `open` method instead of just the modals name. This will become the default behavior in the future.
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
import ConfirmationModal from '../components/confirmation-modal';
|
|
65
|
-
|
|
66
|
-
export default class extends Component {
|
|
67
|
-
//...
|
|
68
|
-
@action
|
|
69
|
-
handleOpenModal() {
|
|
70
|
-
this.modals.open(ConfirmationModal);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
64
|
### Passing data to the rendered component
|
|
76
65
|
|
|
77
66
|
You can pass custom data into your rendered template like so:
|
|
78
67
|
|
|
79
68
|
```js
|
|
80
|
-
this.modals.open(
|
|
69
|
+
this.modals.open(FilePreviewModal, {
|
|
81
70
|
fileUrl: this.fileUrl,
|
|
82
71
|
});
|
|
83
72
|
```
|
|
@@ -112,12 +101,12 @@ this.args.close(results); // or this.close() in classic components
|
|
|
112
101
|
This addon comes with a `{{open-modal}}` template helper which can be used to trigger modals from any templates. It accepts the similar arguments as the `open` method. It can be used to open a modal in a route, closing it automatically when navigating elsewhere.
|
|
113
102
|
|
|
114
103
|
```hbs
|
|
115
|
-
{{open-modal
|
|
104
|
+
{{open-modal this.ConfirmationModalComponent (hash fileUrl=this.fileUrl) close=(fn this.save results)}}
|
|
116
105
|
```
|
|
117
106
|
|
|
118
107
|
Positional arguments mimick the `open()` method on the service:
|
|
119
108
|
|
|
120
|
-
- `
|
|
109
|
+
- `componentClass`: An imported component class of the modal to render
|
|
121
110
|
- `data`: Pass additional context to the modal,
|
|
122
111
|
- `options`: Pass additional options to the modal
|
|
123
112
|
|
|
@@ -144,7 +133,7 @@ a custom `className` can be handed to the `.open()` method.
|
|
|
144
133
|
|
|
145
134
|
```js
|
|
146
135
|
this.modals.open(
|
|
147
|
-
|
|
136
|
+
FilePreviwModal,
|
|
148
137
|
{
|
|
149
138
|
fileUrl: this.fileUrl,
|
|
150
139
|
},
|
|
@@ -201,16 +190,18 @@ The CSS animations which are applied by the custom CSS class _must_ end in
|
|
|
201
190
|
|
|
202
191
|
#### Examples
|
|
203
192
|
|
|
204
|
-
Examples for custom animations and how to apply them can be found in the
|
|
193
|
+
Examples for custom animations and how to apply them can be found in the addon's
|
|
205
194
|
dummy application.
|
|
206
195
|
|
|
207
196
|
See [the application.js controller](./tests/dummy/app/controllers/application.js)
|
|
208
|
-
for how the modals are
|
|
197
|
+
for how the modals are opened in your JavaScript actions and look at
|
|
209
198
|
[app.css](./tests/dummy/app/styles/app.css) for the style definition of these
|
|
210
199
|
custom animations.
|
|
211
200
|
|
|
212
201
|
### CSS Variables
|
|
213
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
|
+
|
|
214
205
|
The addons CSS is run through PostCSS by default, which will create static
|
|
215
206
|
fallbacks for all custom properties using their defaults.
|
|
216
207
|
|
|
@@ -266,7 +257,7 @@ Example for local Focus Trap option, when opening a specific modal:
|
|
|
266
257
|
|
|
267
258
|
```js
|
|
268
259
|
this.modals.open(
|
|
269
|
-
|
|
260
|
+
FilePreviewModal,
|
|
270
261
|
{ fileUrl: this.fileUrl },
|
|
271
262
|
{
|
|
272
263
|
focusTrapOptions: {
|
|
@@ -291,7 +282,7 @@ Or when opening a modal:
|
|
|
291
282
|
|
|
292
283
|
```js
|
|
293
284
|
this.modals.open(
|
|
294
|
-
|
|
285
|
+
FilePreviewModal,
|
|
295
286
|
{ fileUrl: this.fileUrl },
|
|
296
287
|
{
|
|
297
288
|
focusTrapOptions: null,
|
|
@@ -326,4 +317,5 @@ See the [Contributing](CONTRIBUTING.md) guide for details.
|
|
|
326
317
|
|
|
327
318
|
## License
|
|
328
319
|
|
|
329
|
-
|
|
320
|
+
ember-promise-modals is developed by and © Mainmatter GmbH and contributors. It
|
|
321
|
+
is released under the [MIT License](LICENSE.md).
|
package/addon/modal.js
CHANGED
|
@@ -13,16 +13,16 @@ import { defer } from 'rsvp';
|
|
|
13
13
|
/**
|
|
14
14
|
* @class Modal
|
|
15
15
|
* @param {Service} service
|
|
16
|
-
* @param {String}
|
|
16
|
+
* @param {String} componentClass
|
|
17
17
|
* @param {any} data
|
|
18
18
|
* @param {ModalOptions} options
|
|
19
19
|
* @method close - closes the modal
|
|
20
20
|
* @method then - resolves when the modal is closed
|
|
21
21
|
*/
|
|
22
22
|
export default class Modal {
|
|
23
|
-
constructor(service,
|
|
23
|
+
constructor(service, componentClass, data, options = {}) {
|
|
24
24
|
this._service = service;
|
|
25
|
-
this.
|
|
25
|
+
this._componentClass = componentClass;
|
|
26
26
|
this._data = data;
|
|
27
27
|
this._options = {
|
|
28
28
|
className: '',
|
package/addon/services/modals.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { A } from '@ember/array';
|
|
2
|
+
import { deprecate } from '@ember/debug';
|
|
2
3
|
import { computed } from '@ember/object';
|
|
3
4
|
import { alias } from '@ember/object/computed';
|
|
4
5
|
import Service from '@ember/service';
|
|
@@ -34,13 +35,27 @@ export default Service.extend({
|
|
|
34
35
|
},
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
|
-
* @param {
|
|
38
|
+
* @param {*} componentClass component class
|
|
38
39
|
* @param {*} data passed to the component template
|
|
39
40
|
* @param {ModalOptions} options applied to the modal
|
|
40
41
|
* @returns {Modal}
|
|
41
42
|
*/
|
|
42
|
-
open(
|
|
43
|
-
|
|
43
|
+
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
|
+
let modal = new Modal(this, componentClass, data, options);
|
|
44
59
|
|
|
45
60
|
this._stack.pushObject(modal);
|
|
46
61
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{{!-- template-lint-disable no-action --}}
|
|
2
2
|
<div id={{this.modalElementId}} class="epm-modal {{this.optionsClassName}} {{this.animatingClass}}">
|
|
3
|
-
{{#let (component (ensure-safe-component @modal.
|
|
3
|
+
{{#let (component (ensure-safe-component @modal._componentClass) data=@modal._data close=(action "close")) as |ModalComponent|}}
|
|
4
4
|
<ModalComponent />
|
|
5
5
|
{{/let}}
|
|
6
6
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-promise-modals",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "The better way to handle modals in your Ember.js apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test:ember-compatibility": "ember try:each"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ember/test-waiters": "^3.0.
|
|
32
|
+
"@ember/test-waiters": "^3.0.2",
|
|
33
33
|
"@embroider/util": "^1.7.1",
|
|
34
34
|
"broccoli-funnel": "^3.0.8",
|
|
35
35
|
"broccoli-merge-trees": "^4.2.0",
|
|
@@ -41,30 +41,31 @@
|
|
|
41
41
|
"postcss-preset-env": "^7.6.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@babel/eslint-parser": "7.
|
|
44
|
+
"@babel/eslint-parser": "7.23.10",
|
|
45
45
|
"@ember/optional-features": "2.0.0",
|
|
46
|
-
"@ember/
|
|
47
|
-
"@
|
|
46
|
+
"@ember/string": "3.1.1",
|
|
47
|
+
"@ember/test-helpers": "2.9.4",
|
|
48
|
+
"@embroider/macros": "1.13.4",
|
|
49
|
+
"@embroider/test-setup": "3.0.3",
|
|
48
50
|
"@release-it-plugins/lerna-changelog": "5.0.0",
|
|
49
51
|
"broccoli-asset-rev": "3.0.0",
|
|
50
|
-
"ember-cli": "4.
|
|
51
|
-
"ember-cli-dependency-checker": "3.3.
|
|
52
|
+
"ember-cli": "4.12.2",
|
|
53
|
+
"ember-cli-dependency-checker": "3.3.2",
|
|
52
54
|
"ember-cli-inject-live-reload": "2.1.0",
|
|
53
55
|
"ember-cli-sri": "2.1.1",
|
|
54
56
|
"ember-cli-terser": "4.0.2",
|
|
55
57
|
"ember-disable-prototype-extensions": "1.1.3",
|
|
56
|
-
"ember-export-application-global": "2.0.1",
|
|
57
58
|
"ember-load-initializers": "2.1.2",
|
|
58
59
|
"ember-maybe-import-regenerator": "1.0.0",
|
|
59
|
-
"ember-qunit": "
|
|
60
|
-
"ember-resolver": "8.0
|
|
61
|
-
"ember-source": "4.
|
|
60
|
+
"ember-qunit": "8.0.2",
|
|
61
|
+
"ember-resolver": "8.1.0",
|
|
62
|
+
"ember-source": "4.12.4",
|
|
62
63
|
"ember-source-channel-url": "3.0.0",
|
|
63
|
-
"ember-template-lint": "5.
|
|
64
|
+
"ember-template-lint": "5.13.0",
|
|
64
65
|
"ember-try": "2.0.0",
|
|
65
|
-
"eslint": "8.
|
|
66
|
-
"eslint-config-prettier": "8.
|
|
67
|
-
"eslint-plugin-ember": "11.
|
|
66
|
+
"eslint": "8.56.0",
|
|
67
|
+
"eslint-config-prettier": "8.10.0",
|
|
68
|
+
"eslint-plugin-ember": "11.12.0",
|
|
68
69
|
"eslint-plugin-import-helpers": "1.3.1",
|
|
69
70
|
"eslint-plugin-node": "11.1.0",
|
|
70
71
|
"eslint-plugin-prettier": "4.2.1",
|
|
@@ -72,16 +73,16 @@
|
|
|
72
73
|
"eslint-plugin-qunit": "7.3.4",
|
|
73
74
|
"loader.js": "4.7.0",
|
|
74
75
|
"npm-run-all": "4.1.5",
|
|
75
|
-
"prettier": "2.8.
|
|
76
|
-
"qunit": "2.
|
|
76
|
+
"prettier": "2.8.8",
|
|
77
|
+
"qunit": "2.20.0",
|
|
77
78
|
"qunit-console-grouper": "0.3.0",
|
|
78
79
|
"qunit-dom": "2.0.0",
|
|
79
|
-
"release-it": "15.
|
|
80
|
-
"sinon": "15.
|
|
81
|
-
"webpack": "5.
|
|
80
|
+
"release-it": "15.11.0",
|
|
81
|
+
"sinon": "15.2.0",
|
|
82
|
+
"webpack": "5.90.0"
|
|
82
83
|
},
|
|
83
84
|
"engines": {
|
|
84
|
-
"node": "12.* || >=
|
|
85
|
+
"node": "12.* || 14.* || >= 16.*"
|
|
85
86
|
},
|
|
86
87
|
"changelog": {
|
|
87
88
|
"repo": "mainmatter/ember-promise-modals",
|