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.
Files changed (114) hide show
  1. package/build-metadata.json +3 -3
  2. package/dist/dev/packages/@ember/-internals/glimmer/index.js +6 -6
  3. package/dist/dev/packages/@ember/-internals/routing/index.js +2 -2
  4. package/dist/dev/packages/@ember/-internals/runtime/index.js +1 -1
  5. package/dist/dev/packages/@ember/-internals/runtime/lib/ext/rsvp.js +1 -1
  6. package/dist/dev/packages/@ember/application/index.js +3 -3
  7. package/dist/dev/packages/@ember/application/instance.js +1 -1
  8. package/dist/dev/packages/@ember/component/helper.js +1 -1
  9. package/dist/dev/packages/@ember/component/index.js +2 -2
  10. package/dist/dev/packages/@ember/engine/index.js +3 -3
  11. package/dist/dev/packages/@ember/engine/instance.js +1 -1
  12. package/dist/dev/packages/@ember/helper/index.js +1131 -78
  13. package/dist/dev/packages/@ember/modifier/on.js +1 -1
  14. package/dist/dev/packages/@ember/object/compat.js +0 -32
  15. package/dist/dev/packages/@ember/renderer/index.js +1 -1
  16. package/dist/dev/packages/@ember/routing/-internals.js +2 -2
  17. package/dist/dev/packages/@ember/routing/index.js +6 -26
  18. package/dist/dev/packages/@ember/routing/lib/utils.js +2 -2
  19. package/dist/dev/packages/@ember/routing/route.js +2 -2
  20. package/dist/dev/packages/@ember/routing/router-service.js +9 -9
  21. package/dist/dev/packages/@ember/routing/router.js +2 -2
  22. package/dist/dev/packages/@ember/template-compiler/lib/compile-options.js +3 -3
  23. package/dist/dev/packages/@glimmer/runtime/index.js +4 -4
  24. package/dist/dev/packages/ember/version.js +1 -1
  25. package/dist/dev/packages/router_js/index.js +2 -2
  26. package/dist/dev/packages/rsvp/index.js +1 -2281
  27. package/dist/dev/packages/shared-chunks/{element-BYLB-q7a.js → element-Cgoi4ldD.js} +0 -24
  28. package/dist/dev/packages/shared-chunks/get-B4o_4OLA.js +40 -0
  29. package/dist/dev/packages/shared-chunks/hash-Bg4r3CU4.js +57 -0
  30. package/dist/dev/packages/shared-chunks/{helper-DIj85_-f.js → helper--ZiOCQkd.js} +2 -2
  31. package/dist/dev/packages/shared-chunks/{index-B3pPx1fL.js → index-C5Q8WHUG.js} +205 -81
  32. package/dist/dev/packages/shared-chunks/{not-DYh6AY9Z.js → not-JB6ln6bJ.js} +1 -1
  33. package/dist/dev/packages/shared-chunks/{on-DlF0Wy7P.js → on-CQqC2-wL.js} +21 -10
  34. package/dist/dev/packages/shared-chunks/{rsvp.es-DR7yS7qg.js → rsvp-aLN_pQtn.js} +152 -148
  35. package/dist/dev/packages/shared-chunks/{setup-registry-9DCmHTFF.js → setup-registry-Dovj1LIQ.js} +2 -2
  36. package/dist/dev/packages/shared-chunks/{textarea-C4lYkaHj.js → textarea-B5TmhnQU.js} +2 -22
  37. package/dist/dev/packages/shared-chunks/{unique-id-DQOhouG1.js → unique-id-Csxuh1I7.js} +0 -4
  38. package/dist/dev/packages/shared-chunks/{unrecognized-url-error-BJHjL30Q.js → unrecognized-url-error-DyurFqvv.js} +1 -1
  39. package/dist/prod/packages/@ember/-internals/glimmer/index.js +6 -6
  40. package/dist/prod/packages/@ember/-internals/routing/index.js +2 -2
  41. package/dist/prod/packages/@ember/-internals/runtime/index.js +1 -1
  42. package/dist/prod/packages/@ember/-internals/runtime/lib/ext/rsvp.js +1 -1
  43. package/dist/prod/packages/@ember/application/index.js +3 -3
  44. package/dist/prod/packages/@ember/application/instance.js +1 -1
  45. package/dist/prod/packages/@ember/component/helper.js +1 -1
  46. package/dist/prod/packages/@ember/component/index.js +2 -2
  47. package/dist/prod/packages/@ember/engine/index.js +3 -3
  48. package/dist/prod/packages/@ember/engine/instance.js +1 -1
  49. package/dist/prod/packages/@ember/helper/index.js +1131 -78
  50. package/dist/prod/packages/@ember/modifier/on.js +1 -1
  51. package/dist/prod/packages/@ember/object/compat.js +0 -32
  52. package/dist/prod/packages/@ember/renderer/index.js +1 -1
  53. package/dist/prod/packages/@ember/routing/index.js +6 -26
  54. package/dist/prod/packages/@ember/routing/lib/utils.js +2 -2
  55. package/dist/prod/packages/@ember/routing/route.js +2 -2
  56. package/dist/prod/packages/@ember/routing/router-service.js +9 -9
  57. package/dist/prod/packages/@ember/routing/router.js +2 -2
  58. package/dist/prod/packages/@ember/template-compiler/lib/compile-options.js +3 -3
  59. package/dist/prod/packages/@glimmer/runtime/index.js +4 -4
  60. package/dist/prod/packages/ember/version.js +1 -1
  61. package/dist/prod/packages/router_js/index.js +2 -2
  62. package/dist/prod/packages/rsvp/index.js +1 -2281
  63. package/dist/prod/packages/shared-chunks/{element-DgHdPZ8u.js → element-BmBjPjkQ.js} +0 -24
  64. package/dist/prod/packages/shared-chunks/get-DpBAICuC.js +40 -0
  65. package/dist/prod/packages/shared-chunks/hash-D31JO-BD.js +57 -0
  66. package/dist/prod/packages/shared-chunks/{helper-DkXiTBjc.js → helper-Df5MpdcT.js} +2 -2
  67. package/dist/prod/packages/shared-chunks/{index-CslMfEpb.js → index-BQaaoknf.js} +205 -81
  68. package/dist/prod/packages/shared-chunks/{not-BOIVROuv.js → not-Bm2-x-jD.js} +1 -1
  69. package/dist/prod/packages/shared-chunks/{on-BZHAxzdq.js → on-8aS8t_5D.js} +21 -10
  70. package/dist/prod/packages/shared-chunks/{rsvp.es-DR7yS7qg.js → rsvp-aLN_pQtn.js} +152 -148
  71. package/dist/prod/packages/shared-chunks/{setup-registry-U-6VaNQG.js → setup-registry-DMAzVcVn.js} +2 -2
  72. package/dist/prod/packages/shared-chunks/{textarea-DOmZ1x0E.js → textarea-CQmTzSKe.js} +2 -22
  73. package/dist/prod/packages/shared-chunks/{unique-id-o2pS74go.js → unique-id-BJb1p8EG.js} +0 -4
  74. package/dist/prod/packages/shared-chunks/{unrecognized-url-error-EgNrnFu_.js → unrecognized-url-error-DgXBAzKl.js} +1 -1
  75. package/docs/data.json +1216 -1380
  76. package/package.json +3 -6
  77. package/types/stable/@ember/-internals/glimmer/index.d.ts +7 -380
  78. package/types/stable/@ember/-internals/glimmer/lib/component.d.ts +1 -1
  79. package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +2 -2
  80. package/types/stable/@ember/-internals/glimmer/lib/helpers/each-in.d.ts +171 -62
  81. package/types/stable/@ember/-internals/glimmer/lib/helpers/element.d.ts +0 -24
  82. package/types/stable/@ember/-internals/glimmer/lib/helpers/mut.d.ts +3 -2
  83. package/types/stable/@ember/-internals/glimmer/lib/helpers/readonly.d.ts +3 -1
  84. package/types/stable/@ember/-internals/glimmer/lib/helpers/unbound.d.ts +6 -2
  85. package/types/stable/@ember/-internals/glimmer/lib/helpers/unique-id.d.ts +0 -3
  86. package/types/stable/@ember/-internals/glimmer/lib/syntax/mount.d.ts +4 -2
  87. package/types/stable/@ember/-internals/glimmer/lib/syntax/outlet.d.ts +7 -2
  88. package/types/stable/@ember/helper/index.d.ts +1113 -73
  89. package/types/stable/@ember/object/compat.d.ts +0 -32
  90. package/types/stable/@ember/routing/router-service.d.ts +9 -9
  91. package/types/stable/@glimmer/runtime/lib/helpers/array.d.ts +0 -33
  92. package/types/stable/@glimmer/runtime/lib/helpers/concat.d.ts +0 -25
  93. package/types/stable/@glimmer/runtime/lib/helpers/fn.d.ts +0 -70
  94. package/types/stable/@glimmer/runtime/lib/helpers/get.d.ts +0 -69
  95. package/types/stable/@glimmer/runtime/lib/helpers/hash.d.ts +0 -36
  96. package/types/stable/index.d.ts +0 -14
  97. package/dist/dev/packages/shared-chunks/get-6I3sjd-I.js +0 -135
  98. package/dist/dev/packages/shared-chunks/hash-6NDs_5_f.js +0 -198
  99. package/dist/prod/packages/shared-chunks/get-Dago5uGl.js +0 -135
  100. package/dist/prod/packages/shared-chunks/hash-gEXIsSO4.js +0 -198
  101. package/types/stable/@ember/-internals/glimmer/lib/helpers/array.d.ts +0 -43
  102. package/types/stable/@ember/-internals/glimmer/lib/helpers/component.d.ts +0 -93
  103. package/types/stable/@ember/-internals/glimmer/lib/helpers/concat.d.ts +0 -32
  104. package/types/stable/@ember/-internals/glimmer/lib/helpers/fn.d.ts +0 -77
  105. package/types/stable/@ember/-internals/glimmer/lib/helpers/get.d.ts +0 -94
  106. package/types/stable/@ember/-internals/glimmer/lib/helpers/hash.d.ts +0 -46
  107. package/types/stable/@ember/-internals/glimmer/lib/helpers/helper.d.ts +0 -43
  108. package/types/stable/@ember/-internals/glimmer/lib/helpers/if-unless.d.ts +0 -228
  109. package/types/stable/@ember/-internals/glimmer/lib/helpers/log.d.ts +0 -19
  110. package/types/stable/@ember/-internals/glimmer/lib/helpers/modifier.d.ts +0 -42
  111. package/types/stable/@ember/-internals/glimmer/lib/helpers/page-title.d.ts +0 -24
  112. package/types/stable/@ember/-internals/glimmer/lib/modifiers/on.d.ts +0 -95
  113. package/types/stable/@ember/-internals/glimmer/lib/syntax/in-element.d.ts +0 -49
  114. package/types/stable/@ember/-internals/glimmer/lib/syntax/let.d.ts +0 -43
