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 { ElementRef, EventEmitter, NgZone, OnChanges, SimpleChanges, OnDestroy } from '@angular/core';
|
---|
9 | /** Extra CSS classes that can be associated with a calendar cell. */
|
---|
10 | export declare type MatCalendarCellCssClasses = string | string[] | Set<string> | {
|
---|
11 | [key: string]: any;
|
---|
12 | };
|
---|
13 | /** Function that can generate the extra classes that should be added to a calendar cell. */
|
---|
14 | export declare type MatCalendarCellClassFunction<D> = (date: D, view: 'month' | 'year' | 'multi-year') => MatCalendarCellCssClasses;
|
---|
15 | /**
|
---|
16 | * An internal class that represents the data corresponding to a single calendar cell.
|
---|
17 | * @docs-private
|
---|
18 | */
|
---|
19 | export declare class MatCalendarCell<D = any> {
|
---|
20 | value: number;
|
---|
21 | displayValue: string;
|
---|
22 | ariaLabel: string;
|
---|
23 | enabled: boolean;
|
---|
24 | cssClasses: MatCalendarCellCssClasses;
|
---|
25 | compareValue: number;
|
---|
26 | rawValue?: D | undefined;
|
---|
27 | constructor(value: number, displayValue: string, ariaLabel: string, enabled: boolean, cssClasses?: MatCalendarCellCssClasses, compareValue?: number, rawValue?: D | undefined);
|
---|
28 | }
|
---|
29 | /** Event emitted when a date inside the calendar is triggered as a result of a user action. */
|
---|
30 | export interface MatCalendarUserEvent<D> {
|
---|
31 | value: D;
|
---|
32 | event: Event;
|
---|
33 | }
|
---|
34 | /**
|
---|
35 | * An internal component used to display calendar data in a table.
|
---|
36 | * @docs-private
|
---|
37 | */
|
---|
38 | export declare class MatCalendarBody implements OnChanges, OnDestroy {
|
---|
39 | private _elementRef;
|
---|
40 | private _ngZone;
|
---|
41 | /**
|
---|
42 | * Used to skip the next focus event when rendering the preview range.
|
---|
43 | * We need a flag like this, because some browsers fire focus events asynchronously.
|
---|
44 | */
|
---|
45 | private _skipNextFocus;
|
---|
46 | /** The label for the table. (e.g. "Jan 2017"). */
|
---|
47 | label: string;
|
---|
48 | /** The cells to display in the table. */
|
---|
49 | rows: MatCalendarCell[][];
|
---|
50 | /** The value in the table that corresponds to today. */
|
---|
51 | todayValue: number;
|
---|
52 | /** Start value of the selected date range. */
|
---|
53 | startValue: number;
|
---|
54 | /** End value of the selected date range. */
|
---|
55 | endValue: number;
|
---|
56 | /** The minimum number of free cells needed to fit the label in the first row. */
|
---|
57 | labelMinRequiredCells: number;
|
---|
58 | /** The number of columns in the table. */
|
---|
59 | numCols: number;
|
---|
60 | /** The cell number of the active cell in the table. */
|
---|
61 | activeCell: number;
|
---|
62 | /** Whether a range is being selected. */
|
---|
63 | isRange: boolean;
|
---|
64 | /**
|
---|
65 | * The aspect ratio (width / height) to use for the cells in the table. This aspect ratio will be
|
---|
66 | * maintained even as the table resizes.
|
---|
67 | */
|
---|
68 | cellAspectRatio: number;
|
---|
69 | /** Start of the comparison range. */
|
---|
70 | comparisonStart: number | null;
|
---|
71 | /** End of the comparison range. */
|
---|
72 | comparisonEnd: number | null;
|
---|
73 | /** Start of the preview range. */
|
---|
74 | previewStart: number | null;
|
---|
75 | /** End of the preview range. */
|
---|
76 | previewEnd: number | null;
|
---|
77 | /** Emits when a new value is selected. */
|
---|
78 | readonly selectedValueChange: EventEmitter<MatCalendarUserEvent<number>>;
|
---|
79 | /** Emits when the preview has changed as a result of a user action. */
|
---|
80 | readonly previewChange: EventEmitter<MatCalendarUserEvent<MatCalendarCell<any> | null>>;
|
---|
81 | /** The number of blank cells to put at the beginning for the first row. */
|
---|
82 | _firstRowOffset: number;
|
---|
83 | /** Padding for the individual date cells. */
|
---|
84 | _cellPadding: string;
|
---|
85 | /** Width of an individual cell. */
|
---|
86 | _cellWidth: string;
|
---|
87 | constructor(_elementRef: ElementRef<HTMLElement>, _ngZone: NgZone);
|
---|
88 | /** Called when a cell is clicked. */
|
---|
89 | _cellClicked(cell: MatCalendarCell, event: MouseEvent): void;
|
---|
90 | /** Returns whether a cell should be marked as selected. */
|
---|
91 | _isSelected(value: number): boolean;
|
---|
92 | ngOnChanges(changes: SimpleChanges): void;
|
---|
93 | ngOnDestroy(): void;
|
---|
94 | /** Returns whether a cell is active. */
|
---|
95 | _isActiveCell(rowIndex: number, colIndex: number): boolean;
|
---|
96 | /** Focuses the active cell after the microtask queue is empty. */
|
---|
97 | _focusActiveCell(movePreview?: boolean): void;
|
---|
98 | /** Gets whether a value is the start of the main range. */
|
---|
99 | _isRangeStart(value: number): boolean;
|
---|
100 | /** Gets whether a value is the end of the main range. */
|
---|
101 | _isRangeEnd(value: number): boolean;
|
---|
102 | /** Gets whether a value is within the currently-selected range. */
|
---|
103 | _isInRange(value: number): boolean;
|
---|
104 | /** Gets whether a value is the start of the comparison range. */
|
---|
105 | _isComparisonStart(value: number): boolean;
|
---|
106 | /** Whether the cell is a start bridge cell between the main and comparison ranges. */
|
---|
107 | _isComparisonBridgeStart(value: number, rowIndex: number, colIndex: number): boolean;
|
---|
108 | /** Whether the cell is an end bridge cell between the main and comparison ranges. */
|
---|
109 | _isComparisonBridgeEnd(value: number, rowIndex: number, colIndex: number): boolean;
|
---|
110 | /** Gets whether a value is the end of the comparison range. */
|
---|
111 | _isComparisonEnd(value: number): boolean;
|
---|
112 | /** Gets whether a value is within the current comparison range. */
|
---|
113 | _isInComparisonRange(value: number): boolean;
|
---|
114 | /**
|
---|
115 | * Gets whether a value is the same as the start and end of the comparison range.
|
---|
116 | * For context, the functions that we use to determine whether something is the start/end of
|
---|
117 | * a range don't allow for the start and end to be on the same day, because we'd have to use
|
---|
118 | * much more specific CSS selectors to style them correctly in all scenarios. This is fine for
|
---|
119 | * the regular range, because when it happens, the selected styles take over and still show where
|
---|
120 | * the range would've been, however we don't have these selected styles for a comparison range.
|
---|
121 | * This function is used to apply a class that serves the same purpose as the one for selected
|
---|
122 | * dates, but it only applies in the context of a comparison range.
|
---|
123 | */
|
---|
124 | _isComparisonIdentical(value: number): boolean;
|
---|
125 | /** Gets whether a value is the start of the preview range. */
|
---|
126 | _isPreviewStart(value: number): boolean;
|
---|
127 | /** Gets whether a value is the end of the preview range. */
|
---|
128 | _isPreviewEnd(value: number): boolean;
|
---|
129 | /** Gets whether a value is inside the preview range. */
|
---|
130 | _isInPreview(value: number): boolean;
|
---|
131 | /**
|
---|
132 | * Event handler for when the user enters an element
|
---|
133 | * inside the calendar body (e.g. by hovering in or focus).
|
---|
134 | */
|
---|
135 | private _enterHandler;
|
---|
136 | /**
|
---|
137 | * Event handler for when the user's pointer leaves an element
|
---|
138 | * inside the calendar body (e.g. by hovering out or blurring).
|
---|
139 | */
|
---|
140 | private _leaveHandler;
|
---|
141 | /** Finds the MatCalendarCell that corresponds to a DOM node. */
|
---|
142 | private _getCellFromElement;
|
---|
143 | }
|
---|