@ionic/angular 7.3.4-dev.11695051069.10d92d60 → 7.3.4-dev.11695650636.128f2ec9

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 (62) hide show
  1. package/common/directives/control-value-accessors/index.d.ts +1 -0
  2. package/{directives → common/directives}/control-value-accessors/value-accessor.d.ts +2 -2
  3. package/common/index.d.ts +2 -0
  4. package/directives/control-value-accessors/boolean-value-accessor.d.ts +1 -1
  5. package/directives/control-value-accessors/numeric-value-accessor.d.ts +1 -1
  6. package/directives/control-value-accessors/radio-value-accessor.d.ts +1 -1
  7. package/directives/control-value-accessors/select-value-accessor.d.ts +1 -1
  8. package/directives/control-value-accessors/text-value-accessor.d.ts +1 -1
  9. package/esm2020/app-initialize.mjs +2 -2
  10. package/esm2020/common/directives/control-value-accessors/index.mjs +2 -0
  11. package/esm2020/common/directives/control-value-accessors/value-accessor.mjs +141 -0
  12. package/esm2020/common/index.mjs +3 -1
  13. package/esm2020/common/utils/util.mjs +10 -0
  14. package/esm2020/directives/control-value-accessors/boolean-value-accessor.mjs +4 -4
  15. package/esm2020/directives/control-value-accessors/numeric-value-accessor.mjs +2 -2
  16. package/esm2020/directives/control-value-accessors/radio-value-accessor.mjs +6 -3
  17. package/esm2020/directives/control-value-accessors/select-value-accessor.mjs +2 -2
  18. package/esm2020/directives/control-value-accessors/text-value-accessor.mjs +2 -2
  19. package/esm2020/standalone/directives/checkbox.mjs +73 -0
  20. package/esm2020/standalone/directives/datetime.mjs +90 -0
  21. package/esm2020/standalone/directives/index.mjs +13 -0
  22. package/esm2020/standalone/directives/input.mjs +112 -0
  23. package/esm2020/standalone/directives/proxies.mjs +565 -476
  24. package/esm2020/standalone/directives/radio-group.mjs +58 -0
  25. package/esm2020/standalone/directives/radio.mjs +62 -0
  26. package/esm2020/standalone/directives/range.mjs +77 -0
  27. package/esm2020/standalone/directives/searchbar.mjs +80 -0
  28. package/esm2020/standalone/directives/segment.mjs +58 -0
  29. package/esm2020/standalone/directives/select.mjs +81 -0
  30. package/esm2020/standalone/directives/textarea.mjs +90 -0
  31. package/esm2020/standalone/directives/toggle.mjs +73 -0
  32. package/esm2020/standalone/index.mjs +2 -2
  33. package/fesm2015/ionic-angular-common.mjs +149 -1
  34. package/fesm2015/ionic-angular-common.mjs.map +1 -1
  35. package/fesm2015/ionic-angular-standalone.mjs +1448 -570
  36. package/fesm2015/ionic-angular-standalone.mjs.map +1 -1
  37. package/fesm2015/ionic-angular.mjs +8 -152
  38. package/fesm2015/ionic-angular.mjs.map +1 -1
  39. package/fesm2020/ionic-angular-common.mjs +149 -1
  40. package/fesm2020/ionic-angular-common.mjs.map +1 -1
  41. package/fesm2020/ionic-angular-standalone.mjs +1448 -570
  42. package/fesm2020/ionic-angular-standalone.mjs.map +1 -1
  43. package/fesm2020/ionic-angular.mjs +8 -152
  44. package/fesm2020/ionic-angular.mjs.map +1 -1
  45. package/package.json +3 -3
  46. package/standalone/directives/checkbox.d.ts +30 -0
  47. package/standalone/directives/datetime.d.ts +30 -0
  48. package/standalone/directives/index.d.ts +12 -0
  49. package/standalone/directives/input.d.ts +47 -0
  50. package/standalone/directives/proxies.d.ts +0 -314
  51. package/standalone/directives/radio-group.d.ts +18 -0
  52. package/standalone/directives/radio.d.ts +22 -0
  53. package/standalone/directives/range.d.ts +47 -0
  54. package/standalone/directives/searchbar.d.ts +45 -0
  55. package/standalone/directives/segment.d.ts +19 -0
  56. package/standalone/directives/select.d.ts +34 -0
  57. package/standalone/directives/textarea.d.ts +37 -0
  58. package/standalone/directives/toggle.d.ts +28 -0
  59. package/standalone/index.d.ts +1 -1
  60. package/esm2020/directives/control-value-accessors/value-accessor.mjs +0 -141
  61. package/esm2020/util/util.mjs +0 -10
  62. /package/{util → common/utils}/util.d.ts +0 -0
