[6a3a178] | 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 | /**
|
---|
| 9 | * A repeater that destroys views when they are removed from a
|
---|
| 10 | * {@link ViewContainerRef}. When new items are inserted into the container,
|
---|
| 11 | * the repeater will always construct a new embedded view for each item.
|
---|
| 12 | *
|
---|
| 13 | * @template T The type for the embedded view's $implicit property.
|
---|
| 14 | * @template R The type for the item in each IterableDiffer change record.
|
---|
| 15 | * @template C The type for the context passed to each embedded view.
|
---|
| 16 | */
|
---|
| 17 | export class _DisposeViewRepeaterStrategy {
|
---|
| 18 | applyChanges(changes, viewContainerRef, itemContextFactory, itemValueResolver, itemViewChanged) {
|
---|
| 19 | changes.forEachOperation((record, adjustedPreviousIndex, currentIndex) => {
|
---|
| 20 | let view;
|
---|
| 21 | let operation;
|
---|
| 22 | if (record.previousIndex == null) {
|
---|
| 23 | const insertContext = itemContextFactory(record, adjustedPreviousIndex, currentIndex);
|
---|
| 24 | view = viewContainerRef.createEmbeddedView(insertContext.templateRef, insertContext.context, insertContext.index);
|
---|
| 25 | operation = 1 /* INSERTED */;
|
---|
| 26 | }
|
---|
| 27 | else if (currentIndex == null) {
|
---|
| 28 | viewContainerRef.remove(adjustedPreviousIndex);
|
---|
| 29 | operation = 3 /* REMOVED */;
|
---|
| 30 | }
|
---|
| 31 | else {
|
---|
| 32 | view = viewContainerRef.get(adjustedPreviousIndex);
|
---|
| 33 | viewContainerRef.move(view, currentIndex);
|
---|
| 34 | operation = 2 /* MOVED */;
|
---|
| 35 | }
|
---|
| 36 | if (itemViewChanged) {
|
---|
| 37 | itemViewChanged({
|
---|
| 38 | context: view === null || view === void 0 ? void 0 : view.context,
|
---|
| 39 | operation,
|
---|
| 40 | record,
|
---|
| 41 | });
|
---|
| 42 | }
|
---|
|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bmRleCk7XG4gICAgICAgICAgICBvcGVyYXRpb24gPSBfVmlld1JlcGVhdGVyT3BlcmF0aW9uLklOU0VSVEVEO1xuICAgICAgICAgIH0gZWxzZSBpZiAoY3VycmVudEluZGV4ID09IG51bGwpIHtcbiAgICAgICAgICAgIHZpZXdDb250YWluZXJSZWYucmVtb3ZlKGFkanVzdGVkUHJldmlvdXNJbmRleCEpO1xuICAgICAgICAgICAgb3BlcmF0aW9uID0gX1ZpZXdSZXBlYXRlck9wZXJhdGlvbi5SRU1PVkVEO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB2aWV3ID0gdmlld0NvbnRhaW5lclJlZi5nZXQoYWRqdXN0ZWRQcmV2aW91c0luZGV4ISkgYXMgRW1iZWRkZWRWaWV3UmVmPEM+O1xuICAgICAgICAgICAgdmlld0NvbnRhaW5lclJlZi5tb3ZlKHZpZXchLCBjdXJyZW50SW5kZXgpO1xuICAgICAgICAgICAgb3BlcmF0aW9uID0gX1ZpZXdSZXBlYXRlck9wZXJhdGlvbi5NT1ZFRDtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBpZiAoaXRlbVZpZXdDaGFuZ2VkKSB7XG4gICAgICAgICAgICBpdGVtVmlld0NoYW5nZWQoe1xuICAgICAgICAgICAgICBjb250ZXh0OiB2aWV3Py5jb250ZXh0LFxuICAgICAgICAgICAgICBvcGVyYXRpb24sXG4gICAgICAgICAgICAgIHJlY29yZCxcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gIH1cblxuICBkZXRhY2goKSB7XG4gIH1cbn1cbiJdfQ== |
---|