datepicker-input.d.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { ElementRef, EventEmitter, OnDestroy } from '@angular/core';
  9. import { AbstractControl, ControlValueAccessor, ValidationErrors, Validator } from '@angular/forms';
  10. import { DateAdapter, MatDateFormats, ThemePalette } from '@angular/material/core';
  11. import { MatFormField } from '@angular/material/form-field';
  12. import { MatDatepicker } from './datepicker';
  13. /** @docs-private */
  14. export declare const MAT_DATEPICKER_VALUE_ACCESSOR: any;
  15. /** @docs-private */
  16. export declare const MAT_DATEPICKER_VALIDATORS: any;
  17. /**
  18. * An event used for datepicker input and change events. We don't always have access to a native
  19. * input or change event because the event may have been triggered by the user clicking on the
  20. * calendar popup. For consistency, we always use MatDatepickerInputEvent instead.
  21. */
  22. export declare class MatDatepickerInputEvent<D> {
  23. /** Reference to the datepicker input component that emitted the event. */
  24. target: MatDatepickerInput<D>;
  25. /** Reference to the native input element associated with the datepicker input. */
  26. targetElement: HTMLElement;
  27. /** The new value for the target datepicker input. */
  28. value: D | null;
  29. constructor(
  30. /** Reference to the datepicker input component that emitted the event. */
  31. target: MatDatepickerInput<D>,
  32. /** Reference to the native input element associated with the datepicker input. */
  33. targetElement: HTMLElement);
  34. }
  35. /** Directive used to connect an input to a MatDatepicker. */
  36. export declare class MatDatepickerInput<D> implements ControlValueAccessor, OnDestroy, Validator {
  37. private _elementRef;
  38. _dateAdapter: DateAdapter<D>;
  39. private _dateFormats;
  40. private _formField;
  41. /** The datepicker that this input is associated with. */
  42. matDatepicker: MatDatepicker<D>;
  43. _datepicker: MatDatepicker<D>;
  44. /** Function that can be used to filter out dates within the datepicker. */
  45. matDatepickerFilter: (date: D | null) => boolean;
  46. _dateFilter: (date: D | null) => boolean;
  47. /** The value of the input. */
  48. value: D | null;
  49. private _value;
  50. /** The minimum valid date. */
  51. min: D | null;
  52. private _min;
  53. /** The maximum valid date. */
  54. max: D | null;
  55. private _max;
  56. /** Whether the datepicker-input is disabled. */
  57. disabled: boolean;
  58. private _disabled;
  59. /** Emits when a `change` event is fired on this `<input>`. */
  60. readonly dateChange: EventEmitter<MatDatepickerInputEvent<D>>;
  61. /** Emits when an `input` event is fired on this `<input>`. */
  62. readonly dateInput: EventEmitter<MatDatepickerInputEvent<D>>;
  63. /** Emits when the value changes (either due to user input or programmatic change). */
  64. _valueChange: EventEmitter<D | null>;
  65. /** Emits when the disabled state has changed */
  66. _disabledChange: EventEmitter<boolean>;
  67. _onTouched: () => void;
  68. private _cvaOnChange;
  69. private _validatorOnChange;
  70. private _datepickerSubscription;
  71. private _localeSubscription;
  72. /** The form control validator for whether the input parses. */
  73. private _parseValidator;
  74. /** The form control validator for the min date. */
  75. private _minValidator;
  76. /** The form control validator for the max date. */
  77. private _maxValidator;
  78. /** The form control validator for the date filter. */
  79. private _filterValidator;
  80. /** The combined form control validator for this input. */
  81. private _validator;
  82. /** Whether the last value set on the input was valid. */
  83. private _lastValueValid;
  84. constructor(_elementRef: ElementRef<HTMLInputElement>, _dateAdapter: DateAdapter<D>, _dateFormats: MatDateFormats, _formField: MatFormField);
  85. ngOnDestroy(): void;
  86. /** @docs-private */
  87. registerOnValidatorChange(fn: () => void): void;
  88. /** @docs-private */
  89. validate(c: AbstractControl): ValidationErrors | null;
  90. /**
  91. * @deprecated
  92. * @breaking-change 8.0.0 Use `getConnectedOverlayOrigin` instead
  93. */
  94. getPopupConnectionElementRef(): ElementRef;
  95. /**
  96. * Gets the element that the datepicker popup should be connected to.
  97. * @return The element to connect the popup to.
  98. */
  99. getConnectedOverlayOrigin(): ElementRef;
  100. writeValue(value: D): void;
  101. registerOnChange(fn: (value: any) => void): void;
  102. registerOnTouched(fn: () => void): void;
  103. setDisabledState(isDisabled: boolean): void;
  104. _onKeydown(event: KeyboardEvent): void;
  105. _onInput(value: string): void;
  106. _onChange(): void;
  107. /** Returns the palette used by the input's form field, if any. */
  108. _getThemePalette(): ThemePalette;
  109. /** Handles blur events on the input. */
  110. _onBlur(): void;
  111. /** Formats a value and sets it on the input element. */
  112. private _formatValue;
  113. /**
  114. * @param obj The object to check.
  115. * @returns The given object if it is both a date instance and valid, otherwise null.
  116. */
  117. private _getValidDateOrNull;
  118. }