@angular/animations 13.1.0-next.3 → 13.1.3

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 (38) hide show
  1. package/animations.d.ts +172 -164
  2. package/browser/browser.d.ts +10 -9
  3. package/browser/testing/testing.d.ts +3 -3
  4. package/esm2020/browser/src/dsl/animation.mjs +1 -1
  5. package/esm2020/browser/src/dsl/animation_ast_builder.mjs +1 -1
  6. package/esm2020/browser/src/dsl/animation_timeline_builder.mjs +18 -7
  7. package/esm2020/browser/src/dsl/animation_transition_factory.mjs +1 -1
  8. package/esm2020/browser/src/dsl/animation_transition_instruction.mjs +1 -1
  9. package/esm2020/browser/src/dsl/animation_trigger.mjs +1 -1
  10. package/esm2020/browser/src/dsl/element_instruction_map.mjs +3 -10
  11. package/esm2020/browser/src/private_export.mjs +2 -2
  12. package/esm2020/browser/src/render/animation_driver.mjs +8 -7
  13. package/esm2020/browser/src/render/animation_engine_next.mjs +1 -1
  14. package/esm2020/browser/src/render/css_keyframes/css_keyframes_driver.mjs +5 -4
  15. package/esm2020/browser/src/render/shared.mjs +4 -38
  16. package/esm2020/browser/src/render/timeline_animation_engine.mjs +1 -1
  17. package/esm2020/browser/src/render/transition_animation_engine.mjs +35 -37
  18. package/esm2020/browser/src/render/web_animations/web_animations_driver.mjs +5 -4
  19. package/esm2020/browser/src/render/web_animations/web_animations_player.mjs +7 -4
  20. package/esm2020/browser/src/util.mjs +1 -3
  21. package/esm2020/browser/testing/src/mock_animation_driver.mjs +4 -4
  22. package/esm2020/src/animation_builder.mjs +6 -4
  23. package/esm2020/src/animation_metadata.mjs +156 -153
  24. package/esm2020/src/players/animation_player.mjs +1 -1
  25. package/esm2020/src/version.mjs +3 -16
  26. package/fesm2015/animations.mjs +162 -157
  27. package/fesm2015/animations.mjs.map +1 -1
  28. package/fesm2015/browser/testing.mjs +5 -5
  29. package/fesm2015/browser/testing.mjs.map +1 -1
  30. package/fesm2015/browser.mjs +80 -105
  31. package/fesm2015/browser.mjs.map +1 -1
  32. package/fesm2020/animations.mjs +162 -157
  33. package/fesm2020/animations.mjs.map +1 -1
  34. package/fesm2020/browser/testing.mjs +5 -5
  35. package/fesm2020/browser/testing.mjs.map +1 -1
  36. package/fesm2020/browser.mjs +77 -105
  37. package/fesm2020/browser.mjs.map +1 -1
  38. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @license Angular v13.1.0-next.3
3
- * (c) 2010-2021 Google LLC. https://angular.io/
2
+ * @license Angular v13.1.3
3
+ * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
@@ -126,7 +126,6 @@ function parseTimelineCommand(command) {
126
126
  return [id, action];
127
127
  }
128
128
  let _contains = (elm1, elm2) => false;
129
- let _matches = (element, selector) => false;
130
129
  let _query = (element, selector, multi) => {
131
130
  return [];
132
131
  };
@@ -148,44 +147,12 @@ if (_isNode || typeof Element !== 'undefined') {
148
147
  return false;
149
148
  };
150
149
  }
