@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 { __awaiter, __decorate } from 'tslib';
|
|
5
5
|
import * as i3 from '@angular/router';
|
|
6
6
|
import { NavigationStart, PRIMARY_OUTLET, ChildrenOutletContexts, ActivatedRoute, Router } from '@angular/router';
|
|
@@ -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,214 +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 = Object.assign({}, params);
|
|
246
|
-
/**
|
|
247
|
-
* Ionic Angular passes a reference to a modal
|
|
248
|
-
* or popover that can be accessed using a
|
|
249
|
-
* variable in the overlay component. If
|
|
250
|
-
* elementReferenceKey is defined, then we should
|
|
251
|
-
* pass a reference to the component using
|
|
252
|
-
* elementReferenceKey as the key.
|
|
253
|
-
*/
|
|
254
|
-
if (this.elementReferenceKey !== undefined) {
|
|
255
|
-
componentProps[this.elementReferenceKey] = container;
|
|
256
|
-
}
|
|
257
|
-
const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
|
|
258
|
-
resolve(el);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
removeViewFromDom(_container, component) {
|
|
263
|
-
return this.zone.run(() => {
|
|
264
|
-
return new Promise((resolve) => {
|
|
265
|
-
const componentRef = this.elRefMap.get(component);
|
|
266
|
-
if (componentRef) {
|
|
267
|
-
componentRef.destroy();
|
|
268
|
-
this.elRefMap.delete(component);
|
|
269
|
-
const unbindEvents = this.elEventsMap.get(component);
|
|
270
|
-
if (unbindEvents) {
|
|
271
|
-
unbindEvents();
|
|
272
|
-
this.elEventsMap.delete(component);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
resolve();
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
|
|
281
|
-
/**
|
|
282
|
-
* Wraps the injector with a custom injector that
|
|
283
|
-
* provides NavParams to the component.
|
|
284
|
-
*
|
|
285
|
-
* NavParams is a legacy feature from Ionic v3 that allows
|
|
286
|
-
* Angular developers to provide data to a component
|
|
287
|
-
* and access it by providing NavParams as a dependency
|
|
288
|
-
* in the constructor.
|
|
289
|
-
*
|
|
290
|
-
* The modern approach is to access the data directly
|
|
291
|
-
* from the component's class instance.
|
|
292
|
-
*/
|
|
293
|
-
const childInjector = Injector.create({
|
|
294
|
-
providers: getProviders(params),
|
|
295
|
-
parent: injector,
|
|
296
|
-
});
|
|
297
|
-
const componentRef = createComponent(component, {
|
|
298
|
-
environmentInjector,
|
|
299
|
-
elementInjector: childInjector,
|
|
300
|
-
});
|
|
301
|
-
const instance = componentRef.instance;
|
|
302
|
-
const hostElement = componentRef.location.nativeElement;
|
|
303
|
-
if (params) {
|
|
304
|
-
/**
|
|
305
|
-
* For modals and popovers, a reference to the component is
|
|
306
|
-
* added to `params` during the call to attachViewToDom. If
|
|
307
|
-
* a reference using this name is already set, this means
|
|
308
|
-
* the app is trying to use the name as a component prop,
|
|
309
|
-
* which will cause collisions.
|
|
310
|
-
*/
|
|
311
|
-
if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
|
|
312
|
-
console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
|
|
313
|
-
}
|
|
314
|
-
Object.assign(instance, params);
|
|
315
|
-
}
|
|
316
|
-
if (cssClasses) {
|
|
317
|
-
for (const cssClass of cssClasses) {
|
|
318
|
-
hostElement.classList.add(cssClass);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
|
|
322
|
-
container.appendChild(hostElement);
|
|
323
|
-
applicationRef.attachView(componentRef.hostView);
|
|
324
|
-
elRefMap.set(hostElement, componentRef);
|
|
325
|
-
elEventsMap.set(hostElement, unbindEvents);
|
|
326
|
-
return hostElement;
|
|
327
|
-
};
|
|
328
|
-
const LIFECYCLES = [
|
|
329
|
-
LIFECYCLE_WILL_ENTER,
|
|
330
|
-
LIFECYCLE_DID_ENTER,
|
|
331
|
-
LIFECYCLE_WILL_LEAVE,
|
|
332
|
-
LIFECYCLE_DID_LEAVE,
|
|
333
|
-
LIFECYCLE_WILL_UNLOAD,
|
|
334
|
-
];
|
|
335
|
-
const bindLifecycleEvents = (zone, instance, element) => {
|
|
336
|
-
return zone.run(() => {
|
|
337
|
-
const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
|
|
338
|
-
const handler = (ev) => instance[eventName](ev.detail);
|
|
339
|
-
element.addEventListener(eventName, handler);
|
|
340
|
-
return () => element.removeEventListener(eventName, handler);
|
|
341
|
-
});
|
|
342
|
-
return () => unregisters.forEach((fn) => fn());
|
|
343
|
-
});
|
|
344
|
-
};
|
|
345
|
-
const NavParamsToken = new InjectionToken('NavParamsToken');
|
|
346
|
-
const getProviders = (params) => {
|
|
347
|
-
return [
|
|
348
|
-
{
|
|
349
|
-
provide: NavParamsToken,
|
|
350
|
-
useValue: params,
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
provide: NavParams,
|
|
354
|
-
useFactory: provideNavParamsInjectable,
|
|
355
|
-
deps: [NavParamsToken],
|
|
356
|
-
},
|
|
357
|
-
];
|
|
358
|
-
};
|
|
359
|
-
const provideNavParamsInjectable = (params) => {
|
|
360
|
-
return new NavParams(params);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
class ModalController extends OverlayBaseController {
|
|
364
|
-
constructor() {
|
|
365
|
-
super(modalController);
|
|
366
|
-
this.angularDelegate = inject(AngularDelegate);
|
|
367
|
-
this.injector = inject(Injector);
|
|
368
|
-
this.environmentInjector = inject(EnvironmentInjector);
|
|
369
|
-
}
|
|
370
|
-
create(opts) {
|
|
371
|
-
return super.create(Object.assign(Object.assign({}, opts), { delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'modal') }));
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
/** @nocollapse */ ModalController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
375
|
-
/** @nocollapse */ ModalController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController });
|
|
376
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, decorators: [{
|
|
377
|
-
type: Injectable
|
|
378
|
-
}], ctorParameters: function () { return []; } });
|
|
379
|
-
|
|
380
158
|
class PickerController extends OverlayBaseController {
|
|
381
159
|
constructor() {
|
|
382
160
|
super(pickerController);
|
|
@@ -391,23 +169,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
391
169
|
}]
|
|
392
170
|
}], ctorParameters: function () { return []; } });
|
|
393
171
|
|
|
394
|
-
class PopoverController extends OverlayBaseController {
|
|
395
|
-
constructor() {
|
|
396
|
-
super(popoverController);
|
|
397
|
-
this.angularDelegate = inject(AngularDelegate);
|
|
398
|
-
this.injector = inject(Injector);
|
|
399
|
-
this.environmentInjector = inject(EnvironmentInjector);
|
|
400
|
-
}
|
|
401
|
-
create(opts) {
|
|
402
|
-
return super.create(Object.assign(Object.assign({}, opts), { delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'popover') }));
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
/** @nocollapse */ PopoverController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
406
|
-
/** @nocollapse */ PopoverController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController });
|
|
407
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PopoverController, decorators: [{
|
|
408
|
-
type: Injectable
|
|
409
|
-
}], ctorParameters: function () { return []; } });
|
|
410
|
-
|
|
411
172
|
class ToastController extends OverlayBaseController {
|
|
412
173
|
constructor() {
|
|
413
174
|
super(toastController);
|
|
@@ -1040,6 +801,197 @@ const getConfig = () => {
|
|
|
1040
801
|
return null;
|
|
1041
802
|
};
|
|
1042
803
|
|
|
804
|
+
/**
|
|
805
|
+
* @description
|
|
806
|
+
* NavParams are an object that exists on a page and can contain data for that particular view.
|
|
807
|
+
* Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
|
|
808
|
+
* option with a simple `get` method.
|
|
809
|
+
*
|
|
810
|
+
* @usage
|
|
811
|
+
* ```ts
|
|
812
|
+
* import { NavParams } from '@ionic/angular';
|
|
813
|
+
*
|
|
814
|
+
* export class MyClass{
|
|
815
|
+
*
|
|
816
|
+
* constructor(navParams: NavParams){
|
|
817
|
+
* // userParams is an object we have in our nav-parameters
|
|
818
|
+
* navParams.get('userParams');
|
|
819
|
+
* }
|
|
820
|
+
*
|
|
821
|
+
* }
|
|
822
|
+
* ```
|
|
823
|
+
*/
|
|
824
|
+
class NavParams {
|
|
825
|
+
constructor(data = {}) {
|
|
826
|
+
this.data = data;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Get the value of a nav-parameter for the current view
|
|
830
|
+
*
|
|
831
|
+
* ```ts
|
|
832
|
+
* import { NavParams } from 'ionic-angular';
|
|
833
|
+
*
|
|
834
|
+
* export class MyClass{
|
|
835
|
+
* constructor(public navParams: NavParams){
|
|
836
|
+
* // userParams is an object we have in our nav-parameters
|
|
837
|
+
* this.navParams.get('userParams');
|
|
838
|
+
* }
|
|
839
|
+
* }
|
|
840
|
+
* ```
|
|
841
|
+
*
|
|
842
|
+
* @param param Which param you want to look up
|
|
843
|
+
*/
|
|
844
|
+
get(param) {
|
|
845
|
+
return this.data[param];
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// TODO(FW-2827): types
|
|
850
|
+
class AngularDelegate {
|
|
851
|
+
constructor() {
|
|
852
|
+
this.zone = inject(NgZone);
|
|
853
|
+
this.applicationRef = inject(ApplicationRef);
|
|
854
|
+
}
|
|
855
|
+
create(environmentInjector, injector, elementReferenceKey) {
|
|
856
|
+
return new AngularFrameworkDelegate(environmentInjector, injector, this.applicationRef, this.zone, elementReferenceKey);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
/** @nocollapse */ AngularDelegate.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
860
|
+
/** @nocollapse */ AngularDelegate.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate });
|
|
861
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, decorators: [{
|
|
862
|
+
type: Injectable
|
|
863
|
+
}] });
|
|
864
|
+
class AngularFrameworkDelegate {
|
|
865
|
+
constructor(environmentInjector, injector, applicationRef, zone, elementReferenceKey) {
|
|
866
|
+
this.environmentInjector = environmentInjector;
|
|
867
|
+
this.injector = injector;
|
|
868
|
+
this.applicationRef = applicationRef;
|
|
869
|
+
this.zone = zone;
|
|
870
|
+
this.elementReferenceKey = elementReferenceKey;
|
|
871
|
+
this.elRefMap = new WeakMap();
|
|
872
|
+
this.elEventsMap = new WeakMap();
|
|
873
|
+
}
|
|
874
|
+
attachViewToDom(container, component, params, cssClasses) {
|
|
875
|
+
return this.zone.run(() => {
|
|
876
|
+
return new Promise((resolve) => {
|
|
877
|
+
const componentProps = Object.assign({}, params);
|
|
878
|
+
/**
|
|
879
|
+
* Ionic Angular passes a reference to a modal
|
|
880
|
+
* or popover that can be accessed using a
|
|
881
|
+
* variable in the overlay component. If
|
|
882
|
+
* elementReferenceKey is defined, then we should
|
|
883
|
+
* pass a reference to the component using
|
|
884
|
+
* elementReferenceKey as the key.
|
|
885
|
+
*/
|
|
886
|
+
if (this.elementReferenceKey !== undefined) {
|
|
887
|
+
componentProps[this.elementReferenceKey] = container;
|
|
888
|
+
}
|
|
889
|
+
const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
|
|
890
|
+
resolve(el);
|
|
891
|
+
});
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
removeViewFromDom(_container, component) {
|
|
895
|
+
return this.zone.run(() => {
|
|
896
|
+
return new Promise((resolve) => {
|
|
897
|
+
const componentRef = this.elRefMap.get(component);
|
|
898
|
+
if (componentRef) {
|
|
899
|
+
componentRef.destroy();
|
|
900
|
+
this.elRefMap.delete(component);
|
|
901
|
+
const unbindEvents = this.elEventsMap.get(component);
|
|
902
|
+
if (unbindEvents) {
|
|
903
|
+
unbindEvents();
|
|
904
|
+
this.elEventsMap.delete(component);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
resolve();
|
|
908
|
+
});
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
|
|
913
|
+
/**
|
|
914
|
+
* Wraps the injector with a custom injector that
|
|
915
|
+
* provides NavParams to the component.
|
|
916
|
+
*
|
|
917
|
+
* NavParams is a legacy feature from Ionic v3 that allows
|
|
918
|
+
* Angular developers to provide data to a component
|
|
919
|
+
* and access it by providing NavParams as a dependency
|
|
920
|
+
* in the constructor.
|
|
921
|
+
*
|
|
922
|
+
* The modern approach is to access the data directly
|
|
923
|
+
* from the component's class instance.
|
|
924
|
+
*/
|
|
925
|
+
const childInjector = Injector.create({
|
|
926
|
+
providers: getProviders(params),
|
|
927
|
+
parent: injector,
|
|
928
|
+
});
|
|
929
|
+
const componentRef = createComponent(component, {
|
|
930
|
+
environmentInjector,
|
|
931
|
+
elementInjector: childInjector,
|
|
932
|
+
});
|
|
933
|
+
const instance = componentRef.instance;
|
|
934
|
+
const hostElement = componentRef.location.nativeElement;
|
|
935
|
+
if (params) {
|
|
936
|
+
/**
|
|
937
|
+
* For modals and popovers, a reference to the component is
|
|
938
|
+
* added to `params` during the call to attachViewToDom. If
|
|
939
|
+
* a reference using this name is already set, this means
|
|
940
|
+
* the app is trying to use the name as a component prop,
|
|
941
|
+
* which will cause collisions.
|
|
942
|
+
*/
|
|
943
|
+
if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
|
|
944
|
+
console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
|
|
945
|
+
}
|
|
946
|
+
Object.assign(instance, params);
|
|
947
|
+
}
|
|
948
|
+
if (cssClasses) {
|
|
949
|
+
for (const cssClass of cssClasses) {
|
|
950
|
+
hostElement.classList.add(cssClass);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
|
|
954
|
+
container.appendChild(hostElement);
|
|
955
|
+
applicationRef.attachView(componentRef.hostView);
|
|
956
|
+
elRefMap.set(hostElement, componentRef);
|
|
957
|
+
elEventsMap.set(hostElement, unbindEvents);
|
|
958
|
+
return hostElement;
|
|
959
|
+
};
|
|
960
|
+
const LIFECYCLES = [
|
|
961
|
+
LIFECYCLE_WILL_ENTER,
|
|
962
|
+
LIFECYCLE_DID_ENTER,
|
|
963
|
+
LIFECYCLE_WILL_LEAVE,
|
|
964
|
+
LIFECYCLE_DID_LEAVE,
|
|
965
|
+
LIFECYCLE_WILL_UNLOAD,
|
|
966
|
+
];
|
|
967
|
+
const bindLifecycleEvents = (zone, instance, element) => {
|
|
968
|
+
return zone.run(() => {
|
|
969
|
+
const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
|
|
970
|
+
const handler = (ev) => instance[eventName](ev.detail);
|
|
971
|
+
element.addEventListener(eventName, handler);
|
|
972
|
+
return () => element.removeEventListener(eventName, handler);
|
|
973
|
+
});
|
|
974
|
+
return () => unregisters.forEach((fn) => fn());
|
|
975
|
+
});
|
|
976
|
+
};
|
|
977
|
+
const NavParamsToken = new InjectionToken('NavParamsToken');
|
|
978
|
+
const getProviders = (params) => {
|
|
979
|
+
return [
|
|
980
|
+
{
|
|
981
|
+
provide: NavParamsToken,
|
|
982
|
+
useValue: params,
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
provide: NavParams,
|
|
986
|
+
useFactory: provideNavParamsInjectable,
|
|
987
|
+
deps: [NavParamsToken],
|
|
988
|
+
},
|
|
989
|
+
];
|
|
990
|
+
};
|
|
991
|
+
const provideNavParamsInjectable = (params) => {
|
|
992
|
+
return new NavParams(params);
|
|
993
|
+
};
|
|
994
|
+
|
|
1043
995
|
// TODO: Is there a way we can grab this from angular-component-lib instead?
|
|
1044
996
|
const proxyInputs = (Cmp, inputs) => {
|
|
1045
997
|
const Prototype = Cmp.prototype;
|
|
@@ -2619,5 +2571,5 @@ class IonicRouteStrategy {
|
|
|
2619
2571
|
* Generated bundle index. Do not edit.
|
|
2620
2572
|
*/
|
|
2621
2573
|
|
|
2622
|
-
export {
|
|
2574
|
+
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 };
|
|
2623
2575
|
//# sourceMappingURL=ionic-angular-common.mjs.map
|