@@ -8,6 +8,7 @@ import { DOCUMENT } from '@angular/common';
8
8
  import { Subject, fromEvent, BehaviorSubject, combineLatest, of } from 'rxjs';
9
9
  import { __decorate } from 'tslib';
10
10
  import { filter, switchMap, distinctUntilChanged } from 'rxjs/operators';
11
+ import { NgControl } from '@angular/forms';
11
12
 
12
13
  // TODO(FW-2827): types
13
14
  class OverlayBaseController {
@@ -2398,6 +2399,153 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
2398
2399
  args: ['ionTabButtonClick', ['$event']]
2399
2400
  }] } });
2400
2401
 
2402
+ const raf = (h) => {
2403
+ if (typeof __zone_symbol__requestAnimationFrame === 'function') {
2404
+ return __zone_symbol__requestAnimationFrame(h);
2405
+ }
2406
+ if (typeof requestAnimationFrame === 'function') {
2407
+ return requestAnimationFrame(h);
2408
+ }
2409
+ return setTimeout(h);
2410
+ };
2411
+
2412
+ // TODO(FW-2827): types
2413
+ class ValueAccessor {
2414
+ constructor(injector, elementRef) {
2415
+ this.injector = injector;
2416
+ this.elementRef = elementRef;
2417
+ this.onChange = () => {
2418
+ /**/
2419
+ };
2420
+ this.onTouched = () => {
2421
+ /**/
2422
+ };
2423
+ }
2424
+ writeValue(value) {
2425
+ this.elementRef.nativeElement.value = this.lastValue = value;
2426
+ setIonicClasses(this.elementRef);
2427
+ }
2428
+ /**
2429
+ * Notifies the ControlValueAccessor of a change in the value of the control.
2430
+ *
2431
+ * This is called by each of the ValueAccessor directives when we want to update
2432
+ * the status and validity of the form control. For example with text components this
2433
+ * is called when the ionInput event is fired. For select components this is called
2434
+ * when the ionChange event is fired.
2435
+ *
2436
+ * This also updates the Ionic form status classes on the element.
2437
+ *
2438
+ * @param el The component element.
2439
+ * @param value The new value of the control.
2440
+ */
2441
+ handleValueChange(el, value) {
2442
+ if (el === this.elementRef.nativeElement) {
2443
+ if (value !== this.lastValue) {
2444
+ this.lastValue = value;
2445
+ this.onChange(value);
2446
+ }
2447
+ setIonicClasses(this.elementRef);
2448
+ }
2449
+ }
2450
+ _handleBlurEvent(el) {
2451
+ if (el === this.elementRef.nativeElement) {
2452
+ this.onTouched();
2453
+ setIonicClasses(this.elementRef);
2454
+ }
2455
+ }
2456
+ registerOnChange(fn) {
2457
+ this.onChange = fn;
2458
+ }
2459
+ registerOnTouched(fn) {
2460
+ this.onTouched = fn;
2461
+ }
2462
+ setDisabledState(isDisabled) {
2463
+ this.elementRef.nativeElement.disabled = isDisabled;
2464
+ }
2465
+ ngOnDestroy() {
2466
+ if (this.statusChanges) {
2467
+ this.statusChanges.unsubscribe();
2468
+ }
2469
+ }
2470
+ ngAfterViewInit() {
2471
+ let ngControl;
2472
+ try {
2473
+ ngControl = this.injector.get(NgControl);
2474
+ }
2475
+ catch {
2476
+ /* No FormControl or ngModel binding */
2477
+ }
2478
+ if (!ngControl) {
2479
+ return;
2480
+ }
2481
+ // Listen for changes in validity, disabled, or pending states
2482
+ if (ngControl.statusChanges) {
2483
+ this.statusChanges = ngControl.statusChanges.subscribe(() => setIonicClasses(this.elementRef));
2484
+ }
2485
+ /**
2486
+ * TODO FW-2787: Remove this in favor of https://github.com/angular/angular/issues/10887
2487
+ * whenever it is implemented.
2488
+ */
2489
+ const formControl = ngControl.control;
2490
+ if (formControl) {
2491
+ const methodsToPatch = ['markAsTouched', 'markAllAsTouched', 'markAsUntouched', 'markAsDirty', 'markAsPristine'];
2492
+ methodsToPatch.forEach((method) => {
2493
+ if (typeof formControl[method] !== 'undefined') {
2494
+ const oldFn = formControl[method].bind(formControl);
2495
+ formControl[method] = (...params) => {
2496
+ oldFn(...params);
2497
+ setIonicClasses(this.elementRef);
2498
+ };
2499
+ }
2500
+ });
2501
+ }
2502
+ }
2503
+ }
2504
+ /** @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 });
2505
+ /** @nocollapse */ ValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: ValueAccessor, host: { listeners: { "ionBlur": "_handleBlurEvent($event.target)" } }, ngImport: i0 });
2506
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ValueAccessor, decorators: [{
2507
+ type: Directive
2508
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
2509
+ type: HostListener,
2510
+ args: ['ionBlur', ['$event.target']]
2511
+ }] } });
2512
+ const setIonicClasses = (element) => {
2513
+ raf(() => {
2514
+ const input = element.nativeElement;
2515
+ const hasValue = input.value != null && input.value.toString().length > 0;
2516
+ const classes = getClasses(input);
2517
+ setClasses(input, classes);
2518
+ const item = input.closest('ion-item');
2519
+ if (item) {
2520
+ if (hasValue) {
2521
+ setClasses(item, [...classes, 'item-has-value']);
2522
+ }
2523
+ else {
2524
+ setClasses(item, classes);
2525
+ }
2526
+ }
2527
+ });
2528
+ };
2529
+ const getClasses = (element) => {
2530
+ const classList = element.classList;
2531
+ const classes = [];
2532
+ for (let i = 0; i < classList.length; i++) {
2533
+ const item = classList.item(i);
2534
+ if (item !== null && startsWith(item, 'ng-')) {
2535
+ classes.push(`ion-${item.substring(3)}`);
2536
+ }
2537
+ }
2538
+ return classes;
2539
+ };
2540
+ const setClasses = (element, classes) => {
2541
+ const classList = element.classList;
2542
+ classList.remove('ion-valid', 'ion-invalid', 'ion-touched', 'ion-untouched', 'ion-dirty', 'ion-pristine');
2543
+ classList.add(...classes);
2544
+ };
2545
+ const startsWith = (input, search) => {
2546
+ return input.substring(0, search.length) === search;
2547
+ };
2548
+
2401
2549
  /**
2402
2550
  * Provides a way to customize when activated routes get reused.
2403
2551
  */
@@ -2457,5 +2605,5 @@ class IonicRouteStrategy {
2457
2605
  * Generated bundle index. Do not edit.
2458
2606
  */
2459
2607
 
2460
- export { ActionSheetController, AlertController, AngularDelegate, AnimationController, Config, ConfigToken, DomController, GestureController, IonBackButton, IonModal, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, LoadingController, MenuController, ModalController, NavController, NavParams, PickerController, Platform, PopoverController, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ToastController, bindLifecycleEvents, provideComponentInputBinding };
2608
+ export { ActionSheetController, AlertController, AngularDelegate, AnimationController, Config, ConfigToken, DomController, GestureController, IonBackButton, IonModal, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, LoadingController, MenuController, ModalController, NavController, NavParams, PickerController, Platform, PopoverController, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ToastController, ValueAccessor, bindLifecycleEvents, provideComponentInputBinding, raf, setIonicClasses };
2461
2609
  //# sourceMappingURL=ionic-angular-common.mjs.map