@ionic/angular 8.6.7 → 8.7.1-dev.11753971948.1b297d94

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.
@@ -10,6 +10,48 @@ import { __decorate } from 'tslib';
10
10
  import { filter, switchMap, distinctUntilChanged } from 'rxjs/operators';
11
11
  import { NgControl } from '@angular/forms';
12
12
 
13
+ class DomController {
14
+ /**
15
+ * Schedules a task to run during the READ phase of the next frame.
16
+ * This task should only read the DOM, but never modify it.
17
+ */
18
+ read(cb) {
19
+ getQueue().read(cb);
20
+ }
21
+ /**
22
+ * Schedules a task to run during the WRITE phase of the next frame.
23
+ * This task should write the DOM, but never READ it.
24
+ */
25
+ write(cb) {
26
+ getQueue().write(cb);
27
+ }
28
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DomController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
29
+ /** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DomController, providedIn: 'root' });
30
+ }
31
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DomController, decorators: [{
32
+ type: Injectable,
33
+ args: [{
34
+ providedIn: 'root',
35
+ }]
36
+ }] });
37
+ const getQueue = () => {
38
+ const win = typeof window !== 'undefined' ? window : null;
39
+ if (win != null) {
40
+ const Ionic = win.Ionic;
41
+ if (Ionic?.queue) {
42
+ return Ionic.queue;
43
+ }
44
+ return {
45
+ read: (cb) => win.requestAnimationFrame(cb),
46
+ write: (cb) => win.requestAnimationFrame(cb),
47
+ };
48
+ }
49
+ return {
50
+ read: (cb) => cb(),
51
+ write: (cb) => cb(),
52
+ };
53
+ };
54
+
13
55
  class MenuController {
14
56
  menuController;
15
57
  constructor(menuController) {
@@ -124,48 +166,6 @@ class MenuController {
124
166
  }
125
167
  }
126
168
 
127
- class DomController {
128
- /**
129
- * Schedules a task to run during the READ phase of the next frame.
130
- * This task should only read the DOM, but never modify it.
131
- */
132
- read(cb) {
133
- getQueue().read(cb);
134
- }
135
- /**
136
- * Schedules a task to run during the WRITE phase of the next frame.
137
- * This task should write the DOM, but never READ it.
138
- */
139
- write(cb) {
140
- getQueue().write(cb);
141
- }
142
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DomController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
143
- /** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DomController, providedIn: 'root' });
144
- }
145
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DomController, decorators: [{
146
- type: Injectable,
147
- args: [{
148
- providedIn: 'root',
149
- }]
150
- }] });
151
- const getQueue = () => {
152
- const win = typeof window !== 'undefined' ? window : null;
153
- if (win != null) {
154
- const Ionic = win.Ionic;
155
- if (Ionic?.queue) {
156
- return Ionic.queue;
157
- }
158
- return {
159
- read: (cb) => win.requestAnimationFrame(cb),
160
- write: (cb) => win.requestAnimationFrame(cb),
161
- };
162
- }
163
- return {
164
- read: (cb) => cb(),
165
- write: (cb) => cb(),
166
- };
167
- };
168
-
169
169
  class Platform {
170
170
  doc;
171
171
  _readyPromise;
@@ -728,6 +728,8 @@ class NavParams {
728
728
  }
729
729
  }
730
730
 
731
+ // Token for injecting the modal element
732
+ const IonModalToken = new InjectionToken('IonModalToken');
731
733
  // TODO(FW-2827): types
732
734
  class AngularDelegate {
733
735
  zone = inject(NgZone);
@@ -812,8 +814,17 @@ const attachView = (zone, environmentInjector, injector, applicationRef, elRefMa
812
814
  * The modern approach is to access the data directly
813
815
  * from the component's class instance.
814
816
  */
817
+ const providers = getProviders(params);
818
+ // If this is an ion-modal, provide the modal element as an injectable
819
+ // so components inside the modal can inject it directly
820
+ if (container.tagName.toLowerCase() === 'ion-modal') {
821
+ providers.push({
822
+ provide: IonModalToken,
823
+ useValue: container,
824
+ });
825
+ }
815
826
  const childInjector = Injector.create({
816
- providers: getProviders(params),
827
+ providers,
817
828
  parent: injector,
818
829
  });
819
830
  const componentRef = createComponent(component, {
@@ -958,31 +969,39 @@ function ProxyCmp(opts) {
958
969
  return decorator;
959
970
  }
960
971
 
961
- const POPOVER_INPUTS = [
962
- 'alignment',
972
+ const MODAL_INPUTS = [
963
973
  'animated',
964
- 'arrow',
965
974
  'keepContentsMounted',
975
+ 'backdropBreakpoint',
966
976
  'backdropDismiss',
977
+ 'breakpoints',
978
+ 'canDismiss',
967
979
  'cssClass',
968
- 'dismissOnSelect',
969
980
  'enterAnimation',
981
+ 'expandToScroll',
970
982
  'event',
971
983
  'focusTrap',
984
+ 'handle',
985
+ 'handleBehavior',
986
+ 'initialBreakpoint',
972
987
  'isOpen',
973
988
  'keyboardClose',
974
989
  'leaveAnimation',
975
990
  'mode',
991
+ 'presentingElement',
976
992
  'showBackdrop',
977
993
  'translucent',
978
994
  'trigger',
979
- 'triggerAction',
980
- 'reference',
981
- 'size',
982
- 'side',
983
995
  ];
984
- const POPOVER_METHODS = ['present', 'dismiss', 'onDidDismiss', 'onWillDismiss'];
985
- let IonPopover = class IonPopover {
996
+ const MODAL_METHODS = [
997
+ 'present',
998
+ 'dismiss',
999
+ 'onDidDismiss',
1000
+ 'onWillDismiss',
1001
+ 'setCurrentBreakpoint',
1002
+ 'getCurrentBreakpoint',
1003
+ ];
1004
+ let IonModal = class IonModal {
986
1005
  z;
987
1006
  // TODO(FW-2827): type
988
1007
  template;
@@ -1000,23 +1019,24 @@ let IonPopover = class IonPopover {
1000
1019
  c.detectChanges();
1001
1020
  });
1002
1021
  proxyOutputs(this, this.el, [
1003
- 'ionPopoverDidPresent',
1004
- 'ionPopoverWillPresent',
1005
- 'ionPopoverWillDismiss',
1006
- 'ionPopoverDidDismiss',
1022
+ 'ionModalDidPresent',
1023
+ 'ionModalWillPresent',
1024
+ 'ionModalWillDismiss',
1025
+ 'ionModalDidDismiss',
1026
+ 'ionBreakpointDidChange',
1007
1027
  'didPresent',
1008
1028
  'willPresent',
1009
1029
  'willDismiss',
1010
1030
  'didDismiss',
1011
1031
  ]);
1012
1032
  }
1013
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonPopover, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1014
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: IonPopover, selector: "ion-popover", inputs: { alignment: "alignment", animated: "animated", arrow: "arrow", keepContentsMounted: "keepContentsMounted", backdropDismiss: "backdropDismiss", cssClass: "cssClass", dismissOnSelect: "dismissOnSelect", enterAnimation: "enterAnimation", event: "event", focusTrap: "focusTrap", isOpen: "isOpen", keyboardClose: "keyboardClose", leaveAnimation: "leaveAnimation", mode: "mode", showBackdrop: "showBackdrop", translucent: "translucent", trigger: "trigger", triggerAction: "triggerAction", reference: "reference", size: "size", side: "side" }, queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 });
1033
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonModal, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1034
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: IonModal, selector: "ion-modal", inputs: { animated: "animated", keepContentsMounted: "keepContentsMounted", backdropBreakpoint: "backdropBreakpoint", backdropDismiss: "backdropDismiss", breakpoints: "breakpoints", canDismiss: "canDismiss", cssClass: "cssClass", enterAnimation: "enterAnimation", expandToScroll: "expandToScroll", event: "event", focusTrap: "focusTrap", handle: "handle", handleBehavior: "handleBehavior", initialBreakpoint: "initialBreakpoint", isOpen: "isOpen", keyboardClose: "keyboardClose", leaveAnimation: "leaveAnimation", mode: "mode", presentingElement: "presentingElement", showBackdrop: "showBackdrop", translucent: "translucent", trigger: "trigger" }, queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 });
1015
1035
  };
