@ionic/angular 7.3.4-dev.11696436834.1e83c799 → 7.3.4-dev.11699470772.1dad7e66

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.
Files changed (64) hide show
  1. package/common/index.d.ts +0 -2
  2. package/directives/control-value-accessors/boolean-value-accessor.d.ts +1 -1
  3. package/directives/control-value-accessors/numeric-value-accessor.d.ts +1 -1
  4. package/directives/control-value-accessors/radio-value-accessor.d.ts +1 -1
  5. package/directives/control-value-accessors/select-value-accessor.d.ts +1 -1
  6. package/directives/control-value-accessors/text-value-accessor.d.ts +1 -1
  7. package/{common/directives → directives}/control-value-accessors/value-accessor.d.ts +2 -2
  8. package/esm2020/app-initialize.mjs +2 -2
  9. package/esm2020/common/index.mjs +1 -3
  10. package/esm2020/directives/control-value-accessors/boolean-value-accessor.mjs +4 -4
  11. package/esm2020/directives/control-value-accessors/numeric-value-accessor.mjs +2 -2
  12. package/esm2020/directives/control-value-accessors/radio-value-accessor.mjs +3 -6
  13. package/esm2020/directives/control-value-accessors/select-value-accessor.mjs +2 -2
  14. package/esm2020/directives/control-value-accessors/text-value-accessor.mjs +2 -2
  15. package/esm2020/directives/control-value-accessors/value-accessor.mjs +141 -0
  16. package/esm2020/standalone/directives/proxies.mjs +693 -1
  17. package/esm2020/standalone/index.mjs +2 -2
  18. package/esm2020/standalone/navigation/router-link-delegate.mjs +12 -10
  19. package/esm2020/util/util.mjs +10 -0
  20. package/fesm2015/ionic-angular-common.mjs +1 -149
  21. package/fesm2015/ionic-angular-common.mjs.map +1 -1
  22. package/fesm2015/ionic-angular-standalone.mjs +793 -888
  23. package/fesm2015/ionic-angular-standalone.mjs.map +1 -1
  24. package/fesm2015/ionic-angular.mjs +152 -8
  25. package/fesm2015/ionic-angular.mjs.map +1 -1
  26. package/fesm2020/ionic-angular-common.mjs +1 -149
  27. package/fesm2020/ionic-angular-common.mjs.map +1 -1
  28. package/fesm2020/ionic-angular-standalone.mjs +793 -888
  29. package/fesm2020/ionic-angular-standalone.mjs.map +1 -1
  30. package/fesm2020/ionic-angular.mjs +152 -8
  31. package/fesm2020/ionic-angular.mjs.map +1 -1
  32. package/package.json +2 -2
  33. package/standalone/directives/proxies.d.ts +314 -0
  34. package/standalone/index.d.ts +1 -1
  35. package/standalone/navigation/router-link-delegate.d.ts +2 -2
  36. package/common/directives/control-value-accessors/index.d.ts +0 -1
  37. package/esm2020/common/directives/control-value-accessors/index.mjs +0 -2
  38. package/esm2020/common/directives/control-value-accessors/value-accessor.mjs +0 -141
  39. package/esm2020/common/utils/util.mjs +0 -10
  40. package/esm2020/standalone/directives/checkbox.mjs +0 -73
  41. package/esm2020/standalone/directives/datetime.mjs +0 -90
  42. package/esm2020/standalone/directives/index.mjs +0 -13
  43. package/esm2020/standalone/directives/input.mjs +0 -112
  44. package/esm2020/standalone/directives/radio-group.mjs +0 -58
  45. package/esm2020/standalone/directives/radio.mjs +0 -62
  46. package/esm2020/standalone/directives/range.mjs +0 -77
  47. package/esm2020/standalone/directives/searchbar.mjs +0 -80
  48. package/esm2020/standalone/directives/segment.mjs +0 -58
  49. package/esm2020/standalone/directives/select.mjs +0 -81
  50. package/esm2020/standalone/directives/textarea.mjs +0 -90
  51. package/esm2020/standalone/directives/toggle.mjs +0 -73
  52. package/standalone/directives/checkbox.d.ts +0 -30
  53. package/standalone/directives/datetime.d.ts +0 -30
  54. package/standalone/directives/index.d.ts +0 -12
  55. package/standalone/directives/input.d.ts +0 -47
  56. package/standalone/directives/radio-group.d.ts +0 -18
  57. package/standalone/directives/radio.d.ts +0 -22
  58. package/standalone/directives/range.d.ts +0 -47
  59. package/standalone/directives/searchbar.d.ts +0 -45
  60. package/standalone/directives/segment.d.ts +0 -19
  61. package/standalone/directives/select.d.ts +0 -34
  62. package/standalone/directives/textarea.d.ts +0 -37
  63. package/standalone/directives/toggle.d.ts +0 -28
  64. /package/{common/utils → util}/util.d.ts +0 -0
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Directive, HostListener, Component, ChangeDetectionStrategy, ViewChild, ContentChild, ContentChildren, Optional, forwardRef, APP_INITIALIZER, NgZone, NgModule } from '@angular/core';
3
- import { NG_VALUE_ACCESSOR, NG_VALIDATORS, MaxValidator, MinValidator } from '@angular/forms';
3
+ import { NgControl, NG_VALUE_ACCESSOR, NG_VALIDATORS, MaxValidator, MinValidator } from '@angular/forms';
4
4
  import * as i2 from '@ionic/angular/common';
