@ionic/angular 8.6.3-dev.11753378718.15aa6551 → 8.6.3-dev.11754487906.199a3208

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,48 +10,6 @@ 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
-
55
13
  class MenuController {
56
14
  menuController;
57
15
  constructor(menuController) {
@@ -166,6 +124,48 @@ class MenuController {
166
124
  }
167
125
  }
168
126
 
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,8 +728,6 @@ class NavParams {
728
728
  }
729
729
  }
730
730
 
731
- // Token for injecting the modal element
732
- const IonModalToken = new InjectionToken('IonModalToken');
733
731
  // TODO(FW-2827): types
734
732
  class AngularDelegate {
735
733
  zone = inject(NgZone);
@@ -814,17 +812,8 @@ const attachView = (zone, environmentInjector, injector, applicationRef, elRefMa
814
812
  * The modern approach is to access the data directly
815
813
  * from the component's class instance.
816
814
  */
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
- }
826
815
  const childInjector = Injector.create({
827
- providers,
816
+ providers: getProviders(params),
828
817
  parent: injector,
829
818
  });
830
819
  const componentRef = createComponent(component, {
@@ -969,39 +958,31 @@ function ProxyCmp(opts) {
969
958
  return decorator;
970
959
  }
971
960
 
972
- const MODAL_INPUTS = [
961
+ const POPOVER_INPUTS = [
962
+ 'alignment',
973
963
  'animated',
964
+ 'arrow',
974
965
  'keepContentsMounted',
975
- 'backdropBreakpoint',
976
966
  'backdropDismiss',
977
- 'breakpoints',
978
- 'canDismiss',
979
967
  'cssClass',
968
+ 'dismissOnSelect',
980
969
  'enterAnimation',
981
- 'expandToScroll',
982
970
  'event',
983
971
  'focusTrap',
984
- 'handle',
985
- 'handleBehavior',
986
- 'initialBreakpoint',
987
972
  'isOpen',
988
973
  'keyboardClose',
989
974
  'leaveAnimation',
990
975
  'mode',
991
- 'presentingElement',
992
976
  'showBackdrop',
993
977
  'translucent',
994
978
  'trigger',
979
+ 'triggerAction',
980
+ 'reference',
981
+ 'size',
982
+ 'side',
995
983
  ];
996
- const MODAL_METHODS = [
997
- 'present',
998
- 'dismiss',
999
- 'onDidDismiss',
1000
- 'onWillDismiss',
1001
- 'setCurrentBreakpoint',
1002
- 'getCurrentBreakpoint',
1003
- ];
1004
- let IonModal = class IonModal {
984
+ const POPOVER_METHODS = ['present', 'dismiss', 'onDidDismiss', 'onWillDismiss'];
985
+ let IonPopover = class IonPopover {
1005
986
  z;
1006
987
  // TODO(FW-2827): type
1007
988
  template;
@@ -1019,24 +1000,23 @@ let IonModal = class IonModal {
1019
1000
  c.detectChanges();
1020
1001
  });
1021
1002
  proxyOutputs(this, this.el, [
1022
- 'ionModalDidPresent',
1023
- 'ionModalWillPresent',
1024
- 'ionModalWillDismiss',
1025
- 'ionModalDidDismiss',
1026
- 'ionBreakpointDidChange',
1003
+ 'ionPopoverDidPresent',
1004
+ 'ionPopoverWillPresent',
1005
+ 'ionPopoverWillDismiss',
1006
+ 'ionPopoverDidDismiss',
1027
1007
  'didPresent',
1028
1008
  'willPresent',
1029
1009
  'willDismiss',
1030
1010
  'didDismiss',
1031
1011
  ]);
1032
1012
  }
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 });
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 });
1035
1015
  };