1016
- IonPopover = __decorate([
1036
+ IonModal = __decorate([
1017
1037
  ProxyCmp({
1018
- inputs: POPOVER_INPUTS,
1019
- methods: POPOVER_METHODS,
1038
+ inputs: MODAL_INPUTS,
1039
+ methods: MODAL_METHODS,
1020
1040
  })
1021
1041
  /**
1022
1042
  * @Component extends from @Directive
@@ -1024,52 +1044,44 @@ IonPopover = __decorate([
1024
1044
  * do not need to re-define them for the
1025
1045
  * lazy loaded popover.
1026
1046
  */
1027
- ], IonPopover);
1028
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonPopover, decorators: [{
1047
+ ], IonModal);
1048
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonModal, decorators: [{
1029
1049
  type: Directive,
1030
1050
  args: [{
1031
- selector: 'ion-popover',
1051
+ selector: 'ion-modal',
1032
1052
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1033
- inputs: POPOVER_INPUTS,
1053
+ inputs: MODAL_INPUTS,
1034
1054
  }]
1035
1055
  }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { template: [{
1036
1056
  type: ContentChild,
1037
1057
  args: [TemplateRef, { static: false }]
1038
1058
  }] } });
1039
1059
 
1040
- const MODAL_INPUTS = [
1060
+ const POPOVER_INPUTS = [
1061
+ 'alignment',
1041
1062
  'animated',
1063
+ 'arrow',
1042
1064
  'keepContentsMounted',
1043
- 'backdropBreakpoint',
1044
1065
  'backdropDismiss',
1045
- 'breakpoints',
1046
- 'canDismiss',
1047
1066
  'cssClass',
1067
+ 'dismissOnSelect',
1048
1068
  'enterAnimation',
1049
- 'expandToScroll',
1050
1069
  'event',
1051
1070
  'focusTrap',
1052
- 'handle',
1053
- 'handleBehavior',
1054
- 'initialBreakpoint',
1055
1071
  'isOpen',
1056
1072
  'keyboardClose',
1057
1073
  'leaveAnimation',
1058
1074
  'mode',
1059
- 'presentingElement',
1060
1075
  'showBackdrop',
1061
1076
  'translucent',
1062
1077
  'trigger',
1078
+ 'triggerAction',
1079
+ 'reference',
1080
+ 'size',
1081
+ 'side',
1063
1082
  ];
1064
- const MODAL_METHODS = [
1065
- 'present',
1066
- 'dismiss',
1067
- 'onDidDismiss',
1068
- 'onWillDismiss',
1069
- 'setCurrentBreakpoint',
1070
- 'getCurrentBreakpoint',
1071
- ];
1072
- let IonModal = class IonModal {
1083
+ const POPOVER_METHODS = ['present', 'dismiss', 'onDidDismiss', 'onWillDismiss'];
1084
+ let IonPopover = class IonPopover {
1073
1085
  z;
1074
1086
  // TODO(FW-2827): type
1075
1087
  template;
@@ -1087,24 +1099,23 @@ let IonModal = class IonModal {
1087
1099
  c.detectChanges();
1088
1100
  });
1089
1101
  proxyOutputs(this, this.el, [
1090
- 'ionModalDidPresent',
1091
- 'ionModalWillPresent',
1092
- 'ionModalWillDismiss',
1093
- 'ionModalDidDismiss',
1094
- 'ionBreakpointDidChange',
1102
+ 'ionPopoverDidPresent',
1103
+ 'ionPopoverWillPresent',
1104
+ 'ionPopoverWillDismiss',
1105
+ 'ionPopoverDidDismiss',
1095
1106
  'didPresent',
1096
1107
  'willPresent',
1097
1108
  'willDismiss',
1098
1109
  'didDismiss',
1099
1110
  ]);
1100
1111
  }
1101
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonModal, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1102
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: IonModal, selector: "ion-modal", inputs: { animated: "animated", keepContentsMounted: "keepContentsMounted", backdropBreakpoint: "backdropBreakpoint", backdropDismiss: "backdropDismiss", breakpoints: "breakpoints", canDismiss: "canDismiss", cssClass: "cssClass", enterAnimation: "enterAnimation", expandToScroll: "expandToScroll", event: "event", focusTrap: "focusTrap", handle: "handle", handleBehavior: "handleBehavior", initialBreakpoint: "initialBreakpoint", isOpen: "isOpen", keyboardClose: "keyboardClose", leaveAnimation: "leaveAnimation", mode: "mode", presentingElement: "presentingElement", showBackdrop: "showBackdrop", translucent: "translucent", trigger: "trigger" }, queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 });
1112
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonPopover, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1113
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: IonPopover, selector: "ion-popover", inputs: { alignment: "alignment", animated: "animated", arrow: "arrow", keepContentsMounted: "keepContentsMounted", backdropDismiss: "backdropDismiss", cssClass: "cssClass", dismissOnSelect: "dismissOnSelect", enterAnimation: "enterAnimation", event: "event", focusTrap: "focusTrap", isOpen: "isOpen", keyboardClose: "keyboardClose", leaveAnimation: "leaveAnimation", mode: "mode", showBackdrop: "showBackdrop", translucent: "translucent", trigger: "trigger", triggerAction: "triggerAction", reference: "reference", size: "size", side: "side" }, queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 });
1103
1114
  };