5
- import { ValueAccessor, setIonicClasses, IonRouterOutlet as IonRouterOutlet$1, IonTabs as IonTabs$1, IonBackButton as IonBackButton$1, IonNav as IonNav$1, RouterLinkDelegateDirective as RouterLinkDelegateDirective$1, RouterLinkWithHrefDelegateDirective as RouterLinkWithHrefDelegateDirective$1, IonModal as IonModal$1, IonPopover as IonPopover$1, raf, ConfigToken, provideComponentInputBinding, AngularDelegate, ModalController, PopoverController } from '@ionic/angular/common';
5
+ import { IonRouterOutlet as IonRouterOutlet$1, IonTabs as IonTabs$1, IonBackButton as IonBackButton$1, IonNav as IonNav$1, RouterLinkDelegateDirective as RouterLinkDelegateDirective$1, RouterLinkWithHrefDelegateDirective as RouterLinkWithHrefDelegateDirective$1, IonModal as IonModal$1, IonPopover as IonPopover$1, ConfigToken, provideComponentInputBinding, AngularDelegate, ModalController, PopoverController } from '@ionic/angular/common';
6
6
  export { ActionSheetController, AlertController, AngularDelegate, AnimationController, Config, DomController, GestureController, IonicRouteStrategy, LoadingController, MenuController, ModalController, NavController, NavParams, PickerController, Platform, PopoverController, ToastController } from '@ionic/angular/common';
7
7
  import { __decorate } from 'tslib';
8
8
  import { fromEvent } from 'rxjs';
@@ -12,13 +12,160 @@ import { setupConfig } from '@ionic/core';
12
12
  export { IonicSafeString, IonicSlides, createAnimation, createGesture, getPlatforms, getTimeGivenProgression, iosTransitionAnimation, isPlatform, mdTransitionAnimation } from '@ionic/core';
13
13
  import { applyPolyfills, defineCustomElements } from '@ionic/core/loader';
14
14
 
