@nativescript-community/ui-collectionview 4.0.46 → 4.0.49

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +188 -95
  3. package/angular/collectionview-comp.d.ts +5 -5
  4. package/angular/esm2020/collectionview-comp.mjs +263 -0
  5. package/angular/{esm2015/index.js → esm2020/index.mjs} +3 -3
  6. package/angular/{esm2015/nativescript-community-ui-collectionview-angular.js → esm2020/nativescript-community-ui-collectionview-angular.mjs} +0 -0
  7. package/angular/fesm2015/nativescript-community-ui-collectionview-angular.mjs +299 -0
  8. package/angular/fesm2015/nativescript-community-ui-collectionview-angular.mjs.map +1 -0
  9. package/angular/{fesm2015/nativescript-community-ui-collectionview-angular.js → fesm2020/nativescript-community-ui-collectionview-angular.mjs} +32 -35
  10. package/angular/fesm2020/nativescript-community-ui-collectionview-angular.mjs.map +1 -0
  11. package/angular/index.d.ts +3 -3
  12. package/angular/package.json +21 -7
  13. package/{collectionview-common.d.ts → index-common.d.ts} +3 -2
  14. package/{collectionview-common.js → index-common.js} +11 -5
  15. package/index-common.js.map +1 -0
  16. package/{collectionview.android.d.ts → index.android.d.ts} +8 -11
  17. package/{collectionview.android.js → index.android.js} +57 -42
  18. package/index.android.js.map +1 -0
  19. package/{collectionview.d.ts → index.d.ts} +2 -2
  20. package/{collectionview.ios.d.ts → index.ios.d.ts} +2 -3
  21. package/{collectionview.ios.js → index.ios.js} +6 -12
  22. package/{collectionview.ios.js.map → index.ios.js.map} +1 -1
  23. package/package.json +7 -7
  24. package/platforms/android/AndroidManifest.xml +0 -0
  25. package/platforms/android/include.gradle +0 -0
  26. package/platforms/android/java/com/nativescript/collectionview/Adapter.java +0 -0
  27. package/platforms/android/java/com/nativescript/collectionview/AdapterInterface.java +0 -0
  28. package/platforms/android/java/com/nativescript/collectionview/CollectionViewCellHolder.java +0 -0
  29. package/platforms/android/java/com/nativescript/collectionview/GridLayoutManager.java +0 -0
  30. package/platforms/android/java/com/nativescript/collectionview/OnScrollListener.java +0 -0
  31. package/platforms/android/java/com/nativescript/collectionview/PreCachingGridLayoutManager.java +0 -0
  32. package/platforms/android/java/com/nativescript/collectionview/RecyclerView.java +10 -7
  33. package/platforms/android/java/com/nativescript/collectionview/SizeChangedListener.java +1 -0
  34. package/platforms/android/java/com/nativescript/collectionview/SpanSizeLookup.java +0 -0
  35. package/platforms/android/res/layout/collectionview.xml +0 -0
  36. package/react/index.d.ts +8 -8
  37. package/react/index.js +4 -2
  38. package/react/index.js.map +1 -1
  39. package/references.d.ts +1 -0
  40. package/svelte/index.d.ts +1 -1
  41. package/svelte/index.js +4 -3
  42. package/svelte/index.js.map +1 -1
  43. package/typings/android.d.ts +66 -0
  44. package/typings/arv.d.ts +1 -65
  45. package/vue/component.d.ts +0 -0
  46. package/vue/component.js +2 -7
  47. package/vue/component.js.map +1 -1
  48. package/vue/index.d.ts +0 -0
  49. package/vue/index.js +1 -1
  50. package/vue/index.js.map +1 -1
  51. package/LICENSE +0 -201
  52. package/angular/bundles/nativescript-community-ui-collectionview-angular.umd.js +0 -334
  53. package/angular/bundles/nativescript-community-ui-collectionview-angular.umd.js.map +0 -1
  54. package/angular/bundles/nativescript-community-ui-collectionview-angular.umd.min.js +0 -2
  55. package/angular/bundles/nativescript-community-ui-collectionview-angular.umd.min.js.map +0 -1
  56. package/angular/esm2015/collectionview-comp.js +0 -267
  57. package/angular/fesm2015/nativescript-community-ui-collectionview-angular.js.map +0 -1
  58. package/collectionview-common.js.map +0 -1
  59. package/collectionview.android.js.map +0 -1
