ember-source 7.2.0-beta.1 → 7.2.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 +6 -6
- package/dist/dev/packages/@ember/-internals/routing/index.js +2 -2
- package/dist/dev/packages/@ember/-internals/runtime/index.js +1 -1
- package/dist/dev/packages/@ember/-internals/runtime/lib/ext/rsvp.js +1 -1
- package/dist/dev/packages/@ember/application/index.js +3 -3
- package/dist/dev/packages/@ember/application/instance.js +1 -1
- package/dist/dev/packages/@ember/component/helper.js +1 -1
- package/dist/dev/packages/@ember/component/index.js +2 -2
- package/dist/dev/packages/@ember/engine/index.js +3 -3
- package/dist/dev/packages/@ember/engine/instance.js +1 -1
- package/dist/dev/packages/@ember/helper/index.js +1131 -78
- package/dist/dev/packages/@ember/modifier/on.js +1 -1
- package/dist/dev/packages/@ember/object/compat.js +0 -32
- package/dist/dev/packages/@ember/renderer/index.js +1 -1
- package/dist/dev/packages/@ember/routing/-internals.js +2 -2
- package/dist/dev/packages/@ember/routing/index.js +6 -26
- package/dist/dev/packages/@ember/routing/lib/utils.js +2 -2
- package/dist/dev/packages/@ember/routing/route.js +2 -2
- package/dist/dev/packages/@ember/routing/router-service.js +9 -9
- package/dist/dev/packages/@ember/routing/router.js +2 -2
- 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/router_js/index.js +2 -2
- package/dist/dev/packages/rsvp/index.js +1 -2281
- package/dist/dev/packages/shared-chunks/{element-BYLB-q7a.js → element-Cgoi4ldD.js} +0 -24
- package/dist/dev/packages/shared-chunks/get-B4o_4OLA.js +40 -0
- package/dist/dev/packages/shared-chunks/hash-Bg4r3CU4.js +57 -0
- package/dist/dev/packages/shared-chunks/{helper-DIj85_-f.js → helper--ZiOCQkd.js} +2 -2
- package/dist/dev/packages/shared-chunks/{index-B3pPx1fL.js → index-C5Q8WHUG.js} +205 -81
- package/dist/dev/packages/shared-chunks/{not-DYh6AY9Z.js → not-JB6ln6bJ.js} +1 -1
- package/dist/dev/packages/shared-chunks/{on-DlF0Wy7P.js → on-CQqC2-wL.js} +21 -10
- package/dist/dev/packages/shared-chunks/{rsvp.es-DR7yS7qg.js → rsvp-aLN_pQtn.js} +152 -148
- package/dist/dev/packages/shared-chunks/{setup-registry-9DCmHTFF.js → setup-registry-Dovj1LIQ.js} +2 -2
- package/dist/dev/packages/shared-chunks/{textarea-C4lYkaHj.js → textarea-B5TmhnQU.js} +2 -22
- package/dist/dev/packages/shared-chunks/{unique-id-DQOhouG1.js → unique-id-Csxuh1I7.js} +0 -4
- package/dist/dev/packages/shared-chunks/{unrecognized-url-error-BJHjL30Q.js → unrecognized-url-error-DyurFqvv.js} +1 -1
- package/dist/prod/packages/@ember/-internals/glimmer/index.js +6 -6
- package/dist/prod/packages/@ember/-internals/routing/index.js +2 -2
- package/dist/prod/packages/@ember/-internals/runtime/index.js +1 -1
- package/dist/prod/packages/@ember/-internals/runtime/lib/ext/rsvp.js +1 -1
- package/dist/prod/packages/@ember/application/index.js +3 -3
- package/dist/prod/packages/@ember/application/instance.js +1 -1
- package/dist/prod/packages/@ember/component/helper.js +1 -1
- package/dist/prod/packages/@ember/component/index.js +2 -2
- package/dist/prod/packages/@ember/engine/index.js +3 -3
- package/dist/prod/packages/@ember/engine/instance.js +1 -1
- package/dist/prod/packages/@ember/helper/index.js +1131 -78
- package/dist/prod/packages/@ember/modifier/on.js +1 -1
- package/dist/prod/packages/@ember/object/compat.js +0 -32
- package/dist/prod/packages/@ember/renderer/index.js +1 -1
- package/dist/prod/packages/@ember/routing/index.js +6 -26
- package/dist/prod/packages/@ember/routing/lib/utils.js +2 -2
- package/dist/prod/packages/@ember/routing/route.js +2 -2
- package/dist/prod/packages/@ember/routing/router-service.js +9 -9
- package/dist/prod/packages/@ember/routing/router.js +2 -2
- 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/router_js/index.js +2 -2
- package/dist/prod/packages/rsvp/index.js +1 -2281
- package/dist/prod/packages/shared-chunks/{element-DgHdPZ8u.js → element-BmBjPjkQ.js} +0 -24
- package/dist/prod/packages/shared-chunks/get-DpBAICuC.js +40 -0
- package/dist/prod/packages/shared-chunks/hash-D31JO-BD.js +57 -0
- package/dist/prod/packages/shared-chunks/{helper-DkXiTBjc.js → helper-Df5MpdcT.js} +2 -2
- package/dist/prod/packages/shared-chunks/{index-CslMfEpb.js → index-BQaaoknf.js} +205 -81
- package/dist/prod/packages/shared-chunks/{not-BOIVROuv.js → not-Bm2-x-jD.js} +1 -1
- package/dist/prod/packages/shared-chunks/{on-BZHAxzdq.js → on-8aS8t_5D.js} +21 -10
- package/dist/prod/packages/shared-chunks/{rsvp.es-DR7yS7qg.js → rsvp-aLN_pQtn.js} +152 -148
- package/dist/prod/packages/shared-chunks/{setup-registry-U-6VaNQG.js → setup-registry-DMAzVcVn.js} +2 -2
- package/dist/prod/packages/shared-chunks/{textarea-DOmZ1x0E.js → textarea-CQmTzSKe.js} +2 -22
- package/dist/prod/packages/shared-chunks/{unique-id-o2pS74go.js → unique-id-BJb1p8EG.js} +0 -4
- package/dist/prod/packages/shared-chunks/{unrecognized-url-error-EgNrnFu_.js → unrecognized-url-error-DgXBAzKl.js} +1 -1
- package/docs/data.json +1216 -1380
- package/package.json +3 -6
- package/types/stable/@ember/-internals/glimmer/index.d.ts +7 -380
- package/types/stable/@ember/-internals/glimmer/lib/component.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +2 -2
- package/types/stable/@ember/-internals/glimmer/lib/helpers/each-in.d.ts +171 -62
- package/types/stable/@ember/-internals/glimmer/lib/helpers/element.d.ts +0 -24
- package/types/stable/@ember/-internals/glimmer/lib/helpers/mut.d.ts +3 -2
- package/types/stable/@ember/-internals/glimmer/lib/helpers/readonly.d.ts +3 -1
- package/types/stable/@ember/-internals/glimmer/lib/helpers/unbound.d.ts +6 -2
- package/types/stable/@ember/-internals/glimmer/lib/helpers/unique-id.d.ts +0 -3
- package/types/stable/@ember/-internals/glimmer/lib/syntax/mount.d.ts +4 -2
- package/types/stable/@ember/-internals/glimmer/lib/syntax/outlet.d.ts +7 -2
- package/types/stable/@ember/helper/index.d.ts +1113 -73
- package/types/stable/@ember/object/compat.d.ts +0 -32
- package/types/stable/@ember/routing/router-service.d.ts +9 -9
- package/types/stable/@glimmer/runtime/lib/helpers/array.d.ts +0 -33
- package/types/stable/@glimmer/runtime/lib/helpers/concat.d.ts +0 -25
- package/types/stable/@glimmer/runtime/lib/helpers/fn.d.ts +0 -70
- package/types/stable/@glimmer/runtime/lib/helpers/get.d.ts +0 -69
- package/types/stable/@glimmer/runtime/lib/helpers/hash.d.ts +0 -36
- package/types/stable/index.d.ts +0 -14
- package/dist/dev/packages/shared-chunks/get-6I3sjd-I.js +0 -135
- package/dist/dev/packages/shared-chunks/hash-6NDs_5_f.js +0 -198
- package/dist/prod/packages/shared-chunks/get-Dago5uGl.js +0 -135
- package/dist/prod/packages/shared-chunks/hash-gEXIsSO4.js +0 -198
- package/types/stable/@ember/-internals/glimmer/lib/helpers/array.d.ts +0 -43
- package/types/stable/@ember/-internals/glimmer/lib/helpers/component.d.ts +0 -93
- package/types/stable/@ember/-internals/glimmer/lib/helpers/concat.d.ts +0 -32
- package/types/stable/@ember/-internals/glimmer/lib/helpers/fn.d.ts +0 -77
- package/types/stable/@ember/-internals/glimmer/lib/helpers/get.d.ts +0 -94
- package/types/stable/@ember/-internals/glimmer/lib/helpers/hash.d.ts +0 -46
- package/types/stable/@ember/-internals/glimmer/lib/helpers/helper.d.ts +0 -43
- package/types/stable/@ember/-internals/glimmer/lib/helpers/if-unless.d.ts +0 -228
- package/types/stable/@ember/-internals/glimmer/lib/helpers/log.d.ts +0 -19
- package/types/stable/@ember/-internals/glimmer/lib/helpers/modifier.d.ts +0 -42
- package/types/stable/@ember/-internals/glimmer/lib/helpers/page-title.d.ts +0 -24
- package/types/stable/@ember/-internals/glimmer/lib/modifiers/on.d.ts +0 -95
- package/types/stable/@ember/-internals/glimmer/lib/syntax/in-element.d.ts +0 -49
- package/types/stable/@ember/-internals/glimmer/lib/syntax/let.d.ts +0 -43
|
@@ -36,38 +36,6 @@ declare module '@ember/object/compat' {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Classic Example:
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
import { tracked } from '@glimmer/tracking';
|
|
43
|
-
import { dependentKeyCompat } from '@ember/object/compat';
|
|
44
|
-
import EmberObject, { computed, observer, set } from '@ember/object';
|
|
45
|
-
|
|
46
|
-
const Person = EmberObject.extend({
|
|
47
|
-
firstName: tracked(),
|
|
48
|
-
lastName: tracked(),
|
|
49
|
-
|
|
50
|
-
fullName: dependentKeyCompat(function() {
|
|
51
|
-
return `${this.firstName} ${this.lastName}`;
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const Profile = EmberObject.extend({
|
|
56
|
-
person: null,
|
|
57
|
-
|
|
58
|
-
helloMessage: computed('person.fullName', function() {
|
|
59
|
-
return `Hello, ${this.person.fullName}!`;
|
|
60
|
-
}),
|
|
61
|
-
|
|
62
|
-
onNameUpdated: observer('person.fullName', function() {
|
|
63
|
-
console.log('person name updated!');
|
|
64
|
-
}),
|
|
65
|
-
});
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
`dependentKeyCompat()` can receive a getter function or an object containing
|
|
69
|
-
`get`/`set` methods when used in classic classes, like computed properties.
|
|
70
|
-
|
|
71
39
|
In general, only properties which you _expect_ to be watched by older,
|
|
72
40
|
untracked clases should be marked as dependency compatible. The decorator is
|
|
73
41
|
meant as an interop layer for parts of Ember's older classic APIs, and should
|
|
@@ -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.gjs
|
|
20
|
+
```gjs {data-filename="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.gjs
|
|
61
|
+
```gjs {data-filename="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,7 +137,7 @@ 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.gjs
|
|
140
|
+
```gjs {data-filename="app/templates/application.gjs"}
|
|
141
141
|
import CopyLink from '../components/copy-link';
|
|
142
142
|
|
|
143
143
|
<template>
|
|
@@ -145,7 +145,7 @@ declare module '@ember/routing/router-service' {
|
|
|
145
145
|
</template>
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
```app/components/copy-link.gjs
|
|
148
|
+
```gjs {data-filename="app/components/copy-link.gjs"}
|
|
149
149
|
import Component from '@glimmer/component';
|
|
150
150
|
import { service } from '@ember/service';
|
|
151
151
|
import { action } from '@ember/object';
|
|
@@ -168,7 +168,7 @@ declare module '@ember/routing/router-service' {
|
|
|
168
168
|
Just like with `transitionTo` and `replaceWith`, `urlFor` can also handle
|
|
169
169
|
query parameters.
|
|
170
170
|
|
|
171
|
-
```app/templates/application.gjs
|
|
171
|
+
```gjs {data-filename="app/templates/application.gjs"}
|
|
172
172
|
import CopyLink from '../components/copy-link';
|
|
173
173
|
|
|
174
174
|
<template>
|
|
@@ -176,7 +176,7 @@ declare module '@ember/routing/router-service' {
|
|
|
176
176
|
</template>
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
```app/components/copy-link.gjs
|
|
179
|
+
```gjs {data-filename="app/components/copy-link.gjs"}
|
|
180
180
|
import Component from '@glimmer/component';
|
|
181
181
|
import { service } from '@ember/service';
|
|
182
182
|
import { action } from '@ember/object';
|
|
@@ -214,7 +214,7 @@ declare module '@ember/routing/router-service' {
|
|
|
214
214
|
|
|
215
215
|
In the following example, `isActive` will return `true` if the current route is `/posts`.
|
|
216
216
|
|
|
217
|
-
```app/components/posts.gjs
|
|
217
|
+
```gjs {data-filename="app/components/posts.gjs"}
|
|
218
218
|
import Component from '@glimmer/component';
|
|
219
219
|
import { service } from '@ember/service';
|
|
220
220
|
|
|
@@ -230,7 +230,7 @@ declare module '@ember/routing/router-service' {
|
|
|
230
230
|
The next example includes a dynamic segment, and will return `true` if the current route is `/posts/1`,
|
|
231
231
|
assuming the post has an id of 1:
|
|
232
232
|
|
|
233
|
-
```app/components/posts.gjs
|
|
233
|
+
```gjs {data-filename="app/components/posts.gjs"}
|
|
234
234
|
import Component from '@glimmer/component';
|
|
235
235
|
import { service } from '@ember/service';
|
|
236
236
|
|
|
@@ -576,7 +576,7 @@ declare module '@ember/routing/router-service' {
|
|
|
576
576
|
and doesn't change the active route).
|
|
577
577
|
|
|
578
578
|
Usage example:
|
|
579
|
-
```app/components/header.gjs
|
|
579
|
+
```gjs {data-filename="app/components/header.gjs"}
|
|
580
580
|
import Component from '@glimmer/component';
|
|
581
581
|
import { service } from '@ember/service';
|
|
582
582
|
import { notEmpty } from '@ember/object/computed';
|
|
@@ -1,36 +1,3 @@
|
|
|
1
1
|
declare module '@glimmer/runtime/lib/helpers/array' {
|
|
2
|
-
/**
|
|
3
|
-
Use the `{{array}}` helper to create an array to pass as an option to your
|
|
4
|
-
components.
|
|
5
|
-
|
|
6
|
-
```handlebars
|
|
7
|
-
<MyComponent @people={{array
|
|
8
|
-
'Tom Dale'
|
|
9
|
-
'Yehuda Katz'
|
|
10
|
-
this.myOtherPerson}}
|
|
11
|
-
/>
|
|
12
|
-
```
|
|
13
|
-
or
|
|
14
|
-
```handlebars
|
|
15
|
-
{{yield people=(array
|
|
16
|
-
'Tom Dale'
|
|
17
|
-
'Yehuda Katz'
|
|
18
|
-
this.myOtherPerson)
|
|
19
|
-
}}
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Would result in an object such as:
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
['Tom Dale', 'Yehuda Katz', this.get('myOtherPerson')]
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Where the 3rd item in the array is bound to updates of the `myOtherPerson` property.
|
|
29
|
-
|
|
30
|
-
@method array
|
|
31
|
-
@param {Array} options
|
|
32
|
-
@return {Array} Array
|
|
33
|
-
@public
|
|
34
|
-
*/
|
|
35
2
|
export const array: object;
|
|
36
3
|
}
|
|
@@ -1,28 +1,3 @@
|
|
|
1
1
|
declare module '@glimmer/runtime/lib/helpers/concat' {
|
|
2
|
-
/**
|
|
3
|
-
Concatenates the given arguments into a string.
|
|
4
|
-
|
|
5
|
-
Example:
|
|
6
|
-
|
|
7
|
-
|
|
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>
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
or for angle bracket invocation, you actually don't need concat at all.
|
|
19
|
-
|
|
20
|
-
```handlebars
|
|
21
|
-
<SomeComponent @name="{{firstName}} {{lastName}}" />
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
@public
|
|
25
|
-
@method concat
|
|
26
|
-
*/
|
|
27
2
|
export const concat: object;
|
|
28
3
|
}
|
|
@@ -1,73 +1,3 @@
|
|
|
1
1
|
declare module '@glimmer/runtime/lib/helpers/fn' {
|
|
2
|
-
/**
|
|
3
|
-
The `fn` helper allows you to ensure a function that you are passing off
|
|
4
|
-
to another component, helper, or modifier has access to arguments that are
|
|
5
|
-
available in the template.
|
|
6
|
-
|
|
7
|
-
For example, if you have an `each` helper looping over a number of items, you
|
|
8
|
-
may need to pass a function that expects to receive the item as an argument
|
|
9
|
-
to a component invoked within the loop. Here's how you could use the `fn`
|
|
10
|
-
helper to pass both the function and its arguments together:
|
|
11
|
-
|
|
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>
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
```app/components/items-list.gjs
|
|
23
|
-
import Component from '@glimmer/component';
|
|
24
|
-
import { action } from '@ember/object';
|
|
25
|
-
|
|
26
|
-
export default class ItemsList extends Component {
|
|
27
|
-
handleSelected = (item) => {
|
|
28
|
-
// ...snip...
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
In this case the `DisplayItem` component will receive a normal function
|
|
34
|
-
that it can invoke. When it invokes the function, the `handleSelected`
|
|
35
|
-
function will receive the `item` and any arguments passed, thanks to the
|
|
36
|
-
`fn` helper.
|
|
37
|
-
|
|
38
|
-
Let's take look at what that means in a couple circumstances:
|
|
39
|
-
|
|
40
|
-
- When invoked as `this.args.select()` the `handleSelected` function will
|
|
41
|
-
receive the `item` from the loop as its first and only argument.
|
|
42
|
-
- When invoked as `this.args.select('foo')` the `handleSelected` function
|
|
43
|
-
will receive the `item` from the loop as its first argument and the
|
|
44
|
-
string `'foo'` as its second argument.
|
|
45
|
-
|
|
46
|
-
In the example above, we used an arrow function to ensure that
|
|
47
|
-
`handleSelected` is properly bound to the `items-list`, but let's explore what
|
|
48
|
-
happens if we left out the arrow function:
|
|
49
|
-
|
|
50
|
-
```app/components/items-list.gjs
|
|
51
|
-
import Component from '@glimmer/component';
|
|
52
|
-
|
|
53
|
-
export default class ItemsList extends Component {
|
|
54
|
-
handleSelected(item) {
|
|
55
|
-
// ...snip...
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
In this example, when `handleSelected` is invoked inside the `display-item`
|
|
61
|
-
component, it will **not** have access to the component instance. In other
|
|
62
|
-
words, it will have no `this` context, so please make sure your functions
|
|
63
|
-
are bound (via an arrow function or other means) before passing into `fn`!
|
|
64
|
-
|
|
65
|
-
See also [partial application](https://en.wikipedia.org/wiki/Partial_application).
|
|
66
|
-
|
|
67
|
-
`fn` is built-in and does not require any additional imports.
|
|
68
|
-
|
|
69
|
-
@method fn
|
|
70
|
-
@public
|
|
71
|
-
*/
|
|
72
2
|
export const fn: object;
|
|
73
3
|
}
|
|
@@ -1,72 +1,3 @@
|
|
|
1
1
|
declare module '@glimmer/runtime/lib/helpers/get' {
|
|
2
|
-
/**
|
|
3
|
-
Dynamically look up a property on an object. The second argument to `{{get}}`
|
|
4
|
-
should have a string value, although it can be bound.
|
|
5
|
-
|
|
6
|
-
For example, these two usages are equivalent:
|
|
7
|
-
|
|
8
|
-
```app/components/developer-detail.gjs
|
|
9
|
-
import Component from '@glimmer/component';
|
|
10
|
-
import { tracked } from '@glimmer/tracking';
|
|
11
|
-
import { get } from '@ember/object';
|
|
12
|
-
|
|
13
|
-
export default class extends Component {
|
|
14
|
-
@tracked developer = {
|
|
15
|
-
name: "Sandi Metz",
|
|
16
|
-
language: "Ruby"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
<template>
|
|
20
|
-
{{this.developer.name}}
|
|
21
|
-
{{get this.developer "name"}}
|
|
22
|
-
</template>
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
If there were several facts about a person, the `{{get}}` helper can dynamically
|
|
27
|
-
pick one:
|
|
28
|
-
|
|
29
|
-
```app/templates/application.gjs
|
|
30
|
-
<template>
|
|
31
|
-
<DeveloperDetail @factName="language" />
|
|
32
|
-
</template>
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
```handlebars
|
|
36
|
-
{{get this.developer @factName}}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
For a more complex example, this template would allow the user to switch
|
|
40
|
-
between showing the user's height and weight with a click:
|
|
41
|
-
|
|
42
|
-
```app/components/developer-detail.gjs
|
|
43
|
-
import Component from '@glimmer/component';
|
|
44
|
-
import { tracked } from '@glimmer/tracking';
|
|
45
|
-
import { get } from '@ember/object';
|
|
46
|
-
|
|
47
|
-
export default class extends Component {
|
|
48
|
-
@tracked developer = {
|
|
49
|
-
name: "Sandi Metz",
|
|
50
|
-
language: "Ruby"
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@tracked currentFact = 'name'
|
|
54
|
-
|
|
55
|
-
showFact = (fact) => {
|
|
56
|
-
this.currentFact = fact;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
<template>
|
|
60
|
-
{{get this.developer this.currentFact}}
|
|
61
|
-
|
|
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
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
@public
|
|
69
|
-
@method get
|
|
70
|
-
*/
|
|
71
2
|
export const get: object;
|
|
72
3
|
}
|
|
@@ -1,39 +1,3 @@
|
|
|
1
1
|
declare module '@glimmer/runtime/lib/helpers/hash' {
|
|
2
|
-
/**
|
|
3
|
-
Use the `{{hash}}` helper to create a hash to pass as an option to your
|
|
4
|
-
components. This is especially useful for contextual components where you can
|
|
5
|
-
just yield a hash:
|
|
6
|
-
|
|
7
|
-
```handlebars
|
|
8
|
-
{{yield (hash
|
|
9
|
-
name='Sarah'
|
|
10
|
-
title=office
|
|
11
|
-
)}}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Would result in an object such as:
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
{ name: 'Sarah', title: this.get('office') }
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Where the `title` is bound to updates of the `office` property.
|
|
21
|
-
|
|
22
|
-
Note that the hash is an empty object with no prototype chain, therefore
|
|
23
|
-
common methods like `toString` are not available in the resulting hash.
|
|
24
|
-
If you need to use such a method, you can use the `call` or `apply`
|
|
25
|
-
approach:
|
|
26
|
-
|
|
27
|
-
```js
|
|
28
|
-
function toString(obj) {
|
|
29
|
-
return Object.prototype.toString.apply(obj);
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
@method hash
|
|
34
|
-
@param {Object} options
|
|
35
|
-
@return {Object} Hash
|
|
36
|
-
@public
|
|
37
|
-
*/
|
|
38
2
|
export const hash: object;
|
|
39
3
|
}
|
package/types/stable/index.d.ts
CHANGED
|
@@ -74,30 +74,16 @@
|
|
|
74
74
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/-normalize-class.d.ts" />
|
|
75
75
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/-resolve.d.ts" />
|
|
76
76
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/-track-array.d.ts" />
|
|
77
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/array.d.ts" />
|
|
78
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/component.d.ts" />
|
|
79
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/concat.d.ts" />
|
|
80
77
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/each-in.d.ts" />
|
|
81
78
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/element.d.ts" />
|
|
82
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/fn.d.ts" />
|
|
83
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/get.d.ts" />
|
|
84
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/hash.d.ts" />
|
|
85
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/helper.d.ts" />
|
|
86
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/if-unless.d.ts" />
|
|
87
79
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/internal-helper.d.ts" />
|
|
88
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/log.d.ts" />
|
|
89
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/modifier.d.ts" />
|
|
90
80
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/mut.d.ts" />
|
|
91
|
-
/// <reference path="./@ember/-internals/glimmer/lib/helpers/page-title.d.ts" />
|
|
92
81
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/readonly.d.ts" />
|
|
93
82
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/unbound.d.ts" />
|
|
94
83
|
/// <reference path="./@ember/-internals/glimmer/lib/helpers/unique-id.d.ts" />
|
|
95
|
-
/// <reference path="./@ember/-internals/glimmer/lib/modifiers/on.d.ts" />
|
|
96
84
|
/// <reference path="./@ember/-internals/glimmer/lib/renderer.d.ts" />
|
|
97
85
|
/// <reference path="./@ember/-internals/glimmer/lib/resolver.d.ts" />
|
|
98
86
|
/// <reference path="./@ember/-internals/glimmer/lib/setup-registry.d.ts" />
|
|
99
|
-
/// <reference path="./@ember/-internals/glimmer/lib/syntax/in-element.d.ts" />
|
|
100
|
-
/// <reference path="./@ember/-internals/glimmer/lib/syntax/let.d.ts" />
|
|
101
87
|
/// <reference path="./@ember/-internals/glimmer/lib/syntax/mount.d.ts" />
|
|
102
88
|
/// <reference path="./@ember/-internals/glimmer/lib/syntax/outlet.d.ts" />
|
|
103
89
|
/// <reference path="./@ember/-internals/glimmer/lib/template_registry.d.ts" />
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { c as createComputeRef, U as UNDEFINED_REFERENCE, v as valueForRef } from './reference-BqOLhKFy.js';
|
|
2
|
-
import { f as reifyPositional } from './arguments-CDkbOqTS.js';
|
|
3
|
-
import { i as internalHelper } from './hash-6NDs_5_f.js';
|
|
4
|
-
import { setPath, getPath } from '../@glimmer/global-context/index.js';
|
|
5
|
-
import { i as isDict } from './collections-DPkjqeA3.js';
|
|
6
|
-
|
|
7
|
-
const isEmpty = value => {
|
|
8
|
-
return value === null || value === undefined || typeof value.toString !== 'function';
|
|
9
|
-
};
|
|
10
|
-
const normalizeTextValue = value => {
|
|
11
|
-
if (isEmpty(value)) {
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
return String(value);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
Concatenates the given arguments into a string.
|
|
19
|
-
|
|
20
|
-
Example:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```gjs
|
|
24
|
-
import { concat } from '@ember/helper';
|
|
25
|
-
|
|
26
|
-
<template>
|
|
27
|
-
{{yield (concat firstName " " lastName)}}
|
|
28
|
-
|
|
29
|
-
{{! would yield name="<first name value> <last name value>" to the component}}
|
|
30
|
-
</template>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
or for angle bracket invocation, you actually don't need concat at all.
|
|
34
|
-
|
|
35
|
-
```handlebars
|
|
36
|
-
<SomeComponent @name="{{firstName}} {{lastName}}" />
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
@public
|
|
40
|
-
@method concat
|
|
41
|
-
*/
|
|
42
|
-
const concat = internalHelper(({
|
|
43
|
-
positional
|
|
44
|
-
}) => {
|
|
45
|
-
return createComputeRef(() => reifyPositional(positional).map(normalizeTextValue).join(''), null, 'concat');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
Dynamically look up a property on an object. The second argument to `{{get}}`
|
|
50
|
-
should have a string value, although it can be bound.
|
|
51
|
-
|
|
52
|
-
For example, these two usages are equivalent:
|
|
53
|
-
|
|
54
|
-
```app/components/developer-detail.gjs
|
|
55
|
-
import Component from '@glimmer/component';
|
|
56
|
-
import { tracked } from '@glimmer/tracking';
|
|
57
|
-
import { get } from '@ember/object';
|
|
58
|
-
|
|
59
|
-
export default class extends Component {
|
|
60
|
-
@tracked developer = {
|
|
61
|
-
name: "Sandi Metz",
|
|
62
|
-
language: "Ruby"
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
<template>
|
|
66
|
-
{{this.developer.name}}
|
|
67
|
-
{{get this.developer "name"}}
|
|
68
|
-
</template>
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
If there were several facts about a person, the `{{get}}` helper can dynamically
|
|
73
|
-
pick one:
|
|
74
|
-
|
|
75
|
-
```app/templates/application.gjs
|
|
76
|
-
<template>
|
|
77
|
-
<DeveloperDetail @factName="language" />
|
|
78
|
-
</template>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
```handlebars
|
|
82
|
-
{{get this.developer @factName}}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
For a more complex example, this template would allow the user to switch
|
|
86
|
-
between showing the user's height and weight with a click:
|
|
87
|
-
|
|
88
|
-
```app/components/developer-detail.gjs
|
|
89
|
-
import Component from '@glimmer/component';
|
|
90
|
-
import { tracked } from '@glimmer/tracking';
|
|
91
|
-
import { get } from '@ember/object';
|
|
92
|
-
|
|
93
|
-
export default class extends Component {
|
|
94
|
-
@tracked developer = {
|
|
95
|
-
name: "Sandi Metz",
|
|
96
|
-
language: "Ruby"
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@tracked currentFact = 'name'
|
|
100
|
-
|
|
101
|
-
showFact = (fact) => {
|
|
102
|
-
this.currentFact = fact;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
<template>
|
|
106
|
-
{{get this.developer this.currentFact}}
|
|
107
|
-
|
|
108
|
-
<button {{on 'click' (fn this.showFact "name")}}>Show name</button>
|
|
109
|
-
<button {{on 'click' (fn this.showFact "language")}}>Show language</button>
|
|
110
|
-
</template>
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
@public
|
|
115
|
-
@method get
|
|
116
|
-
*/
|
|
117
|
-
const get = internalHelper(({
|
|
118
|
-
positional
|
|
119
|
-
}) => {
|
|
120
|
-
let sourceRef = positional[0] ?? UNDEFINED_REFERENCE;
|
|
121
|
-
let pathRef = positional[1] ?? UNDEFINED_REFERENCE;
|
|
122
|
-
return createComputeRef(() => {
|
|
123
|
-
let source = valueForRef(sourceRef);
|
|
124
|
-
if (isDict(source)) {
|
|
125
|
-
return getPath(source, String(valueForRef(pathRef)));
|
|
126
|
-
}
|
|
127
|
-
}, value => {
|
|
128
|
-
let source = valueForRef(sourceRef);
|
|
129
|
-
if (isDict(source)) {
|
|
130
|
-
return setPath(source, String(valueForRef(pathRef)), value);
|
|
131
|
-
}
|
|
132
|
-
}, 'get');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
export { concat as c, get as g };
|