ember-source 7.1.0-beta.1 → 7.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/build-metadata.json +3 -3
- package/dist/dev/packages/@ember/-internals/glimmer/index.js +5 -5
- package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +1 -1
- package/dist/dev/packages/@ember/application/index.js +1 -1
- package/dist/dev/packages/@ember/application/instance.js +1 -1
- package/dist/dev/packages/@ember/array/index.js +4 -0
- package/dist/dev/packages/@ember/component/helper.js +1 -1
- package/dist/dev/packages/@ember/component/index.js +9 -3
- package/dist/dev/packages/@ember/engine/index.js +1 -1
- package/dist/dev/packages/@ember/helper/index.js +4 -23
- package/dist/dev/packages/@ember/modifier/on.js +1 -1
- package/dist/dev/packages/@ember/object/index.js +22 -17
- package/dist/dev/packages/@ember/renderer/index.js +1 -1
- package/dist/dev/packages/@ember/routing/index.js +8 -4
- package/dist/dev/packages/@ember/routing/route.js +1 -1
- package/dist/dev/packages/@ember/routing/router-service.js +19 -12
- package/dist/dev/packages/@ember/template-compiler/lib/compile-options.js +3 -3
- package/dist/dev/packages/@glimmer/runtime/index.js +4 -4
- package/dist/dev/packages/ember/version.js +1 -1
- package/dist/dev/packages/shared-chunks/{element-DQJOvSlQ.js → element-Cf3hqNOD.js} +2 -0
- package/dist/dev/packages/shared-chunks/{get-D5b5QlqE.js → get-BehtPmsu.js} +30 -33
- package/dist/dev/packages/shared-chunks/{hash-BRRFQJ99.js → hash-BTwOuDGQ.js} +15 -9
- package/dist/dev/packages/shared-chunks/{helper-Do7NCZHI.js → helper-BubrhyuN.js} +18 -6
- package/dist/dev/packages/shared-chunks/{index-CwnQYqK5.js → index-CL1zjHwo.js} +80 -102
- package/dist/dev/packages/shared-chunks/{on-BueSMv9L.js → on-BQii6ILK.js} +6 -6
- package/dist/dev/packages/shared-chunks/{or-O0eJQ4K-.js → or-BTH3yuFG.js} +1 -1
- package/dist/dev/packages/shared-chunks/{setup-registry-BC5VMvei.js → setup-registry-BQZJfq-Y.js} +2 -2
- package/dist/dev/packages/shared-chunks/{textarea-WSlUEr0y.js → textarea-lD4apgrP.js} +6 -2
- package/dist/prod/packages/@ember/-internals/glimmer/index.js +5 -5
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +1 -1
- package/dist/prod/packages/@ember/application/index.js +1 -1
- package/dist/prod/packages/@ember/application/instance.js +1 -1
- package/dist/prod/packages/@ember/array/index.js +4 -0
- package/dist/prod/packages/@ember/component/helper.js +1 -1
- package/dist/prod/packages/@ember/component/index.js +9 -3
- package/dist/prod/packages/@ember/engine/index.js +1 -1
- package/dist/prod/packages/@ember/helper/index.js +4 -23
- package/dist/prod/packages/@ember/modifier/on.js +1 -1
- package/dist/prod/packages/@ember/object/index.js +22 -17
- package/dist/prod/packages/@ember/renderer/index.js +1 -1
- package/dist/prod/packages/@ember/routing/index.js +8 -4
- package/dist/prod/packages/@ember/routing/route.js +1 -1
- package/dist/prod/packages/@ember/routing/router-service.js +19 -12
- package/dist/prod/packages/@ember/template-compiler/lib/compile-options.js +3 -3
- package/dist/prod/packages/@glimmer/runtime/index.js +4 -4
- package/dist/prod/packages/ember/version.js +1 -1
- package/dist/prod/packages/shared-chunks/{element-DUOVW5Ho.js → element-9DRa_9dO.js} +2 -0
- package/dist/prod/packages/shared-chunks/{get-t0-itmA-.js → get-Dt5L0TcU.js} +30 -33
- package/dist/prod/packages/shared-chunks/{hash-mcs3pEFO.js → hash-Dkj3I4L4.js} +15 -9
- package/dist/prod/packages/shared-chunks/{helper-DLjV2ZZW.js → helper-CN6UzshW.js} +18 -6
- package/dist/prod/packages/shared-chunks/{index-qDFz6Mfe.js → index-ClxHbCe9.js} +80 -102
- package/dist/prod/packages/shared-chunks/{on-B5NVufs_.js → on-CWgOWNSL.js} +6 -6
- package/dist/prod/packages/shared-chunks/{or-3AxY5TPj.js → or-Crsa2wci.js} +1 -1
- package/dist/prod/packages/shared-chunks/{setup-registry-C2KfZJWI.js → setup-registry-B3DhqtxX.js} +2 -2
- package/dist/prod/packages/shared-chunks/{textarea-CHqL0Rdh.js → textarea-Byj32raR.js} +6 -2
- package/docs/data.json +180 -180
- package/package.json +3 -6
- package/types/stable/@ember/-internals/glimmer/index.d.ts +165 -121
- package/types/stable/@ember/-internals/glimmer/lib/component.d.ts +8 -2
- package/types/stable/@ember/-internals/glimmer/lib/glimmer-tracking-docs.d.ts +12 -12
- package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +18 -6
- package/types/stable/@ember/-internals/glimmer/lib/helpers/array.d.ts +3 -1
- package/types/stable/@ember/-internals/glimmer/lib/helpers/component.d.ts +65 -121
- package/types/stable/@ember/-internals/glimmer/lib/helpers/concat.d.ts +8 -4
- package/types/stable/@ember/-internals/glimmer/lib/helpers/each-in.d.ts +16 -14
- package/types/stable/@ember/-internals/glimmer/lib/helpers/element.d.ts +2 -0
- package/types/stable/@ember/-internals/glimmer/lib/helpers/fn.d.ts +11 -7
- package/types/stable/@ember/-internals/glimmer/lib/helpers/get.d.ts +23 -29
- package/types/stable/@ember/-internals/glimmer/lib/helpers/hash.d.ts +3 -1
- package/types/stable/@ember/-internals/glimmer/lib/helpers/if-unless.d.ts +95 -49
- package/types/stable/@ember/-internals/glimmer/lib/helpers/mut.d.ts +23 -54
- package/types/stable/@ember/-internals/glimmer/lib/helpers/page-title.d.ts +6 -2
- package/types/stable/@ember/-internals/glimmer/lib/helpers/readonly.d.ts +4 -8
- package/types/stable/@ember/-internals/glimmer/lib/modifiers/on.d.ts +10 -10
- package/types/stable/@ember/-internals/glimmer/lib/syntax/in-element.d.ts +2 -0
- package/types/stable/@ember/-internals/glimmer/lib/syntax/let.d.ts +2 -14
- package/types/stable/@ember/-internals/glimmer/lib/syntax/mount.d.ts +15 -11
- package/types/stable/@ember/-internals/glimmer/lib/syntax/outlet.d.ts +17 -10
- package/types/stable/@ember/-internals/runtime/lib/mixins/target_action_support.d.ts +1 -1
- package/types/stable/@ember/array/index.d.ts +4 -0
- package/types/stable/@ember/controller/index.d.ts +1 -1
- package/types/stable/@ember/helper/index.d.ts +0 -19
- package/types/stable/@ember/object/index.d.ts +4 -3
- package/types/stable/@ember/object/observable.d.ts +4 -0
- package/types/stable/@ember/routing/route.d.ts +1 -1
- package/types/stable/@ember/routing/router-service.d.ts +20 -12
- package/types/stable/@glimmer/runtime/lib/helpers/array.d.ts +1 -1
- package/types/stable/@glimmer/runtime/lib/helpers/concat.d.ts +8 -3
- package/types/stable/@glimmer/runtime/lib/helpers/fn.d.ts +13 -7
- package/types/stable/@glimmer/runtime/lib/helpers/get.d.ts +21 -29
- package/types/stable/@glimmer/runtime/lib/helpers/hash.d.ts +1 -1
- package/types/stable/@glimmer/syntax/lib/get-template-locals.d.ts +1 -1
- package/types/stable/@glimmer/tracking/index.d.ts +12 -12
|
@@ -17,7 +17,7 @@ declare module '@ember/routing/router-service' {
|
|
|
17
17
|
In this example, the Router service is injected into a component to initiate a transition
|
|
18
18
|
to a dedicated route:
|
|
19
19
|
|
|
20
|
-
```app/components/example.
|
|
20
|
+
```app/components/example.gjs
|
|
21
21
|
import Component from '@glimmer/component';
|
|
22
22
|
import { action } from '@ember/object';
|
|
23
23
|
import { service } from '@ember/service';
|
|
@@ -58,7 +58,7 @@ declare module '@ember/routing/router-service' {
|
|
|
58
58
|
specific model from a Component in the first action, and in the second we trigger
|
|
59
59
|
a query-params only transition.
|
|
60
60
|
|
|
61
|
-
```app/components/example.
|
|
61
|
+
```app/components/example.gjs
|
|
62
62
|
import Component from '@glimmer/component';
|
|
63
63
|
import { action } from '@ember/object';
|
|
64
64
|
import { service } from '@ember/service';
|
|
@@ -137,11 +137,15 @@ declare module '@ember/routing/router-service' {
|
|
|
137
137
|
In this example, the URL for the `author.books` route for a given author
|
|
138
138
|
is copied to the clipboard.
|
|
139
139
|
|
|
140
|
-
```app/templates/application.
|
|
141
|
-
|
|
140
|
+
```app/templates/application.gjs
|
|
141
|
+
import CopyLink from '../components/copy-link';
|
|
142
|
+
|
|
143
|
+
<template>
|
|
144
|
+
<CopyLink @author={{hash id="tomster" name="Tomster"}} />
|
|
145
|
+
</template>
|
|
142
146
|
```
|
|
143
147
|
|
|
144
|
-
```app/components/copy-link.
|
|
148
|
+
```app/components/copy-link.gjs
|
|
145
149
|
import Component from '@glimmer/component';
|
|
146
150
|
import { service } from '@ember/service';
|
|
147
151
|
import { action } from '@ember/object';
|
|
@@ -164,11 +168,15 @@ declare module '@ember/routing/router-service' {
|
|
|
164
168
|
Just like with `transitionTo` and `replaceWith`, `urlFor` can also handle
|
|
165
169
|
query parameters.
|
|
166
170
|
|
|
167
|
-
```app/templates/application.
|
|
168
|
-
|
|
171
|
+
```app/templates/application.gjs
|
|
172
|
+
import CopyLink from '../components/copy-link';
|
|
173
|
+
|
|
174
|
+
<template>
|
|
175
|
+
<CopyLink @author={{hash id="tomster" name="Tomster"}} />
|
|
176
|
+
</template>
|
|
169
177
|
```
|
|
170
178
|
|
|
171
|
-
```app/components/copy-link.
|
|
179
|
+
```app/components/copy-link.gjs
|
|
172
180
|
import Component from '@glimmer/component';
|
|
173
181
|
import { service } from '@ember/service';
|
|
174
182
|
import { action } from '@ember/object';
|
|
@@ -206,7 +214,7 @@ declare module '@ember/routing/router-service' {
|
|
|
206
214
|
|
|
207
215
|
In the following example, `isActive` will return `true` if the current route is `/posts`.
|
|
208
216
|
|
|
209
|
-
```app/components/posts.
|
|
217
|
+
```app/components/posts.gjs
|
|
210
218
|
import Component from '@glimmer/component';
|
|
211
219
|
import { service } from '@ember/service';
|
|
212
220
|
|
|
@@ -222,7 +230,7 @@ declare module '@ember/routing/router-service' {
|
|
|
222
230
|
The next example includes a dynamic segment, and will return `true` if the current route is `/posts/1`,
|
|
223
231
|
assuming the post has an id of 1:
|
|
224
232
|
|
|
225
|
-
```app/components/posts.
|
|
233
|
+
```app/components/posts.gjs
|
|
226
234
|
import Component from '@glimmer/component';
|
|
227
235
|
import { service } from '@ember/service';
|
|
228
236
|
|
|
@@ -257,7 +265,7 @@ declare module '@ember/routing/router-service' {
|
|
|
257
265
|
In the following example `recognize` is used to verify if a path belongs to our
|
|
258
266
|
application before transitioning to it.
|
|
259
267
|
|
|
260
|
-
```
|
|
268
|
+
```js
|
|
261
269
|
import Component from '@ember/component';
|
|
262
270
|
import { service } from '@ember/service';
|
|
263
271
|
|
|
@@ -568,7 +576,7 @@ declare module '@ember/routing/router-service' {
|
|
|
568
576
|
and doesn't change the active route).
|
|
569
577
|
|
|
570
578
|
Usage example:
|
|
571
|
-
```app/components/header.
|
|
579
|
+
```app/components/header.gjs
|
|
572
580
|
import Component from '@glimmer/component';
|
|
573
581
|
import { service } from '@ember/service';
|
|
574
582
|
import { notEmpty } from '@ember/object/computed';
|
|
@@ -4,10 +4,15 @@ declare module '@glimmer/runtime/lib/helpers/concat' {
|
|
|
4
4
|
|
|
5
5
|
Example:
|
|
6
6
|
|
|
7
|
-
```handlebars
|
|
8
|
-
{{some-component name=(concat firstName " " lastName)}}
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
```gjs
|
|
9
|
+
import { concat } from '@ember/helper';
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
{{yield (concat firstName " " lastName)}}
|
|
13
|
+
|
|
14
|
+
{{! would yield name="<first name value> <last name value>" to the component}}
|
|
15
|
+
</template>
|
|
11
16
|
```
|
|
12
17
|
|
|
13
18
|
or for angle bracket invocation, you actually don't need concat at all.
|
|
@@ -9,13 +9,17 @@ declare module '@glimmer/runtime/lib/helpers/fn' {
|
|
|
9
9
|
to a component invoked within the loop. Here's how you could use the `fn`
|
|
10
10
|
helper to pass both the function and its arguments together:
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
```app/components/items-listing.gjs
|
|
13
|
+
import DisplayItem from './display-item';
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
{{#each @items as |item|}}
|
|
17
|
+
<DisplayItem @item=item @select={{fn this.handleSelected item}} />
|
|
18
|
+
{{/each}}
|
|
19
|
+
</template>
|
|
16
20
|
```
|
|
17
21
|
|
|
18
|
-
```app/components/items-list.
|
|
22
|
+
```app/components/items-list.gjs
|
|
19
23
|
import Component from '@glimmer/component';
|
|
20
24
|
import { action } from '@ember/object';
|
|
21
25
|
|
|
@@ -26,7 +30,7 @@ declare module '@glimmer/runtime/lib/helpers/fn' {
|
|
|
26
30
|
}
|
|
27
31
|
```
|
|
28
32
|
|
|
29
|
-
In this case the `
|
|
33
|
+
In this case the `DisplayItem` component will receive a normal function
|
|
30
34
|
that it can invoke. When it invokes the function, the `handleSelected`
|
|
31
35
|
function will receive the `item` and any arguments passed, thanks to the
|
|
32
36
|
`fn` helper.
|
|
@@ -43,7 +47,7 @@ declare module '@glimmer/runtime/lib/helpers/fn' {
|
|
|
43
47
|
`handleSelected` is properly bound to the `items-list`, but let's explore what
|
|
44
48
|
happens if we left out the arrow function:
|
|
45
49
|
|
|
46
|
-
```app/components/items-list.
|
|
50
|
+
```app/components/items-list.gjs
|
|
47
51
|
import Component from '@glimmer/component';
|
|
48
52
|
|
|
49
53
|
export default class ItemsList extends Component {
|
|
@@ -60,6 +64,8 @@ declare module '@glimmer/runtime/lib/helpers/fn' {
|
|
|
60
64
|
|
|
61
65
|
See also [partial application](https://en.wikipedia.org/wiki/Partial_application).
|
|
62
66
|
|
|
67
|
+
`fn` is built-in and does not require any additional imports.
|
|
68
|
+
|
|
63
69
|
@method fn
|
|
64
70
|
@public
|
|
65
71
|
*/
|
|
@@ -5,28 +5,31 @@ declare module '@glimmer/runtime/lib/helpers/get' {
|
|
|
5
5
|
|
|
6
6
|
For example, these two usages are equivalent:
|
|
7
7
|
|
|
8
|
-
```app/components/developer-detail.
|
|
8
|
+
```app/components/developer-detail.gjs
|
|
9
9
|
import Component from '@glimmer/component';
|
|
10
10
|
import { tracked } from '@glimmer/tracking';
|
|
11
|
+
import { get } from '@ember/object';
|
|
11
12
|
|
|
12
13
|
export default class extends Component {
|
|
13
14
|
@tracked developer = {
|
|
14
15
|
name: "Sandi Metz",
|
|
15
16
|
language: "Ruby"
|
|
16
17
|
}
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
{{this.developer.name}}
|
|
21
|
+
{{get this.developer "name"}}
|
|
22
|
+
</template>
|
|
17
23
|
}
|
|
18
24
|
```
|
|
19
25
|
|
|
20
|
-
```handlebars
|
|
21
|
-
{{this.developer.name}}
|
|
22
|
-
{{get this.developer "name"}}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
26
|
If there were several facts about a person, the `{{get}}` helper can dynamically
|
|
26
27
|
pick one:
|
|
27
28
|
|
|
28
|
-
```app/templates/application.
|
|
29
|
-
<
|
|
29
|
+
```app/templates/application.gjs
|
|
30
|
+
<template>
|
|
31
|
+
<DeveloperDetail @factName="language" />
|
|
32
|
+
</template>
|
|
30
33
|
```
|
|
31
34
|
|
|
32
35
|
```handlebars
|
|
@@ -36,10 +39,11 @@ declare module '@glimmer/runtime/lib/helpers/get' {
|
|
|
36
39
|
For a more complex example, this template would allow the user to switch
|
|
37
40
|
between showing the user's height and weight with a click:
|
|
38
41
|
|
|
39
|
-
```app/components/developer-detail.
|
|
42
|
+
```app/components/developer-detail.gjs
|
|
40
43
|
import Component from '@glimmer/component';
|
|
41
44
|
import { tracked } from '@glimmer/tracking';
|
|
42
|
-
|
|
45
|
+
import { get } from '@ember/object';
|
|
46
|
+
|
|
43
47
|
export default class extends Component {
|
|
44
48
|
@tracked developer = {
|
|
45
49
|
name: "Sandi Metz",
|
|
@@ -51,28 +55,16 @@ declare module '@glimmer/runtime/lib/helpers/get' {
|
|
|
51
55
|
showFact = (fact) => {
|
|
52
56
|
this.currentFact = fact;
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```app/components/developer-detail.js
|
|
58
|
-
{{get this.developer this.currentFact}}
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
{{get this.developer this.currentFact}}
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
The `{{get}}` helper can also respect mutable values itself. For example:
|
|
65
|
-
|
|
66
|
-
```app/components/developer-detail.js
|
|
67
|
-
<Input @value={{mut (get this.person this.currentFact)}} />
|
|
68
|
-
|
|
69
|
-
<button {{on 'click' (fn this.showFact "name")}}>Show name</button>
|
|
70
|
-
<button {{on 'click' (fn this.showFact "language")}}>Show language</button>
|
|
62
|
+
<button {{on 'click' (fn this.showFact "name")}}>Show name</button>
|
|
63
|
+
<button {{on 'click' (fn this.showFact "language")}}>Show language</button>
|
|
64
|
+
</template>
|
|
65
|
+
}
|
|
71
66
|
```
|
|
72
67
|
|
|
73
|
-
Would allow the user to swap what fact is being displayed, and also edit
|
|
74
|
-
that fact via a two-way mutable binding.
|
|
75
|
-
|
|
76
68
|
@public
|
|
77
69
|
@method get
|
|
78
70
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare module '@glimmer/runtime/lib/helpers/hash' {
|
|
2
2
|
/**
|
|
3
3
|
Use the `{{hash}}` helper to create a hash to pass as an option to your
|
|
4
|
-
components. This is
|
|
4
|
+
components. This is especially useful for contextual components where you can
|
|
5
5
|
just yield a hash:
|
|
6
6
|
|
|
7
7
|
```handlebars
|
|
@@ -4,7 +4,7 @@ declare module '@glimmer/syntax/lib/get-template-locals' {
|
|
|
4
4
|
includeHtmlElements?: boolean;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Parses and traverses a given
|
|
7
|
+
* Parses and traverses a given template to extract all template locals
|
|
8
8
|
* referenced that could possible come from the parent scope. Can exclude known keywords
|
|
9
9
|
* optionally.
|
|
10
10
|
*/
|
|
@@ -20,17 +20,7 @@ declare module '@glimmer/tracking' {
|
|
|
20
20
|
property changes, any templates that used that property, directly or
|
|
21
21
|
indirectly, will rerender. For instance, consider this component:
|
|
22
22
|
|
|
23
|
-
```
|
|
24
|
-
<div>Count: {{this.count}}</div>
|
|
25
|
-
<div>Times Ten: {{this.timesTen}}</div>
|
|
26
|
-
<div>
|
|
27
|
-
<button {{on "click" this.plusOne}}>
|
|
28
|
-
Plus One
|
|
29
|
-
</button>
|
|
30
|
-
</div>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
```javascript
|
|
23
|
+
```gjs
|
|
34
24
|
import Component from '@glimmer/component';
|
|
35
25
|
import { tracked } from '@glimmer/tracking';
|
|
36
26
|
import { action } from '@ember/object';
|
|
@@ -46,6 +36,16 @@ declare module '@glimmer/tracking' {
|
|
|
46
36
|
plusOne() {
|
|
47
37
|
this.count += 1;
|
|
48
38
|
}
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div>Count: {{this.count}}</div>
|
|
42
|
+
<div>Times Ten: {{this.timesTen}}</div>
|
|
43
|
+
<div>
|
|
44
|
+
<button {{on "click" this.plusOne}}>
|
|
45
|
+
Plus One
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -55,7 +55,7 @@ declare module '@glimmer/tracking' {
|
|
|
55
55
|
will cause a rerender when updated - this includes through method calls and
|
|
56
56
|
other means:
|
|
57
57
|
|
|
58
|
-
```
|
|
58
|
+
```gjs
|
|
59
59
|
import Component from '@glimmer/component';
|
|
60
60
|
import { tracked } from '@glimmer/tracking';
|
|
61
61
|
|