1104
- IonModal = __decorate([
1115
+ IonPopover = __decorate([
1105
1116
  ProxyCmp({
1106
- inputs: MODAL_INPUTS,
1107
- methods: MODAL_METHODS,
1117
+ inputs: POPOVER_INPUTS,
1118
+ methods: POPOVER_METHODS,
1108
1119
  })
1109
1120
  /**
1110
1121
  * @Component extends from @Directive
@@ -1112,13 +1123,13 @@ IonModal = __decorate([
1112
1123
  * do not need to re-define them for the
1113
1124
  * lazy loaded popover.
1114
1125
  */
1115
- ], IonModal);
1116
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonModal, decorators: [{
1126
+ ], IonPopover);
1127
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonPopover, decorators: [{
1117
1128
  type: Directive,
1118
1129
  args: [{
1119
- selector: 'ion-modal',
1130
+ selector: 'ion-popover',
1120
1131
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1121
- inputs: MODAL_INPUTS,
1132
+ inputs: POPOVER_INPUTS,
1122
1133
  }]
1123
1134
  }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { template: [{
1124
1135
  type: ContentChild,
@@ -1944,64 +1955,265 @@ function componentInputBindingFactory(router) {
1944
1955
  return null;
1945
1956
  }
1946
1957
 
1947
- const BACK_BUTTON_INPUTS = ['color', 'defaultHref', 'disabled', 'icon', 'mode', 'routerAnimation', 'text', 'type'];
1948
- let IonBackButton = class IonBackButton {
1949
- routerOutlet;
1950
- navCtrl;
1951
- config;
1952
- r;
1953
- z;
1954
- el;
1955
- constructor(routerOutlet, navCtrl, config, r, z, c) {
1956
- this.routerOutlet = routerOutlet;
1957
- this.navCtrl = navCtrl;
1958
- this.config = config;
1959
- this.r = r;
1960
- this.z = z;
1961
- c.detach();
1962
- this.el = this.r.nativeElement;
1958
+ const raf = (h) => {
1959
+ if (typeof __zone_symbol__requestAnimationFrame === 'function') {
1960
+ return __zone_symbol__requestAnimationFrame(h);
1963
1961
  }
1964
- /**
1965
- * @internal
1966
- */
1967
- onClick(ev) {
1968
- const defaultHref = this.defaultHref || this.config.get('backButtonDefaultHref');
1969
- if (this.routerOutlet?.canGoBack()) {
1970
- this.navCtrl.setDirection('back', undefined, undefined, this.routerAnimation);
1971
- this.routerOutlet.pop();
1972
- ev.preventDefault();
1973
- }
1974
- else if (defaultHref != null) {
1975
- this.navCtrl.navigateBack(defaultHref, { animation: this.routerAnimation });
1976
- ev.preventDefault();
1977
- }
1962
+ if (typeof requestAnimationFrame === 'function') {
1963
+ return requestAnimationFrame(h);
1978
1964
  }
1979
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonBackButton, deps: [{ token: IonRouterOutlet, optional: true }, { token: NavController }, { token: Config }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1980
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: IonBackButton, inputs: { color: "color", defaultHref: "defaultHref", disabled: "disabled", icon: "icon", mode: "mode", routerAnimation: "routerAnimation", text: "text", type: "type" }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 });
1965
+ return setTimeout(h);
1981
1966
  };
1982
- IonBackButton = __decorate([
1983
- ProxyCmp({
1984
- inputs: BACK_BUTTON_INPUTS,
1985
- })
1986
- ], IonBackButton);
1987
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonBackButton, decorators: [{
1988
- type: Directive,
1989
- args: [{
1990
- // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1991
- inputs: BACK_BUTTON_INPUTS,
1992
- }]
1993
- }], ctorParameters: function () { return [{ type: IonRouterOutlet, decorators: [{
1994
- type: Optional
1995
- }] }, { type: NavController }, { type: Config }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { onClick: [{
1996
- type: HostListener,
1997
- args: ['click', ['$event']]
1998
- }] } });
1999
1967
 
2000
- /**
2001
- * Adds support for Ionic routing directions and animations to the base Angular router link directive.
2002
- *
2003
- * When the router link is clicked, the directive will assign the direction and
2004
- * animation so that the routing integration will transition correctly.
1968
+ // TODO(FW-2827): types
1969
+ class ValueAccessor {
1970
+ injector;
1971
+ elementRef;
1972
+ onChange = () => {
1973
+ /**/
1974
+ };
1975
+ onTouched = () => {
1976
+ /**/
1977
+ };
1978
+ lastValue;
1979
+ statusChanges;
1980
+ constructor(injector, elementRef) {
1981
+ this.injector = injector;
1982
+ this.elementRef = elementRef;
1983
+ }
1984
+ writeValue(value) {
1985
+ this.elementRef.nativeElement.value = this.lastValue = value;
1986
+ setIonicClasses(this.elementRef);
1987
+ }
1988
+ /**
1989
+ * Notifies the ControlValueAccessor of a change in the value of the control.
1990
+ *
1991
+ * This is called by each of the ValueAccessor directives when we want to update
1992
+ * the status and validity of the form control. For example with text components this
1993
+ * is called when the ionInput event is fired. For select components this is called
1994
+ * when the ionChange event is fired.
1995
+ *
1996
+ * This also updates the Ionic form status classes on the element.
1997
+ *
1998
+ * @param el The component element.
1999
+ * @param value The new value of the control.
2000
+ */
2001
+ handleValueChange(el, value) {
2002
+ if (el === this.elementRef.nativeElement) {
2003
+ if (value !== this.lastValue) {
2004
+ this.lastValue = value;
2005
+ this.onChange(value);
2006
+ }
2007
+ setIonicClasses(this.elementRef);
2008
+ }
2009
+ }
2010
+ _handleBlurEvent(el) {
2011
+ if (el === this.elementRef.nativeElement) {
2012
+ this.onTouched();
2013
+ setIonicClasses(this.elementRef);
2014
+ // When ion-radio is blurred, el and this.elementRef.nativeElement are
2015
+ // different so we need to check if the closest ion-radio-group is the same
2016
+ // as this.elementRef.nativeElement and if so, we need to mark the radio group
2017
+ // as touched
2018
+ }
2019
+ else if (el.closest('ion-radio-group') === this.elementRef.nativeElement) {
2020
+ this.onTouched();
2021
+ }
2022
+ }
2023
+ registerOnChange(fn) {
2024
+ this.onChange = fn;
2025
+ }
2026
+ registerOnTouched(fn) {
2027
+ this.onTouched = fn;
2028
+ }
2029
+ setDisabledState(isDisabled) {
2030
+ this.elementRef.nativeElement.disabled = isDisabled;
2031
+ }
2032
+ ngOnDestroy() {
2033
+ if (this.statusChanges) {
2034
+ this.statusChanges.unsubscribe();
2035
+ }
2036
+ }
2037
+ ngAfterViewInit() {
2038
+ let ngControl;
2039
+ try {
2040
+ ngControl = this.injector.get(NgControl);
2041
+ }
2042
+ catch {
2043
+ /* No FormControl or ngModel binding */
2044
+ }
2045
+ if (!ngControl) {
2046
+ return;
2047
+ }
2048
+ // Listen for changes in validity, disabled, or pending states
2049
+ if (ngControl.statusChanges) {
2050
+ this.statusChanges = ngControl.statusChanges.subscribe(() => setIonicClasses(this.elementRef));
2051
+ }
2052
+ /**
2053
+ * TODO FW-2787: Remove this in favor of https://github.com/angular/angular/issues/10887
2054
+ * whenever it is implemented.
2055
+ */
2056
+ const formControl = ngControl.control;
2057
+ if (formControl) {
2058
+ const methodsToPatch = ['markAsTouched', 'markAllAsTouched', 'markAsUntouched', 'markAsDirty', 'markAsPristine'];
2059
+ methodsToPatch.forEach((method) => {
2060
+ if (typeof formControl[method] !== 'undefined') {
2061
+ const oldFn = formControl[method].bind(formControl);
2062
+ formControl[method] = (...params) => {
2063
+ oldFn(...params);
2064
+ setIonicClasses(this.elementRef);
2065
+ };
2066
+ }
2067
+ });
2068
+ }
2069
+ }
2070
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ValueAccessor, deps: [{ token: i0.Injector }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
2071
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: ValueAccessor, host: { listeners: { "ionBlur": "_handleBlurEvent($event.target)" } }, ngImport: i0 });
2072
+ }
2073
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ValueAccessor, decorators: [{
2074
+ type: Directive
2075
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
2076
+ type: HostListener,
2077
+ args: ['ionBlur', ['$event.target']]
2078
+ }] } });
2079
+ const setIonicClasses = (element) => {
2080
+ raf(() => {
2081
+ const input = element.nativeElement;
2082
+ const hasValue = input.value != null && input.value.toString().length > 0;
2083
+ const classes = getClasses(input);
2084
+ setClasses(input, classes);
2085
+ const item = input.closest('ion-item');
2086
+ if (item) {
2087
+ if (hasValue) {
2088
+ setClasses(item, [...classes, 'item-has-value']);
2089
+ }
2090
+ else {
2091
+ setClasses(item, classes);
2092
+ }
2093
+ }
2094
+ });
2095
+ };
2096
+ const getClasses = (element) => {
2097
+ const classList = element.classList;
2098
+ const classes = [];
2099
+ for (let i = 0; i < classList.length; i++) {
2100
+ const item = classList.item(i);
2101
+ if (item !== null && startsWith(item, 'ng-')) {
2102
+ classes.push(`ion-${item.substring(3)}`);
2103
+ }
2104
+ }
2105
+ return classes;
2106
+ };
2107
+ const setClasses = (element, classes) => {
2108
+ const classList = element.classList;
2109
+ classList.remove('ion-valid', 'ion-invalid', 'ion-touched', 'ion-untouched', 'ion-dirty', 'ion-pristine');
2110
+ classList.add(...classes);
2111
+ };
2112
+ const startsWith = (input, search) => {
2113
+ return input.substring(0, search.length) === search;
2114
+ };
2115
+
2116
+ const BACK_BUTTON_INPUTS = ['color', 'defaultHref', 'disabled', 'icon', 'mode', 'routerAnimation', 'text', 'type'];
2117
+ let IonBackButton = class IonBackButton {
2118
+ routerOutlet;
2119
+ navCtrl;
2120
+ config;
2121
+ r;
2122
+ z;
2123
+ el;
2124
+ constructor(routerOutlet, navCtrl, config, r, z, c) {
2125
+ this.routerOutlet = routerOutlet;
2126
+ this.navCtrl = navCtrl;
2127
+ this.config = config;
2128
+ this.r = r;
2129
+ this.z = z;
2130
+ c.detach();
2131
+ this.el = this.r.nativeElement;
2132
+ }
2133
+ /**
2134
+ * @internal
2135
+ */
2136
+ onClick(ev) {
2137
+ const defaultHref = this.defaultHref || this.config.get('backButtonDefaultHref');
2138
+ if (this.routerOutlet?.canGoBack()) {
2139
+ this.navCtrl.setDirection('back', undefined, undefined, this.routerAnimation);
2140
+ this.routerOutlet.pop();
2141
+ ev.preventDefault();
2142
+ }
2143
+ else if (defaultHref != null) {
2144
+ this.navCtrl.navigateBack(defaultHref, { animation: this.routerAnimation });
2145
+ ev.preventDefault();
2146
+ }
2147
+ }
2148
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonBackButton, deps: [{ token: IonRouterOutlet, optional: true }, { token: NavController }, { token: Config }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2149
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: IonBackButton, inputs: { color: "color", defaultHref: "defaultHref", disabled: "disabled", icon: "icon", mode: "mode", routerAnimation: "routerAnimation", text: "text", type: "type" }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 });
2150
+ };
2151
+ IonBackButton = __decorate([
2152
+ ProxyCmp({
2153
+ inputs: BACK_BUTTON_INPUTS,
2154
+ })
2155
+ ], IonBackButton);
2156
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonBackButton, decorators: [{
2157
+ type: Directive,
2158
+ args: [{
2159
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
2160
+ inputs: BACK_BUTTON_INPUTS,
2161
+ }]
2162
+ }], ctorParameters: function () { return [{ type: IonRouterOutlet, decorators: [{
2163
+ type: Optional
2164
+ }] }, { type: NavController }, { type: Config }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { onClick: [{
2165
+ type: HostListener,
2166
+ args: ['click', ['$event']]
2167
+ }] } });
2168
+
2169
+ const NAV_INPUTS = ['animated', 'animation', 'root', 'rootParams', 'swipeGesture'];
2170
+ const NAV_METHODS = [
2171
+ 'push',
2172
+ 'insert',
2173
+ 'insertPages',
2174
+ 'pop',
2175
+ 'popTo',
2176
+ 'popToRoot',
2177
+ 'removeIndex',
2178
+ 'setRoot',
2179
+ 'setPages',
2180
+ 'getActive',
2181
+ 'getByIndex',
2182
+ 'canGoBack',
2183
+ 'getPrevious',
2184
+ ];
2185
+ let IonNav = class IonNav {
2186
+ z;
2187
+ el;
2188
+ constructor(ref, environmentInjector, injector, angularDelegate, z, c) {
2189
+ this.z = z;
2190
+ c.detach();
2191
+ this.el = ref.nativeElement;
2192
+ ref.nativeElement.delegate = angularDelegate.create(environmentInjector, injector);
2193
+ proxyOutputs(this, this.el, ['ionNavDidChange', 'ionNavWillChange']);
2194
+ }
2195
+ /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonNav, deps: [{ token: i0.ElementRef }, { token: i0.EnvironmentInjector }, { token: i0.Injector }, { token: AngularDelegate }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2196
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: IonNav, inputs: { animated: "animated", animation: "animation", root: "root", rootParams: "rootParams", swipeGesture: "swipeGesture" }, ngImport: i0 });
2197
+ };
2198
+ IonNav = __decorate([
2199
+ ProxyCmp({
2200
+ inputs: NAV_INPUTS,
2201
+ methods: NAV_METHODS,
2202
+ })
2203
+ ], IonNav);
2204
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonNav, decorators: [{
2205
+ type: Directive,
2206
+ args: [{
2207
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
2208
+ inputs: NAV_INPUTS,
2209
+ }]
2210
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.EnvironmentInjector }, { type: i0.Injector }, { type: AngularDelegate }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; } });
2211
+
2212
+ /**
2213
+ * Adds support for Ionic routing directions and animations to the base Angular router link directive.
2214
+ *
2215
+ * When the router link is clicked, the directive will assign the direction and
2216
+ * animation so that the routing integration will transition correctly.
2005
2217
  */