151
- _matches = (() => {
152
- if (_isNode || Element.prototype.matches) {
153
- return (element, selector) => element.matches(selector);
154
- }
155
- else {
156
- const proto = Element.prototype;
157
- const fn = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector ||
158
- proto.oMatchesSelector || proto.webkitMatchesSelector;
159
- if (fn) {
160
- return (element, selector) => fn.apply(element, [selector]);
161
- }
162
- else {
163
- return _matches;
164
- }
165
- }
166
- })();
167
150
  _query = (element, selector, multi) => {
168
- let results = [];
169
151
  if (multi) {
170
- // DO NOT REFACTOR TO USE SPREAD SYNTAX.
171
- // For element queries that return sufficiently large NodeList objects,
172
- // using spread syntax to populate the results array causes a RangeError
173
- // due to the call stack limit being reached. `Array.from` can not be used
174
- // as well, since NodeList is not iterable in IE 11, see
175
- // https://developer.mozilla.org/en-US/docs/Web/API/NodeList
176
- // More info is available in #38551.
177
- const elems = element.querySelectorAll(selector);
178
- for (let i = 0; i < elems.length; i++) {
179
- results.push(elems[i]);
180
- }
181
- }
182
- else {
183
- const elm = element.querySelector(selector);
184
- if (elm) {
185
- results.push(elm);
186
- }
152
+ return Array.from(element.querySelectorAll(selector));
187
153
  }
188
- return results;
154
+ const elem = element.querySelector(selector);
155
+ return elem ? [elem] : [];
189
156
  };
190
157
  }
191
158
  function containsVendorPrefix(prop) {
@@ -216,7 +183,6 @@ function getBodyNode() {
216
183
  }
217
184
  return null;
218
185
  }
219
- const matchesElement = _matches;
220
186
  const containsElement = _contains;
221
187
  const invokeQuery = _query;
222
188
  function hypenatePropsObject(object) {
@@ -242,8 +208,9 @@ class NoopAnimationDriver {
242
208
  validateStyleProperty(prop) {
243
209
  return validateStyleProperty(prop);
244
210
  }
245
- matchesElement(element, selector) {
246
- return matchesElement(element, selector);
211
+ matchesElement(_element, _selector) {
212
+ // This method is deprecated and no longer in use so we return false.
213
+ return false;
247
214
  }
248
215
  containsElement(elm1, elm2) {
249
216
  return containsElement(elm1, elm2);
@@ -258,9 +225,9 @@ class NoopAnimationDriver {
258
225
  return new NoopAnimationPlayer(duration, delay);
259
226
  }
260
227
  }
261
- NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0-next.3", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
262
- NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.0-next.3", ngImport: i0, type: NoopAnimationDriver });
263
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0-next.3", ngImport: i0, type: NoopAnimationDriver, decorators: [{
228
+ NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
229
+ NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NoopAnimationDriver });
230
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NoopAnimationDriver, decorators: [{
264
231
  type: Injectable
265
232
  }] });
