@angular/animations 13.1.0-next.1 → 13.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/animations.d.ts +153 -154
  2. package/browser/browser.d.ts +9 -8
  3. package/browser/testing/testing.d.ts +2 -2
  4. package/esm2020/browser/src/dsl/animation_ast_builder.mjs +3 -2
  5. package/esm2020/browser/src/dsl/animation_timeline_builder.mjs +8 -8
  6. package/esm2020/browser/src/dsl/element_instruction_map.mjs +3 -10
  7. package/esm2020/browser/src/private_export.mjs +2 -2
  8. package/esm2020/browser/src/render/animation_driver.mjs +8 -7
  9. package/esm2020/browser/src/render/css_keyframes/css_keyframes_driver.mjs +5 -4
  10. package/esm2020/browser/src/render/shared.mjs +1 -19
  11. package/esm2020/browser/src/render/transition_animation_engine.mjs +36 -55
  12. package/esm2020/browser/src/render/web_animations/web_animations_driver.mjs +5 -4
  13. package/esm2020/browser/src/render/web_animations/web_animations_player.mjs +7 -4
  14. package/esm2020/browser/src/util.mjs +1 -3
  15. package/esm2020/browser/testing/src/mock_animation_driver.mjs +4 -4
  16. package/esm2020/src/animation_metadata.mjs +153 -154
  17. package/esm2020/src/version.mjs +3 -16
  18. package/fesm2015/animations.mjs +153 -154
  19. package/fesm2015/animations.mjs.map +1 -1
  20. package/fesm2015/browser/testing.mjs +4 -4
  21. package/fesm2015/browser/testing.mjs.map +1 -1
  22. package/fesm2015/browser.mjs +69 -105
  23. package/fesm2015/browser.mjs.map +1 -1
  24. package/fesm2020/animations.mjs +153 -154
  25. package/fesm2020/animations.mjs.map +1 -1
  26. package/fesm2020/browser/testing.mjs +4 -4
  27. package/fesm2020/browser/testing.mjs.map +1 -1
  28. package/fesm2020/browser.mjs +66 -105
  29. package/fesm2020/browser.mjs.map +1 -1
  30. package/package.json +2 -2