2006
2218
  class RouterLinkDelegateDirective {
2007
2219
  locationStrategy;
@@ -2146,49 +2358,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
2146
2358
  args: ['click']
2147
2359
  }] } });
2148
2360
 
2149
- const NAV_INPUTS = ['animated', 'animation', 'root', 'rootParams', 'swipeGesture'];
2150
- const NAV_METHODS = [
2151
- 'push',
2152
- 'insert',
2153
- 'insertPages',
2154
- 'pop',
2155
- 'popTo',
2156
- 'popToRoot',
2157
- 'removeIndex',
2158
- 'setRoot',
2159
- 'setPages',
2160
- 'getActive',
2161
- 'getByIndex',
2162
- 'canGoBack',
2163
- 'getPrevious',
2164
- ];
2165
- let IonNav = class IonNav {
2166
- z;
2167
- el;
2168
- constructor(ref, environmentInjector, injector, angularDelegate, z, c) {
2169
- this.z = z;
2170
- c.detach();
2171
- this.el = ref.nativeElement;
2172
- ref.nativeElement.delegate = angularDelegate.create(environmentInjector, injector);
2173
- proxyOutputs(this, this.el, ['ionNavDidChange', 'ionNavWillChange']);
2174
- }
2175
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonNav, deps: [{ token: i0.ElementRef }, { token: i0.EnvironmentInjector }, { token: i0.Injector }, { token: AngularDelegate }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2176
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: IonNav, inputs: { animated: "animated", animation: "animation", root: "root", rootParams: "rootParams", swipeGesture: "swipeGesture" }, ngImport: i0 });
2177
- };
2178
- IonNav = __decorate([
2179
- ProxyCmp({
2180
- inputs: NAV_INPUTS,
2181
- methods: NAV_METHODS,
2182
- })
2183
- ], IonNav);
2184
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonNav, decorators: [{
2185
- type: Directive,
2186
- args: [{
2187
- // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
2188
- inputs: NAV_INPUTS,
2189
- }]
2190
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.EnvironmentInjector }, { type: i0.Injector }, { type: AngularDelegate }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; } });
2191
-
2192
2361
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
2193
2362
  class IonTabs {
2194
2363
  navCtrl;
@@ -2417,163 +2586,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
2417
2586
  args: ['ionTabButtonClick', ['$event']]
2418
2587
  }] } });
