@nativescript-community/ui-collectionview 4.0.54 → 4.0.57

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,7 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, ɵisListLikeIterable, ElementRef, IterableDiffers, TemplateRef, ViewContainerRef, Component, ChangeDetectionStrategy, Inject, ViewChild, Output, ContentChild, Input, Directive, Host, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2
+ import { EventEmitter, ɵisListLikeIterable, ElementRef, IterableDiffers, NgZone, TemplateRef, ViewContainerRef, Component, ChangeDetectionStrategy, Inject, ViewChild, Output, ContentChild, Input, HostListener, Directive, Host, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
3
3
  import { CollectionView, ListViewViewTypes, CLog, CLogTypes } from '@nativescript-community/ui-collectionview';
4
- import { registerElement, extractSingleViewRecursive } from '@nativescript/angular';
4
+ import * as i1 from '@nativescript/angular';
5
+ import { registerElement, DetachedLoader, NativeScriptRendererFactory, extractSingleViewRecursive } from '@nativescript/angular';
5
6
  import { ObservableArray, Trace, LayoutBase } from '@nativescript/core';
6
7
 
7
8
  const _c0 = ["loader"];
@@ -17,25 +18,31 @@ class ItemContext {
17
18
  }
18
19
  }
19
20
  class CollectionViewComponent {
20
- constructor(_elementRef, _iterableDiffers) {
21
+ constructor(_elementRef, _iterableDiffers, _renderer, _ngZone) {
22
+ this._elementRef = _elementRef;
21
23
  this._iterableDiffers = _iterableDiffers;
24
+ this._renderer = _renderer;
25
+ this._ngZone = _ngZone;
22
26
  this.setupItemView = new EventEmitter();
23
- this.itemViewLoader = (viewType) => {
27
+ this.autoReuseViews = false;
28
+ this.itemViewLoader = (viewType) => this._ngZone.run(() => {
24
29
  switch (viewType) {
25
30
  case ListViewViewTypes.ItemView:
26
31
  if (this._itemTemplate && this.loader) {
27
- const nativeItem = this.loader.createEmbeddedView(this._itemTemplate, new ItemContext(), 0);
28
- const typedView = getItemViewRoot(nativeItem);
29
- typedView[NG_VIEW] = nativeItem;
32
+ const typedView = this.getOrCreate(this._itemTemplate);
30
33
  return typedView;
31
34
  }
32
35
  break;
33
36
  }
34
37
  return null;
35
- };
38
+ });
39
+ this.viewPool = new Map();
40
+ this.viewToTemplate = new WeakMap();
41
+ this.viewToLoader = new WeakMap();
36
42
  this._collectionView = _elementRef.nativeElement;
37
43
  this._collectionView.on(CollectionView.itemLoadingEvent, this.onItemLoading, this);
38
44
  this._collectionView.itemViewLoader = this.itemViewLoader;
45
+ this._loaders = [];
39
46
  }
40
47
  get nativeElement() {
41
48
  return this._collectionView;
@@ -43,6 +50,14 @@ class CollectionViewComponent {
43
50
  get listView() {
44
51
  return this._collectionView;
45
52
  }
53
+ detachedLoaderFactory() {
54
+ const ref = this.loader.createComponent(DetachedLoader, {
55
+ index: 0
56
+ });
57
+ this.loader.detach(0);
58
+ this._loaders.push(ref);
59
+ return ref;
60
+ }
46
61
  get itemTemplate() {
47
62
  return this._itemTemplate;
48
63
  }
@@ -72,6 +87,19 @@ class CollectionViewComponent {
72
87
  }
73
88
  ngOnDestroy() {
74
89
  this._collectionView.off(CollectionView.itemLoadingEvent, this.onItemLoading, this);
90
+ this._collectionView = null;
91
+ this._loaders.forEach((l) => l.destroy());
92
+ this._loaders = null;
93
+ this.viewToLoader = null;
94
+ this.viewToTemplate = null;
95
+ this.viewPool = null;
96
+ this._items = null;
97
+ this._differ = null;
98
+ this._itemTemplate = null;
99
+ if (this._templateMap) {
100
+ this._templateMap.clear();
101
+ }
102
+ this._templateMap = null;
75
103
  }
76
104
  ngDoCheck() {
77
105
  if (Trace.isEnabled()) {
@@ -136,6 +164,31 @@ class CollectionViewComponent {
136
164
  this.setupViewRef(viewRef, currentItem, index);
137
165
  this.detectChangesOnChild(viewRef, index);
138
166
  }
167
+ onItemRecyclingInternal(args) {
168
+ if (!args.view) {
169
+ return;
170
+ }
171
+ let ngView = args.view[NG_VIEW];
172
+ if (!ngView && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {
173
+ ngView = args.view.getChildAt(0)[NG_VIEW];
174
+ }
175
+ if (ngView) {
176
+ ngView.detach();
177
+ }
178
+ }
179
+ onItemDisposingInternal(args) {
180
+ if (!args.view) {
181
+ return;
182
+ }
183
+ let ngView = args.view[NG_VIEW];
184
+ if (!ngView && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {
185
+ ngView = args.view.getChildAt(0)[NG_VIEW];
186
+ }
187
+ if (ngView) {
188
+ ngView.detach();
189
+ this.storeViewRef(ngView);
190
+ }
191
+ }
139
192
  setupViewRef(view, data, index) {
140
193
  const context = view.context;
141
194
  context.$implicit = data;
@@ -158,6 +211,58 @@ class CollectionViewComponent {
158
211
  return resultView;
159
212
  };
160
213
  }
214
+ storeViewRef(viewRef) {
215
+ var _a;
216
+ const templateRef = this.viewToTemplate.get(viewRef);
217
+ if (templateRef) {
218
+ const scrap = this.viewPool.get(templateRef);
219
+ if (scrap) {
220
+ if (scrap.scrapHead.size >= scrap.scrapSize) {
221
+ viewRef.destroy();
222
+ (_a = this.viewToLoader.get(viewRef)) === null || _a === void 0 ? void 0 : _a.destroy();
223
+ }
224
+ else {
225
+ scrap.scrapHead.add(viewRef);
226
+ }
227
+ }
228
+ }
229
+ }
230
+ getOrCreate(templateRef) {
231
+ return this._ngZone.run(() => {
232
+ let viewRef = this.getView(templateRef);
233
+ if (!viewRef) {
234
+ const loader = this.detachedLoaderFactory();
235
+ viewRef = loader.instance.vc.createEmbeddedView(templateRef, new ItemContext(), 0);
236
+ this.viewToLoader.set(viewRef, loader);
237
+ this.viewToTemplate.set(viewRef, templateRef);
238
+ }
239
+ viewRef.detach();
240
+ const resultView = getItemViewRoot(viewRef);
241
+ resultView[NG_VIEW] = viewRef;
242
+ resultView.reusable = this.autoReuseViews;
243
+ return resultView;
244
+ });
245
+ }
246
+ getView(templateRef) {
247
+ const pool = this.getViewPool(templateRef);
248
+ while (pool.scrapHead.size > 0) {
249
+ const viewRef = pool.scrapHead.values().next().value;
250
+ pool.scrapHead.delete(viewRef);
251
+ if (!viewRef.destroyed) {
252
+ return viewRef;
253
+ }
254
+ }
255
+ return null;
256
+ }
257
+ getViewPool(templateRef) {
258
+ if (!this.viewPool.has(templateRef)) {
259
+ this.viewPool.set(templateRef, {
260
+ scrapSize: this.autoReuseViews ? Infinity : 0,
261
+ scrapHead: new Set()
262
+ });
263
+ }
264
+ return this.viewPool.get(templateRef);
265
+ }
161
266
  setItemTemplates() {
162
267
  this.itemTemplate = this.itemTemplateQuery;
163
268
  if (this._templateMap) {
@@ -187,7 +292,7 @@ class CollectionViewComponent {
187
292
  }
188
293
  }
189
294
  }
190
- CollectionViewComponent.ɵfac = function CollectionViewComponent_Factory(t) { return new (t || CollectionViewComponent)(i0.ɵɵdirectiveInject(ElementRef), i0.ɵɵdirectiveInject(IterableDiffers)); };
295
+ CollectionViewComponent.ɵfac = function CollectionViewComponent_Factory(t) { return new (t || CollectionViewComponent)(i0.ɵɵdirectiveInject(ElementRef), i0.ɵɵdirectiveInject(IterableDiffers), i0.ɵɵdirectiveInject(NativeScriptRendererFactory), i0.ɵɵdirectiveInject(NgZone)); };
191
296
  CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewComponent, selectors: [["CollectionView"]], contentQueries: function CollectionViewComponent_ContentQueries(rf, ctx, dirIndex) {
192
297
  if (rf & 1) {
193
298
  i0.ɵɵcontentQuery(dirIndex, TemplateRef, 7, TemplateRef);
@@ -204,7 +309,11 @@ CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewCom
204
309
  let _t;
205
310
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.loader = _t.first);
206
311
  }
207
- }, inputs: { itemTemplate: "itemTemplate", items: "items" }, outputs: { setupItemView: "setupItemView" }, decls: 3, vars: 0, consts: [["loader", ""]], template: function CollectionViewComponent_Template(rf, ctx) {
312
+ }, hostBindings: function CollectionViewComponent_HostBindings(rf, ctx) {
313
+ if (rf & 1) {
314
+ i0.ɵɵlistener("itemLoading", function CollectionViewComponent_itemLoading_HostBindingHandler($event) { return ctx.onItemLoading($event); })("itemRecycling", function CollectionViewComponent_itemRecycling_HostBindingHandler($event) { return ctx.onItemRecyclingInternal($event); })("itemDisposing", function CollectionViewComponent_itemDisposing_HostBindingHandler($event) { return ctx.onItemDisposingInternal($event); });
315
+ }
316
+ }, inputs: { autoReuseViews: "autoReuseViews", itemTemplate: "itemTemplate", items: "items" }, outputs: { setupItemView: "setupItemView" }, decls: 3, vars: 0, consts: [["loader", ""]], template: function CollectionViewComponent_Template(rf, ctx) {
208
317
  if (rf & 1) {
209
318
  i0.ɵɵelementStart(0, "DetachedContainer");
210
319
  i0.ɵɵelement(1, "Placeholder", null, 0);
@@ -230,6 +339,12 @@ CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewCom
230
339
  }] }, { type: i0.IterableDiffers, decorators: [{
231
340
  type: Inject,
232
341
  args: [IterableDiffers]
342
+ }] }, { type: i1.NativeScriptRendererFactory, decorators: [{
343
+ type: Inject,
344
+ args: [NativeScriptRendererFactory]
345
+ }] }, { type: i0.NgZone, decorators: [{
346
+ type: Inject,
347
+ args: [NgZone]
233
348
  }] }];
234
349
  }, { loader: [{
235
350
  type: ViewChild,
@@ -239,10 +354,21 @@ CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewCom
239
354
  }], itemTemplateQuery: [{
240
355
  type: ContentChild,
241
356
  args: [TemplateRef, { read: TemplateRef, static: true }]
357
+ }], autoReuseViews: [{
358
+ type: Input
242
359
  }], itemTemplate: [{
243
360
  type: Input
244
361
  }], items: [{
245
362
  type: Input
363
+ }], onItemLoading: [{
364
+ type: HostListener,
365
+ args: ['itemLoading', ['$event']]
366
+ }], onItemRecyclingInternal: [{
367
+ type: HostListener,
368
+ args: ['itemRecycling', ['$event']]
369
+ }], onItemDisposingInternal: [{
370
+ type: HostListener,
371
+ args: ['itemDisposing', ['$event']]
246
372
  }] });
247
373
  })();
248
374
  function getItemViewRoot(viewRef, rootLocator = extractSingleViewRecursive) {
@@ -1 +1 @@
1
- {"version":3,"file":"nativescript-community-ui-collectionview-angular.mjs","sources":["../../../../src/collectionview/angular/collectionview-comp.ts","../../../../src/collectionview/angular/index.ts"],"sourcesContent":["import {\n AfterContentInit,\n ChangeDetectionStrategy,\n Component,\n ContentChild,\n Directive,\n DoCheck,\n ElementRef,\n EmbeddedViewRef,\n EventEmitter,\n Host,\n Inject,\n Input,\n IterableDiffer,\n IterableDiffers,\n OnDestroy,\n Output,\n TemplateRef,\n ViewChild,\n ViewContainerRef,\n ɵisListLikeIterable as isListLikeIterable\n} from '@angular/core';\nimport { CLog, CLogTypes, CollectionView, CollectionViewItemEventData, ListViewViewTypes } from '@nativescript-community/ui-collectionview';\nimport { extractSingleViewRecursive, registerElement } from '@nativescript/angular';\nimport { KeyedTemplate, LayoutBase, ObservableArray, Trace, View } from '@nativescript/core';\n\nregisterElement('CollectionView', () => CollectionView);\n\nconst NG_VIEW = '_ngViewRef';\n\nexport class ItemContext {\n constructor(public $implicit?: any, public item?: any, public index?: number, public even?: boolean, public odd?: boolean) {}\n}\n\nexport interface SetupItemViewArgs {\n view: EmbeddedViewRef<any>;\n data: any;\n index: number;\n context: ItemContext;\n}\n\n@Component({\n selector: 'CollectionView',\n template: `\n <DetachedContainer>\n <Placeholder #loader></Placeholder>\n </DetachedContainer>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class CollectionViewComponent implements DoCheck, OnDestroy, AfterContentInit {\n public get nativeElement(): any {\n return this._collectionView;\n }\n public get listView(): any {\n return this._collectionView;\n }\n\n @ViewChild('loader', { read: ViewContainerRef, static: true }) public loader: ViewContainerRef;\n @Output() public setupItemView = new EventEmitter<SetupItemViewArgs>();\n @ContentChild(TemplateRef, { read: TemplateRef, static: true }) public itemTemplateQuery: TemplateRef<ItemContext>;\n\n @Input()\n public get itemTemplate() {\n return this._itemTemplate;\n }\n public set itemTemplate(value: any) {\n this._itemTemplate = value;\n this._collectionView.refresh();\n }\n @Input()\n public get items() {\n return this._items;\n }\n public set items(value: any) {\n this._items = value;\n let needDiffer = true;\n if (value instanceof ObservableArray) {\n needDiffer = false;\n }\n if (needDiffer && !this._differ && isListLikeIterable(value)) {\n this._differ = this._iterableDiffers.find(this._items).create((_index, item) => item);\n }\n\n this._collectionView.items = this._items;\n }\n\n private _collectionView: CollectionView;\n private _items: any;\n private _differ: IterableDiffer<KeyedTemplate>;\n private _itemTemplate: TemplateRef<ItemContext>;\n private _templateMap: Map<string, KeyedTemplate>;\n\n constructor(@Inject(ElementRef) _elementRef: ElementRef, @Inject(IterableDiffers) private _iterableDiffers: IterableDiffers) {\n this._collectionView = _elementRef.nativeElement;\n\n this._collectionView.on(CollectionView.itemLoadingEvent, this.onItemLoading, this);\n this._collectionView.itemViewLoader = this.itemViewLoader;\n }\n\n private itemViewLoader = (viewType) => {\n switch (viewType) {\n case ListViewViewTypes.ItemView:\n if (this._itemTemplate && this.loader) {\n const nativeItem = this.loader.createEmbeddedView(this._itemTemplate, new ItemContext(), 0);\n const typedView = getItemViewRoot(nativeItem);\n typedView[NG_VIEW] = nativeItem;\n return typedView;\n }\n break;\n }\n return null;\n };\n\n public ngAfterContentInit() {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'CollectionView.ngAfterContentInit()');\n }\n this.setItemTemplates();\n }\n\n public ngOnDestroy() {\n this._collectionView.off(CollectionView.itemLoadingEvent, this.onItemLoading, this);\n }\n\n public ngDoCheck() {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'ngDoCheck() - execute differ? ' + this._differ);\n }\n if (this._differ) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'ngDoCheck() - execute differ');\n }\n const changes = this._differ.diff(this._items);\n if (changes) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'ngDoCheck() - refresh');\n }\n this.refresh();\n }\n }\n }\n\n public registerTemplate(key: string, template: TemplateRef<ItemContext>) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'registerTemplate for key: ' + key);\n }\n if (!this._templateMap) {\n this._templateMap = new Map<string, KeyedTemplate>();\n }\n\n const keyedTemplate = {\n key,\n createView: this.getItemTemplateViewFactory(template)\n };\n\n this._templateMap.set(key, keyedTemplate);\n }\n\n // @HostListener('itemLoadingInternal', ['$event'])\n public onItemLoading(args: CollectionViewItemEventData) {\n if (!args.view && !this.itemTemplate) {\n return;\n }\n if (!this.items) return;\n const index = args.index;\n const items = (args.object as any).items;\n const currentItem = typeof items.getItem === 'function' ? items.getItem(index) : items[index];\n let viewRef: EmbeddedViewRef<ItemContext>;\n\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, `onItemLoading: ${index} - Reusing existing view`);\n }\n\n viewRef = args.view[NG_VIEW];\n // Getting angular view from original element (in cases when ProxyViewContainer\n // is used NativeScript internally wraps it in a StackLayout)\n if (!viewRef && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {\n viewRef = args.view.getChildAt(0)[NG_VIEW];\n }\n\n if (!viewRef && Trace.isEnabled()) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, `ViewReference not found for item ${index}. View recycling is not working`);\n }\n }\n\n if (!viewRef) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, `onItemLoading: ${index} - Creating view from template`);\n }\n\n viewRef = this.loader.createEmbeddedView(this.itemTemplate, new ItemContext(), 0);\n args.view = getItemViewRoot(viewRef);\n args.view[NG_VIEW] = viewRef;\n }\n\n this.setupViewRef(viewRef, currentItem, index);\n\n this.detectChangesOnChild(viewRef, index);\n }\n\n public setupViewRef(view: EmbeddedViewRef<ItemContext>, data: any, index: number): void {\n const context = view.context;\n context.$implicit = data;\n context.item = data;\n context.index = index;\n context.even = index % 2 === 0;\n context.odd = !context.even;\n\n this.setupItemView.next({\n context,\n data,\n index,\n view\n });\n }\n\n protected getItemTemplateViewFactory(template: TemplateRef<ItemContext>): () => View {\n return () => {\n const viewRef = this.loader.createEmbeddedView(template, new ItemContext(), 0);\n const resultView = getItemViewRoot(viewRef);\n resultView[NG_VIEW] = viewRef;\n\n return resultView;\n };\n }\n\n private setItemTemplates() {\n // The itemTemplateQuery may be changed after list items are added that contain <template> inside,\n // so cache and use only the original template to avoid errors.\n this.itemTemplate = this.itemTemplateQuery;\n\n if (this._templateMap) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'Setting templates');\n }\n\n const templates: KeyedTemplate[] = [];\n this._templateMap.forEach((value) => {\n templates.push(value);\n });\n this._collectionView.itemTemplates = templates;\n } else {\n // If the map was not initialized this means that there are no named templates, so we register the default one.\n this._collectionView.itemTemplate = this.getItemTemplateViewFactory(this.itemTemplate);\n }\n }\n\n private detectChangesOnChild(viewRef: EmbeddedViewRef<ItemContext>, index: number) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'Manually detect changes in child: ' + index);\n }\n viewRef.markForCheck();\n viewRef.detectChanges();\n }\n\n private refresh() {\n if (this._collectionView) {\n this._collectionView.refresh();\n }\n }\n}\n\nexport interface ComponentView {\n rootNodes: any[];\n destroy(): void;\n}\n\nexport type RootLocator = (nodes: any[], nestLevel: number) => View;\n\nexport function getItemViewRoot(viewRef: ComponentView, rootLocator: RootLocator = extractSingleViewRecursive): View {\n const rootView = rootLocator(viewRef.rootNodes, 0);\n return rootView;\n}\n\n@Directive({ selector: '[cvTemplateKey]' })\nexport class TemplateKeyDirective {\n constructor(private templateRef: TemplateRef<any>, @Host() private collectionView: CollectionViewComponent) {}\n\n @Input()\n set cvTemplateKey(value: any) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'cvTemplateKey: ' + value);\n }\n if (this.collectionView && this.templateRef) {\n this.collectionView.registerTemplate(value.toLowerCase(), this.templateRef);\n }\n }\n}\n","// External\nimport { NO_ERRORS_SCHEMA, NgModule } from '@angular/core';\n\nimport { CollectionViewComponent, TemplateKeyDirective } from './collectionview-comp';\nexport { CollectionViewComponent, TemplateKeyDirective } from './collectionview-comp';\n\n@NgModule({\n declarations: [CollectionViewComponent, TemplateKeyDirective],\n exports: [CollectionViewComponent, TemplateKeyDirective],\n schemas: [NO_ERRORS_SCHEMA]\n})\nexport class CollectionViewModule {}\n"],"names":["isListLikeIterable"],"mappings":";;;;;;;AA0BA,eAAe,CAAC,gBAAgB,EAAE,MAAM,cAAc,CAAC,CAAC;AAExD,MAAM,OAAO,GAAG,YAAY,CAAC;MAEhB,WAAW,CAAA;IACpB,WAAmB,CAAA,SAAe,EAAS,IAAU,EAAS,KAAc,EAAS,IAAc,EAAS,GAAa,EAAA;AAAtG,QAAA,IAAS,CAAA,SAAA,GAAT,SAAS,CAAM;AAAS,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAM;AAAS,QAAA,IAAK,CAAA,KAAA,GAAL,KAAK,CAAS;AAAS,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAU;AAAS,QAAA,IAAG,CAAA,GAAA,GAAH,GAAG,CAAU;KAAI;AAChI,CAAA;MAkBY,uBAAuB,CAAA;IA2ChC,WAAgC,CAAA,WAAuB,EAAmC,gBAAiC,EAAA;AAAjC,QAAA,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB,CAAiB;AAlC1G,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,YAAY,EAAqB,CAAC;AAyC/D,QAAA,IAAA,CAAA,cAAc,GAAG,CAAC,QAAQ,KAAI;AAClC,YAAA,QAAQ,QAAQ;gBACZ,KAAK,iBAAiB,CAAC,QAAQ;AAC3B,oBAAA,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,MAAM,EAAE;AACnC,wBAAA,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;AAC5F,wBAAA,MAAM,SAAS,GAAG,eAAe,CAAC,UAAU,CAAC,CAA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KAAA,CAAA,IAAA,oBAAoB,6DACsD,uBAAuB,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA;yDADjG,oBAAoB,EAAA,SAAA,EAAA,CAAA,CAAA,EAAA,EAAA,eAAA,EAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,EAAA,aAAA,EAAA,eAAA,EAAA,EAAA,CAAA,CAAA;;4EAApB,oBAAoB,EAAA,CAAA;kBADhC,SAAS;mBAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAA;;kDAE6C,uBAAuB,EAAA,UAAA,EAAA,CAAA;8BAAtD,IAAI;;SAGpD,aAAa,EAAA,CAAA;sBADhB,KAAK;;;;MC7QG,oBAAoB,CAAA;;wFAApB,oBAAoB,GAAA,CAAA,EAAA,CAAA;wDAApB,oBAAoB,EAAA,CAAA,CAAA;;;4EAApB,oBAAoB,EAAA,CAAA;kBALhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,YAAY,EAAE,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;AAC7D,oBAAA,OAAO,EAAE,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;oBACxD,OAAO,EAAE,CAAC,gBAAgB,CAAC;iBAC9B,CAAA;;;AACY,CAAA,cAAA,CAAA,OAAA,SAAA,KAAA,WAAA,IAAA,SAAA,KAAA,EAAA,CAAA,kBAAA,CAAA,oBAAoB,mBAJd,uBAAuB,EAAE,oBAAoB,CAClD,EAAA,OAAA,EAAA,CAAA,uBAAuB,EAAE,oBAAoB,CAAA,EAAA,CAAA,CAAA,EAAA,GAAA;;;;"}
1
+ {"version":3,"file":"nativescript-community-ui-collectionview-angular.mjs","sources":["../../../../src/collectionview/angular/collectionview-comp.ts","../../../../src/collectionview/angular/index.ts"],"sourcesContent":["import {\n AfterContentInit,\n ChangeDetectionStrategy,\n Component,\n ComponentRef,\n ContentChild,\n Directive,\n DoCheck,\n ElementRef,\n EmbeddedViewRef,\n EventEmitter,\n Host,\n HostListener,\n Inject,\n Input,\n IterableDiffer,\n IterableDiffers,\n NgZone,\n OnDestroy,\n Output,\n TemplateRef,\n ViewChild,\n ViewContainerRef,\n ɵisListLikeIterable as isListLikeIterable\n} from '@angular/core';\nimport { CLog, CLogTypes, CollectionView, CollectionViewItemEventData, ListViewViewTypes } from '@nativescript-community/ui-collectionview';\nimport { DetachedLoader, NativeScriptRendererFactory, extractSingleViewRecursive, registerElement } from '@nativescript/angular';\nimport { KeyedTemplate, LayoutBase, ObservableArray, Trace, View } from '@nativescript/core';\n\nregisterElement('CollectionView', () => CollectionView);\n\nconst NG_VIEW = '_ngViewRef';\n\nexport class ItemContext {\n constructor(public $implicit?: any, public item?: any, public index?: number, public even?: boolean, public odd?: boolean) {}\n}\n\nexport interface SetupItemViewArgs {\n view: EmbeddedViewRef<any>;\n data: any;\n index: number;\n context: ItemContext;\n}\n\n@Component({\n selector: 'CollectionView',\n template: `\n <DetachedContainer>\n <Placeholder #loader></Placeholder>\n </DetachedContainer>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class CollectionViewComponent implements DoCheck, OnDestroy, AfterContentInit {\n public get nativeElement(): any {\n return this._collectionView;\n }\n public get listView(): any {\n return this._collectionView;\n }\n\n @ViewChild('loader', { read: ViewContainerRef, static: true }) public loader: ViewContainerRef;\n @Output() public setupItemView = new EventEmitter<SetupItemViewArgs>();\n @ContentChild(TemplateRef, { read: TemplateRef, static: true }) public itemTemplateQuery: TemplateRef<ItemContext>;\n\n @Input() autoReuseViews = false;\n\n detachedLoaderFactory() {\n const ref = this.loader.createComponent(DetachedLoader, {\n index: 0\n });\n this.loader.detach(0);\n this._loaders.push(ref);\n return ref;\n }\n\n @Input()\n public get itemTemplate() {\n return this._itemTemplate;\n }\n public set itemTemplate(value: any) {\n this._itemTemplate = value;\n this._collectionView.refresh();\n }\n @Input()\n public get items() {\n return this._items;\n }\n public set items(value: any) {\n this._items = value;\n let needDiffer = true;\n if (value instanceof ObservableArray) {\n needDiffer = false;\n }\n if (needDiffer && !this._differ && isListLikeIterable(value)) {\n this._differ = this._iterableDiffers.find(this._items).create((_index, item) => item);\n }\n\n this._collectionView.items = this._items;\n }\n\n private _collectionView: CollectionView;\n private _items: any;\n private _differ: IterableDiffer<KeyedTemplate>;\n private _itemTemplate: TemplateRef<ItemContext>;\n private _templateMap: Map<string, KeyedTemplate>;\n private _loaders: ComponentRef<DetachedLoader>[];\n\n constructor(\n @Inject(ElementRef) private _elementRef: ElementRef,\n @Inject(IterableDiffers) private _iterableDiffers: IterableDiffers,\n @Inject(NativeScriptRendererFactory) private _renderer: NativeScriptRendererFactory,\n @Inject(NgZone) private _ngZone: NgZone\n ) {\n this._collectionView = _elementRef.nativeElement;\n\n this._collectionView.on(CollectionView.itemLoadingEvent, this.onItemLoading, this);\n this._collectionView.itemViewLoader = this.itemViewLoader;\n this._loaders = [];\n }\n\n private itemViewLoader = (viewType) =>\n this._ngZone.run(() => {\n switch (viewType) {\n case ListViewViewTypes.ItemView:\n if (this._itemTemplate && this.loader) {\n const typedView = this.getOrCreate(this._itemTemplate);\n return typedView;\n }\n break;\n }\n return null;\n });\n\n public ngAfterContentInit() {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'CollectionView.ngAfterContentInit()');\n }\n this.setItemTemplates();\n }\n\n public ngOnDestroy() {\n this._collectionView.off(CollectionView.itemLoadingEvent, this.onItemLoading, this);\n this._collectionView = null;\n this._loaders.forEach((l) => l.destroy());\n this._loaders = null;\n this.viewToLoader = null;\n this.viewToTemplate = null;\n this.viewPool = null;\n\n this._items = null;\n this._differ = null;\n this._itemTemplate = null;\n if (this._templateMap) {\n this._templateMap.clear();\n }\n this._templateMap = null;\n }\n\n public ngDoCheck() {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'ngDoCheck() - execute differ? ' + this._differ);\n }\n if (this._differ) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'ngDoCheck() - execute differ');\n }\n const changes = this._differ.diff(this._items);\n if (changes) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'ngDoCheck() - refresh');\n }\n this.refresh();\n }\n }\n }\n\n public registerTemplate(key: string, template: TemplateRef<ItemContext>) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'registerTemplate for key: ' + key);\n }\n if (!this._templateMap) {\n this._templateMap = new Map<string, KeyedTemplate>();\n }\n\n const keyedTemplate = {\n key,\n createView: this.getItemTemplateViewFactory(template)\n };\n\n this._templateMap.set(key, keyedTemplate);\n }\n\n @HostListener('itemLoading', ['$event'])\n public onItemLoading(args: CollectionViewItemEventData) {\n if (!args.view && !this.itemTemplate) {\n return;\n }\n if (!this.items) return;\n const index = args.index;\n const items = (args.object as any).items;\n const currentItem = typeof items.getItem === 'function' ? items.getItem(index) : items[index];\n let viewRef: EmbeddedViewRef<ItemContext>;\n\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, `onItemLoading: ${index} - Reusing existing view`);\n }\n\n viewRef = args.view[NG_VIEW];\n // Getting angular view from original element (in cases when ProxyViewContainer\n // is used NativeScript internally wraps it in a StackLayout)\n if (!viewRef && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {\n viewRef = args.view.getChildAt(0)[NG_VIEW];\n }\n\n if (!viewRef && Trace.isEnabled()) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, `ViewReference not found for item ${index}. View recycling is not working`);\n }\n }\n\n if (!viewRef) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, `onItemLoading: ${index} - Creating view from template`);\n }\n\n viewRef = this.loader.createEmbeddedView(this.itemTemplate, new ItemContext(), 0);\n args.view = getItemViewRoot(viewRef);\n args.view[NG_VIEW] = viewRef;\n }\n\n this.setupViewRef(viewRef, currentItem, index);\n\n this.detectChangesOnChild(viewRef, index);\n }\n @HostListener('itemRecycling', ['$event'])\n public onItemRecyclingInternal(args: any) {\n if (!args.view) {\n return;\n }\n let ngView: EmbeddedViewRef<any> = args.view[NG_VIEW];\n\n // Getting angular view from original element (in cases when ProxyViewContainer\n // is used NativeScript internally wraps it in a StackLayout)\n if (!ngView && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {\n ngView = args.view.getChildAt(0)[NG_VIEW];\n }\n // console.log('recycling', args.view);\n\n if (ngView) {\n ngView.detach();\n }\n }\n\n @HostListener('itemDisposing', ['$event'])\n public onItemDisposingInternal(args: any) {\n if (!args.view) {\n return;\n }\n let ngView: EmbeddedViewRef<any> = args.view[NG_VIEW];\n\n // Getting angular view from original element (in cases when ProxyViewContainer\n // is used NativeScript internally wraps it in a StackLayout)\n if (!ngView && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {\n ngView = args.view.getChildAt(0)[NG_VIEW];\n }\n\n if (ngView) {\n ngView.detach();\n this.storeViewRef(ngView);\n }\n }\n\n public setupViewRef(view: EmbeddedViewRef<ItemContext>, data: any, index: number): void {\n const context = view.context;\n context.$implicit = data;\n context.item = data;\n context.index = index;\n context.even = index % 2 === 0;\n context.odd = !context.even;\n\n this.setupItemView.next({\n context,\n data,\n index,\n view\n });\n }\n\n protected getItemTemplateViewFactory(template: TemplateRef<ItemContext>): () => View {\n return () => {\n const viewRef = this.loader.createEmbeddedView(template, new ItemContext(), 0);\n const resultView = getItemViewRoot(viewRef);\n resultView[NG_VIEW] = viewRef;\n\n return resultView;\n };\n }\n viewPool = new Map<\n TemplateRef<ItemContext>,\n {\n scrapSize: number;\n scrapHead: Set<EmbeddedViewRef<ItemContext>>;\n }\n >();\n private storeViewRef(viewRef: EmbeddedViewRef<any>) {\n const templateRef = this.viewToTemplate.get(viewRef);\n if (templateRef) {\n const scrap = this.viewPool.get(templateRef);\n if (scrap) {\n if (scrap.scrapHead.size >= scrap.scrapSize) {\n viewRef.destroy();\n this.viewToLoader.get(viewRef)?.destroy();\n } else {\n scrap.scrapHead.add(viewRef);\n }\n }\n }\n }\n viewToTemplate = new WeakMap<EmbeddedViewRef<any>, TemplateRef<any>>();\n viewToLoader = new WeakMap<EmbeddedViewRef<any>, ComponentRef<DetachedLoader>>();\n\n private getOrCreate(templateRef: TemplateRef<ItemContext>) {\n return this._ngZone.run(() => {\n let viewRef = this.getView(templateRef);\n if (!viewRef) {\n const loader = this.detachedLoaderFactory();\n // viewRef = this.loader.createEmbeddedView(templateRef, new ItemContext(), 0);\n viewRef = loader.instance.vc.createEmbeddedView(templateRef, new ItemContext(), 0);\n this.viewToLoader.set(viewRef, loader);\n this.viewToTemplate.set(viewRef, templateRef);\n }\n viewRef.detach();\n const resultView = getItemViewRoot(viewRef);\n resultView[NG_VIEW] = viewRef;\n resultView.reusable = this.autoReuseViews;\n return resultView;\n });\n }\n private getView(templateRef: TemplateRef<ItemContext>) {\n const pool = this.getViewPool(templateRef);\n while (pool.scrapHead.size > 0) {\n const viewRef: EmbeddedViewRef<ItemContext> = pool.scrapHead.values().next().value;\n pool.scrapHead.delete(viewRef);\n if (!viewRef.destroyed) {\n return viewRef;\n }\n }\n return null;\n }\n\n private getViewPool(templateRef: TemplateRef<ItemContext>) {\n if (!this.viewPool.has(templateRef)) {\n this.viewPool.set(templateRef, {\n scrapSize: this.autoReuseViews ? Infinity : 0,\n scrapHead: new Set<EmbeddedViewRef<ItemContext>>()\n });\n }\n return this.viewPool.get(templateRef);\n }\n\n private setItemTemplates() {\n // The itemTemplateQuery may be changed after list items are added that contain <template> inside,\n // so cache and use only the original template to avoid errors.\n this.itemTemplate = this.itemTemplateQuery;\n\n if (this._templateMap) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'Setting templates');\n }\n\n const templates: KeyedTemplate[] = [];\n this._templateMap.forEach((value) => {\n templates.push(value);\n });\n this._collectionView.itemTemplates = templates;\n } else {\n // If the map was not initialized this means that there are no named templates, so we register the default one.\n this._collectionView.itemTemplate = this.getItemTemplateViewFactory(this.itemTemplate);\n }\n }\n\n private detectChangesOnChild(viewRef: EmbeddedViewRef<ItemContext>, index: number) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'Manually detect changes in child: ' + index);\n }\n viewRef.markForCheck();\n viewRef.detectChanges();\n }\n\n private refresh() {\n if (this._collectionView) {\n this._collectionView.refresh();\n }\n }\n}\n\nexport interface ComponentView {\n rootNodes: any[];\n destroy(): void;\n}\n\nexport type RootLocator = (nodes: any[], nestLevel: number) => View;\n\nexport function getItemViewRoot(viewRef: ComponentView, rootLocator: RootLocator = extractSingleViewRecursive): View {\n const rootView = rootLocator(viewRef.rootNodes, 0);\n return rootView;\n}\n\n@Directive({ selector: '[cvTemplateKey]' })\nexport class TemplateKeyDirective {\n constructor(private templateRef: TemplateRef<any>, @Host() private collectionView: CollectionViewComponent) {}\n\n @Input()\n set cvTemplateKey(value: any) {\n if (Trace.isEnabled()) {\n CLog(CLogTypes.info, 'cvTemplateKey: ' + value);\n }\n if (this.collectionView && this.templateRef) {\n this.collectionView.registerTemplate(value.toLowerCase(), this.templateRef);\n }\n }\n}\n","// External\nimport { NO_ERRORS_SCHEMA, NgModule } from '@angular/core';\n\nimport { CollectionViewComponent, TemplateKeyDirective } from './collectionview-comp';\nexport { CollectionViewComponent, TemplateKeyDirective } from './collectionview-comp';\n\n@NgModule({\n declarations: [CollectionViewComponent, TemplateKeyDirective],\n exports: [CollectionViewComponent, TemplateKeyDirective],\n schemas: [NO_ERRORS_SCHEMA]\n})\nexport class CollectionViewModule {}\n"],"names":["isListLikeIterable"],"mappings":";;;;;;;;AA6BA,eAAe,CAAC,gBAAgB,EAAE,MAAM,cAAc,CAAC,CAAC;AAExD,MAAM,OAAO,GAAG,YAAY,CAAC;MAEhB,WAAW,CAAA;IACpB,WAAmB,CAAA,SAAe,EAAS,IAAU,EAAS,KAAc,EAAS,IAAc,EAAS,GAAa,EAAA;AAAtG,QAAA,IAAS,CAAA,SAAA,GAAT,SAAS,CAAM;AAAS,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAM;AAAS,QAAA,IAAK,CAAA,KAAA,GAAL,KAAK,CAAS;AAAS,QAAA,IAAI,CAAA,IAAA,GAAJ,I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oBAAoB,6DACsD,uBAAuB,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA;yDADjG,oBAAoB,EAAA,SAAA,EAAA,CAAA,CAAA,EAAA,EAAA,eAAA,EAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,EAAA,aAAA,EAAA,eAAA,EAAA,EAAA,CAAA,CAAA;;4EAApB,oBAAoB,EAAA,CAAA;kBADhC,SAAS;mBAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAA;;kDAE6C,uBAAuB,EAAA,UAAA,EAAA,CAAA;8BAAtD,IAAI;;SAGpD,aAAa,EAAA,CAAA;sBADhB,KAAK;;;;MClZG,oBAAoB,CAAA;;wFAApB,oBAAoB,GAAA,CAAA,EAAA,CAAA;wDAApB,oBAAoB,EAAA,CAAA,CAAA;;;4EAApB,oBAAoB,EAAA,CAAA;kBALhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,YAAY,EAAE,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;AAC7D,oBAAA,OAAO,EAAE,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;oBACxD,OAAO,EAAE,CAAC,gBAAgB,CAAC;iBAC9B,CAAA;;;AACY,CAAA,cAAA,CAAA,OAAA,SAAA,KAAA,WAAA,IAAA,SAAA,KAAA,EAAA,CAAA,kBAAA,CAAA,oBAAoB,mBAJd,uBAAuB,EAAE,oBAAoB,CAClD,EAAA,OAAA,EAAA,CAAA,uBAAuB,EAAE,oBAAoB,CAAA,EAAA,CAAA,CAAA,EAAA,GAAA;;;;"}
@@ -1,7 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, ɵisListLikeIterable, ElementRef, IterableDiffers, TemplateRef, ViewContainerRef, Component, ChangeDetectionStrategy, Inject, ViewChild, Output, ContentChild, Input, Directive, Host, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2
+ import { EventEmitter, ɵisListLikeIterable, ElementRef, IterableDiffers, NgZone, TemplateRef, ViewContainerRef, Component, ChangeDetectionStrategy, Inject, ViewChild, Output, ContentChild, Input, HostListener, Directive, Host, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
3
3
  import { CollectionView, ListViewViewTypes, CLog, CLogTypes } from '@nativescript-community/ui-collectionview';
4
- import { registerElement, extractSingleViewRecursive } from '@nativescript/angular';
4
+ import * as i1 from '@nativescript/angular';
5
+ import { registerElement, DetachedLoader, NativeScriptRendererFactory, extractSingleViewRecursive } from '@nativescript/angular';
5
6
  import { ObservableArray, Trace, LayoutBase } from '@nativescript/core';
6
7
 
7
8
  const _c0 = ["loader"];
@@ -17,25 +18,31 @@ class ItemContext {
17
18
  }
18
19
  }
19
20
  class CollectionViewComponent {
20
- constructor(_elementRef, _iterableDiffers) {
21
+ constructor(_elementRef, _iterableDiffers, _renderer, _ngZone) {
22
+ this._elementRef = _elementRef;
21
23
  this._iterableDiffers = _iterableDiffers;
24
+ this._renderer = _renderer;
25
+ this._ngZone = _ngZone;
22
26
  this.setupItemView = new EventEmitter();
23
- this.itemViewLoader = (viewType) => {
27
+ this.autoReuseViews = false;
28
+ this.itemViewLoader = (viewType) => this._ngZone.run(() => {
24
29
  switch (viewType) {
25
30
  case ListViewViewTypes.ItemView:
26
31
  if (this._itemTemplate && this.loader) {
27
- const nativeItem = this.loader.createEmbeddedView(this._itemTemplate, new ItemContext(), 0);
28
- const typedView = getItemViewRoot(nativeItem);
29
- typedView[NG_VIEW] = nativeItem;
32
+ const typedView = this.getOrCreate(this._itemTemplate);
30
33
  return typedView;
31
34
  }
32
35
  break;
33
36
  }
34
37
  return null;
35
- };
38
+ });
39
+ this.viewPool = new Map();
40
+ this.viewToTemplate = new WeakMap();
41
+ this.viewToLoader = new WeakMap();
36
42
  this._collectionView = _elementRef.nativeElement;
37
43
  this._collectionView.on(CollectionView.itemLoadingEvent, this.onItemLoading, this);
38
44
  this._collectionView.itemViewLoader = this.itemViewLoader;
45
+ this._loaders = [];
39
46
  }
40
47
  get nativeElement() {
41
48
  return this._collectionView;
@@ -43,6 +50,14 @@ class CollectionViewComponent {
43
50
  get listView() {
44
51
  return this._collectionView;
45
52
  }
53
+ detachedLoaderFactory() {
54
+ const ref = this.loader.createComponent(DetachedLoader, {
55
+ index: 0
56
+ });
57
+ this.loader.detach(0);
58
+ this._loaders.push(ref);
59
+ return ref;
60
+ }
46
61
  get itemTemplate() {
47
62
  return this._itemTemplate;
48
63
  }
@@ -72,6 +87,19 @@ class CollectionViewComponent {
72
87
  }
73
88
  ngOnDestroy() {
74
89
  this._collectionView.off(CollectionView.itemLoadingEvent, this.onItemLoading, this);
90
+ this._collectionView = null;
91
+ this._loaders.forEach((l) => l.destroy());
92
+ this._loaders = null;
93
+ this.viewToLoader = null;
94
+ this.viewToTemplate = null;
95
+ this.viewPool = null;
96
+ this._items = null;
97
+ this._differ = null;
98
+ this._itemTemplate = null;
99
+ if (this._templateMap) {
100
+ this._templateMap.clear();
101
+ }
102
+ this._templateMap = null;
75
103
  }
76
104
  ngDoCheck() {
77
105
  if (Trace.isEnabled()) {
@@ -136,6 +164,31 @@ class CollectionViewComponent {
136
164
  this.setupViewRef(viewRef, currentItem, index);
137
165
  this.detectChangesOnChild(viewRef, index);
138
166
  }
167
+ onItemRecyclingInternal(args) {
168
+ if (!args.view) {
169
+ return;
170
+ }
171
+ let ngView = args.view[NG_VIEW];
172
+ if (!ngView && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {
173
+ ngView = args.view.getChildAt(0)[NG_VIEW];
174
+ }
175
+ if (ngView) {
176
+ ngView.detach();
177
+ }
178
+ }
179
+ onItemDisposingInternal(args) {
180
+ if (!args.view) {
181
+ return;
182
+ }
183
+ let ngView = args.view[NG_VIEW];
184
+ if (!ngView && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {
185
+ ngView = args.view.getChildAt(0)[NG_VIEW];
186
+ }
187
+ if (ngView) {
188
+ ngView.detach();
189
+ this.storeViewRef(ngView);
190
+ }
191
+ }
139
192
  setupViewRef(view, data, index) {
140
193
  const context = view.context;
141
194
  context.$implicit = data;
@@ -158,6 +211,57 @@ class CollectionViewComponent {
158
211
  return resultView;
159
212
  };
160
213
  }
214
+ storeViewRef(viewRef) {
215
+ const templateRef = this.viewToTemplate.get(viewRef);
216
+ if (templateRef) {
217
+ const scrap = this.viewPool.get(templateRef);
218
+ if (scrap) {
219
+ if (scrap.scrapHead.size >= scrap.scrapSize) {
220
+ viewRef.destroy();
221
+ this.viewToLoader.get(viewRef)?.destroy();
222
+ }
223
+ else {
224
+ scrap.scrapHead.add(viewRef);
225
+ }
226
+ }
227
+ }
228
+ }
229
+ getOrCreate(templateRef) {
230
+ return this._ngZone.run(() => {
231
+ let viewRef = this.getView(templateRef);
232
+ if (!viewRef) {
233
+ const loader = this.detachedLoaderFactory();
234
+ viewRef = loader.instance.vc.createEmbeddedView(templateRef, new ItemContext(), 0);
235
+ this.viewToLoader.set(viewRef, loader);
236
+ this.viewToTemplate.set(viewRef, templateRef);
237
+ }
238
+ viewRef.detach();
239
+ const resultView = getItemViewRoot(viewRef);
240
+ resultView[NG_VIEW] = viewRef;
241
+ resultView.reusable = this.autoReuseViews;
242
+ return resultView;
243
+ });
244
+ }
245
+ getView(templateRef) {
246
+ const pool = this.getViewPool(templateRef);
247
+ while (pool.scrapHead.size > 0) {
248
+ const viewRef = pool.scrapHead.values().next().value;
249
+ pool.scrapHead.delete(viewRef);
250
+ if (!viewRef.destroyed) {
251
+ return viewRef;
252
+ }
253
+ }
254
+ return null;
255
+ }
256
+ getViewPool(templateRef) {
257
+ if (!this.viewPool.has(templateRef)) {
258
+ this.viewPool.set(templateRef, {
259
+ scrapSize: this.autoReuseViews ? Infinity : 0,
260
+ scrapHead: new Set()
261
+ });
262
+ }
263
+ return this.viewPool.get(templateRef);
264
+ }
161
265
  setItemTemplates() {
162
266
  this.itemTemplate = this.itemTemplateQuery;
163
267
  if (this._templateMap) {
@@ -187,7 +291,7 @@ class CollectionViewComponent {
187
291
  }
188
292
  }
189
293
  }
190
- CollectionViewComponent.ɵfac = function CollectionViewComponent_Factory(t) { return new (t || CollectionViewComponent)(i0.ɵɵdirectiveInject(ElementRef), i0.ɵɵdirectiveInject(IterableDiffers)); };
294
+ CollectionViewComponent.ɵfac = function CollectionViewComponent_Factory(t) { return new (t || CollectionViewComponent)(i0.ɵɵdirectiveInject(ElementRef), i0.ɵɵdirectiveInject(IterableDiffers), i0.ɵɵdirectiveInject(NativeScriptRendererFactory), i0.ɵɵdirectiveInject(NgZone)); };
191
295
  CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewComponent, selectors: [["CollectionView"]], contentQueries: function CollectionViewComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
192
296
  i0.ɵɵcontentQuery(dirIndex, TemplateRef, 7, TemplateRef);
193
297
  } if (rf & 2) {
@@ -198,7 +302,9 @@ CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewCom
198
302
  } if (rf & 2) {
199
303
  let _t;
200
304
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.loader = _t.first);
201
- } }, inputs: { itemTemplate: "itemTemplate", items: "items" }, outputs: { setupItemView: "setupItemView" }, decls: 3, vars: 0, consts: [["loader", ""]], template: function CollectionViewComponent_Template(rf, ctx) { if (rf & 1) {
305
+ } }, hostBindings: function CollectionViewComponent_HostBindings(rf, ctx) { if (rf & 1) {
306
+ i0.ɵɵlistener("itemLoading", function CollectionViewComponent_itemLoading_HostBindingHandler($event) { return ctx.onItemLoading($event); })("itemRecycling", function CollectionViewComponent_itemRecycling_HostBindingHandler($event) { return ctx.onItemRecyclingInternal($event); })("itemDisposing", function CollectionViewComponent_itemDisposing_HostBindingHandler($event) { return ctx.onItemDisposingInternal($event); });
307
+ } }, inputs: { autoReuseViews: "autoReuseViews", itemTemplate: "itemTemplate", items: "items" }, outputs: { setupItemView: "setupItemView" }, decls: 3, vars: 0, consts: [["loader", ""]], template: function CollectionViewComponent_Template(rf, ctx) { if (rf & 1) {
202
308
  i0.ɵɵelementStart(0, "DetachedContainer");
203
309
  i0.ɵɵelement(1, "Placeholder", null, 0);
204
310
  i0.ɵɵelementEnd();
@@ -220,6 +326,12 @@ CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewCom
220
326
  }] }, { type: i0.IterableDiffers, decorators: [{
221
327
  type: Inject,
222
328
  args: [IterableDiffers]
329
+ }] }, { type: i1.NativeScriptRendererFactory, decorators: [{
330
+ type: Inject,
331
+ args: [NativeScriptRendererFactory]
332
+ }] }, { type: i0.NgZone, decorators: [{
333
+ type: Inject,
334
+ args: [NgZone]
223
335
  }] }]; }, { loader: [{
224
336
  type: ViewChild,
225
337
  args: ['loader', { read: ViewContainerRef, static: true }]
@@ -228,10 +340,21 @@ CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewCom
228
340
  }], itemTemplateQuery: [{
229
341
  type: ContentChild,
230
342
  args: [TemplateRef, { read: TemplateRef, static: true }]
343
+ }], autoReuseViews: [{
344
+ type: Input
231
345
  }], itemTemplate: [{
232
346
  type: Input
233
347
  }], items: [{
234
348
  type: Input
349
+ }], onItemLoading: [{
350
+ type: HostListener,
351
+ args: ['itemLoading', ['$event']]
352
+ }], onItemRecyclingInternal: [{
353
+ type: HostListener,
354
+ args: ['itemRecycling', ['$event']]
355
+ }], onItemDisposingInternal: [{
356
+ type: HostListener,
357
+ args: ['itemDisposing', ['$event']]
235
358
  }] }); })();
236
359
  function getItemViewRoot(viewRef, rootLocator = extractSingleViewRecursive) {
237
360
  const rootView = rootLocator(viewRef.rootNodes, 0);