@@ -1,334 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@nativescript/core'), require('@nativescript-community/ui-collectionview'), require('@nativescript/angular')) :
3
- typeof define === 'function' && define.amd ? define('@nativescript-community/ui-collectionview-angular', ['exports', '@angular/core', '@nativescript/core', '@nativescript-community/ui-collectionview', '@nativescript/angular'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['nativescript-community'] = global['nativescript-community'] || {}, global['nativescript-community']['ui-collectionview-angular'] = {}), global.ng.core, global['ns-core'], global['ns-ui-collectionview'], global['ns-angular']));
5
- }(this, (function (exports, i0, core, uiCollectionview, angular) { 'use strict';
6
-
7
- var _c0 = ["loader"];
8
- angular.registerElement('CollectionView', function () { return uiCollectionview.CollectionView; });
9
- var NG_VIEW = '_ngViewRef';
10
- var ItemContext = /** @class */ (function () {
11
- function ItemContext($implicit, item, index, even, odd) {
12
- this.$implicit = $implicit;
13
- this.item = item;
14
- this.index = index;
15
- this.even = even;
16
- this.odd = odd;
17
- }
18
- return ItemContext;
19
- }());
20
- var CollectionViewComponent = /** @class */ (function () {
21
- function CollectionViewComponent(_elementRef, _iterableDiffers) {
22
- var _this = this;
23
- this._iterableDiffers = _iterableDiffers;
24
- this.setupItemView = new i0.EventEmitter();
25
- this.itemViewLoader = function (viewType) {
26
- switch (viewType) {
27
- case uiCollectionview.ListViewViewTypes.ItemView:
28
- if (_this._itemTemplate && _this.loader) {
29
- var nativeItem = _this.loader.createEmbeddedView(_this._itemTemplate, new ItemContext(), 0);
30
- var typedView = getItemViewRoot(nativeItem);
31
- typedView[NG_VIEW] = nativeItem;
32
- return typedView;
33
- }
34
- break;
35
- }
36
- return null;
37
- };
38
- this._collectionView = _elementRef.nativeElement;
39
- this._collectionView.on(uiCollectionview.CollectionView.itemLoadingEvent, this.onItemLoading, this);
40
- this._collectionView.itemViewLoader = this.itemViewLoader;
41
- }
42
- Object.defineProperty(CollectionViewComponent.prototype, "nativeElement", {
43
- get: function () {
44
- return this._collectionView;
45
- },
46
- enumerable: false,
47
- configurable: true
48
- });
49
- Object.defineProperty(CollectionViewComponent.prototype, "listView", {
50
- get: function () {
51
- return this._collectionView;
52
- },
53
- enumerable: false,
54
- configurable: true
55
- });
56
- Object.defineProperty(CollectionViewComponent.prototype, "itemTemplate", {
57
- get: function () {
58
- return this._itemTemplate;
59
- },
60
- set: function (value) {
61
- this._itemTemplate = value;
62
- this._collectionView.refresh();
63
- },
64
- enumerable: false,
65
- configurable: true
66
- });
67
- Object.defineProperty(CollectionViewComponent.prototype, "items", {
68
- get: function () {
69
- return this._items;
70
- },
71
- set: function (value) {
72
- this._items = value;
73
- var needDiffer = true;
74
- if (value instanceof core.ObservableArray) {
75
- needDiffer = false;
76
- }
77
- if (needDiffer && !this._differ && i0.ɵisListLikeIterable(value)) {
78
- this._differ = this._iterableDiffers.find(this._items).create(function (_index, item) { return item; });
79
- }
80
- this._collectionView.items = this._items;
81
- },
82
- enumerable: false,
83
- configurable: true
84
- });
85
- CollectionViewComponent.prototype.ngAfterContentInit = function () {
86
- if (core.Trace.isEnabled()) {
87
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, 'CollectionView.ngAfterContentInit()');
88
- }
89
- this.setItemTemplates();
90
- };
91
- CollectionViewComponent.prototype.ngOnDestroy = function () {
92
- this._collectionView.off(uiCollectionview.CollectionView.itemLoadingEvent, this.onItemLoading, this);
93
- };
94
- CollectionViewComponent.prototype.ngDoCheck = function () {
95
- if (core.Trace.isEnabled()) {
96
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, 'ngDoCheck() - execute differ? ' + this._differ);
97
- }
98
- if (this._differ) {
99
- if (core.Trace.isEnabled()) {
100
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, 'ngDoCheck() - execute differ');
101
- }
102
- var changes = this._differ.diff(this._items);
103
- if (changes) {
104
- if (core.Trace.isEnabled()) {
105
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, 'ngDoCheck() - refresh');
106
- }
107
- this.refresh();
108
- }
109
- }
110
- };
111
- CollectionViewComponent.prototype.registerTemplate = function (key, template) {
112
- if (core.Trace.isEnabled()) {
113
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, 'registerTemplate for key: ' + key);
114
- }
115
- if (!this._templateMap) {
116
- this._templateMap = new Map();
117
- }
118
- var keyedTemplate = {
119
- key: key,
120
- createView: this.getItemTemplateViewFactory(template),
121
- };
122
- this._templateMap.set(key, keyedTemplate);
123
- };
124
- CollectionViewComponent.prototype.onItemLoading = function (args) {
125
- if (!args.view && !this.itemTemplate) {
126
- return;
127
- }
128
- if (!this.items)
129
- return;
130
- var index = args.index;
131
- var items = args.object.items;
132
- var currentItem = typeof items.getItem === 'function'
133
- ? items.getItem(index)
134
- : items[index];
135
- var viewRef;
136
- if (core.Trace.isEnabled()) {
137
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, "onItemLoading: " + index + " - Reusing existing view");
138
- }
139
- viewRef = args.view[NG_VIEW];
140
- if (!viewRef &&
141
- args.view instanceof core.LayoutBase &&
142
- args.view.getChildrenCount() > 0) {
143
- viewRef = args.view.getChildAt(0)[NG_VIEW];
144
- }
145
- if (!viewRef && core.Trace.isEnabled()) {
146
- if (core.Trace.isEnabled()) {
147
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, "ViewReference not found for item " + index + ". View recycling is not working");
148
- }
149
- }
150
- if (!viewRef) {
151
- if (core.Trace.isEnabled()) {
152
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, "onItemLoading: " + index + " - Creating view from template");
153
- }
154
- viewRef = this.loader.createEmbeddedView(this.itemTemplate, new ItemContext(), 0);
155
- args.view = getItemViewRoot(viewRef);
156
- args.view[NG_VIEW] = viewRef;
157
- }
158
- this.setupViewRef(viewRef, currentItem, index);
159
- this.detectChangesOnChild(viewRef, index);
160
- };
161
- CollectionViewComponent.prototype.setupViewRef = function (view, data, index) {
162
- var context = view.context;
163
- context.$implicit = data;
164
- context.item = data;
165
- context.index = index;
166
- context.even = index % 2 === 0;
167
- context.odd = !context.even;
168
- this.setupItemView.next({
169
- context: context,
170
- data: data,
171
- index: index,
172
- view: view,
173
- });
174
- };
175
- CollectionViewComponent.prototype.getItemTemplateViewFactory = function (template) {
176
- var _this = this;
177
- return function () {
178
- var viewRef = _this.loader.createEmbeddedView(template, new ItemContext(), 0);
179
- var resultView = getItemViewRoot(viewRef);
180
- resultView[NG_VIEW] = viewRef;
181
- return resultView;
182
- };
183
- };
184
- CollectionViewComponent.prototype.setItemTemplates = function () {
185
- this.itemTemplate = this.itemTemplateQuery;
186
- if (this._templateMap) {
187
- if (core.Trace.isEnabled()) {
188
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, 'Setting templates');
189
- }
190
- var templates_1 = [];
191
- this._templateMap.forEach(function (value) {
192
- templates_1.push(value);
193
- });
194
- this._collectionView.itemTemplates = templates_1;
195
- }
196
- else {
197
- this._collectionView.itemTemplate = this.getItemTemplateViewFactory(this.itemTemplate);
198
- }
199
- };
200
- CollectionViewComponent.prototype.detectChangesOnChild = function (viewRef, index) {
201
- if (core.Trace.isEnabled()) {
202
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, 'Manually detect changes in child: ' + index);
203
- }
204
- viewRef.markForCheck();
205
- viewRef.detectChanges();
206
- };
207
- CollectionViewComponent.prototype.refresh = function () {
208
- if (this._collectionView) {
209
- this._collectionView.refresh();
210
- }
211
- };
212
- return CollectionViewComponent;
213
- }());
214
- CollectionViewComponent.ɵfac = function CollectionViewComponent_Factory(t) { return new (t || CollectionViewComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.IterableDiffers)); };
215
- CollectionViewComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CollectionViewComponent, selectors: [["CollectionView"]], contentQueries: function CollectionViewComponent_ContentQueries(rf, ctx, dirIndex) {
216
- if (rf & 1) {
217
- i0.ɵɵcontentQuery(dirIndex, i0.TemplateRef, 3, i0.TemplateRef);
218
- }
219
- if (rf & 2) {
220
- var _t = void 0;
221
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.itemTemplateQuery = _t.first);
222
- }
223
- }, viewQuery: function CollectionViewComponent_Query(rf, ctx) {
224
- if (rf & 1) {
225
- i0.ɵɵviewQuery(_c0, 3, i0.ViewContainerRef);
226
- }
227
- if (rf & 2) {
228
- var _t = void 0;
229
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.loader = _t.first);
230
- }
231
- }, inputs: { itemTemplate: "itemTemplate", items: "items" }, outputs: { setupItemView: "setupItemView" }, decls: 3, vars: 0, consts: [["loader", ""]], template: function CollectionViewComponent_Template(rf, ctx) {
232
- if (rf & 1) {
233
- i0.ɵɵelementStart(0, "DetachedContainer");
234
- i0.ɵɵelement(1, "Placeholder", null, 0);
235
- i0.ɵɵelementEnd();
236
- }
237
- }, encapsulation: 2, changeDetection: 0 });
238
- (function () {
239
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CollectionViewComponent, [{
240
- type: i0.Component,
241
- args: [{
242
- selector: 'CollectionView',
243
- template: "\n <DetachedContainer>\n <Placeholder #loader></Placeholder>\n </DetachedContainer>\n ",
244
- changeDetection: i0.ChangeDetectionStrategy.OnPush,
245
- }]
246
- }], function () {
247
- return [{ type: i0.ElementRef, decorators: [{
248
- type: i0.Inject,
249
- args: [i0.ElementRef]
250
- }] }, { type: i0.IterableDiffers, decorators: [{
251
- type: i0.Inject,
252
- args: [i0.IterableDiffers]
253
- }] }];
254
- }, { loader: [{
255
- type: i0.ViewChild,
256
- args: ['loader', { read: i0.ViewContainerRef, static: true }]
257
- }], setupItemView: [{
258
- type: i0.Output
259
- }], itemTemplateQuery: [{
260
- type: i0.ContentChild,
261
- args: [i0.TemplateRef, { read: i0.TemplateRef, static: true }]
262
- }], itemTemplate: [{
263
- type: i0.Input
264
- }], items: [{
265
- type: i0.Input
266
- }] });
267
- })();
268
- function getItemViewRoot(viewRef, rootLocator) {
269
- if (rootLocator === void 0) { rootLocator = angular.getSingleViewRecursive; }
270
- var rootView = rootLocator(viewRef.rootNodes, 0);
271
- return rootView;
272
- }
273
- var TemplateKeyDirective = /** @class */ (function () {
274
- function TemplateKeyDirective(templateRef, collectionView) {
275
- this.templateRef = templateRef;
276
- this.collectionView = collectionView;
277
- }
278
- Object.defineProperty(TemplateKeyDirective.prototype, "cvTemplateKey", {
279
- set: function (value) {
280
- if (core.Trace.isEnabled()) {
281
- uiCollectionview.CLog(uiCollectionview.CLogTypes.info, 'cvTemplateKey: ' + value);
282
- }
283
- if (this.collectionView && this.templateRef) {
284
- this.collectionView.registerTemplate(value.toLowerCase(), this.templateRef);
285
- }
286
- },
287
- enumerable: false,
288
- configurable: true
289
- });
290
- return TemplateKeyDirective;
291
- }());
292
- TemplateKeyDirective.ɵfac = function TemplateKeyDirective_Factory(t) { return new (t || TemplateKeyDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(CollectionViewComponent, 1)); };
293
- TemplateKeyDirective.ɵdir = i0.ɵɵdefineDirective({ type: TemplateKeyDirective, selectors: [["", "cvTemplateKey", ""]], inputs: { cvTemplateKey: "cvTemplateKey" } });
294
- (function () {
295
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TemplateKeyDirective, [{
296
- type: i0.Directive,
297
- args: [{ selector: '[cvTemplateKey]' }]
298
- }], function () {
299
- return [{ type: i0.TemplateRef }, { type: CollectionViewComponent, decorators: [{
300
- type: i0.Host
301
- }] }];
302
- }, { cvTemplateKey: [{
303
- type: i0.Input
304
- }] });
305
- })();
306
-
307
- var CollectionViewModule = /** @class */ (function () {
308
- function CollectionViewModule() {
309
- }
310
- return CollectionViewModule;
311
- }());
312
- CollectionViewModule.ɵfac = function CollectionViewModule_Factory(t) { return new (t || CollectionViewModule)(); };
313
- CollectionViewModule.ɵmod = i0.ɵɵdefineNgModule({ type: CollectionViewModule });
314
- CollectionViewModule.ɵinj = i0.ɵɵdefineInjector({});
315
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CollectionViewModule, { declarations: [CollectionViewComponent, TemplateKeyDirective], exports: [CollectionViewComponent, TemplateKeyDirective] }); })();
316
- (function () {
317
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CollectionViewModule, [{
318
- type: i0.NgModule,
319
- args: [{
320
- declarations: [CollectionViewComponent, TemplateKeyDirective],
321
- exports: [CollectionViewComponent, TemplateKeyDirective],
322
- schemas: [i0.NO_ERRORS_SCHEMA],
323
- }]
324
- }], null, null);
325
- })();
326
-
327
- exports.CollectionViewComponent = CollectionViewComponent;
328
- exports.CollectionViewModule = CollectionViewModule;
329
- exports.TemplateKeyDirective = TemplateKeyDirective;
330
-
331
- Object.defineProperty(exports, '__esModule', { value: true });
332
-
333
- })));
334
- //# sourceMappingURL=nativescript-community-ui-collectionview-angular.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nativescript-community-ui-collectionview-angular.umd.js","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 { KeyedTemplate, LayoutBase, ObservableArray, Trace, View } from '@nativescript/core';\nimport { CLog, CLogTypes, CollectionView, CollectionViewItemEventData, ListViewViewTypes } from '@nativescript-community/ui-collectionview';\n\nimport { getSingleViewRecursive, isKnownView, registerElement } from '@nativescript/angular';\n\nregisterElement('CollectionView', () => CollectionView);\n\nconst NG_VIEW = '_ngViewRef';\n\nexport class ItemContext {\n constructor(\n public $implicit?: any,\n public item?: any,\n public index?: number,\n public even?: boolean,\n public odd?: boolean\n ) {}\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 =\n typeof items.getItem === 'function'\n ? items.getItem(index)\n : 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 (\n !viewRef &&\n args.view instanceof LayoutBase &&\n args.view.getChildrenCount() > 0\n ) {\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(\n this.itemTemplate,\n new ItemContext(),\n 0\n );\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(\n template: TemplateRef<ItemContext>\n ): () => View {\n return () => {\n const viewRef = this.loader.createEmbeddedView(\n template,\n new ItemContext(),\n 0\n );\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 = getSingleViewRecursive): 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":["registerElement","CollectionView","EventEmitter","ListViewViewTypes","ObservableArray","isListLikeIterable","Trace","CLog","CLogTypes","LayoutBase","ElementRef","IterableDiffers","TemplateRef","ViewContainerRef","i0.ɵɵelementStart","i0.ɵɵelement","i0.ɵɵelementEnd","Component","ChangeDetectionStrategy","Inject","ViewChild","Output","ContentChild","Input","Directive","Host","NgModule","NO_ERRORS_SCHEMA"],"mappings":";;;;;;;AA2BAA,2BAAe,CAAC,gBAAgB,EAAE,cAAM,OAAAC,+BAAc,GAAA,CAAC,CAAC;IAExD,IAAM,OAAO,GAAG,YAAY,CAAC;IAE7B;QACI,qBACW,SAAe,EACf,IAAU,EACV,KAAc,EACd,IAAc,EACd,GAAa;YAJb,cAAS,GAAT,SAAS,CAAM;YACf,SAAI,GAAJ,IAAI,CAAM;YACV,UAAK,GAAL,KAAK,CAAS;YACd,SAAI,GAAJ,IAAI,CAAU;YACd,QAAG,GAAH,GAAG,CAAU;SACpB;0BACP;KAAA,IAAA;;QA6DG,iCAAgC,WAAuB,EAAmC,gBAAiC;YAA3H,iBAKC;YALyF,q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ACnD,OAAO,QAAQ,CAAC;IACpB,CAAC;;QAIG,8BAAoB,WAA6B,EAAkB,cAAuC;YAAtF,gBAAW,GAAX,WAAW,CAAkB;YAAkB,mBAAc,GAAd,cAAc,CAAyB;SAAI;QAE9G,sBACI,+CAAa;iBADjB,UACkB,KAAU;gBACxB,IAAIjB,UAAK,CAAC,SAAS,EAAE,EAAE;oBACnBC,qBAAI,CAACC,0BAAS,CAAC,IAAI,EAAE,iBAAiB,GAAG,KAAK,CAAC,CAAC;iBACnD;gBACD,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,EAAE;oBACzC,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;iBAC/E;aACJ;;;WAAA;;;4FAXQ,oBAAoB,6DACsD,uBAAuB;6DADjG,oBAAoB;;gFAApB,oBAAoB;sBADhCgB,YAAS;uBAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE;;sDAE6C,uBAAuB;kCAAtDC,OAAI;;aAGpD,aAAa;0BADhBF,QAAK;;;;;QCrSV;;;;4FAAa,oBAAoB;4DAApB,oBAAoB;;4FAApB,oBAAoB,mBAJd,uBAAuB,EAAE,oBAAoB,aAClD,uBAAuB,EAAE,oBAAoB;;gFAG9C,oBAAoB;sBALhCG,WAAQ;uBAAC;wBACN,YAAY,EAAE,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;wBAC7D,OAAO,EAAE,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;wBACxD,OAAO,EAAE,CAACC,mBAAgB,CAAC;qBAC9B;;;;;;;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@nativescript/core"),require("@nativescript-community/ui-collectionview"),require("@nativescript/angular")):"function"==typeof define&&define.amd?define("@nativescript-community/ui-collectionview-angular",["exports","@angular/core","@nativescript/core","@nativescript-community/ui-collectionview","@nativescript/angular"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self)["nativescript-community"]=e["nativescript-community"]||{},e["nativescript-community"]["ui-collectionview-angular"]={}),e.ng.core,e["ns-core"],e["ns-ui-collectionview"],e["ns-angular"])}(this,(function(e,t,i,n,o){"use strict";var r=["loader"];o.registerElement("CollectionView",(function(){return n.CollectionView}));var a="_ngViewRef",s=function(e,t,i,n,o){this.$implicit=e,this.item=t,this.index=i,this.even=n,this.odd=o},c=function(){function e(e,i){var o=this;this._iterableDiffers=i,this.setupItemView=new t.EventEmitter,this.itemViewLoader=function(e){switch(e){case n.ListViewViewTypes.ItemView:if(o._itemTemplate&&o.loader){var t=o.loader.createEmbeddedView(o._itemTemplate,new s,0),i=l(t);return i[a]=t,i}}return null},this._collectionView=e.nativeElement,this._collectionView.on(n.CollectionView.itemLoadingEvent,this.onItemLoading,this),this._collectionView.itemViewLoader=this.itemViewLoader}return Object.defineProperty(e.prototype,"nativeElement",{get:function(){return this._collectionView},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"listView",{get:function(){return this._collectionView},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"itemTemplate",{get:function(){return this._itemTemplate},set:function(e){this._itemTemplate=e,this._collectionView.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this._items},set:function(e){this._items=e;var n=!0;e instanceof i.ObservableArray&&(n=!1),n&&!this._differ&&t.ɵisListLikeIterable(e)&&(this._differ=this._iterableDiffers.find(this._items).create((function(e,t){return t}))),this._collectionView.items=this._items},enumerable:!1,configurable:!0}),e.prototype.ngAfterContentInit=function(){i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"CollectionView.ngAfterContentInit()"),this.setItemTemplates()},e.prototype.ngOnDestroy=function(){this._collectionView.off(n.CollectionView.itemLoadingEvent,this.onItemLoading,this)},e.prototype.ngDoCheck=function(){(i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"ngDoCheck() - execute differ? "+this._differ),this._differ)&&(i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"ngDoCheck() - execute differ"),this._differ.diff(this._items)&&(i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"ngDoCheck() - refresh"),this.refresh()))},e.prototype.registerTemplate=function(e,t){i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"registerTemplate for key: "+e),this._templateMap||(this._templateMap=new Map);var o={key:e,createView:this.getItemTemplateViewFactory(t)};this._templateMap.set(e,o)},e.prototype.onItemLoading=function(e){if((e.view||this.itemTemplate)&&this.items){var t,o=e.index,r=e.object.items,c="function"==typeof r.getItem?r.getItem(o):r[o];i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"onItemLoading: "+o+" - Reusing existing view"),!(t=e.view[a])&&e.view instanceof i.LayoutBase&&e.view.getChildrenCount()>0&&(t=e.view.getChildAt(0)[a]),!t&&i.Trace.isEnabled()&&i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"ViewReference not found for item "+o+". View recycling is not working"),t||(i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"onItemLoading: "+o+" - Creating view from template"),t=this.loader.createEmbeddedView(this.itemTemplate,new s,0),e.view=l(t),e.view[a]=t),this.setupViewRef(t,c,o),this.detectChangesOnChild(t,o)}},e.prototype.setupViewRef=function(e,t,i){var n=e.context;n.$implicit=t,n.item=t,n.index=i,n.even=i%2==0,n.odd=!n.even,this.setupItemView.next({context:n,data:t,index:i,view:e})},e.prototype.getItemTemplateViewFactory=function(e){var t=this;return function(){var i=t.loader.createEmbeddedView(e,new s,0),n=l(i);return n[a]=i,n}},e.prototype.setItemTemplates=function(){if(this.itemTemplate=this.itemTemplateQuery,this._templateMap){i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"Setting templates");var e=[];this._templateMap.forEach((function(t){e.push(t)})),this._collectionView.itemTemplates=e}else this._collectionView.itemTemplate=this.getItemTemplateViewFactory(this.itemTemplate)},e.prototype.detectChangesOnChild=function(e,t){i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"Manually detect changes in child: "+t),e.markForCheck(),e.detectChanges()},e.prototype.refresh=function(){this._collectionView&&this._collectionView.refresh()},e}();function l(e,t){return void 0===t&&(t=o.getSingleViewRecursive),t(e.rootNodes,0)}c.ɵfac=function(e){return new(e||c)(t.ɵɵdirectiveInject(t.ElementRef),t.ɵɵdirectiveInject(t.IterableDiffers))},c.ɵcmp=t.ɵɵdefineComponent({type:c,selectors:[["CollectionView"]],contentQueries:function(e,i,n){if(1&e&&t.ɵɵcontentQuery(n,t.TemplateRef,3,t.TemplateRef),2&e){var o;t.ɵɵqueryRefresh(o=t.ɵɵloadQuery())&&(i.itemTemplateQuery=o.first)}},viewQuery:function(e,i){if(1&e&&t.ɵɵviewQuery(r,3,t.ViewContainerRef),2&e){var n;t.ɵɵqueryRefresh(n=t.ɵɵloadQuery())&&(i.loader=n.first)}},inputs:{itemTemplate:"itemTemplate",items:"items"},outputs:{setupItemView:"setupItemView"},decls:3,vars:0,consts:[["loader",""]],template:function(e,i){1&e&&(t.ɵɵelementStart(0,"DetachedContainer"),t.ɵɵelement(1,"Placeholder",null,0),t.ɵɵelementEnd())},encapsulation:2,changeDetection:0}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(c,[{type:t.Component,args:[{selector:"CollectionView",template:"\n <DetachedContainer>\n <Placeholder #loader></Placeholder>\n </DetachedContainer>\n ",changeDetection:t.ChangeDetectionStrategy.OnPush}]}],(function(){return[{type:t.ElementRef,decorators:[{type:t.Inject,args:[t.ElementRef]}]},{type:t.IterableDiffers,decorators:[{type:t.Inject,args:[t.IterableDiffers]}]}]}),{loader:[{type:t.ViewChild,args:["loader",{read:t.ViewContainerRef,static:!0}]}],setupItemView:[{type:t.Output}],itemTemplateQuery:[{type:t.ContentChild,args:[t.TemplateRef,{read:t.TemplateRef,static:!0}]}],itemTemplate:[{type:t.Input}],items:[{type:t.Input}]});var p=function(){function e(e,t){this.templateRef=e,this.collectionView=t}return Object.defineProperty(e.prototype,"cvTemplateKey",{set:function(e){i.Trace.isEnabled()&&n.CLog(n.CLogTypes.info,"cvTemplateKey: "+e),this.collectionView&&this.templateRef&&this.collectionView.registerTemplate(e.toLowerCase(),this.templateRef)},enumerable:!1,configurable:!0}),e}();p.ɵfac=function(e){return new(e||p)(t.ɵɵdirectiveInject(t.TemplateRef),t.ɵɵdirectiveInject(c,1))},p.ɵdir=t.ɵɵdefineDirective({type:p,selectors:[["","cvTemplateKey",""]],inputs:{cvTemplateKey:"cvTemplateKey"}}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(p,[{type:t.Directive,args:[{selector:"[cvTemplateKey]"}]}],(function(){return[{type:t.TemplateRef},{type:c,decorators:[{type:t.Host}]}]}),{cvTemplateKey:[{type:t.Input}]});var f=function(){};f.ɵfac=function(e){return new(e||f)},f.ɵmod=t.ɵɵdefineNgModule({type:f}),f.ɵinj=t.ɵɵdefineInjector({}),("undefined"==typeof ngJitMode||ngJitMode)&&t.ɵɵsetNgModuleScope(f,{declarations:[c,p],exports:[c,p]}),("undefined"==typeof ngDevMode||ngDevMode)&&t.ɵsetClassMetadata(f,[{type:t.NgModule,args:[{declarations:[c,p],exports:[c,p],schemas:[t.NO_ERRORS_SCHEMA]}]}],null,null),e.CollectionViewComponent=c,e.CollectionViewModule=f,e.TemplateKeyDirective=p,Object.defineProperty(e,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=nativescript-community-ui-collectionview-angular.umd.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/collectionview/angular/collectionview-comp.ts","../../../../src/collectionview/angular/index.ts"],"names":["registerElement","CollectionView","NG_VIEW","ItemContext","$implicit","item","index","even","odd","this","CollectionViewComponent","_elementRef","_iterableDiffers","_this","setupItemView","EventEmitter","itemViewLoader","viewType","ListViewViewTypes","ItemView","_itemTemplate","loader","nativeItem","createEmbeddedView","typedView","getItemViewRoot","_collectionView","nativeElement","on","itemLoadingEvent","onItemLoading","Object","defineProperty","prototype","value","refresh","_items","needDiffer","ObservableArray","_differ","isListLikeIterable","find","create","_index","items","ngAfterContentInit","Trace","isEnabled","CLog","CLogTypes","info","setItemTemplates","ngOnDestroy","off","ngDoCheck","diff","registerTemplate","key","template","_templateMap","Map","keyedTemplate","createView","getItemTemplateViewFactory","set","args","view","itemTemplate","viewRef","object","currentItem","getItem","LayoutBase","getChildrenCount","getChildAt","setupViewRef","detectChangesOnChild","data","context","next","resultView","itemTemplateQuery","templates_1","forEach","push","itemTemplates","markForCheck","detectChanges","rootLocator","angular","getSingleViewRecursive","rootNodes","i0","ɵɵdirectiveInject","ElementRef","IterableDiffers","selectors","contentQueries","rf","ctx","dirIndex","TemplateRef","ViewContainerRef","i0.ɵɵelementStart","i0.ɵɵelement","i0.ɵɵelementEnd","Component","selector","changeDetection","ChangeDetectionStrategy","OnPush","Inject","ViewChild","read","static","Output","ContentChild","Input","TemplateKeyDirective","templateRef","collectionView","toLowerCase","inputs","cvTemplateKey","Directive","decorators","Host","CollectionViewModule","declarations","exports","NgModule","schemas","NO_ERRORS_SCHEMA"],"mappings":"guBA2BAA,EAAAA,gBAAgB,kBAAkB,WAAM,OAAAC,EAAAA,kBAExC,IAAMC,EAAU,aAEhBC,EACI,SACWC,EACAC,EACAC,EACAC,EACAC,GAJAC,KAAAL,UAAAA,EACAK,KAAAJ,KAAAA,EACAI,KAAAH,MAAAA,EACAG,KAAAF,KAAAA,EACAE,KAAAD,IAAAA,gBA+DX,SAAAE,EAAgCC,EAA0DC,GAA1F,IAAAC,EAAAJ,KAA0FA,KAAAG,iBAAAA,EAlCzEH,KAAAK,cAAgB,IAAIC,EAAAA,aAyC7BN,KAAAO,eAAiB,SAACC,GACtB,OAAQA,GACJ,KAAKC,EAAAA,kBAAkBC,SACnB,GAAIN,EAAKO,eAAiBP,EAAKQ,OAAQ,CACnC,IAAMC,EAAaT,EAAKQ,OAAOE,mBAAmBV,EAAKO,cAAe,IAAIjB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EAAuB,sCADjG4G,EAAoBtB,UAAA,CAAA,CAAA,GAAA,gBAAA,KAAA0B,OAAA,CAAAC,cAAA,mFAApBL,EAAoB,CAAA,MADhCM,EAAAA,gBAAU,CAAEjB,SAAU,oEAEgEjG,EAAuBmH,WAAA,CAAA,MAAtDC,EAAAA,YAGhDH,cAAa,CAAA,MADhBN,EAAAA,gBCrSL,8CAAaU,oCAAAA,mGAAAA,EAAoB,CAAAC,aAAA,CAJdtH,EAAyB4G,GAAoBW,QAAA,CAClDvH,EAAyB4G,qEAG1BS,EAAoB,CAAA,MALhCG,EAAAA,eAAS,CACNF,aAAc,CAACtH,EAAyB4G,GACxCW,QAAS,CAACvH,EAAyB4G,GACnCa,QAAS,CAACC,EAAAA","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 { KeyedTemplate, LayoutBase, ObservableArray, Trace, View } from '@nativescript/core';\nimport { CLog, CLogTypes, CollectionView, CollectionViewItemEventData, ListViewViewTypes } from '@nativescript-community/ui-collectionview';\n\nimport { getSingleViewRecursive, isKnownView, registerElement } from '@nativescript/angular';\n\nregisterElement('CollectionView', () => CollectionView);\n\nconst NG_VIEW = '_ngViewRef';\n\nexport class ItemContext {\n constructor(\n public $implicit?: any,\n public item?: any,\n public index?: number,\n public even?: boolean,\n public odd?: boolean\n ) {}\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 =\n typeof items.getItem === 'function'\n ? items.getItem(index)\n : 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 (\n !viewRef &&\n args.view instanceof LayoutBase &&\n args.view.getChildrenCount() > 0\n ) {\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(\n this.itemTemplate,\n new ItemContext(),\n 0\n );\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(\n template: TemplateRef<ItemContext>\n ): () => View {\n return () => {\n const viewRef = this.loader.createEmbeddedView(\n template,\n new ItemContext(),\n 0\n );\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 = getSingleViewRecursive): 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"]}