@angular/material
Version:
Angular Material
997 lines (990 loc) • 91.4 kB
TypeScript
import * as i0 from '@angular/core';
import { OnChanges, OnDestroy, AfterViewChecked, EventEmitter, SimpleChanges, FactoryProvider, AfterContentInit, ChangeDetectorRef, AfterViewInit, ElementRef, InjectionToken, OnInit, DoCheck, TemplateRef } from '@angular/core';
import { b as MatButton, m as MatButtonModule } from '../module.d-4830783a.js';
import * as i2 from '@angular/cdk/overlay';
import { ScrollStrategy, Overlay } from '@angular/cdk/overlay';
import * as i1 from '@angular/cdk/a11y';
import { FocusOrigin } from '@angular/cdk/a11y';
import * as i3 from '@angular/cdk/portal';
import { ComponentType, Portal, TemplatePortal } from '@angular/cdk/portal';
import { M as MatCommonModule } from '../common-module.d-1b789e68.js';
import { Observable, Subject } from 'rxjs';
import { D as DateAdapter$1 } from '../date-adapter.d-de8dcff3.js';
import { DateAdapter } from '@angular/material/core';
import { T as ThemePalette } from '../palette.d-f5ca9a2b.js';
import { ControlValueAccessor, Validator, ValidatorFn, AbstractControl, ValidationErrors, NgForm, FormGroupDirective, NgControl } from '@angular/forms';
import { M as MatFormFieldControl } from '../form-field-control.d-d7b3a431.js';
import { Directionality } from '@angular/cdk/bidi';
import { E as ErrorStateMatcher } from '../error-options.d-bd1801bf.js';
import * as i5 from '@angular/cdk/scrolling';
import '../index.d-9bdbdee9.js';
import '../ripple.d-816a1e42.js';
import '@angular/cdk/platform';
import '../ripple-loader.d-850167e6.js';
/** Extra CSS classes that can be associated with a calendar cell. */
type MatCalendarCellCssClasses = string | string[] | Set<string> | {
[key: string]: any;
};
/** Function that can generate the extra classes that should be added to a calendar cell. */
type MatCalendarCellClassFunction<D> = (date: D, view: 'month' | 'year' | 'multi-year') => MatCalendarCellCssClasses;
/**
* An internal class that represents the data corresponding to a single calendar cell.
* @docs-private
*/
declare class MatCalendarCell<D = any> {
value: number;
displayValue: string;
ariaLabel: string;
enabled: boolean;
cssClasses: MatCalendarCellCssClasses;
compareValue: number;
rawValue?: D | undefined;
readonly id: number;
constructor(value: number, displayValue: string, ariaLabel: string, enabled: boolean, cssClasses?: MatCalendarCellCssClasses, compareValue?: number, rawValue?: D | undefined);
}
/** Event emitted when a date inside the calendar is triggered as a result of a user action. */
interface MatCalendarUserEvent<D> {
value: D;
event: Event;
}
/**
* An internal component used to display calendar data in a table.
* @docs-private
*/
declare class MatCalendarBody<D = any> implements OnChanges, OnDestroy, AfterViewChecked {
private _elementRef;
private _ngZone;
private _platform;
private _intl;
private _eventCleanups;
/**
* Used to skip the next focus event when rendering the preview range.
* We need a flag like this, because some browsers fire focus events asynchronously.
*/
private _skipNextFocus;
/**
* Used to focus the active cell after change detection has run.
*/
private _focusActiveCellAfterViewChecked;
/** The label for the table. (e.g. "Jan 2017"). */
label: string;
/** The cells to display in the table. */
rows: MatCalendarCell[][];
/** The value in the table that corresponds to today. */
todayValue: number;
/** Start value of the selected date range. */
startValue: number;
/** End value of the selected date range. */
endValue: number;
/** The minimum number of free cells needed to fit the label in the first row. */
labelMinRequiredCells: number;
/** The number of columns in the table. */
numCols: number;
/** The cell number of the active cell in the table. */
activeCell: number;
ngAfterViewChecked(): void;
/** Whether a range is being selected. */
isRange: boolean;
/**
* The aspect ratio (width / height) to use for the cells in the table. This aspect ratio will be
* maintained even as the table resizes.
*/
cellAspectRatio: number;
/** Start of the comparison range. */
comparisonStart: number | null;
/** End of the comparison range. */
comparisonEnd: number | null;
/** Start of the preview range. */
previewStart: number | null;
/** End of the preview range. */
previewEnd: number | null;
/** ARIA Accessible name of the `<input matStartDate/>` */
startDateAccessibleName: string | null;
/** ARIA Accessible name of the `<input matEndDate/>` */
endDateAccessibleName: string | null;
/** Emits when a new value is selected. */
readonly selectedValueChange: EventEmitter<MatCalendarUserEvent<number>>;
/** Emits when the preview has changed as a result of a user action. */
readonly previewChange: EventEmitter<MatCalendarUserEvent<MatCalendarCell<any> | null>>;
readonly activeDateChange: EventEmitter<MatCalendarUserEvent<number>>;
/** Emits the date at the possible start of a drag event. */
readonly dragStarted: EventEmitter<MatCalendarUserEvent<D>>;
/** Emits the date at the conclusion of a drag, or null if mouse was not released on a date. */
readonly dragEnded: EventEmitter<MatCalendarUserEvent<D | null>>;
/** The number of blank cells to put at the beginning for the first row. */
_firstRowOffset: number;
/** Padding for the individual date cells. */
_cellPadding: string;
/** Width of an individual cell. */
_cellWidth: string;
/** ID for the start date label. */
_startDateLabelId: string;
/** ID for the end date label. */
_endDateLabelId: string;
/** ID for the comparison start date label. */
_comparisonStartDateLabelId: string;
/** ID for the comparison end date label. */
_comparisonEndDateLabelId: string;
private _didDragSinceMouseDown;
private _injector;
comparisonDateAccessibleName: string;
/**
* Tracking function for rows based on their identity. Ideally we would use some sort of
* key on the row, but that would require a breaking change for the `rows` input. We don't
* use the built-in identity tracking, because it logs warnings.
*/
_trackRow: (row: MatCalendarCell[]) => MatCalendarCell<any>[];
constructor(...args: unknown[]);
/** Called when a cell is clicked. */
_cellClicked(cell: MatCalendarCell, event: MouseEvent): void;
_emitActiveDateChange(cell: MatCalendarCell, event: FocusEvent): void;
/** Returns whether a cell should be marked as selected. */
_isSelected(value: number): boolean;
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
/** Returns whether a cell is active. */
_isActiveCell(rowIndex: number, colIndex: number): boolean;
/**
* Focuses the active cell after the microtask queue is empty.
*
* Adding a 0ms setTimeout seems to fix Voiceover losing focus when pressing PageUp/PageDown
* (issue #24330).
*
* Determined a 0ms by gradually increasing duration from 0 and testing two use cases with screen
* reader enabled:
*
* 1. Pressing PageUp/PageDown repeatedly with pausing between each key press.
* 2. Pressing and holding the PageDown key with repeated keys enabled.
*
* Test 1 worked roughly 95-99% of the time with 0ms and got a little bit better as the duration
* increased. Test 2 got slightly better until the duration was long enough to interfere with
* repeated keys. If the repeated key speed was faster than the timeout duration, then pressing
* and holding pagedown caused the entire page to scroll.
*
* Since repeated key speed can verify across machines, determined that any duration could
* potentially interfere with repeated keys. 0ms would be best because it almost entirely
* eliminates the focus being lost in Voiceover (#24330) without causing unintended side effects.
* Adding delay also complicates writing tests.
*/
_focusActiveCell(movePreview?: boolean): void;
/** Focuses the active cell after change detection has run and the microtask queue is empty. */
_scheduleFocusActiveCellAfterViewChecked(): void;
/** Gets whether a value is the start of the main range. */
_isRangeStart(value: number): boolean;
/** Gets whether a value is the end of the main range. */
_isRangeEnd(value: number): boolean;
/** Gets whether a value is within the currently-selected range. */
_isInRange(value: number): boolean;
/** Gets whether a value is the start of the comparison range. */
_isComparisonStart(value: number): boolean;
/** Whether the cell is a start bridge cell between the main and comparison ranges. */
_isComparisonBridgeStart(value: number, rowIndex: number, colIndex: number): boolean;
/** Whether the cell is an end bridge cell between the main and comparison ranges. */
_isComparisonBridgeEnd(value: number, rowIndex: number, colIndex: number): boolean;
/** Gets whether a value is the end of the comparison range. */
_isComparisonEnd(value: number): boolean;
/** Gets whether a value is within the current comparison range. */
_isInComparisonRange(value: number): boolean;
/**
* Gets whether a value is the same as the start and end of the comparison range.
* For context, the functions that we use to determine whether something is the start/end of
* a range don't allow for the start and end to be on the same day, because we'd have to use
* much more specific CSS selectors to style them correctly in all scenarios. This is fine for
* the regular range, because when it happens, the selected styles take over and still show where
* the range would've been, however we don't have these selected styles for a comparison range.
* This function is used to apply a class that serves the same purpose as the one for selected
* dates, but it only applies in the context of a comparison range.
*/
_isComparisonIdentical(value: number): boolean;
/** Gets whether a value is the start of the preview range. */
_isPreviewStart(value: number): boolean;
/** Gets whether a value is the end of the preview range. */
_isPreviewEnd(value: number): boolean;
/** Gets whether a value is inside the preview range. */
_isInPreview(value: number): boolean;
/** Gets ids of aria descriptions for the start and end of a date range. */
_getDescribedby(value: number): string | null;
/**
* Event handler for when the user enters an element
* inside the calendar body (e.g. by hovering in or focus).
*/
private _enterHandler;
private _touchmoveHandler;
/**
* Event handler for when the user's pointer leaves an element
* inside the calendar body (e.g. by hovering out or blurring).
*/
private _leaveHandler;
/**
* Triggered on mousedown or touchstart on a date cell.
* Respsonsible for starting a drag sequence.
*/
private _mousedownHandler;
/** Triggered on mouseup anywhere. Respsonsible for ending a drag sequence. */
private _mouseupHandler;
/** Triggered on touchend anywhere. Respsonsible for ending a drag sequence. */
private _touchendHandler;
/** Finds the MatCalendarCell that corresponds to a DOM node. */
private _getCellFromElement;
static ɵfac: i0.ɵɵFactoryDeclaration<MatCalendarBody<any>, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatCalendarBody<any>, "[mat-calendar-body]", ["matCalendarBody"], { "label": { "alias": "label"; "required": false; }; "rows": { "alias": "rows"; "required": false; }; "todayValue": { "alias": "todayValue"; "required": false; }; "startValue": { "alias": "startValue"; "required": false; }; "endValue": { "alias": "endValue"; "required": false; }; "labelMinRequiredCells": { "alias": "labelMinRequiredCells"; "required": false; }; "numCols": { "alias": "numCols"; "required": false; }; "activeCell": { "alias": "activeCell"; "required": false; }; "isRange": { "alias": "isRange"; "required": false; }; "cellAspectRatio": { "alias": "cellAspectRatio"; "required": false; }; "comparisonStart": { "alias": "comparisonStart"; "required": false; }; "comparisonEnd": { "alias": "comparisonEnd"; "required": false; }; "previewStart": { "alias": "previewStart"; "required": false; }; "previewEnd": { "alias": "previewEnd"; "required": false; }; "startDateAccessibleName": { "alias": "startDateAccessibleName"; "required": false; }; "endDateAccessibleName": { "alias": "endDateAccessibleName"; "required": false; }; }, { "selectedValueChange": "selectedValueChange"; "previewChange": "previewChange"; "activeDateChange": "activeDateChange"; "dragStarted": "dragStarted"; "dragEnded": "dragEnded"; }, never, never, true, never>;
}
/** A class representing a range of dates. */
declare class DateRange<D> {
/** The start date of the range. */
readonly start: D | null;
/** The end date of the range. */
readonly end: D | null;
/**
* Ensures that objects with a `start` and `end` property can't be assigned to a variable that
* expects a `DateRange`
*/
private _disableStructuralEquivalency;
constructor(
/** The start date of the range. */
start: D | null,
/** The end date of the range. */
end: D | null);
}
/**
* Conditionally picks the date type, if a DateRange is passed in.
* @docs-private
*/
type ExtractDateTypeFromSelection<T> = T extends DateRange<infer D> ? D : NonNullable<T>;
/**
* Event emitted by the date selection model when its selection changes.
* @docs-private
*/
interface DateSelectionModelChange<S> {
/** New value for the selection. */
selection: S;
/** Object that triggered the change. */
source: unknown;
/** Previous value */
oldValue?: S;
}
/**
* A selection model containing a date selection.
* @docs-private
*/
declare abstract class MatDateSelectionModel<S, D = ExtractDateTypeFromSelection<S>> implements OnDestroy {
/** The current selection. */
readonly selection: S;
protected _adapter: DateAdapter<D>;
private readonly _selectionChanged;
/** Emits when the selection has changed. */
selectionChanged: Observable<DateSelectionModelChange<S>>;
protected constructor(
/** The current selection. */
selection: S, _adapter: DateAdapter<D>);
/**
* Updates the current selection in the model.
* @param value New selection that should be assigned.
* @param source Object that triggered the selection change.
*/
updateSelection(value: S, source: unknown): void;
ngOnDestroy(): void;
protected _isValidDateInstance(date: D): boolean;
/** Adds a date to the current selection. */
abstract add(date: D | null): void;
/** Checks whether the current selection is valid. */
abstract isValid(): boolean;
/** Checks whether the current selection is complete. */
abstract isComplete(): boolean;
/** Clones the selection model. */
abstract clone(): MatDateSelectionModel<S, D>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatDateSelectionModel<any, any>, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<MatDateSelectionModel<any, any>>;
}
/**
* A selection model that contains a single date.
* @docs-private
*/
declare class MatSingleDateSelectionModel<D> extends MatDateSelectionModel<D | null, D> {
constructor(adapter: DateAdapter<D>);
/**
* Adds a date to the current selection. In the case of a single date selection, the added date
* simply overwrites the previous selection
*/
add(date: D | null): void;
/** Checks whether the current selection is valid. */
isValid(): boolean;
/**
* Checks whether the current selection is complete. In the case of a single date selection, this
* is true if the current selection is not null.
*/
isComplete(): boolean;
/** Clones the selection model. */
clone(): MatSingleDateSelectionModel<D>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatSingleDateSelectionModel<any>, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<MatSingleDateSelectionModel<any>>;
}
/**
* A selection model that contains a date range.
* @docs-private
*/
declare class MatRangeDateSelectionModel<D> extends MatDateSelectionModel<DateRange<D>, D> {
constructor(adapter: DateAdapter<D>);
/**
* Adds a date to the current selection. In the case of a date range selection, the added date
* fills in the next `null` value in the range. If both the start and the end already have a date,
* the selection is reset so that the given date is the new `start` and the `end` is null.
*/
add(date: D | null): void;
/** Checks whether the current selection is valid. */
isValid(): boolean;
/**
* Checks whether the current selection is complete. In the case of a date range selection, this
* is true if the current selection has a non-null `start` and `end`.
*/
isComplete(): boolean;
/** Clones the selection model. */
clone(): MatRangeDateSelectionModel<D>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatRangeDateSelectionModel<any>, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<MatRangeDateSelectionModel<any>>;
}
/**
* @docs-private
* @deprecated No longer used, will be removed.
* @breaking-change 21.0.0
*/
declare function MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY(parent: MatSingleDateSelectionModel<unknown>, adapter: DateAdapter<unknown>): MatSingleDateSelectionModel<unknown>;
/**
* Used to provide a single selection model to a component.
* @docs-private
* @deprecated No longer used, will be removed.
* @breaking-change 21.0.0
*/
declare const MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider;
/**
* @docs-private
* @deprecated No longer used, will be removed.
* @breaking-change 21.0.0
*/
declare function MAT_RANGE_DATE_SELECTION_MODEL_FACTORY(parent: MatSingleDateSelectionModel<unknown>, adapter: DateAdapter<unknown>): MatSingleDateSelectionModel<unknown>;
/**
* Used to provide a range selection model to a component.
* @docs-private
* @deprecated No longer used, will be removed.
* @breaking-change 21.0.0
*/
declare const MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider;
/**
* An internal component used to display a single month in the datepicker.
* @docs-private
*/
declare class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
readonly _changeDetectorRef: ChangeDetectorRef;
private _dateFormats;
_dateAdapter: DateAdapter$1<D, any>;
private _dir;
private _rangeStrategy;
private _rerenderSubscription;
/** Flag used to filter out space/enter keyup events that originated outside of the view. */
private _selectionKeyPressed;
/**
* The date to display in this month view (everything other than the month and year is ignored).
*/
get activeDate(): D;
set activeDate(value: D);
private _activeDate;
/** The currently selected date. */
get selected(): DateRange<D> | D | null;
set selected(value: DateRange<D> | D | null);
private _selected;
/** The minimum selectable date. */
get minDate(): D | null;
set minDate(value: D | null);
private _minDate;
/** The maximum selectable date. */
get maxDate(): D | null;
set maxDate(value: D | null);
private _maxDate;
/** Function used to filter which dates are selectable. */
dateFilter: (date: D) => boolean;
/** Function that can be used to add custom CSS classes to dates. */
dateClass: MatCalendarCellClassFunction<D>;
/** Start of the comparison range. */
comparisonStart: D | null;
/** End of the comparison range. */
comparisonEnd: D | null;
/** ARIA Accessible name of the `<input matStartDate/>` */
startDateAccessibleName: string | null;
/** ARIA Accessible name of the `<input matEndDate/>` */
endDateAccessibleName: string | null;
/** Origin of active drag, or null when dragging is not active. */
activeDrag: MatCalendarUserEvent<D> | null;
/** Emits when a new date is selected. */
readonly selectedChange: EventEmitter<D | null>;
/** Emits when any date is selected. */
readonly _userSelection: EventEmitter<MatCalendarUserEvent<D | null>>;
/** Emits when the user initiates a date range drag via mouse or touch. */
readonly dragStarted: EventEmitter<MatCalendarUserEvent<D>>;
/**
* Emits when the user completes or cancels a date range drag.
* Emits null when the drag was canceled or the newly selected date range if completed.
*/
readonly dragEnded: EventEmitter<MatCalendarUserEvent<DateRange<D> | null>>;
/** Emits when any date is activated. */
readonly activeDateChange: EventEmitter<D>;
/** The body of calendar table */
_matCalendarBody: MatCalendarBody;
/** The label for this month (e.g. "January 2017"). */
_monthLabel: string;
/** Grid of calendar cells representing the dates of the month. */
_weeks: MatCalendarCell[][];
/** The number of blank cells in the first row before the 1st of the month. */
_firstWeekOffset: number;
/** Start value of the currently-shown date range. */
_rangeStart: number | null;
/** End value of the currently-shown date range. */
_rangeEnd: number | null;
/** Start value of the currently-shown comparison date range. */
_comparisonRangeStart: number | null;
/** End value of the currently-shown comparison date range. */
_comparisonRangeEnd: number | null;
/** Start of the preview range. */
_previewStart: number | null;
/** End of the preview range. */
_previewEnd: number | null;
/** Whether the user is currently selecting a range of dates. */
_isRange: boolean;
/** The date of the month that today falls on. Null if today is in another month. */
_todayDate: number | null;
/** The names of the weekdays. */
_weekdays: {
long: string;
narrow: string;
id: number;
}[];
constructor(...args: unknown[]);
ngAfterContentInit(): void;
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
/** Handles when a new date is selected. */
_dateSelected(event: MatCalendarUserEvent<number>): void;
/**
* Takes the index of a calendar body cell wrapped in an event as argument. For the date that
* corresponds to the given cell, set `activeDate` to that date and fire `activeDateChange` with
* that date.
*
* This function is used to match each component's model of the active date with the calendar
* body cell that was focused. It updates its value of `activeDate` synchronously and updates the
* parent's value asynchronously via the `activeDateChange` event. The child component receives an
* updated value asynchronously via the `activeCell` Input.
*/
_updateActiveDate(event: MatCalendarUserEvent<number>): void;
/** Handles keydown events on the calendar body when calendar is in month view. */
_handleCalendarBodyKeydown(event: KeyboardEvent): void;
/** Handles keyup events on the calendar body when calendar is in month view. */
_handleCalendarBodyKeyup(event: KeyboardEvent): void;
/** Initializes this month view. */
_init(): void;
/** Focuses the active cell after the microtask queue is empty. */
_focusActiveCell(movePreview?: boolean): void;
/** Focuses the active cell after change detection has run and the microtask queue is empty. */
_focusActiveCellAfterViewChecked(): void;
/** Called when the user has activated a new cell and the preview needs to be updated. */
_previewChanged({ event, value: cell }: MatCalendarUserEvent<MatCalendarCell<D> | null>): void;
/**
* Called when the user has ended a drag. If the drag/drop was successful,
* computes and emits the new range selection.
*/
protected _dragEnded(event: MatCalendarUserEvent<D | null>): void;
/**
* Takes a day of the month and returns a new date in the same month and year as the currently
* active date. The returned date will have the same day of the month as the argument date.
*/
private _getDateFromDayOfMonth;
/** Initializes the weekdays. */
private _initWeekdays;
/** Creates MatCalendarCells for the dates in this month. */
private _createWeekCells;
/** Date filter for the month */
private _shouldEnableDate;
/**
* Gets the date in this month that the given Date falls on.
* Returns null if the given Date is in another month.
*/
private _getDateInCurrentMonth;
/** Checks whether the 2 dates are non-null and fall within the same month of the same year. */
private _hasSameMonthAndYear;
/** Gets the value that will be used to one cell to another. */
private _getCellCompareValue;
/** Determines whether the user has the RTL layout direction. */
private _isRtl;
/** Sets the current range based on a model value. */
private _setRanges;
/** Gets whether a date can be selected in the month view. */
private _canSelect;
/** Clears out preview state. */
private _clearPreview;
static ɵfac: i0.ɵɵFactoryDeclaration<MatMonthView<any>, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatMonthView<any>, "mat-month-view", ["matMonthView"], { "activeDate": { "alias": "activeDate"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; "comparisonStart": { "alias": "comparisonStart"; "required": false; }; "comparisonEnd": { "alias": "comparisonEnd"; "required": false; }; "startDateAccessibleName": { "alias": "startDateAccessibleName"; "required": false; }; "endDateAccessibleName": { "alias": "endDateAccessibleName"; "required": false; }; "activeDrag": { "alias": "activeDrag"; "required": false; }; }, { "selectedChange": "selectedChange"; "_userSelection": "_userSelection"; "dragStarted": "dragStarted"; "dragEnded": "dragEnded"; "activeDateChange": "activeDateChange"; }, never, never, true, never>;
}
declare const yearsPerPage = 24;
declare const yearsPerRow = 4;
/**
* An internal component used to display a year selector in the datepicker.
* @docs-private
*/
declare class MatMultiYearView<D> implements AfterContentInit, OnDestroy {
private _changeDetectorRef;
_dateAdapter: DateAdapter$1<D, any>;
private _dir;
private _rerenderSubscription;
/** Flag used to filter out space/enter keyup events that originated outside of the view. */
private _selectionKeyPressed;
/** The date to display in this multi-year view (everything other than the year is ignored). */
get activeDate(): D;
set activeDate(value: D);
private _activeDate;
/** The currently selected date. */
get selected(): DateRange<D> | D | null;
set selected(value: DateRange<D> | D | null);
private _selected;
/** The minimum selectable date. */
get minDate(): D | null;
set minDate(value: D | null);
private _minDate;
/** The maximum selectable date. */
get maxDate(): D | null;
set maxDate(value: D | null);
private _maxDate;
/** A function used to filter which dates are selectable. */
dateFilter: (date: D) => boolean;
/** Function that can be used to add custom CSS classes to date cells. */
dateClass: MatCalendarCellClassFunction<D>;
/** Emits when a new year is selected. */
readonly selectedChange: EventEmitter<D>;
/** Emits the selected year. This doesn't imply a change on the selected date */
readonly yearSelected: EventEmitter<D>;
/** Emits when any date is activated. */
readonly activeDateChange: EventEmitter<D>;
/** The body of calendar table */
_matCalendarBody: MatCalendarBody;
/** Grid of calendar cells representing the currently displayed years. */
_years: MatCalendarCell[][];
/** The year that today falls on. */
_todayYear: number;
/** The year of the selected date. Null if the selected date is null. */
_selectedYear: number | null;
constructor(...args: unknown[]);
ngAfterContentInit(): void;
ngOnDestroy(): void;
/** Initializes this multi-year view. */
_init(): void;
/** Handles when a new year is selected. */
_yearSelected(event: MatCalendarUserEvent<number>): void;
/**
* Takes the index of a calendar body cell wrapped in an event as argument. For the date that
* corresponds to the given cell, set `activeDate` to that date and fire `activeDateChange` with
* that date.
*
* This function is used to match each component's model of the active date with the calendar
* body cell that was focused. It updates its value of `activeDate` synchronously and updates the
* parent's value asynchronously via the `activeDateChange` event. The child component receives an
* updated value asynchronously via the `activeCell` Input.
*/
_updateActiveDate(event: MatCalendarUserEvent<number>): void;
/** Handles keydown events on the calendar body when calendar is in multi-year view. */
_handleCalendarBodyKeydown(event: KeyboardEvent): void;
/** Handles keyup events on the calendar body when calendar is in multi-year view. */
_handleCalendarBodyKeyup(event: KeyboardEvent): void;
_getActiveCell(): number;
/** Focuses the active cell after the microtask queue is empty. */
_focusActiveCell(): void;
/** Focuses the active cell after change detection has run and the microtask queue is empty. */
_focusActiveCellAfterViewChecked(): void;
/**
* Takes a year and returns a new date on the same day and month as the currently active date
* The returned date will have the same year as the argument date.
*/
private _getDateFromYear;
/** Creates an MatCalendarCell for the given year. */
private _createCellForYear;
/** Whether the given year is enabled. */
private _shouldEnableYear;
/** Determines whether the user has the RTL layout direction. */
private _isRtl;
/** Sets the currently-highlighted year based on a model value. */
private _setSelectedYear;
static ɵfac: i0.ɵɵFactoryDeclaration<MatMultiYearView<any>, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatMultiYearView<any>, "mat-multi-year-view", ["matMultiYearView"], { "activeDate": { "alias": "activeDate"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; }, { "selectedChange": "selectedChange"; "yearSelected": "yearSelected"; "activeDateChange": "activeDateChange"; }, never, never, true, never>;
}
/**
* An internal component used to display a single year in the datepicker.
* @docs-private
*/
declare class MatYearView<D> implements AfterContentInit, OnDestroy {
readonly _changeDetectorRef: ChangeDetectorRef;
private _dateFormats;
_dateAdapter: DateAdapter$1<D, any>;
private _dir;
private _rerenderSubscription;
/** Flag used to filter out space/enter keyup events that originated outside of the view. */
private _selectionKeyPressed;
/** The date to display in this year view (everything other than the year is ignored). */
get activeDate(): D;
set activeDate(value: D);
private _activeDate;
/** The currently selected date. */
get selected(): DateRange<D> | D | null;
set selected(value: DateRange<D> | D | null);
private _selected;
/** The minimum selectable date. */
get minDate(): D | null;
set minDate(value: D | null);
private _minDate;
/** The maximum selectable date. */
get maxDate(): D | null;
set maxDate(value: D | null);
private _maxDate;
/** A function used to filter which dates are selectable. */
dateFilter: (date: D) => boolean;
/** Function that can be used to add custom CSS classes to date cells. */
dateClass: MatCalendarCellClassFunction<D>;
/** Emits when a new month is selected. */
readonly selectedChange: EventEmitter<D>;
/** Emits the selected month. This doesn't imply a change on the selected date */
readonly monthSelected: EventEmitter<D>;
/** Emits when any date is activated. */
readonly activeDateChange: EventEmitter<D>;
/** The body of calendar table */
_matCalendarBody: MatCalendarBody;
/** Grid of calendar cells representing the months of the year. */
_months: MatCalendarCell[][];
/** The label for this year (e.g. "2017"). */
_yearLabel: string;
/** The month in this year that today falls on. Null if today is in a different year. */
_todayMonth: number | null;
/**
* The month in this year that the selected Date falls on.
* Null if the selected Date is in a different year.
*/
_selectedMonth: number | null;
constructor(...args: unknown[]);
ngAfterContentInit(): void;
ngOnDestroy(): void;
/** Handles when a new month is selected. */
_monthSelected(event: MatCalendarUserEvent<number>): void;
/**
* Takes the index of a calendar body cell wrapped in an event as argument. For the date that
* corresponds to the given cell, set `activeDate` to that date and fire `activeDateChange` with
* that date.
*
* This function is used to match each component's model of the active date with the calendar
* body cell that was focused. It updates its value of `activeDate` synchronously and updates the
* parent's value asynchronously via the `activeDateChange` event. The child component receives an
* updated value asynchronously via the `activeCell` Input.
*/
_updateActiveDate(event: MatCalendarUserEvent<number>): void;
/** Handles keydown events on the calendar body when calendar is in year view. */
_handleCalendarBodyKeydown(event: KeyboardEvent): void;
/** Handles keyup events on the calendar body when calendar is in year view. */
_handleCalendarBodyKeyup(event: KeyboardEvent): void;
/** Initializes this year view. */
_init(): void;
/** Focuses the active cell after the microtask queue is empty. */
_focusActiveCell(): void;
/** Schedules the matCalendarBody to focus the active cell after change detection has run */
_focusActiveCellAfterViewChecked(): void;
/**
* Gets the month in this year that the given Date falls on.
* Returns null if the given Date is in another year.
*/
private _getMonthInCurrentYear;
/**
* Takes a month and returns a new date in the same day and year as the currently active date.
* The returned date will have the same month as the argument date.
*/
private _getDateFromMonth;
/** Creates an MatCalendarCell for the given month. */
private _createCellForMonth;
/** Whether the given month is enabled. */
private _shouldEnableMonth;
/**
* Tests whether the combination month/year is after this.maxDate, considering
* just the month and year of this.maxDate
*/
private _isYearAndMonthAfterMaxDate;
/**
* Tests whether the combination month/year is before this.minDate, considering
* just the month and year of this.minDate
*/
private _isYearAndMonthBeforeMinDate;
/** Determines whether the user has the RTL layout direction. */
private _isRtl;
/** Sets the currently-selected month based on a model value. */
private _setSelectedMonth;
static ɵfac: i0.ɵɵFactoryDeclaration<MatYearView<any>, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatYearView<any>, "mat-year-view", ["matYearView"], { "activeDate": { "alias": "activeDate"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; }, { "selectedChange": "selectedChange"; "monthSelected": "monthSelected"; "activeDateChange": "activeDateChange"; }, never, never, true, never>;
}
/**
* Possible views for the calendar.
* @docs-private
*/
type MatCalendarView = 'month' | 'year' | 'multi-year';
/** Default header for MatCalendar */
declare class MatCalendarHeader<D> {
private _intl;
calendar: MatCalendar<D>;
private _dateAdapter;
private _dateFormats;
constructor(...args: unknown[]);
/** The display text for the current calendar view. */
get periodButtonText(): string;
/** The aria description for the current calendar view. */
get periodButtonDescription(): string;
/** The `aria-label` for changing the calendar view. */
get periodButtonLabel(): string;
/** The label for the previous button. */
get prevButtonLabel(): string;
/** The label for the next button. */
get nextButtonLabel(): string;
/** Handles user clicks on the period label. */
currentPeriodClicked(): void;
/** Handles user clicks on the previous button. */
previousClicked(): void;
/** Handles user clicks on the next button. */
nextClicked(): void;
/** Whether the previous period button is enabled. */
previousEnabled(): boolean;
/** Whether the next period button is enabled. */
nextEnabled(): boolean;
/** Whether the two dates represent the same view in the current view mode (month or year). */
private _isSameView;
/**
* Format two individual labels for the minimum year and maximum year available in the multi-year
* calendar view. Returns an array of two strings where the first string is the formatted label
* for the minimum year, and the second string is the formatted label for the maximum year.
*/
private _formatMinAndMaxYearLabels;
_periodButtonLabelId: string;
static ɵfac: i0.ɵɵFactoryDeclaration<MatCalendarHeader<any>, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatCalendarHeader<any>, "mat-calendar-header", ["matCalendarHeader"], {}, {}, never, ["*"], true, never>;
}
/** A calendar that is used as part of the datepicker. */
declare class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDestroy, OnChanges {
private _dateAdapter;
private _dateFormats;
private _changeDetectorRef;
/** An input indicating the type of the header component, if set. */
headerComponent: ComponentType<any>;
/** A portal containing the header component type for this calendar. */
_calendarHeaderPortal: Portal<any>;
private _intlChanges;
/**
* Used for scheduling that focus should be moved to the active cell on the next tick.
* We need to schedule it, rather than do it immediately, because we have to wait
* for Angular to re-evaluate the view children.
*/
private _moveFocusOnNextTick;
/** A date representing the period (month or year) to start the calendar in. */
get startAt(): D | null;
set startAt(value: D | null);
private _startAt;
/** Whether the calendar should be started in month or year view. */
startView: MatCalendarView;
/** The currently selected date. */
get selected(): DateRange<D> | D | null;
set selected(value: DateRange<D> | D | null);
private _selected;
/** The minimum selectable date. */
get minDate(): D | null;
set minDate(value: D | null);
private _minDate;
/** The maximum selectable date. */
get maxDate(): D | null;
set maxDate(value: D | null);
private _maxDate;
/** Function used to filter which dates are selectable. */
dateFilter: (date: D) => boolean;
/** Function that can be used to add custom CSS classes to dates. */
dateClass: MatCalendarCellClassFunction<D>;
/** Start of the comparison range. */
comparisonStart: D | null;
/** End of the comparison range. */
comparisonEnd: D | null;
/** ARIA Accessible name of the `<input matStartDate/>` */
startDateAccessibleName: string | null;
/** ARIA Accessible name of the `<input matEndDate/>` */
endDateAccessibleName: string | null;
/** Emits when the currently selected date changes. */
readonly selectedChange: EventEmitter<D | null>;
/**
* Emits the year chosen in multiyear view.
* This doesn't imply a change on the selected date.
*/
readonly yearSelected: EventEmitter<D>;
/**
* Emits the month chosen in year view.
* This doesn't imply a change on the selected date.
*/
readonly monthSelected: EventEmitter<D>;
/**
* Emits when the current view changes.
*/
readonly viewChanged: EventEmitter<MatCalendarView>;
/** Emits when any date is selected. */
readonly _userSelection: EventEmitter<MatCalendarUserEvent<D | null>>;
/** Emits a new date range value when the user completes a drag drop operation. */
readonly _userDragDrop: EventEmitter<MatCalendarUserEvent<DateRange<D>>>;
/** Reference to the current month view component. */
monthView: MatMonthView<D>;
/** Reference to the current year view component. */
yearView: MatYearView<D>;
/** Reference to the current multi-year view component. */
multiYearView: MatMultiYearView<D>;
/**
* The current active date. This determines which time period is shown and which date is
* highlighted when using keyboard navigation.
*/
get activeDate(): D;
set activeDate(value: D);
private _clampedActiveDate;
/** Whether the calendar is in month view. */
get currentView(): MatCalendarView;
set currentView(value: MatCalendarView);
private _currentView;
/** Origin of active drag, or null when dragging is not active. */
protected _activeDrag: MatCalendarUserEvent<D> | null;
/**
* Emits whenever there is a state change that the header may need to respond to.
*/
readonly stateChanges: Subject<void>;
constructor(...args: unknown[]);
ngAfterContentInit(): void;
ngAfterViewChecked(): void;
ngOnDestroy(): void;
ngOnChanges(changes: SimpleChanges): void;
/** Focuses the active date. */
focusActiveCell(): void;
/** Updates today's date after an update of the active date */
updateTodaysDate(): void;
/** Handles date selection in the month view. */
_dateSelected(event: MatCalendarUserEvent<D | null>): void;
/** Handles year selection in the multiyear view. */
_yearSelectedInMultiYearView(normalizedYear: D): void;
/** Handles month selection in the year view. */
_monthSelectedInYearView(normalizedMonth: D): void;
/** Handles year/month selection in the multi-year/year views. */
_goToDateInView(date: D, view: 'month' | 'year' | 'multi-year'): void;
/** Called when the user starts dragging to change a date range. */
_dragStarted(event: MatCalendarUserEvent<D>): void;
/**
* Called when a drag completes. It may end in cancelation or in the selection
* of a new range.
*/
_dragEnded(event: MatCalendarUserEvent<DateRange<D> | null>): void;
/** Returns the component instance that corresponds to the current calendar view. */
private _getCurrentViewComponent;
static ɵfac: i0.ɵɵFactoryDeclaration<MatCalendar<any>, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatCalendar<any>, "mat-calendar", ["matCalendar"], { "headerComponent": { "alias": "headerComponent"; "required": false; }; "startAt": { "alias": "startAt"; "required": false; }; "startView": { "alias": "startView"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; "comparisonStart": { "alias": "comparisonStart"; "required": false; }; "comparisonEnd": { "alias": "comparisonEnd"; "required": false; }; "startDateAccessibleName": { "alias": "startDateAccessibleName"; "required": false; }; "endDateAccessibleName": { "alias": "endDateAccessibleName"; "required": false; }; }, { "selectedChange": "selectedChange"; "yearSelected": "yearSelected"; "monthSelected": "monthSelected"; "viewChanged": "viewChanged"; "_userSelection": "_userSelection"; "_userDragDrop": "_userDragDrop"; }, never, never, true, never>;
}
/**
* An event used for datepicker input and change events. We don't always have access to a native
* input or change event because the event may have been triggered by the user clicking on the
* calendar popup. For consistency, we always use MatDatepickerInputEvent instead.
*/
declare class MatDatepickerInputEvent<D, S = unknown> {
/** Reference to the datepicker input component that emitted the event. */
target: MatDatepickerInputBase<S, D>;
/** Reference to the native input element associated with the datepicker input. */
targetElement: HTMLElement;
/** The new value for the target datepicker input. */
value: D | null;
constructor(
/** Reference to the datepicker input component that emitted the event. */
target: MatDatepickerInputBase<S, D>,
/** Reference to the native input element associated with the datepicker input. */
targetElement: HTMLElement);
}
/**
* Function that can be used to filter out dates from a calendar.
* Datepicker can sometimes receive a null value as input for the date argument.
* This doesn't represent a "null date" but rather signifies that no date has been selected yet in the calendar.
*/
type DateFilterFn<D> = (date: D | null) => boolean;
/** Base class for datepicker inputs. */
declare abstract class MatDatepickerInputBase<S, D = ExtractDateTypeFromSelection<S>> implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy, Validator {
protected _elementRef: ElementRef<HTMLInputElement>;
_dateAdapter: DateAdapter$1<D, any>;
private _dateFormats;
/** Whether the component has been initialized. */
private _isInitialized;
/** The value of the input. */
get value(): D | null;
set value(value: any);
protected _model: MatDateSelectionModel<S, D> | undefined;
/** Whether the datepicker-input is disabled. */
get disabled(): boolean;
set disabled(value: boolean);
private _disabled;
/** Emits when a `change` event is fired on this `<input>`. */
readonly dateChange: EventEmitter<MatDatepickerInputEvent<D, S>>;
/** Emits when an `input` event is fired on this `<input>`. */
readonly dateInput: EventEmitter<MatDatepickerInputEvent<D, S>>;
/** Emits when the internal state has changed */
readonly stateChanges: Subject<void>;
_onTouched: () => void;
_validatorOnChange: () => void;
private _cvaOnChange;
private _valueChangesSubscription;
private _localeSubscription;
/**
* Since the value is kept on the model which is assigned in an Input,
* we might get a value before we have a model. This property keeps track
* of the value until we have somewhere to assign it.
*/
private _pendingValue;
/** The form control validator for whether the input parses. */
private _parseValidator;
/** The form control validator for the date filter. */
private _filterValidator;
/** The form control validator for the min date. */
private _minValidator;
/** The form control validator for the max date. */
private _maxValidator;
/** Gets the base validator functions. */
protected _getValidators(): ValidatorFn[];
/** Gets the minimum date for the input. Used for validation. */
abstract _getMinDate(): D | null;
/** Gets the maximum date for the input. Used for validation. */
abstract _getMaxDate(): D | null;
/** Gets the date filter function. Used for validation. */
protected abstract _getDateFilter(): DateFilterFn<D> | undefined;
/** Registers a date selection model with the input. */
_registerModel(model: MatDateSelectionModel<S, D>): void;
/** Opens the popup associated with the input. */
protected abstract _openPopup(): void;
/** Assigns a value to the input's model. */
protected abstract _assignValueToModel(model: D | null): void;
/** Converts a value from the model into a native value for the input. */
protected abstract _getValueFromModel(modelValue: S): D | null;
/** Combined form control validator for this input. */
protected abstract _validator: ValidatorFn | null;
/** Predicate that determines whether the input should handle a particular change event. */
protected abstract _shouldHandleChangeEvent(event: DateSelectionModelChange<S>): boolean;
/** Whether the last value set on the input was valid. */
protected _lastValueValid: boolean;
constructor(...args: unknown[]);
ngAfterViewInit(): void;
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
/** @docs-private */
registerOnValidatorChange(fn: () => void): void;
/** @docs-private */
validate(c: AbstractControl): ValidationErrors | null;
writeValue(value: D): void;
registerOnChange(fn: (value: any) => void): void;
registerOnTouched(fn: () => void): void;
setDisabledState(isDisabled: boolean): void;
_onKeydown(event: KeyboardEvent): void;
_onInput(value: string): void;
_onChange(): void;
/** Handles blur events on the input. */
_onBlur(): void;
/** Formats a value and sets it on the input element. */
protected _formatValue(value: D | null): void;
/** Assigns a value to