datepicker.d.ts 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 { Directionality } from '@angular/cdk/bidi';
  9. import { Overlay, OverlayRef, ScrollStrategy } from '@angular/cdk/overlay';
  10. import { ComponentType } from '@angular/cdk/portal';
  11. import { AfterViewInit, ElementRef, EventEmitter, InjectionToken, NgZone, OnDestroy, ViewContainerRef } from '@angular/core';
  12. import { CanColor, CanColorCtor, DateAdapter, ThemePalette } from '@angular/material/core';
  13. import { MatDialog } from '@angular/material/dialog';
  14. import { Subject } from 'rxjs';
  15. import { MatCalendar } from './calendar';
  16. import { MatDatepickerInput } from './datepicker-input';
  17. import { MatCalendarCellCssClasses } from './calendar-body';
  18. /** Injection token that determines the scroll handling while the calendar is open. */
  19. export declare const MAT_DATEPICKER_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
  20. /** @docs-private */
  21. export declare function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy;
  22. /** @docs-private */
  23. export declare const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER: {
  24. provide: InjectionToken<() => ScrollStrategy>;
  25. deps: (typeof Overlay)[];
  26. useFactory: typeof MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY;
  27. };
  28. /** @docs-private */
  29. declare class MatDatepickerContentBase {
  30. _elementRef: ElementRef;
  31. constructor(_elementRef: ElementRef);
  32. }
  33. declare const _MatDatepickerContentMixinBase: CanColorCtor & typeof MatDatepickerContentBase;
  34. /**
  35. * Component used as the content for the datepicker dialog and popup. We use this instead of using
  36. * MatCalendar directly as the content so we can control the initial focus. This also gives us a
  37. * place to put additional features of the popup that are not part of the calendar itself in the
  38. * future. (e.g. confirmation buttons).
  39. * @docs-private
  40. */
  41. export declare class MatDatepickerContent<D> extends _MatDatepickerContentMixinBase implements AfterViewInit, CanColor {
  42. /** Reference to the internal calendar component. */
  43. _calendar: MatCalendar<D>;
  44. /** Reference to the datepicker that created the overlay. */
  45. datepicker: MatDatepicker<D>;
  46. /** Whether the datepicker is above or below the input. */
  47. _isAbove: boolean;
  48. constructor(elementRef: ElementRef);
  49. ngAfterViewInit(): void;
  50. }
  51. /** Component responsible for managing the datepicker popup/dialog. */
  52. export declare class MatDatepicker<D> implements OnDestroy, CanColor {
  53. private _dialog;
  54. private _overlay;
  55. private _ngZone;
  56. private _viewContainerRef;
  57. private _dateAdapter;
  58. private _dir;
  59. private _document;
  60. private _scrollStrategy;
  61. /** An input indicating the type of the custom header component for the calendar, if set. */
  62. calendarHeaderComponent: ComponentType<any>;
  63. /** The date to open the calendar to initially. */
  64. startAt: D | null;
  65. private _startAt;
  66. /** The view that the calendar should start in. */
  67. startView: 'month' | 'year' | 'multi-year';
  68. /** Color palette to use on the datepicker's calendar. */
  69. color: ThemePalette;
  70. _color: ThemePalette;
  71. /**
  72. * Whether the calendar UI is in touch mode. In touch mode the calendar opens in a dialog rather
  73. * than a popup and elements have more padding to allow for bigger touch targets.
  74. */
  75. touchUi: boolean;
  76. private _touchUi;
  77. /** Whether the datepicker pop-up should be disabled. */
  78. disabled: boolean;
  79. private _disabled;
  80. /**
  81. * Emits selected year in multiyear view.
  82. * This doesn't imply a change on the selected date.
  83. */
  84. readonly yearSelected: EventEmitter<D>;
  85. /**
  86. * Emits selected month in year view.
  87. * This doesn't imply a change on the selected date.
  88. */
  89. readonly monthSelected: EventEmitter<D>;
  90. /** Classes to be passed to the date picker panel. Supports the same syntax as `ngClass`. */
  91. panelClass: string | string[];
  92. /** Function that can be used to add custom CSS classes to dates. */
  93. dateClass: (date: D) => MatCalendarCellCssClasses;
  94. /** Emits when the datepicker has been opened. */
  95. openedStream: EventEmitter<void>;
  96. /** Emits when the datepicker has been closed. */
  97. closedStream: EventEmitter<void>;
  98. /** Whether the calendar is open. */
  99. opened: boolean;
  100. private _opened;
  101. /** The id for the datepicker calendar. */
  102. id: string;
  103. /** The currently selected date. */
  104. _selected: D | null;
  105. private _validSelected;
  106. /** The minimum selectable date. */
  107. readonly _minDate: D | null;
  108. /** The maximum selectable date. */
  109. readonly _maxDate: D | null;
  110. readonly _dateFilter: (date: D | null) => boolean;
  111. /** A reference to the overlay when the calendar is opened as a popup. */
  112. _popupRef: OverlayRef;
  113. /** A reference to the dialog when the calendar is opened as a dialog. */
  114. private _dialogRef;
  115. /** A portal containing the calendar for this datepicker. */
  116. private _calendarPortal;
  117. /** Reference to the component instantiated in popup mode. */
  118. private _popupComponentRef;
  119. /** The element that was focused before the datepicker was opened. */
  120. private _focusedElementBeforeOpen;
  121. /** Subscription to value changes in the associated input element. */
  122. private _inputSubscription;
  123. /** The input element this datepicker is associated with. */
  124. _datepickerInput: MatDatepickerInput<D>;
  125. /** Emits when the datepicker is disabled. */
  126. readonly _disabledChange: Subject<boolean>;
  127. /** Emits new selected date when selected date changes. */
  128. readonly _selectedChanged: Subject<D>;
  129. constructor(_dialog: MatDialog, _overlay: Overlay, _ngZone: NgZone, _viewContainerRef: ViewContainerRef, scrollStrategy: any, _dateAdapter: DateAdapter<D>, _dir: Directionality, _document: any);
  130. ngOnDestroy(): void;
  131. /** Selects the given date */
  132. select(date: D): void;
  133. /** Emits the selected year in multiyear view */
  134. _selectYear(normalizedYear: D): void;
  135. /** Emits selected month in year view */
  136. _selectMonth(normalizedMonth: D): void;
  137. /**
  138. * Register an input with this datepicker.
  139. * @param input The datepicker input to register with this datepicker.
  140. */
  141. _registerInput(input: MatDatepickerInput<D>): void;
  142. /** Open the calendar. */
  143. open(): void;
  144. /** Close the calendar. */
  145. close(): void;
  146. /** Open the calendar as a dialog. */
  147. private _openAsDialog;
  148. /** Open the calendar as a popup. */
  149. private _openAsPopup;
  150. /** Create the popup. */
  151. private _createPopup;
  152. /** Create the popup PositionStrategy. */
  153. private _createPopupPositionStrategy;
  154. /**
  155. * @param obj The object to check.
  156. * @returns The given object if it is both a date instance and valid, otherwise null.
  157. */
  158. private _getValidDateOrNull;
  159. /** Passes the current theme color along to the calendar overlay. */
  160. private _setColor;
  161. }
  162. export {};