15
+ const raf = (h) => {
16
+ if (typeof __zone_symbol__requestAnimationFrame === 'function') {
17
+ return __zone_symbol__requestAnimationFrame(h);
18
+ }
19
+ if (typeof requestAnimationFrame === 'function') {
20
+ return requestAnimationFrame(h);
21
+ }
22
+ return setTimeout(h);
23
+ };
24
+
25
+ // TODO(FW-2827): types
26
+ class ValueAccessor {
27
+ constructor(injector, el) {
28
+ this.injector = injector;
29
+ this.el = el;
30
+ this.onChange = () => {
31
+ /**/
32
+ };
33
+ this.onTouched = () => {
34
+ /**/
35
+ };
36
+ }
37
+ writeValue(value) {
38
+ this.el.nativeElement.value = this.lastValue = value;
39
+ setIonicClasses(this.el);
40
+ }
41
+ /**
42
+ * Notifies the ControlValueAccessor of a change in the value of the control.
43
+ *
44
+ * This is called by each of the ValueAccessor directives when we want to update
45
+ * the status and validity of the form control. For example with text components this
46
+ * is called when the ionInput event is fired. For select components this is called
47
+ * when the ionChange event is fired.
48
+ *
49
+ * This also updates the Ionic form status classes on the element.
50
+ *
51
+ * @param el The component element.
52
+ * @param value The new value of the control.
53
+ */
54
+ handleValueChange(el, value) {
55
+ if (el === this.el.nativeElement) {
56
+ if (value !== this.lastValue) {
57
+ this.lastValue = value;
58
+ this.onChange(value);
59
+ }
60
+ setIonicClasses(this.el);
61
+ }
62
+ }
63
+ _handleBlurEvent(el) {
64
+ if (el === this.el.nativeElement) {
65
+ this.onTouched();
66
+ setIonicClasses(this.el);
67
+ }
68
+ }
69
+ registerOnChange(fn) {
70
+ this.onChange = fn;
71
+ }
72
+ registerOnTouched(fn) {
73
+ this.onTouched = fn;
74
+ }
75
+ setDisabledState(isDisabled) {
76
+ this.el.nativeElement.disabled = isDisabled;
77
+ }
78
+ ngOnDestroy() {
79
+ if (this.statusChanges) {
80
+ this.statusChanges.unsubscribe();
81
+ }
82
+ }
83
+ ngAfterViewInit() {
84
+ let ngControl;
85
+ try {
86
+ ngControl = this.injector.get(NgControl);
87
+ }
88
+ catch (_a) {
89
+ /* No FormControl or ngModel binding */
90
+ }
91
+ if (!ngControl) {
92
+ return;
93
+ }
94
+ // Listen for changes in validity, disabled, or pending states
95
+ if (ngControl.statusChanges) {
96
+ this.statusChanges = ngControl.statusChanges.subscribe(() => setIonicClasses(this.el));
97
+ }
98
+ /**
99
+ * TODO FW-2787: Remove this in favor of https://github.com/angular/angular/issues/10887
100
+ * whenever it is implemented.
101
+ */
102
+ const formControl = ngControl.control;
103
+ if (formControl) {
104
+ const methodsToPatch = ['markAsTouched', 'markAllAsTouched', 'markAsUntouched', 'markAsDirty', 'markAsPristine'];
105
+ methodsToPatch.forEach((method) => {
106
+ if (typeof formControl[method] !== 'undefined') {
107
+ const oldFn = formControl[method].bind(formControl);
108
+ formControl[method] = (...params) => {
109
+ oldFn(...params);
110
+ setIonicClasses(this.el);
111
+ };
112
+ }
113
+ });
114
+ }
115
+ }
116
+ }
117
+ /** @nocollapse */ ValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ValueAccessor, deps: [{ token: i0.Injector }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
118
+ /** @nocollapse */ ValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: ValueAccessor, host: { listeners: { "ionBlur": "_handleBlurEvent($event.target)" } }, ngImport: i0 });
119
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ValueAccessor, decorators: [{
120
+ type: Directive
121
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
122
+ type: HostListener,
123
+ args: ['ionBlur', ['$event.target']]
124
+ }] } });
125
+ const setIonicClasses = (element) => {
126
+ raf(() => {
127
+ const input = element.nativeElement;
128
+ const hasValue = input.value != null && input.value.toString().length > 0;
129
+ const classes = getClasses(input);
130
+ setClasses(input, classes);
131
+ const item = input.closest('ion-item');
132
+ if (item) {
133
+ if (hasValue) {
134
+ setClasses(item, [...classes, 'item-has-value']);
135
+ }
136
+ else {
137
+ setClasses(item, classes);
138
+ }
139
+ }
140
+ });
141
+ };
142
+ const getClasses = (element) => {
143
+ const classList = element.classList;
144
+ const classes = [];
145
+ for (let i = 0; i < classList.length; i++) {
146
+ const item = classList.item(i);
147
+ if (item !== null && startsWith(item, 'ng-')) {
148
+ classes.push(`ion-${item.substring(3)}`);
149
+ }
150
+ }
151
+ return classes;
152
+ };
153
+ const setClasses = (element, classes) => {
154
+ const classList = element.classList;
155
+ classList.remove('ion-valid', 'ion-invalid', 'ion-touched', 'ion-untouched', 'ion-dirty', 'ion-pristine');
156
+ classList.add(...classes);
157
+ };
158
+ const startsWith = (input, search) => {
159
+ return input.substring(0, search.length) === search;
160
+ };
161
+
15
162
  class BooleanValueAccessorDirective extends ValueAccessor {
16
163
  constructor(injector, el) {
17
164
  super(injector, el);
18
165
  }
19
166
  writeValue(value) {
20
- this.elementRef.nativeElement.checked = this.lastValue = value;
21
- setIonicClasses(this.elementRef);
167
+ this.el.nativeElement.checked = this.lastValue = value;
168
+ setIonicClasses(this.el);
22
169
  }
23
170
  _handleIonChange(el) {
24
171
  this.handleValueChange(el, el.checked);
@@ -91,11 +238,8 @@ class RadioValueAccessorDirective extends ValueAccessor {
91
238
  constructor(injector, el) {
92
239
  super(injector, el);
93
240
  }
241
+ // TODO(FW-2827): type (HTMLIonRadioElement and HTMLElement are both missing `checked`)
94
242
  _handleIonSelect(el) {
95
- /**
96
- * The `el` type is any to access the `checked` state property
97
- * that is not exposed on the type interface.
98
- */
99
243
  this.handleValueChange(el, el.checked);
100
244
  }
101
245
  }