2419
2588
 
2420
- const raf = (h) => {
2421
- if (typeof __zone_symbol__requestAnimationFrame === 'function') {
2422
- return __zone_symbol__requestAnimationFrame(h);
2423
- }
2424
- if (typeof requestAnimationFrame === 'function') {
2425
- return requestAnimationFrame(h);
2426
- }
2427
- return setTimeout(h);
2428
- };
2429
-
2430
2589
  // TODO(FW-2827): types
2431
- class ValueAccessor {
2432
- injector;
2433
- elementRef;
2434
- onChange = () => {
2435
- /**/
2436
- };
2437
- onTouched = () => {
2438
- /**/
2439
- };
2440
- lastValue;
2441
- statusChanges;
2442
- constructor(injector, elementRef) {
2443
- this.injector = injector;
2444
- this.elementRef = elementRef;
2445
- }
2446
- writeValue(value) {
2447
- this.elementRef.nativeElement.value = this.lastValue = value;
2448
- setIonicClasses(this.elementRef);
2590
+ class OverlayBaseController {
2591
+ ctrl;
2592
+ constructor(ctrl) {
2593
+ this.ctrl = ctrl;
2449
2594
  }
2450
2595
  /**
2451
- * Notifies the ControlValueAccessor of a change in the value of the control.
2452
- *
2453
- * This is called by each of the ValueAccessor directives when we want to update
2454
- * the status and validity of the form control. For example with text components this
2455
- * is called when the ionInput event is fired. For select components this is called
2456
- * when the ionChange event is fired.
2457
- *
2458
- * This also updates the Ionic form status classes on the element.
2459
- *
2460
- * @param el The component element.
2461
- * @param value The new value of the control.
2596
+ * Creates a new overlay
2462
2597
  */
2463
- handleValueChange(el, value) {
2464
- if (el === this.elementRef.nativeElement) {
2465
- if (value !== this.lastValue) {
2466
- this.lastValue = value;
2467
- this.onChange(value);
2468
- }
2469
- setIonicClasses(this.elementRef);
2470
- }
2471
- }
2472
- _handleBlurEvent(el) {
2473
- if (el === this.elementRef.nativeElement) {
2474
- this.onTouched();
2475
- setIonicClasses(this.elementRef);
2476
- // When ion-radio is blurred, el and this.elementRef.nativeElement are
2477
- // different so we need to check if the closest ion-radio-group is the same
2478
- // as this.elementRef.nativeElement and if so, we need to mark the radio group
2479
- // as touched
2480
- }
2481
- else if (el.closest('ion-radio-group') === this.elementRef.nativeElement) {
2482
- this.onTouched();
2483
- }
2484
- }
2485
- registerOnChange(fn) {
2486
- this.onChange = fn;
2487
- }
2488
- registerOnTouched(fn) {
2489
- this.onTouched = fn;
2490
- }
2491
- setDisabledState(isDisabled) {
2492
- this.elementRef.nativeElement.disabled = isDisabled;
2598
+ create(opts) {
2599
+ return this.ctrl.create((opts || {}));
2493
2600
  }
2494
- ngOnDestroy() {
2495
- if (this.statusChanges) {
2496
- this.statusChanges.unsubscribe();
2497
- }
2601
+ /**
2602
+ * When `id` is not provided, it dismisses the top overlay.
2603
+ */
2604
+ dismiss(data, role, id) {
2605
+ return this.ctrl.dismiss(data, role, id);
2498
2606
  }
2499
- ngAfterViewInit() {
2500
- let ngControl;
2501
- try {
2502
- ngControl = this.injector.get(NgControl);
2503
- }
2504
- catch {
2505
- /* No FormControl or ngModel binding */
2506
- }
2507
- if (!ngControl) {
2508
- return;
2509
- }
2510
- // Listen for changes in validity, disabled, or pending states
2511
- if (ngControl.statusChanges) {
2512
- this.statusChanges = ngControl.statusChanges.subscribe(() => setIonicClasses(this.elementRef));
2513
- }
2514
- /**
2515
- * TODO FW-2787: Remove this in favor of https://github.com/angular/angular/issues/10887
2516
- * whenever it is implemented.
2517
- */
2518
- const formControl = ngControl.control;
2519
- if (formControl) {
2520
- const methodsToPatch = ['markAsTouched', 'markAllAsTouched', 'markAsUntouched', 'markAsDirty', 'markAsPristine'];
2521
- methodsToPatch.forEach((method) => {
2522
- if (typeof formControl[method] !== 'undefined') {
2523
- const oldFn = formControl[method].bind(formControl);
2524
- formControl[method] = (...params) => {
2525
- oldFn(...params);
2526
- setIonicClasses(this.elementRef);
2527
- };
2528
- }
2529
- });
2530
- }
2607
+ /**
2608
+ * Returns the top overlay.
2609
+ */
2610
+ getTop() {
2611
+ return this.ctrl.getTop();
2531
2612
  }
2532
- /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ValueAccessor, deps: [{ token: i0.Injector }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
2533
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: ValueAccessor, host: { listeners: { "ionBlur": "_handleBlurEvent($event.target)" } }, ngImport: i0 });
2534
2613
  }
2535
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ValueAccessor, decorators: [{
2536
- type: Directive
2537
- }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
2538
- type: HostListener,
2539
- args: ['ionBlur', ['$event.target']]
2540
- }] } });
2541
- const setIonicClasses = (element) => {
2542
- raf(() => {
2543
- const input = element.nativeElement;
2544
- const hasValue = input.value != null && input.value.toString().length > 0;
2545
- const classes = getClasses(input);
2546
- setClasses(input, classes);
2547
- const item = input.closest('ion-item');
2548
- if (item) {
2549
- if (hasValue) {
2550
- setClasses(item, [...classes, 'item-has-value']);
2551
- }
2552
- else {
2553
- setClasses(item, classes);
2554
- }
2555
- }
2556
- });
2557
- };
2558
- const getClasses = (element) => {
2559
- const classList = element.classList;
2560
- const classes = [];
2561
- for (let i = 0; i < classList.length; i++) {
2562
- const item = classList.item(i);
2563
- if (item !== null && startsWith(item, 'ng-')) {
2564
- classes.push(`ion-${item.substring(3)}`);
2565
- }
2566
- }
2567
- return classes;
2568
- };
2569
- const setClasses = (element, classes) => {
2570
- const classList = element.classList;
2571
- classList.remove('ion-valid', 'ion-invalid', 'ion-touched', 'ion-untouched', 'ion-dirty', 'ion-pristine');
2572
- classList.add(...classes);
2573
- };
2574
- const startsWith = (input, search) => {
2575
- return input.substring(0, search.length) === search;
2576
- };
2577
2614
 
