calendar.d.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 { ComponentType, Portal } from '@angular/cdk/portal';
  9. import { AfterContentInit, AfterViewChecked, ChangeDetectorRef, EventEmitter, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
  10. import { DateAdapter, MatDateFormats } from '@angular/material/core';
  11. import { Subject } from 'rxjs';
  12. import { MatCalendarCellCssClasses } from './calendar-body';
  13. import { MatDatepickerIntl } from './datepicker-intl';
  14. import { MatMonthView } from './month-view';
  15. import { MatMultiYearView } from './multi-year-view';
  16. import { MatYearView } from './year-view';
  17. /**
  18. * Possible views for the calendar.
  19. * @docs-private
  20. */
  21. export declare type MatCalendarView = 'month' | 'year' | 'multi-year';
  22. /** Default header for MatCalendar */
  23. export declare class MatCalendarHeader<D> {
  24. private _intl;
  25. calendar: MatCalendar<D>;
  26. private _dateAdapter;
  27. private _dateFormats;
  28. constructor(_intl: MatDatepickerIntl, calendar: MatCalendar<D>, _dateAdapter: DateAdapter<D>, _dateFormats: MatDateFormats, changeDetectorRef: ChangeDetectorRef);
  29. /** The label for the current calendar view. */
  30. readonly periodButtonText: string;
  31. readonly periodButtonLabel: string;
  32. /** The label for the previous button. */
  33. readonly prevButtonLabel: string;
  34. /** The label for the next button. */
  35. readonly nextButtonLabel: string;
  36. /** Handles user clicks on the period label. */
  37. currentPeriodClicked(): void;
  38. /** Handles user clicks on the previous button. */
  39. previousClicked(): void;
  40. /** Handles user clicks on the next button. */
  41. nextClicked(): void;
  42. /** Whether the previous period button is enabled. */
  43. previousEnabled(): boolean;
  44. /** Whether the next period button is enabled. */
  45. nextEnabled(): boolean;
  46. /** Whether the two dates represent the same view in the current view mode (month or year). */
  47. private _isSameView;
  48. }
  49. /**
  50. * A calendar that is used as part of the datepicker.
  51. * @docs-private
  52. */
  53. export declare class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDestroy, OnChanges {
  54. private _dateAdapter;
  55. private _dateFormats;
  56. private _changeDetectorRef;
  57. /** An input indicating the type of the header component, if set. */
  58. headerComponent: ComponentType<any>;
  59. /** A portal containing the header component type for this calendar. */
  60. _calendarHeaderPortal: Portal<any>;
  61. private _intlChanges;
  62. /**
  63. * Used for scheduling that focus should be moved to the active cell on the next tick.
  64. * We need to schedule it, rather than do it immediately, because we have to wait
  65. * for Angular to re-evaluate the view children.
  66. */
  67. private _moveFocusOnNextTick;
  68. /** A date representing the period (month or year) to start the calendar in. */
  69. startAt: D | null;
  70. private _startAt;
  71. /** Whether the calendar should be started in month or year view. */
  72. startView: MatCalendarView;
  73. /** The currently selected date. */
  74. selected: D | null;
  75. private _selected;
  76. /** The minimum selectable date. */
  77. minDate: D | null;
  78. private _minDate;
  79. /** The maximum selectable date. */
  80. maxDate: D | null;
  81. private _maxDate;
  82. /** Function used to filter which dates are selectable. */
  83. dateFilter: (date: D) => boolean;
  84. /** Function that can be used to add custom CSS classes to dates. */
  85. dateClass: (date: D) => MatCalendarCellCssClasses;
  86. /** Emits when the currently selected date changes. */
  87. readonly selectedChange: EventEmitter<D>;
  88. /**
  89. * Emits the year chosen in multiyear view.
  90. * This doesn't imply a change on the selected date.
  91. */
  92. readonly yearSelected: EventEmitter<D>;
  93. /**
  94. * Emits the month chosen in year view.
  95. * This doesn't imply a change on the selected date.
  96. */
  97. readonly monthSelected: EventEmitter<D>;
  98. /** Emits when any date is selected. */
  99. readonly _userSelection: EventEmitter<void>;
  100. /** Reference to the current month view component. */
  101. monthView: MatMonthView<D>;
  102. /** Reference to the current year view component. */
  103. yearView: MatYearView<D>;
  104. /** Reference to the current multi-year view component. */
  105. multiYearView: MatMultiYearView<D>;
  106. /**
  107. * The current active date. This determines which time period is shown and which date is
  108. * highlighted when using keyboard navigation.
  109. */
  110. activeDate: D;
  111. private _clampedActiveDate;
  112. /** Whether the calendar is in month view. */
  113. currentView: MatCalendarView;
  114. private _currentView;
  115. /**
  116. * Emits whenever there is a state change that the header may need to respond to.
  117. */
  118. stateChanges: Subject<void>;
  119. constructor(_intl: MatDatepickerIntl, _dateAdapter: DateAdapter<D>, _dateFormats: MatDateFormats, _changeDetectorRef: ChangeDetectorRef);
  120. ngAfterContentInit(): void;
  121. ngAfterViewChecked(): void;
  122. ngOnDestroy(): void;
  123. ngOnChanges(changes: SimpleChanges): void;
  124. focusActiveCell(): void;
  125. /** Updates today's date after an update of the active date */
  126. updateTodaysDate(): void;
  127. /** Handles date selection in the month view. */
  128. _dateSelected(date: D): void;
  129. /** Handles year selection in the multiyear view. */
  130. _yearSelectedInMultiYearView(normalizedYear: D): void;
  131. /** Handles month selection in the year view. */
  132. _monthSelectedInYearView(normalizedMonth: D): void;
  133. _userSelected(): void;
  134. /** Handles year/month selection in the multi-year/year views. */
  135. _goToDateInView(date: D, view: 'month' | 'year' | 'multi-year'): void;
  136. /**
  137. * @param obj The object to check.
  138. * @returns The given object if it is both a date instance and valid, otherwise null.
  139. */
  140. private _getValidDateOrNull;
  141. /** Returns the component instance that corresponds to the current calendar view. */
  142. private _getCurrentViewComponent;
  143. }