@angular/animations 13.2.0 → 13.2.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.2.0
2
+ * @license Angular v13.2.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -225,9 +225,9 @@ class NoopAnimationDriver {
225
225
  return new NoopAnimationPlayer(duration, delay);
226
226
  }
227
227
  }
228
- NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
229
- NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: NoopAnimationDriver });
230
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: NoopAnimationDriver, decorators: [{
228
+ NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
229
+ NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: NoopAnimationDriver });
230
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.1", ngImport: i0, type: NoopAnimationDriver, decorators: [{
231
231
  type: Injectable
232
232
  }] });
233
233
  /**
@@ -244,7 +244,7 @@ AnimationDriver.NOOP = ( /* @__PURE__ */new NoopAnimationDriver());
244
244
  * Use of this source code is governed by an MIT-style license that can be
245
245
  * found in the LICENSE file at https://angular.io/license
246
246
  */
247
- const ONE_SECOND$1 = 1000;
247
+ const ONE_SECOND = 1000;
248
248
  const SUBSTITUTION_EXPR_START = '{{';
249
249
  const SUBSTITUTION_EXPR_END = '}}';
250
250
  const ENTER_CLASSNAME = 'ng-enter';
@@ -264,7 +264,7 @@ function resolveTimingValue(value) {
264
264
  function _convertTimeValueToMS(value, unit) {
265
265
  switch (unit) {
266
266
  case 's':
267
- return value * ONE_SECOND$1;
267
+ return value * ONE_SECOND;
268
268
  default: // ms or something else
269
269
  return value;
270
270
  }
@@ -3986,440 +3986,6 @@ function isNonAnimatableStyle(prop) {
3986
3986
  return prop === 'display' || prop === 'position';
3987
3987
  }
3988
3988
 
3989
- /**
3990
- * @license
3991
- * Copyright Google LLC All Rights Reserved.
3992
- *
3993
- * Use of this source code is governed by an MIT-style license that can be
3994
- * found in the LICENSE file at https://angular.io/license
3995
- */
3996
- const ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
3997
- const ANIMATION_PROP = 'animation';
3998
- const ANIMATIONEND_EVENT = 'animationend';
3999
- const ONE_SECOND = 1000;
4000
- class ElementAnimationStyleHandler {
4001
- constructor(_element, _name, _duration, _delay, _easing, _fillMode, _onDoneFn) {
4002
- this._element = _element;
4003
- this._name = _name;
4004
- this._duration = _duration;
4005
- this._delay = _delay;
4006
- this._easing = _easing;
4007
- this._fillMode = _fillMode;
4008
- this._onDoneFn = _onDoneFn;
4009
- this._finished = false;
4010
- this._destroyed = false;
4011
- this._startTime = 0;
4012
- this._position = 0;
4013
- this._eventFn = (e) => this._handleCallback(e);
4014
- }
4015
- apply() {
4016
- applyKeyframeAnimation(this._element, `${this._duration}ms ${this._easing} ${this._delay}ms 1 normal ${this._fillMode} ${this._name}`);
4017
- addRemoveAnimationEvent(this._element, this._eventFn, false);
4018
- this._startTime = Date.now();
4019
- }
4020
- pause() {
4021
- playPauseAnimation(this._element, this._name, 'paused');
4022
- }
4023
- resume() {
4024
- playPauseAnimation(this._element, this._name, 'running');
4025
- }
4026
- setPosition(position) {
4027
- const index = findIndexForAnimation(this._element, this._name);
4028
- this._position = position * this._duration;
4029
- setAnimationStyle(this._element, 'Delay', `-${this._position}ms`, index);
4030
- }
4031
- getPosition() {
4032
- return this._position;
4033
- }
4034
- _handleCallback(event) {
4035
- const timestamp = event._ngTestManualTimestamp || Date.now();
4036
- const elapsedTime = parseFloat(event.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES)) * ONE_SECOND;
4037
- if (event.animationName == this._name &&
4038
- Math.max(timestamp - this._startTime, 0) >= this._delay && elapsedTime >= this._duration) {
4039
- this.finish();
4040
- }
4041
- }
4042
- finish() {
4043
- if (this._finished)
4044
- return;
4045
- this._finished = true;
4046
- this._onDoneFn();
4047
- addRemoveAnimationEvent(this._element, this._eventFn, true);
4048
- }
4049
- destroy() {
4050
- if (this._destroyed)
4051
- return;
4052
- this._destroyed = true;
4053
- this.finish();
4054
- removeKeyframeAnimation(this._element, this._name);
4055
- }
4056
- }
4057
- function playPauseAnimation(element, name, status) {
4058
- const index = findIndexForAnimation(element, name);
4059
- setAnimationStyle(element, 'PlayState', status, index);
4060
- }
4061
- function applyKeyframeAnimation(element, value) {
4062
- const anim = getAnimationStyle(element, '').trim();
4063
- let index = 0;
4064
- if (anim.length) {
4065
- index = countChars(anim, ',') + 1;
4066
- value = `${anim}, ${value}`;
4067
- }
4068
- setAnimationStyle(element, '', value);
4069
- return index;
4070
- }
4071
- function removeKeyframeAnimation(element, name) {
4072
- const anim = getAnimationStyle(element, '');
4073
- const tokens = anim.split(',');
4074
- const index = findMatchingTokenIndex(tokens, name);
4075
- if (index >= 0) {
4076
- tokens.splice(index, 1);
4077
- const newValue = tokens.join(',');
4078
- setAnimationStyle(element, '', newValue);
4079
- }
4080
- }
4081
- function findIndexForAnimation(element, value) {
4082
- const anim = getAnimationStyle(element, '');
4083
- if (anim.indexOf(',') > 0) {
4084
- const tokens = anim.split(',');
4085
- return findMatchingTokenIndex(tokens, value);
4086
- }
4087
- return findMatchingTokenIndex([anim], value);
4088
- }
4089
- function findMatchingTokenIndex(tokens, searchToken) {
4090
- for (let i = 0; i < tokens.length; i++) {
4091
- if (tokens[i].indexOf(searchToken) >= 0) {
4092
- return i;
4093
- }
4094
- }
4095
- return -1;
4096
- }
4097
- function addRemoveAnimationEvent(element, fn, doRemove) {
4098
- doRemove ? element.removeEventListener(ANIMATIONEND_EVENT, fn) :
4099
- element.addEventListener(ANIMATIONEND_EVENT, fn);
4100
- }
4101
- function setAnimationStyle(element, name, value, index) {
4102
- const prop = ANIMATION_PROP + name;
4103
- if (index != null) {
4104
- const oldValue = element.style[prop];
4105
- if (oldValue.length) {
4106
- const tokens = oldValue.split(',');
4107
- tokens[index] = value;
4108
- value = tokens.join(',');
4109
- }
4110
- }
4111
- element.style[prop] = value;
4112
- }
4113
- function getAnimationStyle(element, name) {
4114
- return element.style[ANIMATION_PROP + name] || '';
4115
- }
4116
- function countChars(value, char) {
4117
- let count = 0;
4118
- for (let i = 0; i < value.length; i++) {
4119
- const c = value.charAt(i);
4120
- if (c === char)
4121
- count++;
4122
- }
4123
- return count;
4124
- }
4125
-
4126
- const DEFAULT_FILL_MODE = 'forwards';
4127
- const DEFAULT_EASING = 'linear';
4128
- class CssKeyframesPlayer {
4129
- constructor(element, keyframes, animationName, _duration, _delay, easing, _finalStyles, _specialStyles) {
4130
- this.element = element;
4131
- this.keyframes = keyframes;
4132
- this.animationName = animationName;
4133
- this._duration = _duration;
4134
- this._delay = _delay;
4135
- this._finalStyles = _finalStyles;
4136
- this._specialStyles = _specialStyles;
4137
- this._onDoneFns = [];
4138
- this._onStartFns = [];
4139
- this._onDestroyFns = [];
4140
- this.currentSnapshot = {};
4141
- this._state = 0;
4142
- this.easing = easing || DEFAULT_EASING;
4143
- this.totalTime = _duration + _delay;
4144
- this._buildStyler();
4145
- }
4146
- onStart(fn) {
4147
- this._onStartFns.push(fn);
4148
- }
4149
- onDone(fn) {
4150
- this._onDoneFns.push(fn);
4151
- }
4152
- onDestroy(fn) {
4153
- this._onDestroyFns.push(fn);
4154
- }
4155
- destroy() {
4156
- this.init();
4157
- if (this._state >= 4 /* DESTROYED */)
4158
- return;
4159
- this._state = 4 /* DESTROYED */;
4160
- this._styler.destroy();
4161
- this._flushStartFns();
4162
- this._flushDoneFns();
4163
- if (this._specialStyles) {
4164
- this._specialStyles.destroy();
4165
- }
4166
- this._onDestroyFns.forEach(fn => fn());
4167
- this._onDestroyFns = [];
4168
- }
4169
- _flushDoneFns() {
4170
- this._onDoneFns.forEach(fn => fn());
4171
- this._onDoneFns = [];
4172
- }
4173
- _flushStartFns() {
4174
- this._onStartFns.forEach(fn => fn());
4175
- this._onStartFns = [];
4176
- }
4177
- finish() {
4178
- this.init();
4179
- if (this._state >= 3 /* FINISHED */)
4180
- return;
4181
- this._state = 3 /* FINISHED */;
4182
- this._styler.finish();
4183
- this._flushStartFns();
4184
- if (this._specialStyles) {
4185
- this._specialStyles.finish();
4186
- }
4187
- this._flushDoneFns();
4188
- }
4189
- setPosition(value) {
4190
- this._styler.setPosition(value);
4191
- }
4192
- getPosition() {
4193
- return this._styler.getPosition();
4194
- }
4195
- hasStarted() {
4196
- return this._state >= 2 /* STARTED */;
4197
- }
4198
- init() {
4199
- if (this._state >= 1 /* INITIALIZED */)
4200
- return;
4201
- this._state = 1 /* INITIALIZED */;
4202
- const elm = this.element;
4203
- this._styler.apply();
4204
- if (this._delay) {
4205
- this._styler.pause();
4206
- }
4207
- }
4208
- play() {
4209
- this.init();
4210
- if (!this.hasStarted()) {
4211
- this._flushStartFns();
4212
- this._state = 2 /* STARTED */;
4213
- if (this._specialStyles) {
4214
- this._specialStyles.start();
4215
- }
4216
- }
4217
- this._styler.resume();
4218
- }
4219
- pause() {
4220
- this.init();
4221
- this._styler.pause();
4222
- }
4223
- restart() {
4224
- this.reset();
4225
- this.play();
4226
- }
4227
- reset() {
4228
- this._state = 0 /* RESET */;
4229
- this._styler.destroy();
4230
- this._buildStyler();
4231
- this._styler.apply();
4232
- }
4233
- _buildStyler() {
4234
- this._styler = new ElementAnimationStyleHandler(this.element, this.animationName, this._duration, this._delay, this.easing, DEFAULT_FILL_MODE, () => this.finish());
4235
- }
4236
- /** @internal */
4237
- triggerCallback(phaseName) {
4238
- const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
4239
- methods.forEach(fn => fn());
4240
- methods.length = 0;
4241
- }
4242
- beforeDestroy() {
4243
- this.init();
4244
- const styles = {};
4245
- if (this.hasStarted()) {
4246
- const finished = this._state >= 3 /* FINISHED */;
4247
- Object.keys(this._finalStyles).forEach(prop => {
4248
- if (prop != 'offset') {
4249
- styles[prop] = finished ? this._finalStyles[prop] : computeStyle(this.element, prop);
4250
- }
4251
- });
4252
- }
4253
- this.currentSnapshot = styles;
4254
- }
4255
- }
4256
-
4257
- /**
4258
- * @license
4259
- * Copyright Google LLC All Rights Reserved.
4260
- *
4261
- * Use of this source code is governed by an MIT-style license that can be
4262
- * found in the LICENSE file at https://angular.io/license
4263
- */
4264
- class DirectStylePlayer extends NoopAnimationPlayer {
4265
- constructor(element, styles) {
4266
- super();
4267
- this.element = element;
4268
- this._startingStyles = {};
4269
- this.__initialized = false;
4270
- this._styles = hypenatePropsObject(styles);
4271
- }
4272
- init() {
4273
- if (this.__initialized || !this._startingStyles)
4274
- return;
4275
- this.__initialized = true;
4276
- Object.keys(this._styles).forEach(prop => {
4277
- this._startingStyles[prop] = this.element.style[prop];
4278
- });
4279
- super.init();
4280
- }
4281
- play() {
4282
- if (!this._startingStyles)
4283
- return;
4284
- this.init();
4285
- Object.keys(this._styles)
4286
- .forEach(prop => this.element.style.setProperty(prop, this._styles[prop]));
4287
- super.play();
4288
- }
4289
- destroy() {
4290
- if (!this._startingStyles)
4291
- return;
4292
- Object.keys(this._startingStyles).forEach(prop => {
4293
- const value = this._startingStyles[prop];
4294
- if (value) {
4295
- this.element.style.setProperty(prop, value);
4296
- }
4297
- else {
4298
- this.element.style.removeProperty(prop);
4299
- }
4300
- });
4301
- this._startingStyles = null;
4302
- super.destroy();
4303
- }
4304
- }
4305
-
4306
- const KEYFRAMES_NAME_PREFIX = 'gen_css_kf_';
4307
- const TAB_SPACE = ' ';
4308
- class CssKeyframesDriver {
4309
- constructor() {
4310
- this._count = 0;
4311
- }
4312
- validateStyleProperty(prop) {
4313
- return validateStyleProperty(prop);
4314
- }
4315
- matchesElement(_element, _selector) {
4316
- // This method is deprecated and no longer in use so we return false.
4317
- return false;
4318
- }
4319
- containsElement(elm1, elm2) {
4320
- return containsElement(elm1, elm2);
4321
- }
4322
- query(element, selector, multi) {
4323
- return invokeQuery(element, selector, multi);
4324
- }
4325
- computeStyle(element, prop, defaultValue) {
4326
- return window.getComputedStyle(element)[prop];
4327
- }
4328
- buildKeyframeElement(element, name, keyframes) {
4329
- keyframes = keyframes.map(kf => hypenatePropsObject(kf));
4330
- let keyframeStr = `@keyframes ${name} {\n`;
4331
- let tab = '';
4332
- keyframes.forEach(kf => {
4333
- tab = TAB_SPACE;
4334
- const offset = parseFloat(kf['offset']);
4335
- keyframeStr += `${tab}${offset * 100}% {\n`;
4336
- tab += TAB_SPACE;
4337
- Object.keys(kf).forEach(prop => {
4338
- const value = kf[prop];
4339
- switch (prop) {
4340
- case 'offset':
4341
- return;
4342
- case 'easing':
4343
- if (value) {
4344
- keyframeStr += `${tab}animation-timing-function: ${value};\n`;
4345
- }
4346
- return;
4347
- default:
4348
- keyframeStr += `${tab}${prop}: ${value};\n`;
4349
- return;
4350
- }
4351
- });
4352
- keyframeStr += `${tab}}\n`;
4353
- });
4354
- keyframeStr += `}\n`;
4355
- const kfElm = document.createElement('style');
4356
- kfElm.textContent = keyframeStr;
4357
- return kfElm;
4358
- }
4359
- animate(element, keyframes, duration, delay, easing, previousPlayers = [], scrubberAccessRequested) {
4360
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && scrubberAccessRequested) {
4361
- notifyFaultyScrubber();
4362
- }
4363
- const previousCssKeyframePlayers = previousPlayers.filter(player => player instanceof CssKeyframesPlayer);
4364
- const previousStyles = {};
4365
- if (allowPreviousPlayerStylesMerge(duration, delay)) {
4366
- previousCssKeyframePlayers.forEach(player => {
4367
- let styles = player.currentSnapshot;
4368
- Object.keys(styles).forEach(prop => previousStyles[prop] = styles[prop]);
4369
- });
4370
- }
4371
- keyframes = balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles);
4372
- const finalStyles = flattenKeyframesIntoStyles(keyframes);
4373
- // if there is no animation then there is no point in applying
4374
- // styles and waiting for an event to get fired. This causes lag.
4375
- // It's better to just directly apply the styles to the element
4376
- // via the direct styling animation player.
4377
- if (duration == 0) {
4378
- return new DirectStylePlayer(element, finalStyles);
4379
- }
4380
- const animationName = `${KEYFRAMES_NAME_PREFIX}${this._count++}`;
4381
- const kfElm = this.buildKeyframeElement(element, animationName, keyframes);
4382
- const nodeToAppendKfElm = findNodeToAppendKeyframeElement(element);
4383
- nodeToAppendKfElm.appendChild(kfElm);
4384
- const specialStyles = packageNonAnimatableStyles(element, keyframes);
4385
- const player = new CssKeyframesPlayer(element, keyframes, animationName, duration, delay, easing, finalStyles, specialStyles);
4386
- player.onDestroy(() => removeElement(kfElm));
4387
- return player;
4388
- }
4389
- }
4390
- function findNodeToAppendKeyframeElement(element) {
4391
- var _a;
4392
- const rootNode = (_a = element.getRootNode) === null || _a === void 0 ? void 0 : _a.call(element);
4393
- if (typeof ShadowRoot !== 'undefined' && rootNode instanceof ShadowRoot) {
4394
- return rootNode;
4395
- }
4396
- return document.head;
4397
- }
4398
- function flattenKeyframesIntoStyles(keyframes) {
4399
- let flatKeyframes = {};
4400
- if (keyframes) {
4401
- const kfs = Array.isArray(keyframes) ? keyframes : [keyframes];
4402
- kfs.forEach(kf => {
4403
- Object.keys(kf).forEach(prop => {
4404
- if (prop == 'offset' || prop == 'easing')
4405
- return;
4406
- flatKeyframes[prop] = kf[prop];
4407
- });
4408
- });
4409
- }
4410
- return flatKeyframes;
4411
- }
4412
- function removeElement(node) {
4413
- node.parentNode.removeChild(node);
4414
- }
4415
- let warningIssued = false;
4416
- function notifyFaultyScrubber() {
4417
- if (warningIssued)
4418
- return;
4419
- console.warn('@angular/animations: please load the web-animations.js polyfill to allow programmatic access...\n', ' visit https://bit.ly/IWukam to learn more about using the web-animation-js polyfill.');
4420
- warningIssued = true;
4421
- }
4422
-
4423
3989
  class WebAnimationsPlayer {
4424
3990
  constructor(element, keyframes, options, _specialStyles) {
4425
3991
  this.element = element;
@@ -4575,10 +4141,6 @@ class WebAnimationsPlayer {
4575
4141
  }
4576
4142
 
4577
4143
  class WebAnimationsDriver {
4578
- constructor() {
4579
- this._isNativeImpl = /\{\s*\[native\s+code\]\s*\}/.test(getElementAnimateFn().toString());
4580
- this._cssKeyframesDriver = new CssKeyframesDriver();
4581
- }
4582
4144
  validateStyleProperty(prop) {
4583
4145
  return validateStyleProperty(prop);
4584
4146
  }
@@ -4595,14 +4157,7 @@ class WebAnimationsDriver {
4595
4157
  computeStyle(element, prop, defaultValue) {
4596
4158
  return window.getComputedStyle(element)[prop];
4597
4159
  }
4598
- overrideWebAnimationsSupport(supported) {
4599
- this._isNativeImpl = supported;
4600
- }
4601
- animate(element, keyframes, duration, delay, easing, previousPlayers = [], scrubberAccessRequested) {
4602
- const useKeyframes = !scrubberAccessRequested && !this._isNativeImpl;
4603
- if (useKeyframes) {
4604
- return this._cssKeyframesDriver.animate(element, keyframes, duration, delay, easing, previousPlayers);
4605
- }
4160
+ animate(element, keyframes, duration, delay, easing, previousPlayers = []) {
4606
4161
  const fill = delay == 0 ? 'both' : 'forwards';
4607
4162
  const playerOptions = { duration, delay, fill };
4608
4163
  // we check for this to avoid having a null|undefined value be present
@@ -4624,12 +4179,6 @@ class WebAnimationsDriver {
4624
4179
  return new WebAnimationsPlayer(element, keyframes, playerOptions, specialStyles);
4625
4180
  }
4626
4181
  }
4627
- function supportsWebAnimations() {
4628
- return typeof getElementAnimateFn() === 'function';
4629
- }
4630
- function getElementAnimateFn() {
4631
- return (isBrowser() && Element.prototype['animate']) || {};
4632
- }
4633
4182
 
4634
4183
  /**
4635
4184
  * @license
@@ -4667,5 +4216,5 @@ function getElementAnimateFn() {
4667
4216
  * Generated bundle index. Do not edit.
4668
4217
  */
4669
4218
 
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 };
4219
+ export { AnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, NoopAnimationDriver as ɵNoopAnimationDriver, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, containsElement as ɵcontainsElement, invokeQuery as ɵinvokeQuery, validateStyleProperty as ɵvalidateStyleProperty };
4671
4220
  //# sourceMappingURL=browser.mjs.map