266
233
  /**
@@ -282,8 +249,6 @@ const SUBSTITUTION_EXPR_START = '{{';
282
249
  const SUBSTITUTION_EXPR_END = '}}';
283
250
  const ENTER_CLASSNAME = 'ng-enter';
284
251
  const LEAVE_CLASSNAME = 'ng-leave';
285
- const ENTER_SELECTOR = '.ng-enter';
286
- const LEAVE_SELECTOR = '.ng-leave';
287
252
  const NG_TRIGGER_CLASSNAME = 'ng-trigger';
288
253
  const NG_TRIGGER_SELECTOR = '.ng-trigger';
289
254
  const NG_ANIMATING_CLASSNAME = 'ng-animating';
@@ -1156,15 +1121,8 @@ class ElementInstructionMap {
1156
1121
  constructor() {
1157
1122
  this._map = new Map();
1158
1123
  }
1159
- consume(element) {
1160
- let instructions = this._map.get(element);
1161
- if (instructions) {
1162
- this._map.delete(element);
1163
- }
1164
- else {
1165
- instructions = [];
1166
- }
1167
- return instructions;
1124
+ get(element) {
1125
+ return this._map.get(element) || [];
1168
1126
  }
1169
1127
  append(element, instructions) {
1170
1128
  let existingInstructions = this._map.get(element);
@@ -1262,7 +1220,7 @@ const LEAVE_TOKEN_REGEX = new RegExp(LEAVE_TOKEN, 'g');
1262
1220
  * from all previous keyframes up until where it is first used. For the timeline keyframe generation
1263
1221
  * to properly fill in the style it will place the previous value (the value from the parent
1264
1222
  * timeline) or a default value of `*` into the backFill object. Given that each of the keyframe
1265
- * styles are objects that prototypically inherits from the backFill object, this means that if a
1223
+ * styles is an object that prototypically inherits from the backFill object, this means that if a
1266
1224
  * value is added into the backFill then it will automatically propagate any missing values to all
1267
1225
  * keyframes. Therefore the missing `height` value will be properly filled into the already
1268
1226
  * processed keyframes.
@@ -1289,10 +1247,21 @@ class AnimationTimelineBuilderVisitor {
1289
1247
  visitDslNode(this, ast, context);
1290
1248
  // this checks to see if an actual animation happened
1291
1249
  const timelines = context.timelines.filter(timeline => timeline.containsAnimation());
1292
- if (timelines.length && Object.keys(finalStyles).length) {
1293
- const tl = timelines[timelines.length - 1];
1294
- if (!tl.allowOnlyTimelineStyles()) {
1295
- tl.setStyles([finalStyles], null, context.errors, options);
1250
+ if (Object.keys(finalStyles).length) {
1251
+ // note: we just want to apply the final styles for the rootElement, so we do not
1252
+ // just apply the styles to the last timeline but the last timeline which
1253
+ // element is the root one (basically `*`-styles are replaced with the actual
1254
+ // state style values only for the root element)
1255
+ let lastRootTimeline;
1256
+ for (let i = timelines.length - 1; i >= 0; i--) {
1257
+ const timeline = timelines[i];
1258
+ if (timeline.element === rootElement) {
1259
+ lastRootTimeline = timeline;
1260
+ break;
1261
+ }
1262
+ }
1263
+ if (lastRootTimeline && !lastRootTimeline.allowOnlyTimelineStyles()) {
1264
+ lastRootTimeline.setStyles([finalStyles], null, context.errors, options);
1296
1265
  }
1297
1266
  }
1298
1267
  return timelines.length ? timelines.map(timeline => timeline.buildKeyframes()) :
@@ -1308,7 +1277,7 @@ class AnimationTimelineBuilderVisitor {
1308
1277
  // these values are not visited in this AST
1309
1278
  }
1310
1279
  visitAnimateChild(ast, context) {
1311
- const elementInstructions = context.subInstructions.consume(context.element);
1280
+ const elementInstructions = context.subInstructions.get(context.element);
1312
1281
  if (elementInstructions) {
1313
1282
  const innerContext = context.createSubContext(ast.options);
1314
1283
  const startTime = context.currentTimeline.currentTime;
@@ -2574,9 +2543,11 @@ class AnimationTransitionNamespace {
2574
2543
  }
2575
2544
  triggerLeaveAnimation(element, context, destroyAfterComplete, defaultToFallback) {
2576
2545
  const triggerStates = this._engine.statesByElement.get(element);
2546
+ const previousTriggersValues = new Map();
2577
2547
  if (triggerStates) {
2578
2548
  const players = [];
2579
2549
  Object.keys(triggerStates).forEach(triggerName => {
2550
+ previousTriggersValues.set(triggerName, triggerStates[triggerName].value);
2580
2551
  // this check is here in the event that an element is removed
2581
2552
  // twice (both on the host level and the component level)
2582
2553
  if (this._triggers[triggerName]) {
@@ -2587,7 +2558,7 @@ class AnimationTransitionNamespace {
2587
2558
  }
2588
2559
  });
2589
2560
  if (players.length) {
2590
- this._engine.markElementAsRemoved(this.id, element, true, context);
2561
+ this._engine.markElementAsRemoved(this.id, element, true, context, previousTriggersValues);
2591
2562
  if (destroyAfterComplete) {
2592
2563
  optimizeGroupPlayer(players).onDone(() => this._engine.processLeaveNode(element));
2593
2564
  }
@@ -2944,10 +2915,15 @@ class TransitionAnimationEngine {
2944
2915
  this._onRemovalComplete(element, context);
2945
2916
  }
2946
2917
  }
2947
- markElementAsRemoved(namespaceId, element, hasAnimation, context) {
2918
+ markElementAsRemoved(namespaceId, element, hasAnimation, context, previousTriggersValues) {
2948
2919
  this.collectedLeaveElements.push(element);
2949
- element[REMOVAL_FLAG] =
2950
- { namespaceId, setForRemoval: context, hasAnimation, removedBeforeQueried: false };
2920
+ element[REMOVAL_FLAG] = {
2921
+ namespaceId,
2922
+ setForRemoval: context,
2923
+ hasAnimation,
2924
+ removedBeforeQueried: false,
2925
+ previousTriggersValues
2926
+ };
2951
2927
  }
2952
2928
  listen(namespaceId, element, name, phase, callback) {
2953
2929
  if (isElementNode(element)) {
@@ -2999,6 +2975,7 @@ class TransitionAnimationEngine {
2999
2975
  });
3000
2976
  }
3001
2977
  processLeaveNode(element) {
2978
+ var _a;
3002
2979
  const details = element[REMOVAL_FLAG];
3003
2980
  if (details && details.setForRemoval) {
3004
2981
  // this will prevent it from removing it twice
@@ -3012,7 +2989,7 @@ class TransitionAnimationEngine {
3012
2989
  }
3013
2990
  this._onRemovalComplete(element, details.setForRemoval);
3014
2991
  }
3015
- if (this.driver.matchesElement(element, DISABLED_SELECTOR)) {
2992
+ if ((_a = element.classList) === null || _a === void 0 ? void 0 : _a.contains(DISABLED_CLASSNAME)) {
3016
2993
  this.markElementAsDisabled(element, false);
3017
2994
  }
3018
2995
  this.driver.query(element, DISABLED_SELECTOR, true).forEach(node => {
@@ -3149,8 +3126,19 @@ class TransitionAnimationEngine {
3149
3126
  allPlayers.push(player);
3150
3127
  if (this.collectedEnterElements.length) {
3151
3128
  const details = element[REMOVAL_FLAG];
3152
- // move animations are currently not supported...
3129
+ // animations for move operations (elements being removed and reinserted,
3130
+ // e.g. when the order of an *ngFor list changes) are currently not supported
3153
3131
  if (details && details.setForMove) {
3132
+ if (details.previousTriggersValues &&
3133
+ details.previousTriggersValues.has(entry.triggerName)) {
3134
+ const previousValue = details.previousTriggersValues.get(entry.triggerName);
3135
+ // we need to restore the previous trigger value since the element has
3136
+ // only been moved and hasn't actually left the DOM
3137
+ const triggersWithStates = this.statesByElement.get(entry.element);
3138
+ if (triggersWithStates && triggersWithStates[entry.triggerName]) {
3139
+ triggersWithStates[entry.triggerName].value = previousValue;
3140
+ }
3141
+ }
3154
3142
  player.destroy();
3155
3143
  return;
3156
3144
  }
@@ -3187,7 +3175,14 @@ class TransitionAnimationEngine {
3187
3175
  // instead stretch the first keyframe gap until the animation starts. This is
3188
3176
  // important in order to prevent extra initialization styles from being
3189
3177
  // required by the user for the animation.
3190
- instruction.timelines.forEach(tl => tl.stretchStartingKeyframe = true);
3178
+ const timelines = [];
3179
+ instruction.timelines.forEach(tl => {
3180
+ tl.stretchStartingKeyframe = true;
3181
+ if (!this.disabledNodes.has(tl.element)) {
3182
+ timelines.push(tl);
3183
+ }
3184
+ });
3185
+ instruction.timelines = timelines;
3191
3186
  subTimelines.append(element, instruction.timelines);
3192
3187
  const tuple = { instruction, player, element };
3193
3188
  queuedInstructions.push(tuple);
@@ -3760,38 +3755,13 @@ function buildRootMap(roots, nodes) {
3760
3755
  });
3761
3756
  return rootMap;
3762
3757
  }
3763
- const CLASSES_CACHE_KEY = '$$classes';
3764
- function containsClass(element, className) {
3765
- if (element.classList) {
3766
- return element.classList.contains(className);
3767
- }
3768
- else {
3769
- const classes = element[CLASSES_CACHE_KEY];
3770
- return classes && classes[className];
3771
- }
3772
- }
3773
3758
  function addClass(element, className) {
3774
- if (element.classList) {
3775
- element.classList.add(className);
3776
- }
3777
- else {
3778
- let classes = element[CLASSES_CACHE_KEY];
3779
- if (!classes) {
3780
- classes = element[CLASSES_CACHE_KEY] = {};
3781
- }
3782
- classes[className] = true;
3783
- }
3759
+ var _a;
3760
+ (_a = element.classList) === null || _a === void 0 ? void 0 : _a.add(className);
3784
3761
  }
3785
3762
  function removeClass(element, className) {
3786
- if (element.classList) {
3787
- element.classList.remove(className);
3788
- }
3789
- else {
3790
- let classes = element[CLASSES_CACHE_KEY];
3791
- if (classes) {
3792
- delete classes[className];
3793
- }
3794
- }
3763
+ var _a;
3764
+ (_a = element.classList) === null || _a === void 0 ? void 0 : _a.remove(className);
3795
3765
  }
3796
3766
  function removeNodesAfterAnimationDone(engine, element, players) {
3797
3767
  optimizeGroupPlayer(players).onDone(() => engine.processLeaveNode(element));
@@ -4342,8 +4312,9 @@ class CssKeyframesDriver {
4342
4312
  validateStyleProperty(prop) {
4343
4313
  return validateStyleProperty(prop);
4344
4314
  }
4345
- matchesElement(element, selector) {
4346
- return matchesElement(element, selector);
4315
+ matchesElement(_element, _selector) {
4316
+ // This method is deprecated and no longer in use so we return false.
4317
+ return false;
4347
4318
  }
4348
4319
  containsElement(elm1, elm2) {
4349
4320
  return containsElement(elm1, elm2);
@@ -4583,10 +4554,13 @@ class WebAnimationsPlayer {
4583
4554
  beforeDestroy() {
4584
4555
  const styles = {};
4585
4556
  if (this.hasStarted()) {
4586
- Object.keys(this._finalKeyframe).forEach(prop => {
4557
+ // note: this code is invoked only when the `play` function was called prior to this
4558
+ // (thus `hasStarted` returns true), this implies that the code that initializes
4559
+ // `_finalKeyframe` has also been executed and the non-null assertion can be safely used here
4560
+ const finalKeyframe = this._finalKeyframe;
4561
+ Object.keys(finalKeyframe).forEach(prop => {
4587
4562
  if (prop != 'offset') {
4588
- styles[prop] =
4589
- this._finished ? this._finalKeyframe[prop] : computeStyle(this.element, prop);
4563
+ styles[prop] = this._finished ? finalKeyframe[prop] : computeStyle(this.element, prop);
4590
4564
  }
4591
4565
  });
4592
4566
  }
@@ -4608,8 +4582,9 @@ class WebAnimationsDriver {
4608
4582
  validateStyleProperty(prop) {
4609
4583
  return validateStyleProperty(prop);
4610
4584
  }
4611
- matchesElement(element, selector) {
4612
- return matchesElement(element, selector);
4585
+ matchesElement(_element, _selector) {
4586
+ // This method is deprecated and no longer in use so we return false.
4587
+ return false;
4613
4588
  }
4614
4589
  containsElement(elm1, elm2) {
4615
4590
  return containsElement(elm1, elm2);
@@ -4692,5 +4667,5 @@ function getElementAnimateFn() {
4692
4667
  * Generated bundle index. Do not edit.
4693
4668
  */
4694
4669
 
4695
- export { AnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, CssKeyframesDriver as ɵCssKeyframesDriver, CssKeyframesPlayer as ɵCssKeyframesPlayer, NoopAnimationDriver as ɵNoopAnimationDriver, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, containsElement as ɵcontainsElement, invokeQuery as ɵinvokeQuery, matchesElement as ɵmatchesElement, supportsWebAnimations as ɵsupportsWebAnimations, validateStyleProperty as ɵvalidateStyleProperty };
4670
+ export { AnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, CssKeyframesDriver as ɵCssKeyframesDriver, CssKeyframesPlayer as ɵCssKeyframesPlayer, NoopAnimationDriver as ɵNoopAnimationDriver, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, containsElement as ɵcontainsElement, invokeQuery as ɵinvokeQuery, supportsWebAnimations as ɵsupportsWebAnimations, validateStyleProperty as ɵvalidateStyleProperty };
4696
4671
  //# sourceMappingURL=browser.mjs.map