multi-year-view.d.ts 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 } from '@angular/material/core';
  10. import { Directionality } from '@angular/cdk/bidi';
  11. import { MatCalendarBody, MatCalendarCell } from './calendar-body';
  12. export declare const yearsPerPage = 24;
  13. export declare const yearsPerRow = 4;
  14. /**
  15. * An internal component used to display a year selector in the datepicker.
  16. * @docs-private
  17. */
  18. export declare class MatMultiYearView<D> implements AfterContentInit {
  19. private _changeDetectorRef;
  20. _dateAdapter: DateAdapter<D>;
  21. private _dir?;
  22. /** The date to display in this multi-year view (everything other than the year is ignored). */
  23. activeDate: D;
  24. private _activeDate;
  25. /** The currently selected date. */
  26. selected: D | null;
  27. private _selected;
  28. /** The minimum selectable date. */
  29. minDate: D | null;
  30. private _minDate;
  31. /** The maximum selectable date. */
  32. maxDate: D | null;
  33. private _maxDate;
  34. /** A function used to filter which dates are selectable. */
  35. dateFilter: (date: D) => boolean;
  36. /** Emits when a new year is selected. */
  37. readonly selectedChange: EventEmitter<D>;
  38. /** Emits the selected year. This doesn't imply a change on the selected date */
  39. readonly yearSelected: EventEmitter<D>;
  40. /** Emits when any date is activated. */
  41. readonly activeDateChange: EventEmitter<D>;
  42. /** The body of calendar table */
  43. _matCalendarBody: MatCalendarBody;
  44. /** Grid of calendar cells representing the currently displayed years. */
  45. _years: MatCalendarCell[][];
  46. /** The year that today falls on. */
  47. _todayYear: number;
  48. /** The year of the selected date. Null if the selected date is null. */
  49. _selectedYear: number | null;
  50. constructor(_changeDetectorRef: ChangeDetectorRef, _dateAdapter: DateAdapter<D>, _dir?: Directionality | undefined);
  51. ngAfterContentInit(): void;
  52. /** Initializes this multi-year view. */
  53. _init(): void;
  54. /** Handles when a new year is selected. */
  55. _yearSelected(year: number): void;
  56. /** Handles keydown events on the calendar body when calendar is in multi-year view. */
  57. _handleCalendarBodyKeydown(event: KeyboardEvent): void;
  58. _getActiveCell(): number;
  59. /** Focuses the active cell after the microtask queue is empty. */
  60. _focusActiveCell(): void;
  61. /** Creates an MatCalendarCell for the given year. */
  62. private _createCellForYear;
  63. /** Whether the given year is enabled. */
  64. private _shouldEnableYear;
  65. /**
  66. * @param obj The object to check.
  67. * @returns The given object if it is both a date instance and valid, otherwise null.
  68. */
  69. private _getValidDateOrNull;
  70. /** Determines whether the user has the RTL layout direction. */
  71. private _isRtl;
  72. }
  73. export declare function isSameMultiYearView<D>(dateAdapter: DateAdapter<D>, date1: D, date2: D, minDate: D | null, maxDate: D | null): boolean;
  74. /**
  75. * When the multi-year view is first opened, the active year will be in view.
  76. * So we compute how many years are between the active year and the *slot* where our
  77. * "startingYear" will render when paged into view.
  78. */
  79. export declare function getActiveOffset<D>(dateAdapter: DateAdapter<D>, activeDate: D, minDate: D | null, maxDate: D | null): number;