1036
- IonModal = __decorate([
1016
+ IonPopover = __decorate([
1037
1017
  ProxyCmp({
1038
- inputs: MODAL_INPUTS,
1039
- methods: MODAL_METHODS,
1018
+ inputs: POPOVER_INPUTS,
1019
+ methods: POPOVER_METHODS,
1040
1020
  })
1041
1021
  /**
1042
1022
  * @Component extends from @Directive
@@ -1044,44 +1024,52 @@ IonModal = __decorate([
1044
1024
  * do not need to re-define them for the
1045
1025
  * lazy loaded popover.
1046
1026
  */
1047
- ], IonModal);
1048
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonModal, decorators: [{
1027
+ ], IonPopover);
1028
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonPopover, decorators: [{
1049
1029
  type: Directive,
1050
1030
  args: [{
1051
- selector: 'ion-modal',
1031
+ selector: 'ion-popover',
1052
1032
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1053
- inputs: MODAL_INPUTS,
1033
+ inputs: POPOVER_INPUTS,
1054
1034
  }]
1055
1035
  }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { template: [{
1056
1036
  type: ContentChild,
1057
1037
  args: [TemplateRef, { static: false }]
1058
1038
  }] } });
1059
1039
 
1060
- const POPOVER_INPUTS = [
1061
- 'alignment',
1040
+ const MODAL_INPUTS = [
1062
1041
  'animated',
1063
- 'arrow',
1064
1042
  'keepContentsMounted',
1043
+ 'backdropBreakpoint',
1065
1044
  'backdropDismiss',
1045
+ 'breakpoints',
1046
+ 'canDismiss',
1066
1047
  'cssClass',
1067
- 'dismissOnSelect',
1068
1048
  'enterAnimation',
1049
+ 'expandToScroll',
1069
1050
  'event',
1070
1051
  'focusTrap',
1052
+ 'handle',
1053
+ 'handleBehavior',
1054
+ 'initialBreakpoint',
1071
1055
  'isOpen',
1072
1056
  'keyboardClose',
1073
1057
  'leaveAnimation',
1074
1058
  'mode',
1059
+ 'presentingElement',
1075
1060
  'showBackdrop',
1076
1061
  'translucent',
1077
1062
  'trigger',
1078
- 'triggerAction',
1079
- 'reference',
1080
- 'size',
1081
- 'side',
1082
1063
  ];
1083
- const POPOVER_METHODS = ['present', 'dismiss', 'onDidDismiss', 'onWillDismiss'];
1084
- let IonPopover = class IonPopover {
1064
+ const MODAL_METHODS = [
1065
+ 'present',
1066
+ 'dismiss',
1067
+ 'onDidDismiss',
1068
+ 'onWillDismiss',
1069
+ 'setCurrentBreakpoint',
1070
+ 'getCurrentBreakpoint',
1071
+ ];
1072
+ let IonModal = class IonModal {
1085
1073
  z;
1086
1074
  // TODO(FW-2827): type
1087
1075
  template;
@@ -1099,23 +1087,24 @@ let IonPopover = class IonPopover {
1099
1087
  c.detectChanges();
1100
1088
  });
1101
1089
  proxyOutputs(this, this.el, [
1102
- 'ionPopoverDidPresent',
1103
- 'ionPopoverWillPresent',
1104
- 'ionPopoverWillDismiss',
1105
- 'ionPopoverDidDismiss',
1090
+ 'ionModalDidPresent',
1091
+ 'ionModalWillPresent',
1092
+ 'ionModalWillDismiss',
1093
+ 'ionModalDidDismiss',
1094
+ 'ionBreakpointDidChange',
1106
1095
  'didPresent',
1107
1096
  'willPresent',
1108
1097
  'willDismiss',
1109
1098
  'didDismiss',
1110
1099
  ]);
1111
1100
  }
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 });
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 });
1114
1103
  };
