@ionic/angular 7.5.4 → 7.5.5-dev.11699885110.10e38569
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.
- package/common/index.d.ts +1 -3
- package/common/utils/overlay.d.ts +1 -2
- package/esm2020/common/index.mjs +2 -4
- package/esm2020/common/utils/overlay.mjs +1 -1
- package/esm2020/index.mjs +5 -2
- package/esm2020/ionic-module.mjs +4 -2
- package/esm2020/providers/action-sheet-controller.mjs +18 -0
- package/esm2020/providers/modal-controller.mjs +24 -0
- package/esm2020/providers/popover-controller.mjs +18 -0
- package/esm2020/standalone/index.mjs +5 -2
- package/esm2020/standalone/providers/action-sheet-controller.mjs +18 -0
- package/esm2020/standalone/providers/ionic-angular.mjs +4 -2
- package/esm2020/standalone/providers/modal-controller.mjs +24 -0
- package/esm2020/standalone/providers/popover-controller.mjs +18 -0
- package/fesm2015/ionic-angular-common.mjs +194 -242
- package/fesm2015/ionic-angular-common.mjs.map +1 -1
- package/fesm2015/ionic-angular-standalone.mjs +48 -5
- package/fesm2015/ionic-angular-standalone.mjs.map +1 -1
- package/fesm2015/ionic-angular.mjs +48 -5
- package/fesm2015/ionic-angular.mjs.map +1 -1
- package/fesm2020/ionic-angular-common.mjs +196 -250
- package/fesm2020/ionic-angular-common.mjs.map +1 -1
- package/fesm2020/ionic-angular-standalone.mjs +54 -5
- package/fesm2020/ionic-angular-standalone.mjs.map +1 -1
- package/fesm2020/ionic-angular.mjs +54 -5
- package/fesm2020/ionic-angular.mjs.map +1 -1
- package/index.d.ts +4 -1
- package/package.json +2 -2
- package/providers/action-sheet-controller.d.ts +8 -0
- package/providers/modal-controller.d.ts +12 -0
- package/providers/popover-controller.d.ts +9 -0
- package/standalone/index.d.ts +4 -1
- package/{common → standalone}/providers/action-sheet-controller.d.ts +1 -1
- package/{common → standalone}/providers/modal-controller.d.ts +1 -1
- package/{common → standalone}/providers/popover-controller.d.ts +1 -4
- package/esm2020/common/providers/action-sheet-controller.mjs +0 -18
- package/esm2020/common/providers/modal-controller.mjs +0 -25
- package/esm2020/common/providers/popover-controller.mjs +0 -25
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable,
|
|
3
|
-
import {
|
|
2
|
+
import { Injectable, Inject, Optional, InjectionToken, inject, NgZone, ApplicationRef, Injector, createComponent, TemplateRef, Directive, ContentChild, EventEmitter, ViewContainerRef, EnvironmentInjector, Attribute, SkipSelf, Input, Output, reflectComponentType, HostListener, ElementRef, ViewChild } from '@angular/core';
|
|
3
|
+
import { alertController, loadingController, pickerController, toastController, createAnimation, getTimeGivenProgression, createGesture, isPlatform, getPlatforms, LIFECYCLE_WILL_ENTER, LIFECYCLE_DID_ENTER, LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_UNLOAD, componentOnReady } from '@ionic/core/components';
|
|
4
4
|
import * as i3 from '@angular/router';
|
|
5
5
|
import { NavigationStart, PRIMARY_OUTLET, ChildrenOutletContexts, ActivatedRoute, Router } from '@angular/router';
|
|
6
6
|
import * as i1 from '@angular/common';
|
|
@@ -35,20 +35,6 @@ class OverlayBaseController {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
class ActionSheetController extends OverlayBaseController {
|
|
39
|
-
constructor() {
|
|
40
|
-
super(actionSheetController);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/** @nocollapse */ ActionSheetController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ActionSheetController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
44
|
-
/** @nocollapse */ ActionSheetController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ActionSheetController, providedIn: 'root' });
|
|
45
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ActionSheetController, decorators: [{
|
|
46
|
-
type: Injectable,
|
|
47
|
-
args: [{
|
|
48
|
-
providedIn: 'root',
|
|
49
|
-
}]
|
|
50
|
-
}], ctorParameters: function () { return []; } });
|
|
51
|
-
|
|
52
38
|
class AlertController extends OverlayBaseController {
|
|
53
39
|
constructor() {
|
|
54
40
|
super(alertController);
|
|
@@ -169,219 +155,6 @@ class MenuController {
|
|
|
169
155
|
}
|
|
170
156
|
}
|
|
171
157
|
|
|
172
|
-
/**
|
|
173
|
-
* @description
|
|
174
|
-
* NavParams are an object that exists on a page and can contain data for that particular view.
|
|
175
|
-
* Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
|
|
176
|
-
* option with a simple `get` method.
|
|
177
|
-
*
|
|
178
|
-
* @usage
|
|
179
|
-
* ```ts
|
|
180
|
-
* import { NavParams } from '@ionic/angular';
|
|
181
|
-
*
|
|
182
|
-
* export class MyClass{
|
|
183
|
-
*
|
|
184
|
-
* constructor(navParams: NavParams){
|
|
185
|
-
* // userParams is an object we have in our nav-parameters
|
|
186
|
-
* navParams.get('userParams');
|
|
187
|
-
* }
|
|
188
|
-
*
|
|
189
|
-
* }
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
class NavParams {
|
|
193
|
-
constructor(data = {}) {
|
|
194
|
-
this.data = data;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Get the value of a nav-parameter for the current view
|
|
198
|
-
*
|
|
199
|
-
* ```ts
|
|
200
|
-
* import { NavParams } from 'ionic-angular';
|
|
201
|
-
*
|
|
202
|
-
* export class MyClass{
|
|
203
|
-
* constructor(public navParams: NavParams){
|
|
204
|
-
* // userParams is an object we have in our nav-parameters
|
|
205
|
-
* this.navParams.get('userParams');
|
|
206
|
-
* }
|
|
207
|
-
* }
|
|
208
|
-
* ```
|
|
209
|
-
*
|
|
210
|
-
* @param param Which param you want to look up
|
|
211
|
-
*/
|
|
212
|
-
get(param) {
|
|
213
|
-
return this.data[param];
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// TODO(FW-2827): types
|
|
218
|
-
class AngularDelegate {
|
|
219
|
-
constructor() {
|
|
220
|
-
this.zone = inject(NgZone);
|
|
221
|
-
this.applicationRef = inject(ApplicationRef);
|
|
222
|
-
}
|
|
223
|
-
create(environmentInjector, injector, elementReferenceKey) {
|
|
224
|
-
return new AngularFrameworkDelegate(environmentInjector, injector, this.applicationRef, this.zone, elementReferenceKey);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
/** @nocollapse */ AngularDelegate.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
228
|
-
/** @nocollapse */ AngularDelegate.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate });
|
|
229
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, decorators: [{
|
|
230
|
-
type: Injectable
|
|
231
|
-
}] });
|
|
232
|
-
class AngularFrameworkDelegate {
|
|
233
|
-
constructor(environmentInjector, injector, applicationRef, zone, elementReferenceKey) {
|
|
234
|
-
this.environmentInjector = environmentInjector;
|
|
235
|
-
this.injector = injector;
|
|
236
|
-
this.applicationRef = applicationRef;
|
|
237
|
-
this.zone = zone;
|
|
238
|
-
this.elementReferenceKey = elementReferenceKey;
|
|
239
|
-
this.elRefMap = new WeakMap();
|
|
240
|
-
this.elEventsMap = new WeakMap();
|
|
241
|
-
}
|
|
242
|
-
attachViewToDom(container, component, params, cssClasses) {
|
|
243
|
-
return this.zone.run(() => {
|
|
244
|
-
return new Promise((resolve) => {
|
|
245
|
-
const componentProps = {
|
|
246
|
-
...params,
|
|
247
|
-
};
|
|
248
|
-
/**
|
|
249
|
-
* Ionic Angular passes a reference to a modal
|
|
250
|
-
* or popover that can be accessed using a
|
|
251
|
-
* variable in the overlay component. If
|
|
252
|
-
* elementReferenceKey is defined, then we should
|
|
253
|
-
* pass a reference to the component using
|
|
254
|
-
* elementReferenceKey as the key.
|
|
255
|
-
*/
|
|
256
|
-
if (this.elementReferenceKey !== undefined) {
|
|
257
|
-
componentProps[this.elementReferenceKey] = container;
|
|
258
|
-
}
|
|
259
|
-
const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
|
|
260
|
-
resolve(el);
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
removeViewFromDom(_container, component) {
|
|
265
|
-
return this.zone.run(() => {
|
|
266
|
-
return new Promise((resolve) => {
|
|
267
|
-
const componentRef = this.elRefMap.get(component);
|
|
268
|
-
if (componentRef) {
|
|
269
|
-
componentRef.destroy();
|
|
270
|
-
this.elRefMap.delete(component);
|
|
271
|
-
const unbindEvents = this.elEventsMap.get(component);
|
|
272
|
-
if (unbindEvents) {
|
|
273
|
-
unbindEvents();
|
|
274
|
-
this.elEventsMap.delete(component);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
resolve();
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
|
|
283
|
-
/**
|
|
284
|
-
* Wraps the injector with a custom injector that
|
|
285
|
-
* provides NavParams to the component.
|
|
286
|
-
*
|
|
287
|
-
* NavParams is a legacy feature from Ionic v3 that allows
|
|
288
|
-
* Angular developers to provide data to a component
|
|
289
|
-
* and access it by providing NavParams as a dependency
|
|
290
|
-
* in the constructor.
|
|
291
|
-
*
|
|
292
|
-
* The modern approach is to access the data directly
|
|
293
|
-
* from the component's class instance.
|
|
294
|
-
*/
|
|
295
|
-
const childInjector = Injector.create({
|
|
296
|
-
providers: getProviders(params),
|
|
297
|
-
parent: injector,
|
|
298
|
-
});
|
|
299
|
-
const componentRef = createComponent(component, {
|
|
300
|
-
environmentInjector,
|
|
301
|
-
elementInjector: childInjector,
|
|
302
|
-
});
|
|
303
|
-
const instance = componentRef.instance;
|
|
304
|
-
const hostElement = componentRef.location.nativeElement;
|
|
305
|
-
if (params) {
|
|
306
|
-
/**
|
|
307
|
-
* For modals and popovers, a reference to the component is
|
|
308
|
-
* added to `params` during the call to attachViewToDom. If
|
|
309
|
-
* a reference using this name is already set, this means
|
|
310
|
-
* the app is trying to use the name as a component prop,
|
|
311
|
-
* which will cause collisions.
|
|
312
|
-
*/
|
|
313
|
-
if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
|
|
314
|
-
console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
|
|
315
|
-
}
|
|
316
|
-
Object.assign(instance, params);
|
|
317
|
-
}
|
|
318
|
-
if (cssClasses) {
|
|
319
|
-
for (const cssClass of cssClasses) {
|
|
320
|
-
hostElement.classList.add(cssClass);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
|
|
324
|
-
container.appendChild(hostElement);
|
|
325
|
-
applicationRef.attachView(componentRef.hostView);
|
|
326
|
-
elRefMap.set(hostElement, componentRef);
|
|
327
|
-
elEventsMap.set(hostElement, unbindEvents);
|
|
328
|
-
return hostElement;
|
|
329
|
-
};
|
|
330
|
-
const LIFECYCLES = [
|
|
331
|
-
LIFECYCLE_WILL_ENTER,
|
|
332
|
-
LIFECYCLE_DID_ENTER,
|
|
333
|
-
LIFECYCLE_WILL_LEAVE,
|
|
334
|
-
LIFECYCLE_DID_LEAVE,
|
|
335
|
-
LIFECYCLE_WILL_UNLOAD,
|
|
336
|
-
];
|
|
337
|
-
const bindLifecycleEvents = (zone, instance, element) => {
|
|
338
|
-
return zone.run(() => {
|
|
339
|
-
const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
|
|
340
|
-
const handler = (ev) => instance[eventName](ev.detail);
|
|
341
|
-
element.addEventListener(eventName, handler);
|
|
342
|
-
return () => element.removeEventListener(eventName, handler);
|
|
343
|
-
});
|
|
344
|
-
return () => unregisters.forEach((fn) => fn());
|
|
345
|
-
});
|
|
346
|
-
};
|
|
347
|
-
const NavParamsToken = new InjectionToken('NavParamsToken');
|
|
348
|
-
const getProviders = (params) => {
|
|
349
|
-
return [
|
|
350
|
-
{
|
|
351
|
-
provide: NavParamsToken,
|
|
352
|
-
useValue: params,
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
provide: NavParams,
|
|
356
|
-
useFactory: provideNavParamsInjectable,
|
|
357
|
-
deps: [NavParamsToken],
|
|
358
|
-
},
|
|
359
|
-
];
|
|
360
|
-
};
|
|
361
|
-
const provideNavParamsInjectable = (params) => {
|
|
362
|
-
return new NavParams(params);
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
class ModalController extends OverlayBaseController {
|
|
366
|
-
constructor() {
|
|
367
|
-
super(modalController);
|
|
368
|
-
this.angularDelegate = inject(AngularDelegate);
|
|
369
|
-
this.injector = inject(Injector);
|
|
370
|
-
this.environmentInjector = inject(EnvironmentInjector);
|
|
371
|
-
}
|
|
372
|
-
create(opts) {
|
|
373
|
-
return super.create({
|
|
374
|
-
...opts,
|
|
375
|
-
delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'modal'),
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
/** @nocollapse */ ModalController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
380
|
-
/** @nocollapse */ ModalController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController });
|
|
381
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, decorators: [{
|
|
382
|
-
type: Injectable
|
|
383
|
-
}], ctorParameters: function () { return []; } });
|
|
384
|
-
|
|
385
158
|
class PickerController extends OverlayBaseController {
|
|
386
159
|
constructor() {
|
|
387
160
|
super(pickerController);
|
|
@@ -396,26 +169,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
396
169
|
}]
|
|
397
170
|
}], ctorParameters: function () { return []; } });
|
|
398
171
|
|
|
399
|
-
class PopoverController extends OverlayBaseController {
|
|
400
|
-
constructor() {
|
|
401
|
-
super(popoverController);
|
|
402
|
-
this.angularDelegate = inject(AngularDelegate);
|
|
403
|
-
this.injector = inject(Injector);
|
|
404
|
-
this.environmentInjector = inject(EnvironmentInjector);
|
|
405
|
-
}
|
|
406
|
-
create(opts) {
|
|
407
|
-
return super.create({
|
|
408
|
-
...opts,
|
|
409
|
-
delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'popover'),
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
/** @nocollapse */ PopoverController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
414
|
-
/** @nocollapse */ PopoverController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController });
|
|
415
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController, decorators: [{
|
|
416
|
-
type: Injectable
|
|
417
|
-
}], ctorParameters: function () { return []; } });
|
|
418
|
-
|
|
419
172
|
class ToastController extends OverlayBaseController {
|
|
420
173
|
constructor() {
|
|
421
174
|
super(toastController);
|
|
@@ -1040,6 +793,199 @@ const getConfig = () => {
|
|
|
1040
793
|
return null;
|
|
1041
794
|
};
|
|
1042
795
|
|
|
796
|
+
/**
|
|
797
|
+
* @description
|
|
798
|
+
* NavParams are an object that exists on a page and can contain data for that particular view.
|
|
799
|
+
* Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
|
|
800
|
+
* option with a simple `get` method.
|
|
801
|
+
*
|
|
802
|
+
* @usage
|
|
803
|
+
* ```ts
|
|
804
|
+
* import { NavParams } from '@ionic/angular';
|
|
805
|
+
*
|
|
806
|
+
* export class MyClass{
|
|
807
|
+
*
|
|
808
|
+
* constructor(navParams: NavParams){
|
|
809
|
+
* // userParams is an object we have in our nav-parameters
|
|
810
|
+
* navParams.get('userParams');
|
|
811
|
+
* }
|
|
812
|
+
*
|
|
813
|
+
* }
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
816
|
+
class NavParams {
|
|
817
|
+
constructor(data = {}) {
|
|
818
|
+
this.data = data;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Get the value of a nav-parameter for the current view
|
|
822
|
+
*
|
|
823
|
+
* ```ts
|
|
824
|
+
* import { NavParams } from 'ionic-angular';
|
|
825
|
+
*
|
|
826
|
+
* export class MyClass{
|
|
827
|
+
* constructor(public navParams: NavParams){
|
|
828
|
+
* // userParams is an object we have in our nav-parameters
|
|
829
|
+
* this.navParams.get('userParams');
|
|
830
|
+
* }
|
|
831
|
+
* }
|
|
832
|
+
* ```
|
|
833
|
+
*
|
|
834
|
+
* @param param Which param you want to look up
|
|
835
|
+
*/
|
|
836
|
+
get(param) {
|
|
837
|
+
return this.data[param];
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// TODO(FW-2827): types
|
|
842
|
+
class AngularDelegate {
|
|
843
|
+
constructor() {
|
|
844
|
+
this.zone = inject(NgZone);
|
|
845
|
+
this.applicationRef = inject(ApplicationRef);
|
|
846
|
+
}
|
|
847
|
+
create(environmentInjector, injector, elementReferenceKey) {
|
|
848
|
+
return new AngularFrameworkDelegate(environmentInjector, injector, this.applicationRef, this.zone, elementReferenceKey);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
/** @nocollapse */ AngularDelegate.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
852
|
+
/** @nocollapse */ AngularDelegate.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate });
|
|
853
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, decorators: [{
|
|
854
|
+
type: Injectable
|
|
855
|
+
}] });
|
|
856
|
+
class AngularFrameworkDelegate {
|
|
857
|
+
constructor(environmentInjector, injector, applicationRef, zone, elementReferenceKey) {
|
|
858
|
+
this.environmentInjector = environmentInjector;
|
|
859
|
+
this.injector = injector;
|
|
860
|
+
this.applicationRef = applicationRef;
|
|
861
|
+
this.zone = zone;
|
|
862
|
+
this.elementReferenceKey = elementReferenceKey;
|
|
863
|
+
this.elRefMap = new WeakMap();
|
|
864
|
+
this.elEventsMap = new WeakMap();
|
|
865
|
+
}
|
|
866
|
+
attachViewToDom(container, component, params, cssClasses) {
|
|
867
|
+
return this.zone.run(() => {
|
|
868
|
+
return new Promise((resolve) => {
|
|
869
|
+
const componentProps = {
|
|
870
|
+
...params,
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* Ionic Angular passes a reference to a modal
|
|
874
|
+
* or popover that can be accessed using a
|
|
875
|
+
* variable in the overlay component. If
|
|
876
|
+
* elementReferenceKey is defined, then we should
|
|
877
|
+
* pass a reference to the component using
|
|
878
|
+
* elementReferenceKey as the key.
|
|
879
|
+
*/
|
|
880
|
+
if (this.elementReferenceKey !== undefined) {
|
|
881
|
+
componentProps[this.elementReferenceKey] = container;
|
|
882
|
+
}
|
|
883
|
+
const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
|
|
884
|
+
resolve(el);
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
removeViewFromDom(_container, component) {
|
|
889
|
+
return this.zone.run(() => {
|
|
890
|
+
return new Promise((resolve) => {
|
|
891
|
+
const componentRef = this.elRefMap.get(component);
|
|
892
|
+
if (componentRef) {
|
|
893
|
+
componentRef.destroy();
|
|
894
|
+
this.elRefMap.delete(component);
|
|
895
|
+
const unbindEvents = this.elEventsMap.get(component);
|
|
896
|
+
if (unbindEvents) {
|
|
897
|
+
unbindEvents();
|
|
898
|
+
this.elEventsMap.delete(component);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
resolve();
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
|
|
907
|
+
/**
|
|
908
|
+
* Wraps the injector with a custom injector that
|
|
909
|
+
* provides NavParams to the component.
|
|
910
|
+
*
|
|
911
|
+
* NavParams is a legacy feature from Ionic v3 that allows
|
|
912
|
+
* Angular developers to provide data to a component
|
|
913
|
+
* and access it by providing NavParams as a dependency
|
|
914
|
+
* in the constructor.
|
|
915
|
+
*
|
|
916
|
+
* The modern approach is to access the data directly
|
|
917
|
+
* from the component's class instance.
|
|
918
|
+
*/
|
|
919
|
+
const childInjector = Injector.create({
|
|
920
|
+
providers: getProviders(params),
|
|
921
|
+
parent: injector,
|
|
922
|
+
});
|
|
923
|
+
const componentRef = createComponent(component, {
|
|
924
|
+
environmentInjector,
|
|
925
|
+
elementInjector: childInjector,
|
|
926
|
+
});
|
|
927
|
+
const instance = componentRef.instance;
|
|
928
|
+
const hostElement = componentRef.location.nativeElement;
|
|
929
|
+
if (params) {
|
|
930
|
+
/**
|
|
931
|
+
* For modals and popovers, a reference to the component is
|
|
932
|
+
* added to `params` during the call to attachViewToDom. If
|
|
933
|
+
* a reference using this name is already set, this means
|
|
934
|
+
* the app is trying to use the name as a component prop,
|
|
935
|
+
* which will cause collisions.
|
|
936
|
+
*/
|
|
937
|
+
if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
|
|
938
|
+
console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
|
|
939
|
+
}
|
|
940
|
+
Object.assign(instance, params);
|
|
941
|
+
}
|
|
942
|
+
if (cssClasses) {
|
|
943
|
+
for (const cssClass of cssClasses) {
|
|
944
|
+
hostElement.classList.add(cssClass);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
|
|
948
|
+
container.appendChild(hostElement);
|
|
949
|
+
applicationRef.attachView(componentRef.hostView);
|
|
950
|
+
elRefMap.set(hostElement, componentRef);
|
|
951
|
+
elEventsMap.set(hostElement, unbindEvents);
|
|
952
|
+
return hostElement;
|
|
953
|
+
};
|
|
954
|
+
const LIFECYCLES = [
|
|
955
|
+
LIFECYCLE_WILL_ENTER,
|
|
956
|
+
LIFECYCLE_DID_ENTER,
|
|
957
|
+
LIFECYCLE_WILL_LEAVE,
|
|
958
|
+
LIFECYCLE_DID_LEAVE,
|
|
959
|
+
LIFECYCLE_WILL_UNLOAD,
|
|
960
|
+
];
|
|
961
|
+
const bindLifecycleEvents = (zone, instance, element) => {
|
|
962
|
+
return zone.run(() => {
|
|
963
|
+
const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
|
|
964
|
+
const handler = (ev) => instance[eventName](ev.detail);
|
|
965
|
+
element.addEventListener(eventName, handler);
|
|
966
|
+
return () => element.removeEventListener(eventName, handler);
|
|
967
|
+
});
|
|
968
|
+
return () => unregisters.forEach((fn) => fn());
|
|
969
|
+
});
|
|
970
|
+
};
|
|
971
|
+
const NavParamsToken = new InjectionToken('NavParamsToken');
|
|
972
|
+
const getProviders = (params) => {
|
|
973
|
+
return [
|
|
974
|
+
{
|
|
975
|
+
provide: NavParamsToken,
|
|
976
|
+
useValue: params,
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
provide: NavParams,
|
|
980
|
+
useFactory: provideNavParamsInjectable,
|
|
981
|
+
deps: [NavParamsToken],
|
|
982
|
+
},
|
|
983
|
+
];
|
|
984
|
+
};
|
|
985
|
+
const provideNavParamsInjectable = (params) => {
|
|
986
|
+
return new NavParams(params);
|
|
987
|
+
};
|
|
988
|
+
|
|
1043
989
|
// TODO: Is there a way we can grab this from angular-component-lib instead?
|
|
1044
990
|
const proxyInputs = (Cmp, inputs) => {
|
|
1045
991
|
const Prototype = Cmp.prototype;
|
|
@@ -2608,5 +2554,5 @@ class IonicRouteStrategy {
|
|
|
2608
2554
|
* Generated bundle index. Do not edit.
|
|
2609
2555
|
*/
|
|
2610
2556
|
|
|
2611
|
-
export {
|
|
2557
|
+
export { AlertController, AngularDelegate, AnimationController, Config, ConfigToken, DomController, GestureController, IonBackButton, IonModal, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, LoadingController, MenuController, NavController, NavParams, OverlayBaseController, PickerController, Platform, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ToastController, ValueAccessor, bindLifecycleEvents, provideComponentInputBinding, raf, setIonicClasses };
|
|
2612
2558
|
//# sourceMappingURL=ionic-angular-common.mjs.map
|