@@ -67,30 +67,6 @@ function getElementDefinition(tagName) {
67
67
 
68
68
  // ============ Element Helper ============
69
69
 
70
- /**
71
- The `element` helper lets you dynamically set the tag name of an element.
72
-
73
- ```handlebars
74
- {{#let (element @tagName) as |Tag|}}
75
- <Tag class="my-element">Hello</Tag>
76
- {{/let}}
77
- ```
78
-
79
- When `@tagName` is `"h1"`, this renders `<h1 class="my-element">Hello</h1>`.
80
-
81
- When `@tagName` is an empty string `""`, the block content is rendered without
82
- a wrapping element.
83
-
84
- Passing `null`, `undefined`, or non-string values will throw an assertion error.
85
-
86
- Changing the tag name will tear down and recreate the element and its contents.
87
-
88
- The `element` helper is built-in and does not need to be imported.
89
-
90
- @method element
91
- @for Ember.Templates.helpers
92
- @public
93
- */
94
70
  const element = internalHelper(({
95
71
  positional,
96
72
  named
@@ -0,0 +1,40 @@
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-Bg4r3CU4.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
+ const concat = internalHelper(({
17
+ positional
18
+ }) => {
19
+ return createComputeRef(() => reifyPositional(positional).map(normalizeTextValue).join(''), null, 'concat');
20
+ });
21
+
22
+ const get = internalHelper(({
23
+ positional
24
+ }) => {
25
+ let sourceRef = positional[0] ?? UNDEFINED_REFERENCE;
26
+ let pathRef = positional[1] ?? UNDEFINED_REFERENCE;
27
+ return createComputeRef(() => {
28
+ let source = valueForRef(sourceRef);
29
+ if (isDict(source)) {
30
+ return getPath(source, String(valueForRef(pathRef)));
31
+ }
32
+ }, value => {
33
+ let source = valueForRef(sourceRef);
34
+ if (isDict(source)) {
35
+ return setPath(source, String(valueForRef(pathRef)), value);
36
+ }
37
+ }, 'get');
38
+ });
39
+
40
+ export { concat as c, get as g };
@@ -0,0 +1,57 @@
1
+ import { c as createComputeRef, b as isInvokableRef, u as updateRef, v as valueForRef } from './reference-BqOLhKFy.js';
2
+ import { f as reifyPositional, g as buildUntouchableThis, h as check, e as reifyNamed } from './arguments-CDkbOqTS.js';
3
+ import { j as setInternalHelperManager } from './api-DuLOZMO_.js';
4
+
5
+ function internalHelper(helper) {
6
+ return setInternalHelperManager(helper, {});
7
+ }
8
+
9
+ const array = internalHelper(({
10
+ positional
11
+ }) => {
12
+ return createComputeRef(() => reifyPositional(positional), null, 'array');
13
+ });
14
+
15
+ const context = buildUntouchableThis('`fn` helper');
16
+ const fn = internalHelper(({
17
+ positional
18
+ }) => {
19
+ let callbackRef = check(positional[0]);
20
+ return createComputeRef(() => {
21
+ return (...invocationArgs) => {
22
+ let [fn, ...args] = reifyPositional(positional);
23
+ assertCallbackIsFn(callbackRef);
24
+ if (isInvokableRef(callbackRef)) {
25
+ let value = args.length > 0 ? args[0] : invocationArgs[0];
26
+ return void updateRef(callbackRef, value);
27
+ } else {
28
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- @fixme
29
+ return fn.call(context, ...args, ...invocationArgs);
30
+ }
31
+ };
32
+ }, null, 'fn');
33
+ });
34
+ function assertCallbackIsFn(callbackRef) {
35
+ if (!(callbackRef && (isInvokableRef(callbackRef) || typeof valueForRef(callbackRef) === 'function'))) {
36
+ throw new Error(`You must pass a function as the \`fn\` helper's first argument, you passed ${callbackRef ? valueForRef(callbackRef) : callbackRef}. While rendering:\n\n${callbackRef?.debugLabel}`);
37
+ }
38
+ }
39
+
40
+ const hash = internalHelper(({
41
+ named
42
+ }) => {
43
+ let ref = createComputeRef(() => {
44
+ return reifyNamed(named);
45
+ }, null, 'hash');
46
+
47
+ // Setup the children so that templates can bypass getting the value of
48
+ // the reference and treat children lazily
49
+ let children = new Map();
50
+ for (let name in named) {
51
+ children.set(name, named[name]);
52
+ }
53
+ ref.children = children;
54
+ return ref;
55
+ });
56
+
57
+ export { array as a, fn as f, hash as h, internalHelper as i };
@@ -29,7 +29,7 @@ const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
29
29
  Ember Helpers are functions that can compute values, and are used in templates.
30
30
  For example, this code calls a helper named `format-currency`:
31
31
 
32
- ```app/templates/application.gjs
32
+ ```gjs {data-filename="app/templates/application.gjs"}
33
33
  import Cost from '../components/cost';
34
34
 
35
35
  <template>
@@ -37,7 +37,7 @@ const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
37
37
  </template>
38
38
  ```
39
39
 
40
- ```app/components/cost.gjs
40
+ ```gjs {data-filename="app/components/cost.gjs"}
41
41
  import formatCurrency from '../helpers/format-currency';
42
42
 
43
43
  <template>
@@ -36,13 +36,13 @@ import { i as isHTMLSafe } from './index-D-xTBV4B.js';
36
36
  import isArray from '../@ember/array/lib/is-array.js';
37
37
  import { g as getComponentTemplate } from './template-R_5UMHhb.js';
38
38
  import { c as hasInternalComponentManager, j as setInternalHelperManager, g as getInternalComponentManager } from './api-DuLOZMO_.js';
39
- import { h as hash, f as fn, a as array } from './hash-6NDs_5_f.js';
40
- import { g as get$1, c as concat } from './get-6I3sjd-I.js';
41
- import { o as on } from './on-DlF0Wy7P.js';
39
+ import { h as hash, f as fn, a as array } from './hash-Bg4r3CU4.js';
40
+ import { g as get$1, c as concat } from './get-B4o_4OLA.js';
41
+ import { o as on } from './on-CQqC2-wL.js';
42
42
  import { T as TEMPLATE_ONLY_COMPONENT_MANAGER, t as templateOnlyComponent } from './template-only-Cu639ICT.js';
43
- import { i as isClassicHelper, C as CLASSIC_HELPER_MANAGER } from './helper-DIj85_-f.js';
43
+ import { i as isClassicHelper, C as CLASSIC_HELPER_MANAGER } from './helper--ZiOCQkd.js';
44
44
  import { dasherize } from '../@ember/-internals/string/index.js';
45
- import { a as uniqueId } from './unique-id-DQOhouG1.js';
45
+ import { a as uniqueId } from './unique-id-Csxuh1I7.js';
46
46
  import { generateControllerFactory } from '../@ember/routing/lib/generate_controller.js';
47
47
  import { E as EvaluationContextImpl } from './program-context-Dq8xN2HI.js';
48
48
 
@@ -238,7 +238,7 @@ class RootComponentDefinition {
238
238
  }
239
239
 
240
240
  /**
241
- @module ember
241
+ @module @ember/helper
242
242
  */
243
243
 
244
244
  /**
@@ -248,46 +248,91 @@ class RootComponentDefinition {
248
248
  The default behavior of `{{#each}}` is to yield its inner block once for every
249
249
  item in an array passing the item as the first block parameter.
250
250
 
251
- Assuming the `@developers` argument contains this array:
251
+ ```gjs {data-filename="app/components/developer-list.gjs"}
252
+ import Component from '@glimmer/component';
252
253
 
253
- ```javascript
254
- [{ name: 'Yehuda' },{ name: 'Tom' }, { name: 'Paul' }];
255
- ```
254
+ export default class DeveloperList extends Component {
255
+ developers = [
256
+ { name: 'Yehuda' },
257
+ { name: 'Tom' },
258
+ { name: 'Paul' },
259
+ ];
256
260
 
257
- ```handlebars
258
- <ul>
259
- {{#each @developers as |person|}}
260
- <li>Hello, {{person.name}}!</li>
261
- {{/each}}
262
- </ul>
261
+ <template>
262
+ <ul>
263
+ {{#each this.developers as |person|}}
264
+ <li>Hello, {{person.name}}!</li>
265
+ {{/each}}
266
+ </ul>
267
+ </template>
268
+ }
263
269
  ```
264
270
 
265
- The same rules apply to arrays of primitives.
271
+ The same rules apply to arrays of primitives:
272
+
273
+ ```app/components/developer-names.gjs
274
+ import Component from '@glimmer/component';
275
+
276
+ export default class DeveloperNames extends Component {
277
+ developerNames = ['Yehuda', 'Tom', 'Paul'];
266
278
 
267
- ```javascript
268
- ['Yehuda', 'Tom', 'Paul']
279
+ <template>
280
+ <ul>
281
+ {{#each this.developerNames as |name|}}
282
+ <li>Hello, {{name}}!</li>
283
+ {{/each}}
284
+ </ul>
285
+ </template>
286
+ }
269
287
  ```
270
288
 
271
- ```handlebars
272
- <ul>
273
- {{#each @developerNames as |name|}}
274
- <li>Hello, {{name}}!</li>
275
- {{/each}}
276
- </ul>
289
+ `{{#each}}` also supports native JavaScript [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
290
+ values and other iterables:
291
+
292
+ ```gjs {data-filename="app/components/developer-set.gjs"}
293
+ import Component from '@glimmer/component';
294
+
295
+ export default class DeveloperSet extends Component {
296
+ developers = new Set([
297
+ { name: 'Yehuda' },
298
+ { name: 'Tom' },
299
+ { name: 'Paul' },
300
+ ]);
301
+
302
+ <template>
303
+ <ul>
304
+ {{#each this.developers as |person|}}
305
+ <li>Hello, {{person.name}}!</li>
306
+ {{/each}}
307
+ </ul>
308
+ </template>
309
+ }
277
310
  ```
278
311
 
279
- During iteration, the index of each item in the array is provided as a second block
280
- parameter.
312
+ During iteration, the index of each item in the array is provided as a second
313
+ block parameter:
281
314
 
282
- ```handlebars
283
- <ul>
284
- {{#each @developers as |person index|}}
285
- <li>Hello, {{person.name}}! You're number {{index}} in line</li>
286
- {{/each}}
287
- </ul>
315
+ ```app/components/developer-list-with-index.gjs
316
+ import Component from '@glimmer/component';
317
+
318
+ export default class DeveloperListWithIndex extends Component {
319
+ developers = [
320
+ { name: 'Yehuda' },
321
+ { name: 'Tom' },
322
+ { name: 'Paul' },
323
+ ];
324
+
325
+ <template>
326
+ <ul>
327
+ {{#each this.developers as |person index|}}
328
+ <li>Hello, {{person.name}}! You're number {{index}} in line</li>
329
+ {{/each}}
330
+ </ul>
331
+ </template>
332
+ }
288
333
  ```
289
-
290
- `#each` is a keyword and does not need to be imported.
334
+
335
+ `#each` is a keyword and does not need to be imported.
291
336
 
292
337
  ### Specifying Keys
293
338
 
@@ -303,30 +348,38 @@ class RootComponentDefinition {
303
348
  needed. However, in some rare cases, the objects' identities may change even
304
349
  though they represent the same underlying data.
305
350
 
306
- For example:
351
+ For example, mapping over `people` produces a new array of new objects on each
352
+ render. Use `key` so Ember can match items across those renders:
307
353
 
308
- ```javascript
309
- people.map(person => {
310
- return { ...person, type: 'developer' };
311
- });
312
- ```
354
+ ```gjs {data-filename="app/components/mapped-developers.gjs"}
355
+ import Component from '@glimmer/component';
313
356
 
314
- In this case, each time the `people` array is `map`-ed over, it will produce
315
- an new array with completely different objects between renders. In these cases,
316
- you can help Ember determine how these objects related to each other with the
317
- `key` option:
357
+ export default class MappedDevelopers extends Component {
358
+ people = [
359
+ { name: 'Yehuda' },
360
+ { name: 'Tom' },
361
+ { name: 'Paul' },
362
+ ];
318
363
 
319
- ```handlebars
320
- <ul>
321
- {{#each @developers key="name" as |person|}}
322
- <li>Hello, {{person.name}}!</li>
323
- {{/each}}
324
- </ul>
364
+ get developers() {
365
+ return this.people.map((person) => {
366
+ return { ...person, type: 'developer' };
367
+ });
368
+ }
369
+
370
+ <template>
371
+ <ul>
372
+ {{#each this.developers key="name" as |person|}}
373
+ <li>Hello, {{person.name}}!</li>
374
+ {{/each}}
375
+ </ul>
376
+ </template>
377
+ }
325
378
  ```
326
379
 
327
380
  By doing so, Ember will use the value of the property specified (`person.name`
328
381
  in the example) to find a "match" from the previous render. That is, if Ember
329
- has previously seen an object from the `@developers` array with a matching
382
+ has previously seen an object from the `developers` array with a matching
330
383
  name, its DOM elements will be re-used.
331
384
 
332
385
  There are two special values for `key`:
@@ -339,36 +392,47 @@ class RootComponentDefinition {
339
392
  `{{#each}}` can have a matching `{{else}}`. The contents of this block will render
340
393
  if the collection is empty.
341
394
 
342
- ```handlebars
343
- <ul>
344
- {{#each @developers as |person|}}
345
- <li>{{person.name}} is available!</li>
346
- {{else}}
347
- <li>Sorry, nobody is available for this task.</li>
348
- {{/each}}
349
- </ul>
395
+ ```gjs {data-filename="app/components/available-developers.gjs"}
396
+ import Component from '@glimmer/component';
397
+
398
+ export default class AvailableDevelopers extends Component {
399
+ developers = [];
400
+
401
+ <template>
402
+ <ul>
403
+ {{#each this.developers as |person|}}
404
+ <li>{{person.name}} is available!</li>
405
+ {{else}}
406
+ <li>Sorry, nobody is available for this task.</li>
407
+ {{/each}}
408
+ </ul>
409
+ </template>
410
+ }
350
411
  ```
351
412
 
352
413
  @method each
353
- @for Ember.Templates.helpers
414
+ @for Keywords
415
+ @static
416
+ @noimport
354
417
  @public
355
418
  */
356
419
 
357
420
  /**
358
- The `{{#each-in}}` keyword loops over properties on an object.
421
+ The `{{#each-in}}` keyword loops over properties on an object, or entries in a
422
+ native JavaScript [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).
359
423
 
360
424
  For example, given this component definition:
361
425
 
362
- ```app/components/developer-details.gjs
426
+ ```gjs {data-filename="app/components/developer-details.gjs"}
363
427
  import Component from '@glimmer/component';
364
428
  import { tracked } from '@glimmer/tracking';
365
429
 
366
- export default class extends Component {
430
+ export default class DeveloperDetails extends Component {
367
431
  @tracked developer = {
368
- "name": "Shelly Sails",
369
- "age": 42
432
+ name: 'Shelly Sails',
433
+ age: 42,
370
434
  };
371
-
435
+
372
436
  <template>
373
437
  <ul>
374
438
  {{#each-in this.developer as |key value|}}
@@ -388,11 +452,56 @@ class RootComponentDefinition {
388
452
  <li>age: 42</li>
389
453
  </ul>
390
454
  ```
391
-
455
+
456
+ The same pattern works with a `Map`:
457
+
458
+ ```gjs {data-filename="app/components/developer-map.gjs"}
459
+ import Component from '@glimmer/component';
460
+
461
+ export default class DeveloperMap extends Component {
462
+ map = new Map([
463
+ ['name', 'Shelly Sails'],
464
+ ['age', 42],
465
+ ]);
466
+
467
+ <template>
468
+ <ul>
469
+ {{#each-in this.map as |key value|}}
470
+ <li>{{key}}: {{value}}</li>
471
+ {{/each-in}}
472
+ </ul>
473
+ </template>
474
+ }
475
+ ```
476
+
477
+ When a `Map` uses object keys, you can pass `key="@identity"` to explicitly
478
+ track entries across re-renders using the JavaScript identity of each key:
479
+
480
+ ```gjs {data-filename="app/components/object-keyed-map.gjs"}
481
+ import Component from '@glimmer/component';
482
+
483
+ export default class ObjectKeyedMap extends Component {
484
+ map = new Map([
485
+ [{ name: 'one' }, 'foo'],
486
+ [{ name: 'two' }, 'bar'],
487
+ ]);
488
+
489
+ <template>
490
+ <ul>
491
+ {{#each-in this.map key="@identity" as |key value|}}
492
+ <li>{{key.name}}: {{value}}</li>
493
+ {{/each-in}}
494
+ </ul>
495
+ </template>
496
+ }
497
+ ```
498
+
392
499
  `#each-in` is a keyword and does not need to be imported.
393
500
 
394
501
  @method each-in
395
- @for Ember.Templates.helpers
502
+ @static
503
+ @noimport
504
+ @for Keywords
396
505
  @public
397
506
  @since 2.1.0
398
507
  */
@@ -855,7 +964,7 @@ const trackArray = internalHelper(({
855
964
  });
856
965
 
857
966
  /**
858
- @module ember
967
+ @module @ember/helper
859
968
  */
860
969
 
861
970
  /**
@@ -875,7 +984,7 @@ const trackArray = internalHelper(({
875
984
 
876
985
  The child `Component` would invoke the function with the new click count:
877
986
 
878
- ```app/components/my-child.gjs
987
+ ```gjs {data-filename="app/components/my-child.gjs"}
879
988
  import Component from '@glimmer/component';
880
989
  import { action } from '@ember/object';
881
990
 
@@ -897,7 +1006,8 @@ const trackArray = internalHelper(({
897
1006
 
898
1007
  @method mut
899
1008
  @param {Object} [attr] the "two-way" attribute that can be modified.
900
- @for Ember.Templates.helpers
1009
+ @static
1010
+ @for Keywords
901
1011
  @public
902
1012
  */
903
1013
 
@@ -922,7 +1032,7 @@ const mut = internalHelper(({
922
1032
  });
923
1033
 
924
1034
  /**
925
- @module ember
1035
+ @module @ember/helper
926
1036
  */
927
1037
 
928
1038
 
@@ -1034,7 +1144,9 @@ const mut = internalHelper(({
1034
1144
 
1035
1145
  @method readonly
1036
1146
  @param {Object} [attr] the read-only attribute.
1037
- @for Ember.Templates.helpers
1147
+ @for Keywords
1148
+ @noimport
1149
+ @static
1038
1150
  @private
1039
1151
  */
1040
1152
  const readonly = internalHelper(({
@@ -1046,7 +1158,7 @@ const readonly = internalHelper(({
1046
1158
  });
1047
1159
 
1048
1160
  /**
1049
- @module ember
1161
+ @module @ember/helper
1050
1162
  */
1051
1163
 
1052
1164
 
@@ -1072,9 +1184,13 @@ const readonly = internalHelper(({
1072
1184
 
1073
1185
  The `unbound` helper only accepts a single argument, and it return an
1074
1186
  unbound value.
1187
+
1188
+ `unbound` is a template keyword and does not need to be imported.
1075
1189
 
1076
1190
  @method unbound
1077
- @for Ember.Templates.helpers
1191
+ @static
1192
+ @noimport
1193
+ @for Keywords
1078
1194
  @public
1079
1195
  */
1080
1196
 
@@ -1217,7 +1333,7 @@ class MountDefinition {
1217
1333
  }
1218
1334
 
1219
1335
  /**
1220
- @module ember
1336
+ @module @ember/helper
1221
1337
  */
1222
1338
 
1223
1339
 
@@ -1228,7 +1344,7 @@ class MountDefinition {
1228
1344
 
1229
1345
  For example, the following template mounts the `ember-chat` engine:
1230
1346
 
1231
- ```app/templates/application.gjs
1347
+ ```gjs {data-filename="app/templates/application.gjs"}
1232
1348
  {{mount "ember-chat"}}
1233
1349
  ```
1234
1350
 
@@ -1262,7 +1378,9 @@ class MountDefinition {
1262
1378
  @param {String} name Name of the engine to mount.
1263
1379
  @param {Object} [model] Object that will be set as
1264
1380
  the model of the engine.
1265
- @for Ember.Templates.helpers
1381
+ @for Keywords
1382
+ @static
1383
+ @noimport
1266
1384
  @public
1267
1385
  */
1268
1386
  const mountHelper = internalHelper((args, owner) => {
@@ -1397,12 +1515,16 @@ function makeRouteTemplate(owner, name, template) {
1397
1515
  return curry(0, routeTemplate, owner, null, true);
1398
1516
  }
1399
1517
 
1518
+ /**
1519
+ @module @ember/helper
1520
+ */
1521
+
1400
1522
  /**
1401
1523
  The `{{outlet}}` helper lets you specify where a child route will render in
1402
1524
  your template. An important use of the `{{outlet}}` helper is in your
1403
1525
  application's `application.gjs` file:
1404
1526
 
1405
- ```app/templates/application.gjs
1527
+ ```gjs {data-filename="app/templates/application.gjs"}
1406
1528
  import MyHeader from '../components/my-header';
1407
1529
  import MyFooter from '../components/my-footer';
1408
1530
 
@@ -1425,7 +1547,9 @@ function makeRouteTemplate(owner, name, template) {
1425
1547
  `outlet` is built-in and does not need to be imported.
1426
1548
 
1427
1549
  @method outlet
1428
- @for Ember.Templates.helpers
1550
+ @for Keywords
1551
+ @static
1552
+ @noimport
1429
1553
  @public
1430
1554
  */
1431
1555
  const outletHelper = internalHelper((_args, owner, scope) => {
@@ -1,6 +1,6 @@
1
1
  import { toBool } from '../@glimmer/global-context/index.js';
2
2
  import { c as createComputeRef, v as valueForRef } from './reference-BqOLhKFy.js';
3
- import { i as internalHelper } from './hash-6NDs_5_f.js';
3
+ import { i as internalHelper } from './hash-Bg4r3CU4.js';
4
4
 
5
5
  /**
6
6
  * Performs a strict equality comparison.
@@ -131,6 +131,10 @@ function addEventListener(element, eventName, callback, options) {
131
131
  element.addEventListener(eventName, callback, options);
132
132
  }
133
133
 
134
+ /**
135
+ @module @ember/helper
136
+ */
137
+
134
138
  /**
135
139
  The `{{on}}` modifier lets you easily add event listeners (it uses
136
140
  [EventTarget.addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener)
@@ -139,12 +143,13 @@ function addEventListener(element, eventName, callback, options) {
139
143
  For example, if you'd like to run a function on your component when a `<button>`
140
144
  in the components template is clicked you might do something like:
141
145
 
142
- ```app/components/like-post.gjs
146
+ ```gjs {data-filename="app/components/like-post.gjs"}
143
147
  import Component from '@glimmer/component';
144
148
  import { action } from '@ember/object';
145
149
 
146
- export default class LikePostComponent extends Component {
147
- saveLike = () => {
150
+ export default class LikePost extends Component {
151
+ @action
152
+ saveLike() {
148
153
  // someone likes your post!
149
154
  // better send a request off to your server...
150
155
  }
@@ -186,7 +191,7 @@ function addEventListener(element, eventName, callback, options) {
186
191
  For example, in our example case above if you'd like to pass in the post that
187
192
  was being liked when the button is clicked you could do something like:
188
193
 
189
- ```app/components/like-post.hbs
194
+ ```hbs
190
195
  <button {{on 'click' (fn this.saveLike @post)}}>Like this post!</button>
191
196
  ```
192
197
 
@@ -195,14 +200,14 @@ function addEventListener(element, eventName, callback, options) {
195
200
 
196
201
  ### Function Context
197
202
 
198
- In the example above, we used an arrow function to ensure that `likePost` is
199
- properly bound to the `items-list`, but let's explore what happens if we
200
- left out the arrow function:
203
+ In the example above, we used `@action` to ensure that `likePost` is
204
+ properly bound to the `LikePost` Component, but let's explore what happens if we
205
+ left out `@action`:
201
206
 
202
- ```app/components/like-post.gjs
207
+ ```gjs {data-filename="app/components/like-post.gjs"}
203
208
  import Component from '@glimmer/component';
204
209
 
205
- export default class LikePostComponent extends Component {
210
+ export default class LikePost extends Component {
206
211
  saveLike() {
207
212
  // ...snip...
208
213
  }
@@ -212,10 +217,16 @@ function addEventListener(element, eventName, callback, options) {
212
217
  In this example, when the button is clicked `saveLike` will be invoked,
213
218
  it will **not** have access to the component instance. In other
214
219
  words, it will have no `this` context, so please make sure your functions
215
- are bound (via an arrow function or other means) before passing into `on`!
220
+ are bound (via `@action` or other means) before passing into `on`!
221
+
222
+ The `on` modifier is a keyword and does not need to be imported.
216
223
 
217
224
  @method on
225
+ @static
226
+ @for Keywords
227
+ @noimport
218
228
  @public
229
+ @since 3.11.0
219
230
  */
220
231
  class OnModifierManager {
221
232
  getDebugName() {