1115
- IonPopover = __decorate([
1104
+ IonModal = __decorate([
1116
1105
  ProxyCmp({
1117
- inputs: POPOVER_INPUTS,
1118
- methods: POPOVER_METHODS,
1106
+ inputs: MODAL_INPUTS,
1107
+ methods: MODAL_METHODS,
1119
1108
  })
1120
1109
  /**
1121
1110
  * @Component extends from @Directive
@@ -1123,13 +1112,13 @@ IonPopover = __decorate([
1123
1112
  * do not need to re-define them for the
1124
1113
  * lazy loaded popover.
1125
1114
  */
1126
- ], IonPopover);
1127
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonPopover, decorators: [{
1115
+ ], IonModal);
1116
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonModal, decorators: [{
1128
1117
  type: Directive,
1129
1118
  args: [{
1130
- selector: 'ion-popover',
1119
+ selector: 'ion-modal',
1131
1120
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1132
- inputs: POPOVER_INPUTS,
1121
+ inputs: MODAL_INPUTS,
1133
1122
  }]
1134
1123
  }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { template: [{
1135
1124
  type: ContentChild,
@@ -1955,259 +1944,58 @@ function componentInputBindingFactory(router) {
1955
1944
  return null;
1956
1945
  }
1957
1946
 
1958
- const raf = (h) => {
1959
- if (typeof __zone_symbol__requestAnimationFrame === 'function') {
1960
- return __zone_symbol__requestAnimationFrame(h);
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;
1961
1963
  }
1962
- if (typeof requestAnimationFrame === 'function') {
1963
- return requestAnimationFrame(h);
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
+ }
1964
1978
  }
1965
- return setTimeout(h);
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 });
1966
1981
  };
1967
-
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 }]; } });
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
+ }] } });
2211
1999
 
2212
2000
  /**
2213
2001
  * Adds support for Ionic routing directions and animations to the base Angular router link directive.
@@ -2358,6 +2146,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
2358
2146
  args: ['click']
2359
2147
  }] } });
2360
2148
 
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
+
2361
2192
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
2362
2193
  class IonTabs {
2363
2194
  navCtrl;
@@ -2586,31 +2417,163 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
2586
2417
  args: ['ionTabButtonClick', ['$event']]
2587
2418
  }] } });
2588
2419
 
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
+
2589
2430
  // TODO(FW-2827): types
2590
- class OverlayBaseController {
2591
- ctrl;
2592
- constructor(ctrl) {
2593
- this.ctrl = ctrl;
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;
2594
2445
  }
2595
- /**
2596
- * Creates a new overlay
2597
- */
2598
- create(opts) {
2599
- return this.ctrl.create((opts || {}));
2446
+ writeValue(value) {
2447
+ this.elementRef.nativeElement.value = this.lastValue = value;
2448
+ setIonicClasses(this.elementRef);
2600
2449
  }
2601
2450
  /**
2602
- * When `id` is not provided, it dismisses the top overlay.
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.
2603
2462
  */
2604
- dismiss(data, role, id) {
2605
- return this.ctrl.dismiss(data, role, id);
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
+ }
2606
2471
  }
2607
- /**
2608
- * Returns the top overlay.
2609
- */
2610
- getTop() {
2611
- return this.ctrl.getTop();
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;
2493
+ }
2494
+ ngOnDestroy() {
2495
+ if (this.statusChanges) {
2496
+ this.statusChanges.unsubscribe();
2497
+ }
2612
2498
  }
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
+ }
2531
+ }
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 });
2613
2534
  }
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
+ };
2614
2577
 
2615
2578
  /**
2616
2579
  * Provides a way to customize when activated routes get reused.
@@ -2667,9 +2630,35 @@ class IonicRouteStrategy {
2667
2630
  }
2668
2631
  }
2669
2632
 
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
+
2670
2659
  /**
2671
2660
  * Generated bundle index. Do not edit.
2672
2661
  */
2673
2662
 
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 };
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 };
2675
2664
  //# sourceMappingURL=ionic-angular-common.mjs.map