@ionic/angular 7.5.5-dev.11699655013.1a2cb3ad → 7.5.5-dev.11699885804.1d8011d5
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 +4 -0
- package/{providers → common/providers}/animation-controller.d.ts +1 -1
- package/{standalone → common}/providers/modal-controller.d.ts +1 -1
- package/{standalone → common}/providers/toast-controller.d.ts +1 -1
- package/esm2020/common/index.mjs +5 -1
- package/esm2020/common/providers/animation-controller.mjs +37 -0
- package/esm2020/common/providers/gesture-controller.mjs +31 -0
- package/esm2020/common/providers/modal-controller.mjs +25 -0
- package/esm2020/common/providers/toast-controller.mjs +18 -0
- package/esm2020/index.mjs +3 -7
- package/esm2020/ionic-module.mjs +2 -3
- package/esm2020/standalone/index.mjs +3 -7
- package/esm2020/standalone/providers/ionic-angular.mjs +2 -3
- package/fesm2015/ionic-angular-common.mjs +287 -194
- package/fesm2015/ionic-angular-common.mjs.map +1 -1
- package/fesm2015/ionic-angular-standalone.mjs +10 -103
- package/fesm2015/ionic-angular-standalone.mjs.map +1 -1
- package/fesm2015/ionic-angular.mjs +9 -102
- package/fesm2015/ionic-angular.mjs.map +1 -1
- package/fesm2020/ionic-angular-common.mjs +292 -196
- package/fesm2020/ionic-angular-common.mjs.map +1 -1
- package/fesm2020/ionic-angular-standalone.mjs +10 -106
- package/fesm2020/ionic-angular-standalone.mjs.map +1 -1
- package/fesm2020/ionic-angular.mjs +9 -105
- package/fesm2020/ionic-angular.mjs.map +1 -1
- package/index.d.ts +2 -6
- package/package.json +2 -2
- package/standalone/index.d.ts +2 -6
- package/esm2020/providers/animation-controller.mjs +0 -37
- package/esm2020/providers/gesture-controller.mjs +0 -31
- package/esm2020/providers/modal-controller.mjs +0 -24
- package/esm2020/providers/toast-controller.mjs +0 -18
- package/esm2020/standalone/providers/animation-controller.mjs +0 -37
- package/esm2020/standalone/providers/gesture-controller.mjs +0 -31
- package/esm2020/standalone/providers/modal-controller.mjs +0 -24
- package/esm2020/standalone/providers/toast-controller.mjs +0 -18
- package/providers/gesture-controller.d.ts +0 -13
- package/providers/modal-controller.d.ts +0 -12
- package/providers/toast-controller.d.ts +0 -8
- package/standalone/providers/animation-controller.d.ts +0 -25
- /package/{standalone → common}/providers/gesture-controller.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable,
|
|
3
|
-
import { alertController, loadingController,
|
|
2
|
+
import { Injectable, inject, NgZone, ApplicationRef, Injector, createComponent, InjectionToken, EnvironmentInjector, Inject, Optional, TemplateRef, Directive, ContentChild, EventEmitter, ViewContainerRef, Attribute, SkipSelf, Input, Output, reflectComponentType, HostListener, ElementRef, ViewChild } from '@angular/core';
|
|
3
|
+
import { alertController, loadingController, LIFECYCLE_WILL_ENTER, LIFECYCLE_DID_ENTER, LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_UNLOAD, modalController, pickerController, toastController, createAnimation, getTimeGivenProgression, createGesture, isPlatform, getPlatforms, 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';
|
|
@@ -155,6 +155,219 @@ class MenuController {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
* @description
|
|
160
|
+
* NavParams are an object that exists on a page and can contain data for that particular view.
|
|
161
|
+
* Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
|
|
162
|
+
* option with a simple `get` method.
|
|
163
|
+
*
|
|
164
|
+
* @usage
|
|
165
|
+
* ```ts
|
|
166
|
+
* import { NavParams } from '@ionic/angular';
|
|
167
|
+
*
|
|
168
|
+
* export class MyClass{
|
|
169
|
+
*
|
|
170
|
+
* constructor(navParams: NavParams){
|
|
171
|
+
* // userParams is an object we have in our nav-parameters
|
|
172
|
+
* navParams.get('userParams');
|
|
173
|
+
* }
|
|
174
|
+
*
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
class NavParams {
|
|
179
|
+
constructor(data = {}) {
|
|
180
|
+
this.data = data;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get the value of a nav-parameter for the current view
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { NavParams } from 'ionic-angular';
|
|
187
|
+
*
|
|
188
|
+
* export class MyClass{
|
|
189
|
+
* constructor(public navParams: NavParams){
|
|
190
|
+
* // userParams is an object we have in our nav-parameters
|
|
191
|
+
* this.navParams.get('userParams');
|
|
192
|
+
* }
|
|
193
|
+
* }
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @param param Which param you want to look up
|
|
197
|
+
*/
|
|
198
|
+
get(param) {
|
|
199
|
+
return this.data[param];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// TODO(FW-2827): types
|
|
204
|
+
class AngularDelegate {
|
|
205
|
+
constructor() {
|
|
206
|
+
this.zone = inject(NgZone);
|
|
207
|
+
this.applicationRef = inject(ApplicationRef);
|
|
208
|
+
}
|
|
209
|
+
create(environmentInjector, injector, elementReferenceKey) {
|
|
210
|
+
return new AngularFrameworkDelegate(environmentInjector, injector, this.applicationRef, this.zone, elementReferenceKey);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** @nocollapse */ AngularDelegate.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
214
|
+
/** @nocollapse */ AngularDelegate.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate });
|
|
215
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, decorators: [{
|
|
216
|
+
type: Injectable
|
|
217
|
+
}] });
|
|
218
|
+
class AngularFrameworkDelegate {
|
|
219
|
+
constructor(environmentInjector, injector, applicationRef, zone, elementReferenceKey) {
|
|
220
|
+
this.environmentInjector = environmentInjector;
|
|
221
|
+
this.injector = injector;
|
|
222
|
+
this.applicationRef = applicationRef;
|
|
223
|
+
this.zone = zone;
|
|
224
|
+
this.elementReferenceKey = elementReferenceKey;
|
|
225
|
+
this.elRefMap = new WeakMap();
|
|
226
|
+
this.elEventsMap = new WeakMap();
|
|
227
|
+
}
|
|
228
|
+
attachViewToDom(container, component, params, cssClasses) {
|
|
229
|
+
return this.zone.run(() => {
|
|
230
|
+
return new Promise((resolve) => {
|
|
231
|
+
const componentProps = {
|
|
232
|
+
...params,
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Ionic Angular passes a reference to a modal
|
|
236
|
+
* or popover that can be accessed using a
|
|
237
|
+
* variable in the overlay component. If
|
|
238
|
+
* elementReferenceKey is defined, then we should
|
|
239
|
+
* pass a reference to the component using
|
|
240
|
+
* elementReferenceKey as the key.
|
|
241
|
+
*/
|
|
242
|
+
if (this.elementReferenceKey !== undefined) {
|
|
243
|
+
componentProps[this.elementReferenceKey] = container;
|
|
244
|
+
}
|
|
245
|
+
const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
|
|
246
|
+
resolve(el);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
removeViewFromDom(_container, component) {
|
|
251
|
+
return this.zone.run(() => {
|
|
252
|
+
return new Promise((resolve) => {
|
|
253
|
+
const componentRef = this.elRefMap.get(component);
|
|
254
|
+
if (componentRef) {
|
|
255
|
+
componentRef.destroy();
|
|
256
|
+
this.elRefMap.delete(component);
|
|
257
|
+
const unbindEvents = this.elEventsMap.get(component);
|
|
258
|
+
if (unbindEvents) {
|
|
259
|
+
unbindEvents();
|
|
260
|
+
this.elEventsMap.delete(component);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
resolve();
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
|
|
269
|
+
/**
|
|
270
|
+
* Wraps the injector with a custom injector that
|
|
271
|
+
* provides NavParams to the component.
|
|
272
|
+
*
|
|
273
|
+
* NavParams is a legacy feature from Ionic v3 that allows
|
|
274
|
+
* Angular developers to provide data to a component
|
|
275
|
+
* and access it by providing NavParams as a dependency
|
|
276
|
+
* in the constructor.
|
|
277
|
+
*
|
|
278
|
+
* The modern approach is to access the data directly
|
|
279
|
+
* from the component's class instance.
|
|
280
|
+
*/
|
|
281
|
+
const childInjector = Injector.create({
|
|
282
|
+
providers: getProviders(params),
|
|
283
|
+
parent: injector,
|
|
284
|
+
});
|
|
285
|
+
const componentRef = createComponent(component, {
|
|
286
|
+
environmentInjector,
|
|
287
|
+
elementInjector: childInjector,
|
|
288
|
+
});
|
|
289
|
+
const instance = componentRef.instance;
|
|
290
|
+
const hostElement = componentRef.location.nativeElement;
|
|
291
|
+
if (params) {
|
|
292
|
+
/**
|
|
293
|
+
* For modals and popovers, a reference to the component is
|
|
294
|
+
* added to `params` during the call to attachViewToDom. If
|
|
295
|
+
* a reference using this name is already set, this means
|
|
296
|
+
* the app is trying to use the name as a component prop,
|
|
297
|
+
* which will cause collisions.
|
|
298
|
+
*/
|
|
299
|
+
if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
|
|
300
|
+
console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
|
|
301
|
+
}
|
|
302
|
+
Object.assign(instance, params);
|
|
303
|
+
}
|
|
304
|
+
if (cssClasses) {
|
|
305
|
+
for (const cssClass of cssClasses) {
|
|
306
|
+
hostElement.classList.add(cssClass);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
|
|
310
|
+
container.appendChild(hostElement);
|
|
311
|
+
applicationRef.attachView(componentRef.hostView);
|
|
312
|
+
elRefMap.set(hostElement, componentRef);
|
|
313
|
+
elEventsMap.set(hostElement, unbindEvents);
|
|
314
|
+
return hostElement;
|
|
315
|
+
};
|
|
316
|
+
const LIFECYCLES = [
|
|
317
|
+
LIFECYCLE_WILL_ENTER,
|
|
318
|
+
LIFECYCLE_DID_ENTER,
|
|
319
|
+
LIFECYCLE_WILL_LEAVE,
|
|
320
|
+
LIFECYCLE_DID_LEAVE,
|
|
321
|
+
LIFECYCLE_WILL_UNLOAD,
|
|
322
|
+
];
|
|
323
|
+
const bindLifecycleEvents = (zone, instance, element) => {
|
|
324
|
+
return zone.run(() => {
|
|
325
|
+
const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
|
|
326
|
+
const handler = (ev) => instance[eventName](ev.detail);
|
|
327
|
+
element.addEventListener(eventName, handler);
|
|
328
|
+
return () => element.removeEventListener(eventName, handler);
|
|
329
|
+
});
|
|
330
|
+
return () => unregisters.forEach((fn) => fn());
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
const NavParamsToken = new InjectionToken('NavParamsToken');
|
|
334
|
+
const getProviders = (params) => {
|
|
335
|
+
return [
|
|
336
|
+
{
|
|
337
|
+
provide: NavParamsToken,
|
|
338
|
+
useValue: params,
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
provide: NavParams,
|
|
342
|
+
useFactory: provideNavParamsInjectable,
|
|
343
|
+
deps: [NavParamsToken],
|
|
344
|
+
},
|
|
345
|
+
];
|
|
346
|
+
};
|
|
347
|
+
const provideNavParamsInjectable = (params) => {
|
|
348
|
+
return new NavParams(params);
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
class ModalController extends OverlayBaseController {
|
|
352
|
+
constructor() {
|
|
353
|
+
super(modalController);
|
|
354
|
+
this.angularDelegate = inject(AngularDelegate);
|
|
355
|
+
this.injector = inject(Injector);
|
|
356
|
+
this.environmentInjector = inject(EnvironmentInjector);
|
|
357
|
+
}
|
|
358
|
+
create(opts) {
|
|
359
|
+
return super.create({
|
|
360
|
+
...opts,
|
|
361
|
+
delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'modal'),
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/** @nocollapse */ ModalController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
366
|
+
/** @nocollapse */ ModalController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController });
|
|
367
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, decorators: [{
|
|
368
|
+
type: Injectable
|
|
369
|
+
}], ctorParameters: function () { return []; } });
|
|
370
|
+
|
|
158
371
|
class PickerController extends OverlayBaseController {
|
|
159
372
|
constructor() {
|
|
160
373
|
super(pickerController);
|
|
@@ -169,6 +382,82 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
169
382
|
}]
|
|
170
383
|
}], ctorParameters: function () { return []; } });
|
|
171
384
|
|
|
385
|
+
class ToastController extends OverlayBaseController {
|
|
386
|
+
constructor() {
|
|
387
|
+
super(toastController);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/** @nocollapse */ ToastController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ToastController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
391
|
+
/** @nocollapse */ ToastController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ToastController, providedIn: 'root' });
|
|
392
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ToastController, decorators: [{
|
|
393
|
+
type: Injectable,
|
|
394
|
+
args: [{
|
|
395
|
+
providedIn: 'root',
|
|
396
|
+
}]
|
|
397
|
+
}], ctorParameters: function () { return []; } });
|
|
398
|
+
|
|
399
|
+
class AnimationController {
|
|
400
|
+
/**
|
|
401
|
+
* Create a new animation
|
|
402
|
+
*/
|
|
403
|
+
create(animationId) {
|
|
404
|
+
return createAnimation(animationId);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* EXPERIMENTAL
|
|
408
|
+
*
|
|
409
|
+
* Given a progression and a cubic bezier function,
|
|
410
|
+
* this utility returns the time value(s) at which the
|
|
411
|
+
* cubic bezier reaches the given time progression.
|
|
412
|
+
*
|
|
413
|
+
* If the cubic bezier never reaches the progression
|
|
414
|
+
* the result will be an empty array.
|
|
415
|
+
*
|
|
416
|
+
* This is most useful for switching between easing curves
|
|
417
|
+
* when doing a gesture animation (i.e. going from linear easing
|
|
418
|
+
* during a drag, to another easing when `progressEnd` is called)
|
|
419
|
+
*/
|
|
420
|
+
easingTime(p0, p1, p2, p3, progression) {
|
|
421
|
+
return getTimeGivenProgression(p0, p1, p2, p3, progression);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
/** @nocollapse */ AnimationController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AnimationController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
425
|
+
/** @nocollapse */ AnimationController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AnimationController, providedIn: 'root' });
|
|
426
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AnimationController, decorators: [{
|
|
427
|
+
type: Injectable,
|
|
428
|
+
args: [{
|
|
429
|
+
providedIn: 'root',
|
|
430
|
+
}]
|
|
431
|
+
}] });
|
|
432
|
+
|
|
433
|
+
class GestureController {
|
|
434
|
+
constructor(zone) {
|
|
435
|
+
this.zone = zone;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Create a new gesture
|
|
439
|
+
*/
|
|
440
|
+
create(opts, runInsideAngularZone = false) {
|
|
441
|
+
if (runInsideAngularZone) {
|
|
442
|
+
Object.getOwnPropertyNames(opts).forEach((key) => {
|
|
443
|
+
if (typeof opts[key] === 'function') {
|
|
444
|
+
const fn = opts[key];
|
|
445
|
+
opts[key] = (...props) => this.zone.run(() => fn(...props));
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
return createGesture(opts);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/** @nocollapse */ GestureController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GestureController, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
453
|
+
/** @nocollapse */ GestureController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GestureController, providedIn: 'root' });
|
|
454
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GestureController, decorators: [{
|
|
455
|
+
type: Injectable,
|
|
456
|
+
args: [{
|
|
457
|
+
providedIn: 'root',
|
|
458
|
+
}]
|
|
459
|
+
}], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
|
|
460
|
+
|
|
172
461
|
class DomController {
|
|
173
462
|
/**
|
|
174
463
|
* Schedules a task to run during the READ phase of the next frame.
|
|
@@ -717,199 +1006,6 @@ const getConfig = () => {
|
|
|
717
1006
|
return null;
|
|
718
1007
|
};
|
|
719
1008
|
|
|
720
|
-
/**
|
|
721
|
-
* @description
|
|
722
|
-
* NavParams are an object that exists on a page and can contain data for that particular view.
|
|
723
|
-
* Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
|
|
724
|
-
* option with a simple `get` method.
|
|
725
|
-
*
|
|
726
|
-
* @usage
|
|
727
|
-
* ```ts
|
|
728
|
-
* import { NavParams } from '@ionic/angular';
|
|
729
|
-
*
|
|
730
|
-
* export class MyClass{
|
|
731
|
-
*
|
|
732
|
-
* constructor(navParams: NavParams){
|
|
733
|
-
* // userParams is an object we have in our nav-parameters
|
|
734
|
-
* navParams.get('userParams');
|
|
735
|
-
* }
|
|
736
|
-
*
|
|
737
|
-
* }
|
|
738
|
-
* ```
|
|
739
|
-
*/
|
|
740
|
-
class NavParams {
|
|
741
|
-
constructor(data = {}) {
|
|
742
|
-
this.data = data;
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Get the value of a nav-parameter for the current view
|
|
746
|
-
*
|
|
747
|
-
* ```ts
|
|
748
|
-
* import { NavParams } from 'ionic-angular';
|
|
749
|
-
*
|
|
750
|
-
* export class MyClass{
|
|
751
|
-
* constructor(public navParams: NavParams){
|
|
752
|
-
* // userParams is an object we have in our nav-parameters
|
|
753
|
-
* this.navParams.get('userParams');
|
|
754
|
-
* }
|
|
755
|
-
* }
|
|
756
|
-
* ```
|
|
757
|
-
*
|
|
758
|
-
* @param param Which param you want to look up
|
|
759
|
-
*/
|
|
760
|
-
get(param) {
|
|
761
|
-
return this.data[param];
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
// TODO(FW-2827): types
|
|
766
|
-
class AngularDelegate {
|
|
767
|
-
constructor() {
|
|
768
|
-
this.zone = inject(NgZone);
|
|
769
|
-
this.applicationRef = inject(ApplicationRef);
|
|
770
|
-
}
|
|
771
|
-
create(environmentInjector, injector, elementReferenceKey) {
|
|
772
|
-
return new AngularFrameworkDelegate(environmentInjector, injector, this.applicationRef, this.zone, elementReferenceKey);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
/** @nocollapse */ AngularDelegate.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
776
|
-
/** @nocollapse */ AngularDelegate.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate });
|
|
777
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, decorators: [{
|
|
778
|
-
type: Injectable
|
|
779
|
-
}] });
|
|
780
|
-
class AngularFrameworkDelegate {
|
|
781
|
-
constructor(environmentInjector, injector, applicationRef, zone, elementReferenceKey) {
|
|
782
|
-
this.environmentInjector = environmentInjector;
|
|
783
|
-
this.injector = injector;
|
|
784
|
-
this.applicationRef = applicationRef;
|
|
785
|
-
this.zone = zone;
|
|
786
|
-
this.elementReferenceKey = elementReferenceKey;
|
|
787
|
-
this.elRefMap = new WeakMap();
|
|
788
|
-
this.elEventsMap = new WeakMap();
|
|
789
|
-
}
|
|
790
|
-
attachViewToDom(container, component, params, cssClasses) {
|
|
791
|
-
return this.zone.run(() => {
|
|
792
|
-
return new Promise((resolve) => {
|
|
793
|
-
const componentProps = {
|
|
794
|
-
...params,
|
|
795
|
-
};
|
|
796
|
-
/**
|
|
797
|
-
* Ionic Angular passes a reference to a modal
|
|
798
|
-
* or popover that can be accessed using a
|
|
799
|
-
* variable in the overlay component. If
|
|
800
|
-
* elementReferenceKey is defined, then we should
|
|
801
|
-
* pass a reference to the component using
|
|
802
|
-
* elementReferenceKey as the key.
|
|
803
|
-
*/
|
|
804
|
-
if (this.elementReferenceKey !== undefined) {
|
|
805
|
-
componentProps[this.elementReferenceKey] = container;
|
|
806
|
-
}
|
|
807
|
-
const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
|
|
808
|
-
resolve(el);
|
|
809
|
-
});
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
removeViewFromDom(_container, component) {
|
|
813
|
-
return this.zone.run(() => {
|
|
814
|
-
return new Promise((resolve) => {
|
|
815
|
-
const componentRef = this.elRefMap.get(component);
|
|
816
|
-
if (componentRef) {
|
|
817
|
-
componentRef.destroy();
|
|
818
|
-
this.elRefMap.delete(component);
|
|
819
|
-
const unbindEvents = this.elEventsMap.get(component);
|
|
820
|
-
if (unbindEvents) {
|
|
821
|
-
unbindEvents();
|
|
822
|
-
this.elEventsMap.delete(component);
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
resolve();
|
|
826
|
-
});
|
|
827
|
-
});
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
|
|
831
|
-
/**
|
|
832
|
-
* Wraps the injector with a custom injector that
|
|
833
|
-
* provides NavParams to the component.
|
|
834
|
-
*
|
|
835
|
-
* NavParams is a legacy feature from Ionic v3 that allows
|
|
836
|
-
* Angular developers to provide data to a component
|
|
837
|
-
* and access it by providing NavParams as a dependency
|
|
838
|
-
* in the constructor.
|
|
839
|
-
*
|
|
840
|
-
* The modern approach is to access the data directly
|
|
841
|
-
* from the component's class instance.
|
|
842
|
-
*/
|
|
843
|
-
const childInjector = Injector.create({
|
|
844
|
-
providers: getProviders(params),
|
|
845
|
-
parent: injector,
|
|
846
|
-
});
|
|
847
|
-
const componentRef = createComponent(component, {
|
|
848
|
-
environmentInjector,
|
|
849
|
-
elementInjector: childInjector,
|
|
850
|
-
});
|
|
851
|
-
const instance = componentRef.instance;
|
|
852
|
-
const hostElement = componentRef.location.nativeElement;
|
|
853
|
-
if (params) {
|
|
854
|
-
/**
|
|
855
|
-
* For modals and popovers, a reference to the component is
|
|
856
|
-
* added to `params` during the call to attachViewToDom. If
|
|
857
|
-
* a reference using this name is already set, this means
|
|
858
|
-
* the app is trying to use the name as a component prop,
|
|
859
|
-
* which will cause collisions.
|
|
860
|
-
*/
|
|
861
|
-
if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
|
|
862
|
-
console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
|
|
863
|
-
}
|
|
864
|
-
Object.assign(instance, params);
|
|
865
|
-
}
|
|
866
|
-
if (cssClasses) {
|
|
867
|
-
for (const cssClass of cssClasses) {
|
|
868
|
-
hostElement.classList.add(cssClass);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
|
|
872
|
-
container.appendChild(hostElement);
|
|
873
|
-
applicationRef.attachView(componentRef.hostView);
|
|
874
|
-
elRefMap.set(hostElement, componentRef);
|
|
875
|
-
elEventsMap.set(hostElement, unbindEvents);
|
|
876
|
-
return hostElement;
|
|
877
|
-
};
|
|
878
|
-
const LIFECYCLES = [
|
|
879
|
-
LIFECYCLE_WILL_ENTER,
|
|
880
|
-
LIFECYCLE_DID_ENTER,
|
|
881
|
-
LIFECYCLE_WILL_LEAVE,
|
|
882
|
-
LIFECYCLE_DID_LEAVE,
|
|
883
|
-
LIFECYCLE_WILL_UNLOAD,
|
|
884
|
-
];
|
|
885
|
-
const bindLifecycleEvents = (zone, instance, element) => {
|
|
886
|
-
return zone.run(() => {
|
|
887
|
-
const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
|
|
888
|
-
const handler = (ev) => instance[eventName](ev.detail);
|
|
889
|
-
element.addEventListener(eventName, handler);
|
|
890
|
-
return () => element.removeEventListener(eventName, handler);
|
|
891
|
-
});
|
|
892
|
-
return () => unregisters.forEach((fn) => fn());
|
|
893
|
-
});
|
|
894
|
-
};
|
|
895
|
-
const NavParamsToken = new InjectionToken('NavParamsToken');
|
|
896
|
-
const getProviders = (params) => {
|
|
897
|
-
return [
|
|
898
|
-
{
|
|
899
|
-
provide: NavParamsToken,
|
|
900
|
-
useValue: params,
|
|
901
|
-
},
|
|
902
|
-
{
|
|
903
|
-
provide: NavParams,
|
|
904
|
-
useFactory: provideNavParamsInjectable,
|
|
905
|
-
deps: [NavParamsToken],
|
|
906
|
-
},
|
|
907
|
-
];
|
|
908
|
-
};
|
|
909
|
-
const provideNavParamsInjectable = (params) => {
|
|
910
|
-
return new NavParams(params);
|
|
911
|
-
};
|
|
912
|
-
|
|
913
1009
|
// TODO: Is there a way we can grab this from angular-component-lib instead?
|
|
914
1010
|
const proxyInputs = (Cmp, inputs) => {
|
|
915
1011
|
const Prototype = Cmp.prototype;
|
|
@@ -2478,5 +2574,5 @@ class IonicRouteStrategy {
|
|
|
2478
2574
|
* Generated bundle index. Do not edit.
|
|
2479
2575
|
*/
|
|
2480
2576
|
|
|
2481
|
-
export { AlertController, AngularDelegate, Config, ConfigToken, DomController, IonBackButton, IonModal, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, LoadingController, MenuController, NavController, NavParams, OverlayBaseController, PickerController, Platform, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ValueAccessor, bindLifecycleEvents, provideComponentInputBinding, raf, setIonicClasses };
|
|
2577
|
+
export { AlertController, AngularDelegate, AnimationController, Config, ConfigToken, DomController, GestureController, IonBackButton, IonModal, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, LoadingController, MenuController, ModalController, NavController, NavParams, OverlayBaseController, PickerController, Platform, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ToastController, ValueAccessor, bindLifecycleEvents, provideComponentInputBinding, raf, setIonicClasses };
|
|
2482
2578
|
//# sourceMappingURL=ionic-angular-common.mjs.map
|