month-view.d.ts 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 { AfterContentInit, ChangeDetectorRef, EventEmitter } from '@angular/core';
  9. import { DateAdapter, MatDateFormats } from '@angular/material/core';
  10. import { Directionality } from '@angular/cdk/bidi';
  11. import { MatCalendarBody, MatCalendarCell, MatCalendarCellCssClasses } from './calendar-body';
  12. /**
  13. * An internal component used to display a single month in the datepicker.
  14. * @docs-private
  15. */
  16. export declare class MatMonthView<D> implements AfterContentInit {
  17. private _changeDetectorRef;
  18. private _dateFormats;
  19. _dateAdapter: DateAdapter<D>;
  20. private _dir?;
  21. /**
  22. * The date to display in this month view (everything other than the month and year is ignored).
  23. */
  24. activeDate: D;
  25. private _activeDate;
  26. /** The currently selected date. */
  27. selected: D | null;
  28. private _selected;
  29. /** The minimum selectable date. */
  30. minDate: D | null;
  31. private _minDate;
  32. /** The maximum selectable date. */
  33. maxDate: D | null;
  34. private _maxDate;
  35. /** Function used to filter which dates are selectable. */
  36. dateFilter: (date: D) => boolean;
  37. /** Function that can be used to add custom CSS classes to dates. */
  38. dateClass: (date: D) => MatCalendarCellCssClasses;
  39. /** Emits when a new date is selected. */
  40. readonly selectedChange: EventEmitter<D | null>;
  41. /** Emits when any date is selected. */
  42. readonly _userSelection: EventEmitter<void>;
  43. /** Emits when any date is activated. */
  44. readonly activeDateChange: EventEmitter<D>;
  45. /** The body of calendar table */
  46. _matCalendarBody: MatCalendarBody;
  47. /** The label for this month (e.g. "January 2017"). */
  48. _monthLabel: string;
  49. /** Grid of calendar cells representing the dates of the month. */
  50. _weeks: MatCalendarCell[][];
  51. /** The number of blank cells in the first row before the 1st of the month. */
  52. _firstWeekOffset: number;
  53. /**
  54. * The date of the month that the currently selected Date falls on.
  55. * Null if the currently selected Date is in another month.
  56. */
  57. _selectedDate: number | null;
  58. /** The date of the month that today falls on. Null if today is in another month. */
  59. _todayDate: number | null;
  60. /** The names of the weekdays. */
  61. _weekdays: {
  62. long: string;
  63. narrow: string;
  64. }[];
  65. constructor(_changeDetectorRef: ChangeDetectorRef, _dateFormats: MatDateFormats, _dateAdapter: DateAdapter<D>, _dir?: Directionality | undefined);
  66. ngAfterContentInit(): void;
  67. /** Handles when a new date is selected. */
  68. _dateSelected(date: number): void;
  69. /** Handles keydown events on the calendar body when calendar is in month view. */
  70. _handleCalendarBodyKeydown(event: KeyboardEvent): void;
  71. /** Initializes this month view. */
  72. _init(): void;
  73. /** Focuses the active cell after the microtask queue is empty. */
  74. _focusActiveCell(): void;
  75. /** Initializes the weekdays. */
  76. private _initWeekdays;
  77. /** Creates MatCalendarCells for the dates in this month. */
  78. private _createWeekCells;
  79. /** Date filter for the month */
  80. private _shouldEnableDate;
  81. /**
  82. * Gets the date in this month that the given Date falls on.
  83. * Returns null if the given Date is in another month.
  84. */
  85. private _getDateInCurrentMonth;
  86. /** Checks whether the 2 dates are non-null and fall within the same month of the same year. */
  87. private _hasSameMonthAndYear;
  88. /**
  89. * @param obj The object to check.
  90. * @returns The given object if it is both a date instance and valid, otherwise null.
  91. */
  92. private _getValidDateOrNull;
  93. /** Determines whether the user has the RTL layout direction. */
  94. private _isRtl;
  95. }