1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { InjectionToken, IterableChangeRecord, IterableChanges, TemplateRef, ViewContainerRef } from '@angular/core';
|
---|
9 | /**
|
---|
10 | * The context for an embedded view in the repeater's view container.
|
---|
11 | *
|
---|
12 | * @template T The type for the embedded view's $implicit property.
|
---|
13 | */
|
---|
14 | export interface _ViewRepeaterItemContext<T> {
|
---|
15 | $implicit?: T;
|
---|
16 | }
|
---|
17 | /**
|
---|
18 | * The arguments needed to construct an embedded view for an item in a view
|
---|
19 | * container.
|
---|
20 | *
|
---|
21 | * @template C The type for the context passed to each embedded view.
|
---|
22 | */
|
---|
23 | export interface _ViewRepeaterItemInsertArgs<C> {
|
---|
24 | templateRef: TemplateRef<C>;
|
---|
25 | context?: C;
|
---|
26 | index?: number;
|
---|
27 | }
|
---|
28 | /**
|
---|
29 | * A factory that derives the embedded view context for an item in a view
|
---|
30 | * container.
|
---|
31 | *
|
---|
32 | * @template T The type for the embedded view's $implicit property.
|
---|
33 | * @template R The type for the item in each IterableDiffer change record.
|
---|
34 | * @template C The type for the context passed to each embedded view.
|
---|
35 | */
|
---|
36 | export declare type _ViewRepeaterItemContextFactory<T, R, C extends _ViewRepeaterItemContext<T>> = (record: IterableChangeRecord<R>, adjustedPreviousIndex: number | null, currentIndex: number | null) => _ViewRepeaterItemInsertArgs<C>;
|
---|
37 | /**
|
---|
38 | * Extracts the value of an item from an {@link IterableChangeRecord}.
|
---|
39 | *
|
---|
40 | * @template T The type for the embedded view's $implicit property.
|
---|
41 | * @template R The type for the item in each IterableDiffer change record.
|
---|
42 | */
|
---|
43 | export declare type _ViewRepeaterItemValueResolver<T, R> = (record: IterableChangeRecord<R>) => T;
|
---|
44 | /** Indicates how a view was changed by a {@link _ViewRepeater}. */
|
---|
45 | export declare const enum _ViewRepeaterOperation {
|
---|
46 | /** The content of an existing view was replaced with another item. */
|
---|
47 | REPLACED = 0,
|
---|
48 | /** A new view was created with `createEmbeddedView`. */
|
---|
49 | INSERTED = 1,
|
---|
50 | /** The position of a view changed, but the content remains the same. */
|
---|
51 | MOVED = 2,
|
---|
52 | /** A view was detached from the view container. */
|
---|
53 | REMOVED = 3
|
---|
54 | }
|
---|
55 | /**
|
---|
56 | * Meta data describing the state of a view after it was updated by a
|
---|
57 | * {@link _ViewRepeater}.
|
---|
58 | *
|
---|
59 | * @template R The type for the item in each IterableDiffer change record.
|
---|
60 | * @template C The type for the context passed to each embedded view.
|
---|
61 | */
|
---|
62 | export interface _ViewRepeaterItemChange<R, C> {
|
---|
63 | /** The view's context after it was changed. */
|
---|
64 | context?: C;
|
---|
65 | /** Indicates how the view was changed. */
|
---|
66 | operation: _ViewRepeaterOperation;
|
---|
67 | /** The view's corresponding change record. */
|
---|
68 | record: IterableChangeRecord<R>;
|
---|
69 | }
|
---|
70 | /**
|
---|
71 | * Type for a callback to be executed after a view has changed.
|
---|
72 | *
|
---|
73 | * @template R The type for the item in each IterableDiffer change record.
|
---|
74 | * @template C The type for the context passed to each embedded view.
|
---|
75 | */
|
---|
76 | export declare type _ViewRepeaterItemChanged<R, C> = (change: _ViewRepeaterItemChange<R, C>) => void;
|
---|
77 | /**
|
---|
78 | * Describes a strategy for rendering items in a {@link ViewContainerRef}.
|
---|
79 | *
|
---|
80 | * @template T The type for the embedded view's $implicit property.
|
---|
81 | * @template R The type for the item in each IterableDiffer change record.
|
---|
82 | * @template C The type for the context passed to each embedded view.
|
---|
83 | */
|
---|
84 | export interface _ViewRepeater<T, R, C extends _ViewRepeaterItemContext<T>> {
|
---|
85 | applyChanges(changes: IterableChanges<R>, viewContainerRef: ViewContainerRef, itemContextFactory: _ViewRepeaterItemContextFactory<T, R, C>, itemValueResolver: _ViewRepeaterItemValueResolver<T, R>, itemViewChanged?: _ViewRepeaterItemChanged<R, C>): void;
|
---|
86 | detach(): void;
|
---|
87 | }
|
---|
88 | /**
|
---|
89 | * Injection token for {@link _ViewRepeater}. This token is for use by Angular Material only.
|
---|
90 | * @docs-private
|
---|
91 | */
|
---|
92 | export declare const _VIEW_REPEATER_STRATEGY: InjectionToken<_ViewRepeater<unknown, unknown, _ViewRepeaterItemContext<unknown>>>;
|
---|