2578
2615
  /**
2579
2616
  * Provides a way to customize when activated routes get reused.
@@ -2630,35 +2667,9 @@ class IonicRouteStrategy {
2630
2667
  }
2631
2668
  }
2632
2669
 
2633
- // TODO(FW-2827): types
2634
- class OverlayBaseController {
2635
- ctrl;
2636
- constructor(ctrl) {
2637
- this.ctrl = ctrl;
2638
- }
2639
- /**
2640
- * Creates a new overlay
2641
- */
2642
- create(opts) {
2643
- return this.ctrl.create((opts || {}));
2644
- }
2645
- /**
2646
- * When `id` is not provided, it dismisses the top overlay.
2647
- */
2648
- dismiss(data, role, id) {
2649
- return this.ctrl.dismiss(data, role, id);
2650
- }
2651
- /**
2652
- * Returns the top overlay.
2653
- */
2654
- getTop() {
2655
- return this.ctrl.getTop();
2656
- }
2657
- }
2658
-
2659
2670
  /**
2660
2671
  * Generated bundle index. Do not edit.
2661
2672
  */
2662
2673
 
2663
- export { AngularDelegate, Config, ConfigToken, DomController, IonBackButton, IonModal, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, MenuController, NavController, NavParams, OverlayBaseController, Platform, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ValueAccessor, bindLifecycleEvents, provideComponentInputBinding, raf, setIonicClasses };
2674
+ export { AngularDelegate, Config, ConfigToken, DomController, IonBackButton, IonModal, IonModalToken, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, MenuController, NavController, NavParams, OverlayBaseController, Platform, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ValueAccessor, bindLifecycleEvents, provideComponentInputBinding, raf, setIonicClasses };
2664
2675
  //# sourceMappingURL=ionic-angular-common.mjs.map