[6a3a178] | 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, OnDestroy, SimpleChanges, OnChanges } from '@angular/core';
|
---|
| 9 | import { DateAdapter, MatDateFormats } from '@angular/material/core';
|
---|
| 10 | import { Directionality } from '@angular/cdk/bidi';
|
---|
| 11 | import { MatCalendarBody, MatCalendarCell, MatCalendarUserEvent, MatCalendarCellClassFunction } from './calendar-body';
|
---|
| 12 | import { DateRange } from './date-selection-model';
|
---|
| 13 | import { MatDateRangeSelectionStrategy } from './date-range-selection-strategy';
|
---|
| 14 | /**
|
---|
| 15 | * An internal component used to display a single month in the datepicker.
|
---|
| 16 | * @docs-private
|
---|
| 17 | */
|
---|
| 18 | export declare class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
|
---|
| 19 | readonly _changeDetectorRef: ChangeDetectorRef;
|
---|
| 20 | private _dateFormats;
|
---|
| 21 | _dateAdapter: DateAdapter<D>;
|
---|
| 22 | private _dir?;
|
---|
| 23 | private _rangeStrategy?;
|
---|
| 24 | private _rerenderSubscription;
|
---|
| 25 | /** Flag used to filter out space/enter keyup events that originated outside of the view. */
|
---|
| 26 | private _selectionKeyPressed;
|
---|
| 27 | /**
|
---|
| 28 | * The date to display in this month view (everything other than the month and year is ignored).
|
---|
| 29 | */
|
---|
| 30 | get activeDate(): D;
|
---|
| 31 | set activeDate(value: D);
|
---|
| 32 | private _activeDate;
|
---|
| 33 | /** The currently selected date. */
|
---|
| 34 | get selected(): DateRange<D> | D | null;
|
---|
| 35 | set selected(value: DateRange<D> | D | null);
|
---|
| 36 | private _selected;
|
---|
| 37 | /** The minimum selectable date. */
|
---|
| 38 | get minDate(): D | null;
|
---|
| 39 | set minDate(value: D | null);
|
---|
| 40 | private _minDate;
|
---|
| 41 | /** The maximum selectable date. */
|
---|
| 42 | get maxDate(): D | null;
|
---|
| 43 | set maxDate(value: D | null);
|
---|
| 44 | private _maxDate;
|
---|
| 45 | /** Function used to filter which dates are selectable. */
|
---|
| 46 | dateFilter: (date: D) => boolean;
|
---|
| 47 | /** Function that can be used to add custom CSS classes to dates. */
|
---|
| 48 | dateClass: MatCalendarCellClassFunction<D>;
|
---|
| 49 | /** Start of the comparison range. */
|
---|
| 50 | comparisonStart: D | null;
|
---|
| 51 | /** End of the comparison range. */
|
---|
| 52 | comparisonEnd: D | null;
|
---|
| 53 | /** Emits when a new date is selected. */
|
---|
| 54 | readonly selectedChange: EventEmitter<D | null>;
|
---|
| 55 | /** Emits when any date is selected. */
|
---|
| 56 | readonly _userSelection: EventEmitter<MatCalendarUserEvent<D | null>>;
|
---|
| 57 | /** Emits when any date is activated. */
|
---|
| 58 | readonly activeDateChange: EventEmitter<D>;
|
---|
| 59 | /** The body of calendar table */
|
---|
| 60 | _matCalendarBody: MatCalendarBody;
|
---|
| 61 | /** The label for this month (e.g. "January 2017"). */
|
---|
| 62 | _monthLabel: string;
|
---|
| 63 | /** Grid of calendar cells representing the dates of the month. */
|
---|
| 64 | _weeks: MatCalendarCell[][];
|
---|
| 65 | /** The number of blank cells in the first row before the 1st of the month. */
|
---|
| 66 | _firstWeekOffset: number;
|
---|
| 67 | /** Start value of the currently-shown date range. */
|
---|
| 68 | _rangeStart: number | null;
|
---|
| 69 | /** End value of the currently-shown date range. */
|
---|
| 70 | _rangeEnd: number | null;
|
---|
| 71 | /** Start value of the currently-shown comparison date range. */
|
---|
| 72 | _comparisonRangeStart: number | null;
|
---|
| 73 | /** End value of the currently-shown comparison date range. */
|
---|
| 74 | _comparisonRangeEnd: number | null;
|
---|
| 75 | /** Start of the preview range. */
|
---|
| 76 | _previewStart: number | null;
|
---|
| 77 | /** End of the preview range. */
|
---|
| 78 | _previewEnd: number | null;
|
---|
| 79 | /** Whether the user is currently selecting a range of dates. */
|
---|
| 80 | _isRange: boolean;
|
---|
| 81 | /** The date of the month that today falls on. Null if today is in another month. */
|
---|
| 82 | _todayDate: number | null;
|
---|
| 83 | /** The names of the weekdays. */
|
---|
| 84 | _weekdays: {
|
---|
| 85 | long: string;
|
---|
| 86 | narrow: string;
|
---|
| 87 | }[];
|
---|
| 88 | constructor(_changeDetectorRef: ChangeDetectorRef, _dateFormats: MatDateFormats, _dateAdapter: DateAdapter<D>, _dir?: Directionality | undefined, _rangeStrategy?: MatDateRangeSelectionStrategy<D> | undefined);
|
---|
| 89 | ngAfterContentInit(): void;
|
---|
| 90 | ngOnChanges(changes: SimpleChanges): void;
|
---|
| 91 | ngOnDestroy(): void;
|
---|
| 92 | /** Handles when a new date is selected. */
|
---|
| 93 | _dateSelected(event: MatCalendarUserEvent<number>): void;
|
---|
| 94 | /** Handles keydown events on the calendar body when calendar is in month view. */
|
---|
| 95 | _handleCalendarBodyKeydown(event: KeyboardEvent): void;
|
---|
| 96 | /** Handles keyup events on the calendar body when calendar is in month view. */
|
---|
| 97 | _handleCalendarBodyKeyup(event: KeyboardEvent): void;
|
---|
| 98 | /** Initializes this month view. */
|
---|
| 99 | _init(): void;
|
---|
| 100 | /** Focuses the active cell after the microtask queue is empty. */
|
---|
| 101 | _focusActiveCell(movePreview?: boolean): void;
|
---|
| 102 | /** Called when the user has activated a new cell and the preview needs to be updated. */
|
---|
| 103 | _previewChanged({ event, value: cell }: MatCalendarUserEvent<MatCalendarCell<D> | null>): void;
|
---|
| 104 | /** Initializes the weekdays. */
|
---|
| 105 | private _initWeekdays;
|
---|
| 106 | /** Creates MatCalendarCells for the dates in this month. */
|
---|
| 107 | private _createWeekCells;
|
---|
| 108 | /** Date filter for the month */
|
---|
| 109 | private _shouldEnableDate;
|
---|
| 110 | /**
|
---|
| 111 | * Gets the date in this month that the given Date falls on.
|
---|
| 112 | * Returns null if the given Date is in another month.
|
---|
| 113 | */
|
---|
| 114 | private _getDateInCurrentMonth;
|
---|
| 115 | /** Checks whether the 2 dates are non-null and fall within the same month of the same year. */
|
---|
| 116 | private _hasSameMonthAndYear;
|
---|
| 117 | /** Gets the value that will be used to one cell to another. */
|
---|
| 118 | private _getCellCompareValue;
|
---|
| 119 | /** Determines whether the user has the RTL layout direction. */
|
---|
| 120 | private _isRtl;
|
---|
| 121 | /** Sets the current range based on a model value. */
|
---|
| 122 | private _setRanges;
|
---|
| 123 | /** Gets whether a date can be selected in the month view. */
|
---|
| 124 | private _canSelect;
|
---|
| 125 | }
|
---|