@ionic/angular 7.5.5-dev.11699885110.10e38569 → 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.
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
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';
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 { __awaiter, __decorate } from 'tslib';
5
5
  import * as i3 from '@angular/router';
6
6
  import { NavigationStart, PRIMARY_OUTLET, ChildrenOutletContexts, ActivatedRoute, Router } from '@angular/router';
@@ -155,6 +155,214 @@ 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 = Object.assign({}, params);
232
+ /**
233
+ * Ionic Angular passes a reference to a modal
234
+ * or popover that can be accessed using a
235
+ * variable in the overlay component. If
236
+ * elementReferenceKey is defined, then we should
237
+ * pass a reference to the component using
238
+ * elementReferenceKey as the key.
239
+ */
240
+ if (this.elementReferenceKey !== undefined) {
241
+ componentProps[this.elementReferenceKey] = container;
242
+ }
243
+ const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
244
+ resolve(el);
245
+ });
246
+ });
247
+ }
248
+ removeViewFromDom(_container, component) {
249
+ return this.zone.run(() => {
250
+ return new Promise((resolve) => {
251
+ const componentRef = this.elRefMap.get(component);
252
+ if (componentRef) {
253
+ componentRef.destroy();
254
+ this.elRefMap.delete(component);
255
+ const unbindEvents = this.elEventsMap.get(component);
256
+ if (unbindEvents) {
257
+ unbindEvents();
258
+ this.elEventsMap.delete(component);
259
+ }
260
+ }
261
+ resolve();
262
+ });
263
+ });
264
+ }
265
+ }
266
+ const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
267
+ /**
268
+ * Wraps the injector with a custom injector that
269
+ * provides NavParams to the component.
270
+ *
271
+ * NavParams is a legacy feature from Ionic v3 that allows
272
+ * Angular developers to provide data to a component
273
+ * and access it by providing NavParams as a dependency
274
+ * in the constructor.
275
+ *
276
+ * The modern approach is to access the data directly
277
+ * from the component's class instance.
278
+ */
279
+ const childInjector = Injector.create({
280
+ providers: getProviders(params),
281
+ parent: injector,
282
+ });
283
+ const componentRef = createComponent(component, {
284
+ environmentInjector,
285
+ elementInjector: childInjector,
286
+ });
287
+ const instance = componentRef.instance;
288
+ const hostElement = componentRef.location.nativeElement;
289
+ if (params) {
290
+ /**
291
+ * For modals and popovers, a reference to the component is
292
+ * added to `params` during the call to attachViewToDom. If
293
+ * a reference using this name is already set, this means
294
+ * the app is trying to use the name as a component prop,
295
+ * which will cause collisions.
296
+ */
297
+ if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
298
+ console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
299
+ }
300
+ Object.assign(instance, params);
301
+ }
302
+ if (cssClasses) {
303
+ for (const cssClass of cssClasses) {
304
+ hostElement.classList.add(cssClass);
305
+ }
306
+ }
307
+ const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
308
+ container.appendChild(hostElement);
309
+ applicationRef.attachView(componentRef.hostView);
310
+ elRefMap.set(hostElement, componentRef);
311
+ elEventsMap.set(hostElement, unbindEvents);
312
+ return hostElement;
313
+ };
314
+ const LIFECYCLES = [
315
+ LIFECYCLE_WILL_ENTER,
316
+ LIFECYCLE_DID_ENTER,
317
+ LIFECYCLE_WILL_LEAVE,
318
+ LIFECYCLE_DID_LEAVE,
319
+ LIFECYCLE_WILL_UNLOAD,
320
+ ];
321
+ const bindLifecycleEvents = (zone, instance, element) => {
322
+ return zone.run(() => {
323
+ const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
324
+ const handler = (ev) => instance[eventName](ev.detail);
325
+ element.addEventListener(eventName, handler);
326
+ return () => element.removeEventListener(eventName, handler);
327
+ });
328
+ return () => unregisters.forEach((fn) => fn());
329
+ });
330
+ };
331
+ const NavParamsToken = new InjectionToken('NavParamsToken');
332
+ const getProviders = (params) => {
333
+ return [
334
+ {
335
+ provide: NavParamsToken,
336
+ useValue: params,
337
+ },
338
+ {
339
+ provide: NavParams,
340
+ useFactory: provideNavParamsInjectable,
341
+ deps: [NavParamsToken],
342
+ },
343
+ ];
344
+ };
345
+ const provideNavParamsInjectable = (params) => {
346
+ return new NavParams(params);
347
+ };
348
+
349
+ class ModalController extends OverlayBaseController {
350
+ constructor() {
351
+ super(modalController);
352
+ this.angularDelegate = inject(AngularDelegate);
353
+ this.injector = inject(Injector);
354
+ this.environmentInjector = inject(EnvironmentInjector);
355
+ }
356
+ create(opts) {
357
+ return super.create(Object.assign(Object.assign({}, opts), { delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'modal') }));
358
+ }
359
+ }
360
+ /** @nocollapse */ ModalController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
361
+ /** @nocollapse */ ModalController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController });
362
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalController, decorators: [{
363
+ type: Injectable
364
+ }], ctorParameters: function () { return []; } });
365
+
158
366
  class PickerController extends OverlayBaseController {
159
367
  constructor() {
160
368
  super(pickerController);
@@ -801,197 +1009,6 @@ const getConfig = () => {
801
1009
  return null;
802
1010
  };
803
1011
 
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
-
995
1012
  // TODO: Is there a way we can grab this from angular-component-lib instead?
996
1013
  const proxyInputs = (Cmp, inputs) => {
997
1014
  const Prototype = Cmp.prototype;
@@ -2571,5 +2588,5 @@ class IonicRouteStrategy {
2571
2588
  * Generated bundle index. Do not edit.
2572
2589
  */
2573
2590
 
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 };
2591
+ 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 };
2575
2592
  //# sourceMappingURL=ionic-angular-common.mjs.map