package/animations.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.1.0-next.1
2
+ * @license Angular v13.1.1
3
3
  * (c) 2010-2021 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -81,10 +81,6 @@ export declare function animate(timings: string | number, styles?: AnimationStyl
81
81
  * with animations that are assigned using the Angular animation library. CSS keyframes
82
82
  * and transitions are not handled by this API.
83
83
  *
84
- * `animateChild()` does not currently work with route transition animations. Please see
85
- * GitHub Issue {@link https://github.com/angular/angular/issues/30477 #30477} for more
86
- * information.
87
- *
88
84
  * @publicApi
89
85
  */
90
86
  export declare function animateChild(options?: AnimateChildOptions | null): AnimationAnimateChildMetadata;
@@ -940,7 +936,9 @@ export declare class NoopAnimationPlayer implements AnimationPlayer {
940
936
  *
941
937
  * @param selector The element to query, or a set of elements that contain Angular-specific
942
938
  * characteristics, specified with one or more of the following tokens.
943
- * - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements.
939
+ * - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements (not
940
+ * all elements can be queried via these tokens, see
941
+ * [Entering and Leaving Elements](#entering-and-leaving-elements))
944
942
  * - `query(":animating")` : Query all currently animating elements.
945
943
  * - `query("@triggerName")` : Query elements that contain an animation trigger.
946
944
  * - `query("@*")` : Query all elements that contain an animation triggers.
@@ -953,6 +951,9 @@ export declare class NoopAnimationPlayer implements AnimationPlayer {
953
951
  * @return An object that encapsulates the query data.
954
952
  *
955
953
  * @usageNotes
954
+ *
955
+ * ### Multiple Tokens
956
+ *
956
957
  * Tokens can be merged into a combined query selector string. For example:
957
958
  *
958
959
  * ```typescript
@@ -980,6 +981,26 @@ export declare class NoopAnimationPlayer implements AnimationPlayer {
980
981
  * ], { optional: true })
981
982
  * ```
982
983
  *
984
+ * ### Entering and Leaving Elements
985
+ *
986
+ * Not all elements can be queried via the `:enter` and `:leave` tokens, the only ones
987
+ * that can are those that Angular assumes can enter/leave based on their own logic
988
+ * (if their insertion/removal is simply a consequence of that of their parent they
989
+ * should be queried via a different token in their parent's `:enter`/`:leave` transitions).
990
+ *
991
+ * The only elements Angular assumes can enter/leave on their own logic (thus the only
992
+ * ones that can be queried via the `:enter` and `:leave` tokens) are:
993
+ * - Those inserted dynamically (via `ViewContainerRef`)
994
+ * - Those that have a structural directive (which, under the hood, are a subset of the above ones)
995
+ *
996
+ * <div class="alert is-helpful">
997
+ *
998
+ * Note that elements will be successfully queried via `:enter`/`:leave` even if their
999
+ * insertion/removal is not done manually via `ViewContainerRef`or caused by their structural
1000
+ * directive (e.g. they enter/exit alongside their parent).
1001
+ *
1002
+ * </div>
1003
+ *
983
1004
  * ### Usage Example
984
1005
  *
985
1006
  * The following example queries for inner elements and animates them
@@ -1204,8 +1225,8 @@ export declare function state(name: string, styles: AnimationStyleMetadata, opti
1204
1225
  * style({ width: 100, height: 0 })
1205
1226
  * ```
1206
1227
  *
1207
- * The following example uses auto-styling to allow a component to animate from
1208
- * a height of 0 up to the height of the parent element:
1228
+ * The following example uses auto-styling to allow an element to animate from
1229
+ * a height of 0 up to its full height:
1209
1230
  *
1210
1231
  * ```
1211
1232
  * style({ height: 0 }),
@@ -1221,170 +1242,148 @@ export declare function style(tokens: '*' | {
1221
1242
  }>): AnimationStyleMetadata;
1222
1243
 
1223
1244
  /**
1224
- * Declares an animation transition as a sequence of animation steps to run when a given
1225
- * condition is satisfied. The condition is a Boolean expression or function that compares
1226
- * the previous and current animation states, and returns true if this transition should occur.
1227
- * When the state criteria of a defined transition are met, the associated animation is
1228
- * triggered.
1229
- *
1230
- * @param stateChangeExpr A Boolean expression or function that compares the previous and current
1231
- * animation states, and returns true if this transition should occur. Note that "true" and "false"
1232
- * match 1 and 0, respectively. An expression is evaluated each time a state change occurs in the
1233
- * animation trigger element.
1234
- * The animation steps run when the expression evaluates to true.
1235
- *
1236
- * - A state-change string takes the form "state1 => state2", where each side is a defined animation
1237
- * state, or an asterix (*) to refer to a dynamic start or end state.
1238
- * - The expression string can contain multiple comma-separated statements;
1239
- * for example "state1 => state2, state3 => state4".
1240
- * - Special values `:enter` and `:leave` initiate a transition on the entry and exit states,
1241
- * equivalent to "void => *" and "* => void".
1242
- * - Special values `:increment` and `:decrement` initiate a transition when a numeric value has
1243
- * increased or decreased in value.
1244
- * - A function is executed each time a state change occurs in the animation trigger element.
1245
- * The animation steps run when the function returns true.
1246
- *
1247
- * @param steps One or more animation objects, as returned by the `animate()` or
1248
- * `sequence()` function, that form a transformation from one state to another.
1249
- * A sequence is used by default when you pass an array.
1250
- * @param options An options object that can contain a delay value for the start of the animation,
1251
- * and additional developer-defined parameters. Provided values for additional parameters are used
1252
- * as defaults, and override values can be passed to the caller on invocation.
1253
- * @returns An object that encapsulates the transition data.
1245
+ * Declares an animation transition which is played when a certain specified condition is met.
1254
1246
  *
1255
- * @usageNotes
1256
- * The template associated with a component binds an animation trigger to an element.
1247
+ * @param stateChangeExpr A string with a specific format or a function that specifies when the
1248
+ * animation transition should occur (see [State Change Expression](#state-change-expression)).
1257
1249
  *
1258
- * ```HTML
1259
- * <!-- somewhere inside of my-component-tpl.html -->
1260
- * <div [@myAnimationTrigger]="myStatusExp">...</div>
1261
- * ```
1250
+ * @param steps One or more animation objects that represent the animation's instructions.
1262
1251
  *
1263
- * All transitions are defined within an animation trigger,
1264
- * along with named states that the transitions change to and from.
1252
+ * @param options An options object that can be used to specify a delay for the animation or provide
1253
+ * custom parameters for it.
1265
1254
  *
1266
- * ```typescript
1267
- * trigger("myAnimationTrigger", [
1268
- * // define states
1269
- * state("on", style({ background: "green" })),
1270
- * state("off", style({ background: "grey" })),
1271
- * ...]
1272
- * ```
1255
+ * @returns An object that encapsulates the transition data.
1273
1256
  *
1274
- * Note that when you call the `sequence()` function within a `{@link animations/group group()}`
1275
- * or a `transition()` call, execution does not continue to the next instruction
1276
- * until each of the inner animation steps have completed.
1257
+ * @usageNotes
1277
1258
  *
1278
- * ### Syntax examples
1259
+ * ### State Change Expression
1260
+ *
1261
+ * The State Change Expression instructs Angular when to run the transition's animations, it can
1262
+ *either be
1263
+ * - a string with a specific syntax
1264
+ * - or a function that compares the previous and current state (value of the expression bound to
1265
+ * the element's trigger) and returns `true` if the transition should occur or `false` otherwise
1266
+ *
1267
+ * The string format can be:
1268
+ * - `fromState => toState`, which indicates that the transition's animations should occur then the
1269
+ * expression bound to the trigger's element goes from `fromState` to `toState`
1270
+ *
1271
+ * _Example:_
1272
+ * ```typescript
1273
+ * transition('open => closed', animate('.5s ease-out', style({ height: 0 }) ))
1274
+ * ```
1275
+ *
1276
+ * - `fromState <=> toState`, which indicates that the transition's animations should occur then
1277
+ * the expression bound to the trigger's element goes from `fromState` to `toState` or vice versa
1278
+ *
1279
+ * _Example:_
1280
+ * ```typescript
1281
+ * transition('enabled <=> disabled', animate('1s cubic-bezier(0.8,0.3,0,1)'))
1282
+ * ```
1283
+ *
1284
+ * - `:enter`/`:leave`, which indicates that the transition's animations should occur when the
1285
+ * element enters or exists the DOM
1286
+ *
1287
+ * _Example:_
1288
+ * ```typescript
1289
+ * transition(':enter', [
1290
+ * style({ opacity: 0 }),
1291
+ * animate('500ms', style({ opacity: 1 }))
1292
+ * ])
1293
+ * ```
1294
+ *
1295
+ * - `:increment`/`:decrement`, which indicates that the transition's animations should occur when
1296
+ * the numerical expression bound to the trigger's element has increased in value or decreased
1297
+ *
1298
+ * _Example:_
1299
+ * ```typescript
1300
+ * transition(':increment', query('@counter', animateChild()))
1301
+ * ```
1302
+ *
1303
+ * - a sequence of any of the above divided by commas, which indicates that transition's animations
1304
+ * should occur whenever one of the state change expressions matches
1305
+ *
1306
+ * _Example:_
1307
+ * ```typescript
1308
+ * transition(':increment, * => enabled, :enter', animate('1s ease', keyframes([
1309
+ * style({ transform: 'scale(1)', offset: 0}),
1310
+ * style({ transform: 'scale(1.1)', offset: 0.7}),
1311
+ * style({ transform: 'scale(1)', offset: 1})
1312
+ * ]))),
1313
+ * ```
1314
+ *
1315
+ * Also note that in such context:
1316
+ * - `void` can be used to indicate the absence of the element
1317
+ * - asterisks can be used as wildcards that match any state
1318
+ * - (as a consequence of the above, `void => *` is equivalent to `:enter` and `* => void` is
1319
+ * equivalent to `:leave`)
1320
+ * - `true` and `false` also match expression values of `1` and `0` respectively (but do not match
1321
+ * _truthy_ and _falsy_ values)
1322
+ *
1323
+ * <div class="alert is-helpful">
1324
+ *
1325
+ * Be careful about entering end leaving elements as their transitions present a common
1326
+ * pitfall for developers.
1327
+ *
1328
+ * Note that when an element with a trigger enters the DOM its `:enter` transition always
1329
+ * gets executed, but its `:leave` transition will not be executed if the element is removed
1330
+ * alongside its parent (as it will be removed "without warning" before its transition has
1331
+ * a chance to be executed, the only way that such transition can occur is if the element
1332
+ * is exiting the DOM on its own).
1279
1333
  *
1280
- * The following examples define transitions between the two defined states (and default states),
1281
- * using various options:
1282
1334
  *
1283
- * ```typescript
1284
- * // Transition occurs when the state value
1285
- * // bound to "myAnimationTrigger" changes from "on" to "off"
1286
- * transition("on => off", animate(500))
1287
- * // Run the same animation for both directions
1288
- * transition("on <=> off", animate(500))
1289
- * // Define multiple state-change pairs separated by commas
1290
- * transition("on => off, off => void", animate(500))
1291
- * ```
1335
+ * </div>
1292
1336
  *
1293
- * ### Special values for state-change expressions
1337
+ * ### Animating to a Final State
1294
1338
  *
1295
- * - Catch-all state change for when an element is inserted into the page and the
1296
- * destination state is unknown:
1339
+ * If the final step in a transition is a call to `animate()` that uses a timing value
1340
+ * with no `style` data, that step is automatically considered the final animation arc,
1341
+ * for the element to reach the final state, in such case Angular automatically adds or removes
1342
+ * CSS styles to ensure that the element is in the correct final state.
1297
1343
  *
1298
- * ```typescript
1299
- * transition("void => *", [
1300
- * style({ opacity: 0 }),
1301
- * animate(500)
1302
- * ])
1303
- * ```
1304
1344
  *
1305
- * - Capture a state change between any states:
1345
+ * ### Usage Examples
1306
1346
  *
1307
- * `transition("* => *", animate("1s 0s"))`
1347
+ * - Transition animations applied based on
1348
+ * the trigger's expression value
1308
1349
  *
1309
- * - Entry and exit transitions:
1350
+ * ```HTML
1351
+ * <div [@myAnimationTrigger]="myStatusExp">
1352
+ * ...
1353
+ * </div>
1354
+ * ```
1310
1355
  *
1311
- * ```typescript
1312
- * transition(":enter", [
1313
- * style({ opacity: 0 }),
1314
- * animate(500, style({ opacity: 1 }))
1315
- * ]),
1316
- * transition(":leave", [
1317
- * animate(500, style({ opacity: 0 }))
1356
+ * ```typescript
1357
+ * trigger("myAnimationTrigger", [
1358
+ * ..., // states
1359
+ * transition("on => off, open => closed", animate(500)),
1360
+ * transition("* <=> error", query('.indicator', animateChild()))
1318
1361
  * ])
1319
- * ```
1320
- *
1321
- * - Use `:increment` and `:decrement` to initiate transitions:
1322
- *
1323
- * ```typescript
1324
- * transition(":increment", group([
1325
- * query(':enter', [
1326
- * style({ left: '100%' }),
1327
- * animate('0.5s ease-out', style('*'))
1328
- * ]),
1329
- * query(':leave', [
1330
- * animate('0.5s ease-out', style({ left: '-100%' }))
1331
- * ])
1332
- * ]))
1333
- *
1334
- * transition(":decrement", group([
1335
- * query(':enter', [
1336
- * style({ left: '100%' }),
1337
- * animate('0.5s ease-out', style('*'))
1338
- * ]),
1339
- * query(':leave', [
1340
- * animate('0.5s ease-out', style({ left: '-100%' }))
1341
- * ])
1342
- * ]))
1343
- * ```
1344
- *
1345
- * ### State-change functions
1346
- *
1347
- * Here is an example of a `fromState` specified as a state-change function that invokes an
1348
- * animation when true:
1349
- *
1350
- * ```typescript
1351
- * transition((fromState, toState) =>
1352
- * {
1353
- * return fromState == "off" && toState == "on";
1354
- * },
1355
- * animate("1s 0s"))
1356
- * ```
1357
- *
1358
- * ### Animating to the final state
1359
- *
1360
- * If the final step in a transition is a call to `animate()` that uses a timing value
1361
- * with no style data, that step is automatically considered the final animation arc,
1362
- * for the element to reach the final state. Angular automatically adds or removes
1363
- * CSS styles to ensure that the element is in the correct final state.
1362
+ * ```
1364
1363
  *
1365
- * The following example defines a transition that starts by hiding the element,
1366
- * then makes sure that it animates properly to whatever state is currently active for trigger:
1364
+ * - Transition animations applied based on custom logic dependent
1365
+ * on the trigger's expression value and provided parameters
1367
1366
  *
1368
- * ```typescript
1369
- * transition("void => *", [
1370
- * style({ opacity: 0 }),
1371
- * animate(500)
1372
- * ])
1373
- * ```
1374
- * ### Boolean value matching
1375
- * If a trigger binding value is a Boolean, it can be matched using a transition expression
1376
- * that compares true and false or 1 and 0. For example:
1377
- *
1378
- * ```
1379
- * // in the template
1380
- * <div [@openClose]="open ? true : false">...</div>
1381
- * // in the component metadata
1382
- * trigger('openClose', [
1383
- * state('true', style({ height: '*' })),
1384
- * state('false', style({ height: '0px' })),
1385
- * transition('false <=> true', animate(500))
1386
- * ])
1387
- * ```
1367
+ * ```HTML
1368
+ * <div [@myAnimationTrigger]="{
1369
+ * value: stepName,
1370
+ * params: { target: currentTarget }
1371
+ * }">
1372
+ * ...
1373
+ * </div>
1374
+ * ```
1375
+ *
1376
+ * ```typescript
1377
+ * trigger("myAnimationTrigger", [
1378
+ * ..., // states
1379
+ * transition(
1380
+ * (fromState, toState, _element, params) =>
1381
+ * ['firststep', 'laststep'].includes(fromState.toLowerCase())
1382
+ * && toState === params?.['target'],
1383
+ * animate('1s')
1384
+ * )
1385
+ * ])
1386
+ * ```
1388
1387
  *
1389
1388
  * @publicApi
1390
1389
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.1.0-next.1
2
+ * @license Angular v13.1.1
3
3
  * (c) 2010-2021 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -17,6 +17,9 @@ import { ɵStyleData } from '@angular/animations';
17
17
  export declare abstract class AnimationDriver {
18
18
  static NOOP: AnimationDriver;
19
19
  abstract validateStyleProperty(prop: string): boolean;
20
+ /**
21
+ * @deprecated No longer in use. Will be removed.
22
+ */
20
23
  abstract matchesElement(element: any, selector: string): boolean;
21
24
  abstract containsElement(elm1: any, elm2: any): boolean;
22
25
  abstract query(element: any, selector: string, multi: boolean): any[];
@@ -72,7 +75,7 @@ declare interface DOMAnimation {
72
75
 
73
76
  declare class ElementInstructionMap {
74
77
  private _map;
75
- consume(element: any): AnimationTimelineInstruction[];
78
+ get(element: any): AnimationTimelineInstruction[];
76
79
  append(element: any, instructions: AnimationTimelineInstruction[]): void;
77
80
  has(element: any): boolean;
78
81
  clear(): void;
@@ -150,7 +153,7 @@ export declare const ɵcontainsElement: (elm1: any, elm2: any) => boolean;
150
153
  export declare class ɵCssKeyframesDriver implements AnimationDriver {
151
154
  private _count;
152
155
  validateStyleProperty(prop: string): boolean;
153
- matchesElement(element: any, selector: string): boolean;
156
+ matchesElement(_element: any, _selector: string): boolean;
154
157
  containsElement(elm1: any, elm2: any): boolean;
155
158
  query(element: any, selector: string, multi: boolean): any[];
156
159
  computeStyle(element: any, prop: string, defaultValue?: string): string;
@@ -207,14 +210,12 @@ export declare class ɵCssKeyframesPlayer implements AnimationPlayer {
207
210
 
208
211
  export declare const ɵinvokeQuery: (element: any, selector: string, multi: boolean) => any[];
209
212
 
210
- export declare const ɵmatchesElement: (element: any, selector: string) => boolean;
211
-
212
213
  /**
213
214
  * @publicApi
214
215
  */
215
216
  export declare class ɵNoopAnimationDriver implements AnimationDriver {
216
217
  validateStyleProperty(prop: string): boolean;
217
- matchesElement(element: any, selector: string): boolean;
218
+ matchesElement(_element: any, _selector: string): boolean;
218
219
  containsElement(elm1: any, elm2: any): boolean;
219
220
  query(element: any, selector: string, multi: boolean): any[];
220
221
  computeStyle(element: any, prop: string, defaultValue?: string): string;
@@ -241,7 +242,7 @@ export declare class ɵWebAnimationsDriver implements AnimationDriver {
241
242
  private _isNativeImpl;
242
243
  private _cssKeyframesDriver;
243
244
  validateStyleProperty(prop: string): boolean;
244
- matchesElement(element: any, selector: string): boolean;
245
+ matchesElement(_element: any, _selector: string): boolean;
245
246
  containsElement(elm1: any, elm2: any): boolean;
246
247
  query(element: any, selector: string, multi: boolean): any[];
247
248
  computeStyle(element: any, prop: string, defaultValue?: string): string;
@@ -267,7 +268,7 @@ export declare class ɵWebAnimationsPlayer implements AnimationPlayer {
267
268
  private _finished;
268
269
  private _started;
269
270
  private _destroyed;
270
- private _finalKeyframe;
271
+ private _finalKeyframe?;
271
272
  readonly domPlayer: DOMAnimation;
272
273
  time: number;
273
274
  parentPlayer: AnimationPlayer | null;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.1.0-next.1
2
+ * @license Angular v13.1.1
3
3
  * (c) 2010-2021 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -15,7 +15,7 @@ import { ɵStyleData } from '@angular/animations';
15
15
  export declare class MockAnimationDriver implements AnimationDriver {
16
16
  static log: AnimationPlayer[];
17
17
  validateStyleProperty(prop: string): boolean;
18
- matchesElement(element: any, selector: string): boolean;
18
+ matchesElement(_element: any, _selector: string): boolean;
19
19
  containsElement(elm1: any, elm2: any): boolean;
20
20
  query(element: any, selector: string, multi: boolean): any[];
21
21
  computeStyle(element: any, prop: string, defaultValue?: string): string;