@angular/animations 20.0.0-next.4 → 20.0.0-next.6

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.
@@ -0,0 +1,1176 @@
1
+ /**
2
+ * @license Angular v20.0.0-next.6
3
+ * (c) 2010-2025 Google LLC. https://angular.io/
4
+ * License: MIT
5
+ */
6
+
7
+ /**
8
+ * @description Constants for the categories of parameters that can be defined for animations.
9
+ *
10
+ * A corresponding function defines a set of parameters for each category, and
11
+ * collects them into a corresponding `AnimationMetadata` object.
12
+ *
13
+ * @publicApi
14
+ */
15
+ var AnimationMetadataType;
16
+ (function (AnimationMetadataType) {
17
+ /**
18
+ * Associates a named animation state with a set of CSS styles.
19
+ * See [`state()`](api/animations/state)
20
+ */
21
+ AnimationMetadataType[AnimationMetadataType["State"] = 0] = "State";
22
+ /**
23
+ * Data for a transition from one animation state to another.
24
+ * See `transition()`
25
+ */
26
+ AnimationMetadataType[AnimationMetadataType["Transition"] = 1] = "Transition";
27
+ /**
28
+ * Contains a set of animation steps.
29
+ * See `sequence()`
30
+ */
31
+ AnimationMetadataType[AnimationMetadataType["Sequence"] = 2] = "Sequence";
32
+ /**
33
+ * Contains a set of animation steps.
34
+ * See `{@link /api/animations/group group()}`
35
+ */
36
+ AnimationMetadataType[AnimationMetadataType["Group"] = 3] = "Group";
37
+ /**
38
+ * Contains an animation step.
39
+ * See `animate()`
40
+ */
41
+ AnimationMetadataType[AnimationMetadataType["Animate"] = 4] = "Animate";
42
+ /**
43
+ * Contains a set of animation steps.
44
+ * See `keyframes()`
45
+ */
46
+ AnimationMetadataType[AnimationMetadataType["Keyframes"] = 5] = "Keyframes";
47
+ /**
48
+ * Contains a set of CSS property-value pairs into a named style.
49
+ * See `style()`
50
+ */
51
+ AnimationMetadataType[AnimationMetadataType["Style"] = 6] = "Style";
52
+ /**
53
+ * Associates an animation with an entry trigger that can be attached to an element.
54
+ * See `trigger()`
55
+ */
56
+ AnimationMetadataType[AnimationMetadataType["Trigger"] = 7] = "Trigger";
57
+ /**
58
+ * Contains a re-usable animation.
59
+ * See `animation()`
60
+ */
61
+ AnimationMetadataType[AnimationMetadataType["Reference"] = 8] = "Reference";
62
+ /**
63
+ * Contains data to use in executing child animations returned by a query.
64
+ * See `animateChild()`
65
+ */
66
+ AnimationMetadataType[AnimationMetadataType["AnimateChild"] = 9] = "AnimateChild";
67
+ /**
68
+ * Contains animation parameters for a re-usable animation.
69
+ * See `useAnimation()`
70
+ */
71
+ AnimationMetadataType[AnimationMetadataType["AnimateRef"] = 10] = "AnimateRef";
72
+ /**
73
+ * Contains child-animation query data.
74
+ * See `query()`
75
+ */
76
+ AnimationMetadataType[AnimationMetadataType["Query"] = 11] = "Query";
77
+ /**
78
+ * Contains data for staggering an animation sequence.
79
+ * See `stagger()`
80
+ */
81
+ AnimationMetadataType[AnimationMetadataType["Stagger"] = 12] = "Stagger";
82
+ })(AnimationMetadataType || (AnimationMetadataType = {}));
83
+ /**
84
+ * Specifies automatic styling.
85
+ *
86
+ * @publicApi
87
+ */
88
+ const AUTO_STYLE = '*';
89
+ /**
90
+ * Creates a named animation trigger, containing a list of [`state()`](api/animations/state)
91
+ * and `transition()` entries to be evaluated when the expression
92
+ * bound to the trigger changes.
93
+ *
94
+ * @param name An identifying string.
95
+ * @param definitions An animation definition object, containing an array of
96
+ * [`state()`](api/animations/state) and `transition()` declarations.
97
+ *
98
+ * @return An object that encapsulates the trigger data.
99
+ *
100
+ * @usageNotes
101
+ * Define an animation trigger in the `animations` section of `@Component` metadata.
102
+ * In the template, reference the trigger by name and bind it to a trigger expression that
103
+ * evaluates to a defined animation state, using the following format:
104
+ *
105
+ * `[@triggerName]="expression"`
106
+ *
107
+ * Animation trigger bindings convert all values to strings, and then match the
108
+ * previous and current values against any linked transitions.
109
+ * Booleans can be specified as `1` or `true` and `0` or `false`.
110
+ *
111
+ * ### Usage Example
112
+ *
113
+ * The following example creates an animation trigger reference based on the provided
114
+ * name value.
115
+ * The provided animation value is expected to be an array consisting of state and
116
+ * transition declarations.
117
+ *
118
+ * ```ts
119
+ * @Component({
120
+ * selector: "my-component",
121
+ * templateUrl: "my-component-tpl.html",
122
+ * animations: [
123
+ * trigger("myAnimationTrigger", [
124
+ * state(...),
125
+ * state(...),
126
+ * transition(...),
127
+ * transition(...)
128
+ * ])
129
+ * ]
130
+ * })
131
+ * class MyComponent {
132
+ * myStatusExp = "something";
133
+ * }
134
+ * ```
135
+ *
136
+ * The template associated with this component makes use of the defined trigger
137
+ * by binding to an element within its template code.
138
+ *
139
+ * ```html
140
+ * <!-- somewhere inside of my-component-tpl.html -->
141
+ * <div [@myAnimationTrigger]="myStatusExp">...</div>
142
+ * ```
143
+ *
144
+ * ### Using an inline function
145
+ * The `transition` animation method also supports reading an inline function which can decide
146
+ * if its associated animation should be run.
147
+ *
148
+ * ```ts
149
+ * // this method is run each time the `myAnimationTrigger` trigger value changes.
150
+ * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:
151
+ string]: any}): boolean {
152
+ * // notice that `element` and `params` are also available here
153
+ * return toState == 'yes-please-animate';
154
+ * }
155
+ *
156
+ * @Component({
157
+ * selector: 'my-component',
158
+ * templateUrl: 'my-component-tpl.html',
159
+ * animations: [
160
+ * trigger('myAnimationTrigger', [
161
+ * transition(myInlineMatcherFn, [
162
+ * // the animation sequence code
163
+ * ]),
164
+ * ])
165
+ * ]
166
+ * })
167
+ * class MyComponent {
168
+ * myStatusExp = "yes-please-animate";
169
+ * }
170
+ * ```
171
+ *
172
+ * ### Disabling Animations
173
+ * When true, the special animation control binding `@.disabled` binding prevents
174
+ * all animations from rendering.
175
+ * Place the `@.disabled` binding on an element to disable
176
+ * animations on the element itself, as well as any inner animation triggers
177
+ * within the element.
178
+ *
179
+ * The following example shows how to use this feature:
180
+ *
181
+ * ```angular-ts
182
+ * @Component({
183
+ * selector: 'my-component',
184
+ * template: `
185
+ * <div [@.disabled]="isDisabled">
186
+ * <div [@childAnimation]="exp"></div>
187
+ * </div>
188
+ * `,
189
+ * animations: [
190
+ * trigger("childAnimation", [
191
+ * // ...
192
+ * ])
193
+ * ]
194
+ * })
195
+ * class MyComponent {
196
+ * isDisabled = true;
197
+ * exp = '...';
198
+ * }
199
+ * ```
200
+ *
201
+ * When `@.disabled` is true, it prevents the `@childAnimation` trigger from animating,
202
+ * along with any inner animations.
203
+ *
204
+ * ### Disable animations application-wide
205
+ * When an area of the template is set to have animations disabled,
206
+ * **all** inner components have their animations disabled as well.
207
+ * This means that you can disable all animations for an app
208
+ * by placing a host binding set on `@.disabled` on the topmost Angular component.
209
+ *
210
+ * ```ts
211
+ * import {Component, HostBinding} from '@angular/core';
212
+ *
213
+ * @Component({
214
+ * selector: 'app-component',
215
+ * templateUrl: 'app.component.html',
216
+ * })
217
+ * class AppComponent {
218
+ * @HostBinding('@.disabled')
219
+ * public animationsDisabled = true;
220
+ * }
221
+ * ```
222
+ *
223
+ * ### Overriding disablement of inner animations
224
+ * Despite inner animations being disabled, a parent animation can `query()`
225
+ * for inner elements located in disabled areas of the template and still animate
226
+ * them if needed. This is also the case for when a sub animation is
227
+ * queried by a parent and then later animated using `animateChild()`.
228
+ *
229
+ * ### Detecting when an animation is disabled
230
+ * If a region of the DOM (or the entire application) has its animations disabled, the animation
231
+ * trigger callbacks still fire, but for zero seconds. When the callback fires, it provides
232
+ * an instance of an `AnimationEvent`. If animations are disabled,
233
+ * the `.disabled` flag on the event is true.
234
+ *
235
+ * @publicApi
236
+ */
237
+ function trigger(name, definitions) {
238
+ return { type: AnimationMetadataType.Trigger, name, definitions, options: {} };
239
+ }
240
+ /**
241
+ * Defines an animation step that combines styling information with timing information.
242
+ *
243
+ * @param timings Sets `AnimateTimings` for the parent animation.
244
+ * A string in the format "duration [delay] [easing]".
245
+ * - Duration and delay are expressed as a number and optional time unit,
246
+ * such as "1s" or "10ms" for one second and 10 milliseconds, respectively.
247
+ * The default unit is milliseconds.
248
+ * - The easing value controls how the animation accelerates and decelerates
249
+ * during its runtime. Value is one of `ease`, `ease-in`, `ease-out`,
250
+ * `ease-in-out`, or a `cubic-bezier()` function call.
251
+ * If not supplied, no easing is applied.
252
+ *
253
+ * For example, the string "1s 100ms ease-out" specifies a duration of
254
+ * 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style,
255
+ * which decelerates near the end of the duration.
256
+ * @param styles Sets AnimationStyles for the parent animation.
257
+ * A function call to either `style()` or `keyframes()`
258
+ * that returns a collection of CSS style entries to be applied to the parent animation.
259
+ * When null, uses the styles from the destination state.
260
+ * This is useful when describing an animation step that will complete an animation;
261
+ * see "Animating to the final state" in `transitions()`.
262
+ * @returns An object that encapsulates the animation step.
263
+ *
264
+ * @usageNotes
265
+ * Call within an animation `sequence()`, {@link /api/animations/group group()}, or
266
+ * `transition()` call to specify an animation step
267
+ * that applies given style data to the parent animation for a given amount of time.
268
+ *
269
+ * ### Syntax Examples
270
+ * **Timing examples**
271
+ *
272
+ * The following examples show various `timings` specifications.
273
+ * - `animate(500)` : Duration is 500 milliseconds.
274
+ * - `animate("1s")` : Duration is 1000 milliseconds.
275
+ * - `animate("100ms 0.5s")` : Duration is 100 milliseconds, delay is 500 milliseconds.
276
+ * - `animate("5s ease-in")` : Duration is 5000 milliseconds, easing in.
277
+ * - `animate("5s 10ms cubic-bezier(.17,.67,.88,.1)")` : Duration is 5000 milliseconds, delay is 10
278
+ * milliseconds, easing according to a bezier curve.
279
+ *
280
+ * **Style examples**
281
+ *
282
+ * The following example calls `style()` to set a single CSS style.
283
+ * ```ts
284
+ * animate(500, style({ background: "red" }))
285
+ * ```
286
+ * The following example calls `keyframes()` to set a CSS style
287
+ * to different values for successive keyframes.
288
+ * ```ts
289
+ * animate(500, keyframes(
290
+ * [
291
+ * style({ background: "blue" }),
292
+ * style({ background: "red" })
293
+ * ])
294
+ * ```
295
+ *
296
+ * @publicApi
297
+ */
298
+ function animate(timings, styles = null) {
299
+ return { type: AnimationMetadataType.Animate, styles, timings };
300
+ }
301
+ /**
302
+ * @description Defines a list of animation steps to be run in parallel.
303
+ *
304
+ * @param steps An array of animation step objects.
305
+ * - When steps are defined by `style()` or `animate()`
306
+ * function calls, each call within the group is executed instantly.
307
+ * - To specify offset styles to be applied at a later time, define steps with
308
+ * `keyframes()`, or use `animate()` calls with a delay value.
309
+ * For example:
310
+ *
311
+ * ```ts
312
+ * group([
313
+ * animate("1s", style({ background: "black" })),
314
+ * animate("2s", style({ color: "white" }))
315
+ * ])
316
+ * ```
317
+ *
318
+ * @param options An options object containing a delay and
319
+ * developer-defined parameters that provide styling defaults and
320
+ * can be overridden on invocation.
321
+ *
322
+ * @return An object that encapsulates the group data.
323
+ *
324
+ * @usageNotes
325
+ * Grouped animations are useful when a series of styles must be
326
+ * animated at different starting times and closed off at different ending times.
327
+ *
328
+ * When called within a `sequence()` or a
329
+ * `transition()` call, does not continue to the next
330
+ * instruction until all of the inner animation steps have completed.
331
+ *
332
+ * @publicApi
333
+ */
334
+ function group(steps, options = null) {
335
+ return { type: AnimationMetadataType.Group, steps, options };
336
+ }
337
+ /**
338
+ * Defines a list of animation steps to be run sequentially, one by one.
339
+ *
340
+ * @param steps An array of animation step objects.
341
+ * - Steps defined by `style()` calls apply the styling data immediately.
342
+ * - Steps defined by `animate()` calls apply the styling data over time
343
+ * as specified by the timing data.
344
+ *
345
+ * ```ts
346
+ * sequence([
347
+ * style({ opacity: 0 }),
348
+ * animate("1s", style({ opacity: 1 }))
349
+ * ])
350
+ * ```
351
+ *
352
+ * @param options An options object containing a delay and
353
+ * developer-defined parameters that provide styling defaults and
354
+ * can be overridden on invocation.
355
+ *
356
+ * @return An object that encapsulates the sequence data.
357
+ *
358
+ * @usageNotes
359
+ * When you pass an array of steps to a
360
+ * `transition()` call, the steps run sequentially by default.
361
+ * Compare this to the {@link /api/animations/group group()} call, which runs animation steps in
362
+ *parallel.
363
+ *
364
+ * When a sequence is used within a {@link /api/animations/group group()} or a `transition()` call,
365
+ * execution continues to the next instruction only after each of the inner animation
366
+ * steps have completed.
367
+ *
368
+ * @publicApi
369
+ **/
370
+ function sequence(steps, options = null) {
371
+ return { type: AnimationMetadataType.Sequence, steps, options };
372
+ }
373
+ /**
374
+ * Declares a key/value object containing CSS properties/styles that
375
+ * can then be used for an animation [`state`](api/animations/state), within an animation
376
+ *`sequence`, or as styling data for calls to `animate()` and `keyframes()`.
377
+ *
378
+ * @param tokens A set of CSS styles or HTML styles associated with an animation state.
379
+ * The value can be any of the following:
380
+ * - A key-value style pair associating a CSS property with a value.
381
+ * - An array of key-value style pairs.
382
+ * - An asterisk (*), to use auto-styling, where styles are derived from the element
383
+ * being animated and applied to the animation when it starts.
384
+ *
385
+ * Auto-styling can be used to define a state that depends on layout or other
386
+ * environmental factors.
387
+ *
388
+ * @return An object that encapsulates the style data.
389
+ *
390
+ * @usageNotes
391
+ * The following examples create animation styles that collect a set of
392
+ * CSS property values:
393
+ *
394
+ * ```ts
395
+ * // string values for CSS properties
396
+ * style({ background: "red", color: "blue" })
397
+ *
398
+ * // numerical pixel values
399
+ * style({ width: 100, height: 0 })
400
+ * ```
401
+ *
402
+ * The following example uses auto-styling to allow an element to animate from
403
+ * a height of 0 up to its full height:
404
+ *
405
+ * ```ts
406
+ * style({ height: 0 }),
407
+ * animate("1s", style({ height: "*" }))
408
+ * ```
409
+ *
410
+ * @publicApi
411
+ **/
412
+ function style(tokens) {
413
+ return { type: AnimationMetadataType.Style, styles: tokens, offset: null };
414
+ }
415
+ /**
416
+ * Declares an animation state within a trigger attached to an element.
417
+ *
418
+ * @param name One or more names for the defined state in a comma-separated string.
419
+ * The following reserved state names can be supplied to define a style for specific use
420
+ * cases:
421
+ *
422
+ * - `void` You can associate styles with this name to be used when
423
+ * the element is detached from the application. For example, when an `ngIf` evaluates
424
+ * to false, the state of the associated element is void.
425
+ * - `*` (asterisk) Indicates the default state. You can associate styles with this name
426
+ * to be used as the fallback when the state that is being animated is not declared
427
+ * within the trigger.
428
+ *
429
+ * @param styles A set of CSS styles associated with this state, created using the
430
+ * `style()` function.
431
+ * This set of styles persists on the element once the state has been reached.
432
+ * @param options Parameters that can be passed to the state when it is invoked.
433
+ * 0 or more key-value pairs.
434
+ * @return An object that encapsulates the new state data.
435
+ *
436
+ * @usageNotes
437
+ * Use the `trigger()` function to register states to an animation trigger.
438
+ * Use the `transition()` function to animate between states.
439
+ * When a state is active within a component, its associated styles persist on the element,
440
+ * even when the animation ends.
441
+ *
442
+ * @publicApi
443
+ **/
444
+ function state(name, styles, options) {
445
+ return { type: AnimationMetadataType.State, name, styles, options };
446
+ }
447
+ /**
448
+ * Defines a set of animation styles, associating each style with an optional `offset` value.
449
+ *
450
+ * @param steps A set of animation styles with optional offset data.
451
+ * The optional `offset` value for a style specifies a percentage of the total animation
452
+ * time at which that style is applied.
453
+ * @returns An object that encapsulates the keyframes data.
454
+ *
455
+ * @usageNotes
456
+ * Use with the `animate()` call. Instead of applying animations
457
+ * from the current state
458
+ * to the destination state, keyframes describe how each style entry is applied and at what point
459
+ * within the animation arc.
460
+ * Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).
461
+ *
462
+ * ### Usage
463
+ *
464
+ * In the following example, the offset values describe
465
+ * when each `backgroundColor` value is applied. The color is red at the start, and changes to
466
+ * blue when 20% of the total time has elapsed.
467
+ *
468
+ * ```ts
469
+ * // the provided offset values
470
+ * animate("5s", keyframes([
471
+ * style({ backgroundColor: "red", offset: 0 }),
472
+ * style({ backgroundColor: "blue", offset: 0.2 }),
473
+ * style({ backgroundColor: "orange", offset: 0.3 }),
474
+ * style({ backgroundColor: "black", offset: 1 })
475
+ * ]))
476
+ * ```
477
+ *
478
+ * If there are no `offset` values specified in the style entries, the offsets
479
+ * are calculated automatically.
480
+ *
481
+ * ```ts
482
+ * animate("5s", keyframes([
483
+ * style({ backgroundColor: "red" }) // offset = 0
484
+ * style({ backgroundColor: "blue" }) // offset = 0.33
485
+ * style({ backgroundColor: "orange" }) // offset = 0.66
486
+ * style({ backgroundColor: "black" }) // offset = 1
487
+ * ]))
488
+ *```
489
+
490
+ * @publicApi
491
+ */
492
+ function keyframes(steps) {
493
+ return { type: AnimationMetadataType.Keyframes, steps };
494
+ }
495
+ /**
496
+ * Declares an animation transition which is played when a certain specified condition is met.
497
+ *
498
+ * @param stateChangeExpr A string with a specific format or a function that specifies when the
499
+ * animation transition should occur (see [State Change Expression](#state-change-expression)).
500
+ *
501
+ * @param steps One or more animation objects that represent the animation's instructions.
502
+ *
503
+ * @param options An options object that can be used to specify a delay for the animation or provide
504
+ * custom parameters for it.
505
+ *
506
+ * @returns An object that encapsulates the transition data.
507
+ *
508
+ * @usageNotes
509
+ *
510
+ * ### State Change Expression
511
+ *
512
+ * The State Change Expression instructs Angular when to run the transition's animations, it can
513
+ *either be
514
+ * - a string with a specific syntax
515
+ * - or a function that compares the previous and current state (value of the expression bound to
516
+ * the element's trigger) and returns `true` if the transition should occur or `false` otherwise
517
+ *
518
+ * The string format can be:
519
+ * - `fromState => toState`, which indicates that the transition's animations should occur then the
520
+ * expression bound to the trigger's element goes from `fromState` to `toState`
521
+ *
522
+ * _Example:_
523
+ * ```ts
524
+ * transition('open => closed', animate('.5s ease-out', style({ height: 0 }) ))
525
+ * ```
526
+ *
527
+ * - `fromState <=> toState`, which indicates that the transition's animations should occur then
528
+ * the expression bound to the trigger's element goes from `fromState` to `toState` or vice versa
529
+ *
530
+ * _Example:_
531
+ * ```ts
532
+ * transition('enabled <=> disabled', animate('1s cubic-bezier(0.8,0.3,0,1)'))
533
+ * ```
534
+ *
535
+ * - `:enter`/`:leave`, which indicates that the transition's animations should occur when the
536
+ * element enters or exists the DOM
537
+ *
538
+ * _Example:_
539
+ * ```ts
540
+ * transition(':enter', [
541
+ * style({ opacity: 0 }),
542
+ * animate('500ms', style({ opacity: 1 }))
543
+ * ])
544
+ * ```
545
+ *
546
+ * - `:increment`/`:decrement`, which indicates that the transition's animations should occur when
547
+ * the numerical expression bound to the trigger's element has increased in value or decreased
548
+ *
549
+ * _Example:_
550
+ * ```ts
551
+ * transition(':increment', query('@counter', animateChild()))
552
+ * ```
553
+ *
554
+ * - a sequence of any of the above divided by commas, which indicates that transition's animations
555
+ * should occur whenever one of the state change expressions matches
556
+ *
557
+ * _Example:_
558
+ * ```ts
559
+ * transition(':increment, * => enabled, :enter', animate('1s ease', keyframes([
560
+ * style({ transform: 'scale(1)', offset: 0}),
561
+ * style({ transform: 'scale(1.1)', offset: 0.7}),
562
+ * style({ transform: 'scale(1)', offset: 1})
563
+ * ]))),
564
+ * ```
565
+ *
566
+ * Also note that in such context:
567
+ * - `void` can be used to indicate the absence of the element
568
+ * - asterisks can be used as wildcards that match any state
569
+ * - (as a consequence of the above, `void => *` is equivalent to `:enter` and `* => void` is
570
+ * equivalent to `:leave`)
571
+ * - `true` and `false` also match expression values of `1` and `0` respectively (but do not match
572
+ * _truthy_ and _falsy_ values)
573
+ *
574
+ * <div class="docs-alert docs-alert-helpful">
575
+ *
576
+ * Be careful about entering end leaving elements as their transitions present a common
577
+ * pitfall for developers.
578
+ *
579
+ * Note that when an element with a trigger enters the DOM its `:enter` transition always
580
+ * gets executed, but its `:leave` transition will not be executed if the element is removed
581
+ * alongside its parent (as it will be removed "without warning" before its transition has
582
+ * a chance to be executed, the only way that such transition can occur is if the element
583
+ * is exiting the DOM on its own).
584
+ *
585
+ *
586
+ * </div>
587
+ *
588
+ * ### Animating to a Final State
589
+ *
590
+ * If the final step in a transition is a call to `animate()` that uses a timing value
591
+ * with no `style` data, that step is automatically considered the final animation arc,
592
+ * for the element to reach the final state, in such case Angular automatically adds or removes
593
+ * CSS styles to ensure that the element is in the correct final state.
594
+ *
595
+ *
596
+ * ### Usage Examples
597
+ *
598
+ * - Transition animations applied based on
599
+ * the trigger's expression value
600
+ *
601
+ * ```html
602
+ * <div [@myAnimationTrigger]="myStatusExp">
603
+ * ...
604
+ * </div>
605
+ * ```
606
+ *
607
+ * ```ts
608
+ * trigger("myAnimationTrigger", [
609
+ * ..., // states
610
+ * transition("on => off, open => closed", animate(500)),
611
+ * transition("* <=> error", query('.indicator', animateChild()))
612
+ * ])
613
+ * ```
614
+ *
615
+ * - Transition animations applied based on custom logic dependent
616
+ * on the trigger's expression value and provided parameters
617
+ *
618
+ * ```html
619
+ * <div [@myAnimationTrigger]="{
620
+ * value: stepName,
621
+ * params: { target: currentTarget }
622
+ * }">
623
+ * ...
624
+ * </div>
625
+ * ```
626
+ *
627
+ * ```ts
628
+ * trigger("myAnimationTrigger", [
629
+ * ..., // states
630
+ * transition(
631
+ * (fromState, toState, _element, params) =>
632
+ * ['firststep', 'laststep'].includes(fromState.toLowerCase())
633
+ * && toState === params?.['target'],
634
+ * animate('1s')
635
+ * )
636
+ * ])
637
+ * ```
638
+ *
639
+ * @publicApi
640
+ **/
641
+ function transition(stateChangeExpr, steps, options = null) {
642
+ return { type: AnimationMetadataType.Transition, expr: stateChangeExpr, animation: steps, options };
643
+ }
644
+ /**
645
+ * Produces a reusable animation that can be invoked in another animation or sequence,
646
+ * by calling the `useAnimation()` function.
647
+ *
648
+ * @param steps One or more animation objects, as returned by the `animate()`
649
+ * or `sequence()` function, that form a transformation from one state to another.
650
+ * A sequence is used by default when you pass an array.
651
+ * @param options An options object that can contain a delay value for the start of the
652
+ * animation, and additional developer-defined parameters.
653
+ * Provided values for additional parameters are used as defaults,
654
+ * and override values can be passed to the caller on invocation.
655
+ * @returns An object that encapsulates the animation data.
656
+ *
657
+ * @usageNotes
658
+ * The following example defines a reusable animation, providing some default parameter
659
+ * values.
660
+ *
661
+ * ```ts
662
+ * var fadeAnimation = animation([
663
+ * style({ opacity: '{{ start }}' }),
664
+ * animate('{{ time }}',
665
+ * style({ opacity: '{{ end }}'}))
666
+ * ],
667
+ * { params: { time: '1000ms', start: 0, end: 1 }});
668
+ * ```
669
+ *
670
+ * The following invokes the defined animation with a call to `useAnimation()`,
671
+ * passing in override parameter values.
672
+ *
673
+ * ```js
674
+ * useAnimation(fadeAnimation, {
675
+ * params: {
676
+ * time: '2s',
677
+ * start: 1,
678
+ * end: 0
679
+ * }
680
+ * })
681
+ * ```
682
+ *
683
+ * If any of the passed-in parameter values are missing from this call,
684
+ * the default values are used. If one or more parameter values are missing before a step is
685
+ * animated, `useAnimation()` throws an error.
686
+ *
687
+ * @publicApi
688
+ */
689
+ function animation(steps, options = null) {
690
+ return { type: AnimationMetadataType.Reference, animation: steps, options };
691
+ }
692
+ /**
693
+ * Executes a queried inner animation element within an animation sequence.
694
+ *
695
+ * @param options An options object that can contain a delay value for the start of the
696
+ * animation, and additional override values for developer-defined parameters.
697
+ * @return An object that encapsulates the child animation data.
698
+ *
699
+ * @usageNotes
700
+ * Each time an animation is triggered in Angular, the parent animation
701
+ * has priority and any child animations are blocked. In order
702
+ * for a child animation to run, the parent animation must query each of the elements
703
+ * containing child animations, and run them using this function.
704
+ *
705
+ * Note that this feature is designed to be used with `query()` and it will only work
706
+ * with animations that are assigned using the Angular animation library. CSS keyframes
707
+ * and transitions are not handled by this API.
708
+ *
709
+ * @publicApi
710
+ */
711
+ function animateChild(options = null) {
712
+ return { type: AnimationMetadataType.AnimateChild, options };
713
+ }
714
+ /**
715
+ * Starts a reusable animation that is created using the `animation()` function.
716
+ *
717
+ * @param animation The reusable animation to start.
718
+ * @param options An options object that can contain a delay value for the start of
719
+ * the animation, and additional override values for developer-defined parameters.
720
+ * @return An object that contains the animation parameters.
721
+ *
722
+ * @publicApi
723
+ */
724
+ function useAnimation(animation, options = null) {
725
+ return { type: AnimationMetadataType.AnimateRef, animation, options };
726
+ }
727
+ /**
728
+ * Finds one or more inner elements within the current element that is
729
+ * being animated within a sequence. Use with `animate()`.
730
+ *
731
+ * @param selector The element to query, or a set of elements that contain Angular-specific
732
+ * characteristics, specified with one or more of the following tokens.
733
+ * - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements (not
734
+ * all elements can be queried via these tokens, see
735
+ * [Entering and Leaving Elements](#entering-and-leaving-elements))
736
+ * - `query(":animating")` : Query all currently animating elements.
737
+ * - `query("@triggerName")` : Query elements that contain an animation trigger.
738
+ * - `query("@*")` : Query all elements that contain an animation triggers.
739
+ * - `query(":self")` : Include the current element into the animation sequence.
740
+ *
741
+ * @param animation One or more animation steps to apply to the queried element or elements.
742
+ * An array is treated as an animation sequence.
743
+ * @param options An options object. Use the 'limit' field to limit the total number of
744
+ * items to collect.
745
+ * @return An object that encapsulates the query data.
746
+ *
747
+ * @usageNotes
748
+ *
749
+ * ### Multiple Tokens
750
+ *
751
+ * Tokens can be merged into a combined query selector string. For example:
752
+ *
753
+ * ```ts
754
+ * query(':self, .record:enter, .record:leave, @subTrigger', [...])
755
+ * ```
756
+ *
757
+ * The `query()` function collects multiple elements and works internally by using
758
+ * `element.querySelectorAll`. Use the `limit` field of an options object to limit
759
+ * the total number of items to be collected. For example:
760
+ *
761
+ * ```js
762
+ * query('div', [
763
+ * animate(...),
764
+ * animate(...)
765
+ * ], { limit: 1 })
766
+ * ```
767
+ *
768
+ * By default, throws an error when zero items are found. Set the
769
+ * `optional` flag to ignore this error. For example:
770
+ *
771
+ * ```js
772
+ * query('.some-element-that-may-not-be-there', [
773
+ * animate(...),
774
+ * animate(...)
775
+ * ], { optional: true })
776
+ * ```
777
+ *
778
+ * ### Entering and Leaving Elements
779
+ *
780
+ * Not all elements can be queried via the `:enter` and `:leave` tokens, the only ones
781
+ * that can are those that Angular assumes can enter/leave based on their own logic
782
+ * (if their insertion/removal is simply a consequence of that of their parent they
783
+ * should be queried via a different token in their parent's `:enter`/`:leave` transitions).
784
+ *
785
+ * The only elements Angular assumes can enter/leave based on their own logic (thus the only
786
+ * ones that can be queried via the `:enter` and `:leave` tokens) are:
787
+ * - Those inserted dynamically (via `ViewContainerRef`)
788
+ * - Those that have a structural directive (which, under the hood, are a subset of the above ones)
789
+ *
790
+ * <div class="docs-alert docs-alert-helpful">
791
+ *
792
+ * Note that elements will be successfully queried via `:enter`/`:leave` even if their
793
+ * insertion/removal is not done manually via `ViewContainerRef`or caused by their structural
794
+ * directive (e.g. they enter/exit alongside their parent).
795
+ *
796
+ * </div>
797
+ *
798
+ * <div class="docs-alert docs-alert-important">
799
+ *
800
+ * There is an exception to what previously mentioned, besides elements entering/leaving based on
801
+ * their own logic, elements with an animation trigger can always be queried via `:leave` when
802
+ * their parent is also leaving.
803
+ *
804
+ * </div>
805
+ *
806
+ * ### Usage Example
807
+ *
808
+ * The following example queries for inner elements and animates them
809
+ * individually using `animate()`.
810
+ *
811
+ * ```angular-ts
812
+ * @Component({
813
+ * selector: 'inner',
814
+ * template: `
815
+ * <div [@queryAnimation]="exp">
816
+ * <h1>Title</h1>
817
+ * <div class="content">
818
+ * Blah blah blah
819
+ * </div>
820
+ * </div>
821
+ * `,
822
+ * animations: [
823
+ * trigger('queryAnimation', [
824
+ * transition('* => goAnimate', [
825
+ * // hide the inner elements
826
+ * query('h1', style({ opacity: 0 })),
827
+ * query('.content', style({ opacity: 0 })),
828
+ *
829
+ * // animate the inner elements in, one by one
830
+ * query('h1', animate(1000, style({ opacity: 1 }))),
831
+ * query('.content', animate(1000, style({ opacity: 1 }))),
832
+ * ])
833
+ * ])
834
+ * ]
835
+ * })
836
+ * class Cmp {
837
+ * exp = '';
838
+ *
839
+ * goAnimate() {
840
+ * this.exp = 'goAnimate';
841
+ * }
842
+ * }
843
+ * ```
844
+ *
845
+ * @publicApi
846
+ */
847
+ function query(selector, animation, options = null) {
848
+ return { type: AnimationMetadataType.Query, selector, animation, options };
849
+ }
850
+ /**
851
+ * Use within an animation `query()` call to issue a timing gap after
852
+ * each queried item is animated.
853
+ *
854
+ * @param timings A delay value.
855
+ * @param animation One ore more animation steps.
856
+ * @returns An object that encapsulates the stagger data.
857
+ *
858
+ * @usageNotes
859
+ * In the following example, a container element wraps a list of items stamped out
860
+ * by an `ngFor`. The container element contains an animation trigger that will later be set
861
+ * to query for each of the inner items.
862
+ *
863
+ * Each time items are added, the opacity fade-in animation runs,
864
+ * and each removed item is faded out.
865
+ * When either of these animations occur, the stagger effect is
866
+ * applied after each item's animation is started.
867
+ *
868
+ * ```html
869
+ * <!-- list.component.html -->
870
+ * <button (click)="toggle()">Show / Hide Items</button>
871
+ * <hr />
872
+ * <div [@listAnimation]="items.length">
873
+ * <div *ngFor="let item of items">
874
+ * {{ item }}
875
+ * </div>
876
+ * </div>
877
+ * ```
878
+ *
879
+ * Here is the component code:
880
+ *
881
+ * ```ts
882
+ * import {trigger, transition, style, animate, query, stagger} from '@angular/animations';
883
+ * @Component({
884
+ * templateUrl: 'list.component.html',
885
+ * animations: [
886
+ * trigger('listAnimation', [
887
+ * ...
888
+ * ])
889
+ * ]
890
+ * })
891
+ * class ListComponent {
892
+ * items = [];
893
+ *
894
+ * showItems() {
895
+ * this.items = [0,1,2,3,4];
896
+ * }
897
+ *
898
+ * hideItems() {
899
+ * this.items = [];
900
+ * }
901
+ *
902
+ * toggle() {
903
+ * this.items.length ? this.hideItems() : this.showItems();
904
+ * }
905
+ * }
906
+ * ```
907
+ *
908
+ * Here is the animation trigger code:
909
+ *
910
+ * ```ts
911
+ * trigger('listAnimation', [
912
+ * transition('* => *', [ // each time the binding value changes
913
+ * query(':leave', [
914
+ * stagger(100, [
915
+ * animate('0.5s', style({ opacity: 0 }))
916
+ * ])
917
+ * ]),
918
+ * query(':enter', [
919
+ * style({ opacity: 0 }),
920
+ * stagger(100, [
921
+ * animate('0.5s', style({ opacity: 1 }))
922
+ * ])
923
+ * ])
924
+ * ])
925
+ * ])
926
+ * ```
927
+ *
928
+ * @publicApi
929
+ */
930
+ function stagger(timings, animation) {
931
+ return { type: AnimationMetadataType.Stagger, timings, animation };
932
+ }
933
+
934
+ /**
935
+ * An empty programmatic controller for reusable animations.
936
+ * Used internally when animations are disabled, to avoid
937
+ * checking for the null case when an animation player is expected.
938
+ *
939
+ * @see {@link animate}
940
+ * @see {@link AnimationPlayer}
941
+ *
942
+ * @publicApi
943
+ */
944
+ class NoopAnimationPlayer {
945
+ _onDoneFns = [];
946
+ _onStartFns = [];
947
+ _onDestroyFns = [];
948
+ _originalOnDoneFns = [];
949
+ _originalOnStartFns = [];
950
+ _started = false;
951
+ _destroyed = false;
952
+ _finished = false;
953
+ _position = 0;
954
+ parentPlayer = null;
955
+ totalTime;
956
+ constructor(duration = 0, delay = 0) {
957
+ this.totalTime = duration + delay;
958
+ }
959
+ _onFinish() {
960
+ if (!this._finished) {
961
+ this._finished = true;
962
+ this._onDoneFns.forEach((fn) => fn());
963
+ this._onDoneFns = [];
964
+ }
965
+ }
966
+ onStart(fn) {
967
+ this._originalOnStartFns.push(fn);
968
+ this._onStartFns.push(fn);
969
+ }
970
+ onDone(fn) {
971
+ this._originalOnDoneFns.push(fn);
972
+ this._onDoneFns.push(fn);
973
+ }
974
+ onDestroy(fn) {
975
+ this._onDestroyFns.push(fn);
976
+ }
977
+ hasStarted() {
978
+ return this._started;
979
+ }
980
+ init() { }
981
+ play() {
982
+ if (!this.hasStarted()) {
983
+ this._onStart();
984
+ this.triggerMicrotask();
985
+ }
986
+ this._started = true;
987
+ }
988
+ /** @internal */
989
+ triggerMicrotask() {
990
+ queueMicrotask(() => this._onFinish());
991
+ }
992
+ _onStart() {
993
+ this._onStartFns.forEach((fn) => fn());
994
+ this._onStartFns = [];
995
+ }
996
+ pause() { }
997
+ restart() { }
998
+ finish() {
999
+ this._onFinish();
1000
+ }
1001
+ destroy() {
1002
+ if (!this._destroyed) {
1003
+ this._destroyed = true;
1004
+ if (!this.hasStarted()) {
1005
+ this._onStart();
1006
+ }
1007
+ this.finish();
1008
+ this._onDestroyFns.forEach((fn) => fn());
1009
+ this._onDestroyFns = [];
1010
+ }
1011
+ }
1012
+ reset() {
1013
+ this._started = false;
1014
+ this._finished = false;
1015
+ this._onStartFns = this._originalOnStartFns;
1016
+ this._onDoneFns = this._originalOnDoneFns;
1017
+ }
1018
+ setPosition(position) {
1019
+ this._position = this.totalTime ? position * this.totalTime : 1;
1020
+ }
1021
+ getPosition() {
1022
+ return this.totalTime ? this._position / this.totalTime : 1;
1023
+ }
1024
+ /** @internal */
1025
+ triggerCallback(phaseName) {
1026
+ const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
1027
+ methods.forEach((fn) => fn());
1028
+ methods.length = 0;
1029
+ }
1030
+ }
1031
+
1032
+ /**
1033
+ * A programmatic controller for a group of reusable animations.
1034
+ * Used internally to control animations.
1035
+ *
1036
+ * @see {@link AnimationPlayer}
1037
+ * @see {@link animations/group group}
1038
+ *
1039
+ */
1040
+ class AnimationGroupPlayer {
1041
+ _onDoneFns = [];
1042
+ _onStartFns = [];
1043
+ _finished = false;
1044
+ _started = false;
1045
+ _destroyed = false;
1046
+ _onDestroyFns = [];
1047
+ parentPlayer = null;
1048
+ totalTime = 0;
1049
+ players;
1050
+ constructor(_players) {
1051
+ this.players = _players;
1052
+ let doneCount = 0;
1053
+ let destroyCount = 0;
1054
+ let startCount = 0;
1055
+ const total = this.players.length;
1056
+ if (total == 0) {
1057
+ queueMicrotask(() => this._onFinish());
1058
+ }
1059
+ else {
1060
+ this.players.forEach((player) => {
1061
+ player.onDone(() => {
1062
+ if (++doneCount == total) {
1063
+ this._onFinish();
1064
+ }
1065
+ });
1066
+ player.onDestroy(() => {
1067
+ if (++destroyCount == total) {
1068
+ this._onDestroy();
1069
+ }
1070
+ });
1071
+ player.onStart(() => {
1072
+ if (++startCount == total) {
1073
+ this._onStart();
1074
+ }
1075
+ });
1076
+ });
1077
+ }
1078
+ this.totalTime = this.players.reduce((time, player) => Math.max(time, player.totalTime), 0);
1079
+ }
1080
+ _onFinish() {
1081
+ if (!this._finished) {
1082
+ this._finished = true;
1083
+ this._onDoneFns.forEach((fn) => fn());
1084
+ this._onDoneFns = [];
1085
+ }
1086
+ }
1087
+ init() {
1088
+ this.players.forEach((player) => player.init());
1089
+ }
1090
+ onStart(fn) {
1091
+ this._onStartFns.push(fn);
1092
+ }
1093
+ _onStart() {
1094
+ if (!this.hasStarted()) {
1095
+ this._started = true;
1096
+ this._onStartFns.forEach((fn) => fn());
1097
+ this._onStartFns = [];
1098
+ }
1099
+ }
1100
+ onDone(fn) {
1101
+ this._onDoneFns.push(fn);
1102
+ }
1103
+ onDestroy(fn) {
1104
+ this._onDestroyFns.push(fn);
1105
+ }
1106
+ hasStarted() {
1107
+ return this._started;
1108
+ }
1109
+ play() {
1110
+ if (!this.parentPlayer) {
1111
+ this.init();
1112
+ }
1113
+ this._onStart();
1114
+ this.players.forEach((player) => player.play());
1115
+ }
1116
+ pause() {
1117
+ this.players.forEach((player) => player.pause());
1118
+ }
1119
+ restart() {
1120
+ this.players.forEach((player) => player.restart());
1121
+ }
1122
+ finish() {
1123
+ this._onFinish();
1124
+ this.players.forEach((player) => player.finish());
1125
+ }
1126
+ destroy() {
1127
+ this._onDestroy();
1128
+ }
1129
+ _onDestroy() {
1130
+ if (!this._destroyed) {
1131
+ this._destroyed = true;
1132
+ this._onFinish();
1133
+ this.players.forEach((player) => player.destroy());
1134
+ this._onDestroyFns.forEach((fn) => fn());
1135
+ this._onDestroyFns = [];
1136
+ }
1137
+ }
1138
+ reset() {
1139
+ this.players.forEach((player) => player.reset());
1140
+ this._destroyed = false;
1141
+ this._finished = false;
1142
+ this._started = false;
1143
+ }
1144
+ setPosition(p) {
1145
+ const timeAtPosition = p * this.totalTime;
1146
+ this.players.forEach((player) => {
1147
+ const position = player.totalTime ? Math.min(1, timeAtPosition / player.totalTime) : 1;
1148
+ player.setPosition(position);
1149
+ });
1150
+ }
1151
+ getPosition() {
1152
+ const longestPlayer = this.players.reduce((longestSoFar, player) => {
1153
+ const newPlayerIsLongest = longestSoFar === null || player.totalTime > longestSoFar.totalTime;
1154
+ return newPlayerIsLongest ? player : longestSoFar;
1155
+ }, null);
1156
+ return longestPlayer != null ? longestPlayer.getPosition() : 0;
1157
+ }
1158
+ beforeDestroy() {
1159
+ this.players.forEach((player) => {
1160
+ if (player.beforeDestroy) {
1161
+ player.beforeDestroy();
1162
+ }
1163
+ });
1164
+ }
1165
+ /** @internal */
1166
+ triggerCallback(phaseName) {
1167
+ const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
1168
+ methods.forEach((fn) => fn());
1169
+ methods.length = 0;
1170
+ }
1171
+ }
1172
+
1173
+ const ɵPRE_STYLE = '!';
1174
+
1175
+ export { AUTO_STYLE, AnimationGroupPlayer, AnimationMetadataType, NoopAnimationPlayer, animate, animateChild, animation, group, keyframes, query, sequence, stagger, state, style, transition, trigger, useAnimation, ɵPRE_STYLE };
1176
+ //# sourceMappingURL=private_export-CacKMzxJ.mjs.map