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 { Directionality } from '@angular/cdk/bidi';
|
---|
9 | import { BooleanInput } from '@angular/cdk/coercion';
|
---|
10 | import { Overlay, ScrollStrategy } from '@angular/cdk/overlay';
|
---|
11 | import { ComponentType, TemplatePortal } from '@angular/cdk/portal';
|
---|
12 | import { AfterViewInit, ElementRef, EventEmitter, InjectionToken, NgZone, OnDestroy, ViewContainerRef, ChangeDetectorRef, OnChanges, SimpleChanges, OnInit } from '@angular/core';
|
---|
13 | import { CanColor, DateAdapter, ThemePalette } from '@angular/material/core';
|
---|
14 | import { Subject, Observable } from 'rxjs';
|
---|
15 | import { MatCalendar, MatCalendarView } from './calendar';
|
---|
16 | import { MatCalendarUserEvent, MatCalendarCellClassFunction } from './calendar-body';
|
---|
17 | import { DateFilterFn } from './datepicker-input-base';
|
---|
18 | import { ExtractDateTypeFromSelection, MatDateSelectionModel, DateRange } from './date-selection-model';
|
---|
19 | import { MatDateRangeSelectionStrategy } from './date-range-selection-strategy';
|
---|
20 | import { MatDatepickerIntl } from './datepicker-intl';
|
---|
21 | /** Injection token that determines the scroll handling while the calendar is open. */
|
---|
22 | export declare const MAT_DATEPICKER_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
|
---|
23 | /** @docs-private */
|
---|
24 | export declare function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy;
|
---|
25 | /** Possible positions for the datepicker dropdown along the X axis. */
|
---|
26 | export declare type DatepickerDropdownPositionX = 'start' | 'end';
|
---|
27 | /** Possible positions for the datepicker dropdown along the Y axis. */
|
---|
28 | export declare type DatepickerDropdownPositionY = 'above' | 'below';
|
---|
29 | /** @docs-private */
|
---|
30 | export declare const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER: {
|
---|
31 | provide: InjectionToken<() => ScrollStrategy>;
|
---|
32 | deps: (typeof Overlay)[];
|
---|
33 | useFactory: typeof MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY;
|
---|
34 | };
|
---|
35 | /** @docs-private */
|
---|
36 | declare const _MatDatepickerContentBase: import("@angular/material/core/common-behaviors/constructor").Constructor<CanColor> & import("@angular/material/core/common-behaviors/constructor").AbstractConstructor<CanColor> & {
|
---|
37 | new (_elementRef: ElementRef): {
|
---|
38 | _elementRef: ElementRef;
|
---|
39 | };
|
---|
40 | };
|
---|
41 | /**
|
---|
42 | * Component used as the content for the datepicker overlay. We use this instead of using
|
---|
43 | * MatCalendar directly as the content so we can control the initial focus. This also gives us a
|
---|
44 | * place to put additional features of the overlay that are not part of the calendar itself in the
|
---|
45 | * future. (e.g. confirmation buttons).
|
---|
46 | * @docs-private
|
---|
47 | */
|
---|
48 | export declare class MatDatepickerContent<S, D = ExtractDateTypeFromSelection<S>> extends _MatDatepickerContentBase implements OnInit, AfterViewInit, OnDestroy, CanColor {
|
---|
49 | private _changeDetectorRef;
|
---|
50 | private _globalModel;
|
---|
51 | private _dateAdapter;
|
---|
52 | private _rangeSelectionStrategy;
|
---|
53 | private _subscriptions;
|
---|
54 | private _model;
|
---|
55 | /** Reference to the internal calendar component. */
|
---|
56 | _calendar: MatCalendar<D>;
|
---|
57 | /** Reference to the datepicker that created the overlay. */
|
---|
58 | datepicker: MatDatepickerBase<any, S, D>;
|
---|
59 | /** Start of the comparison range. */
|
---|
60 | comparisonStart: D | null;
|
---|
61 | /** End of the comparison range. */
|
---|
62 | comparisonEnd: D | null;
|
---|
63 | /** Whether the datepicker is above or below the input. */
|
---|
64 | _isAbove: boolean;
|
---|
65 | /** Current state of the animation. */
|
---|
66 | _animationState: 'enter-dropdown' | 'enter-dialog' | 'void';
|
---|
67 | /** Emits when an animation has finished. */
|
---|
68 | readonly _animationDone: Subject<void>;
|
---|
69 | /** Text for the close button. */
|
---|
70 | _closeButtonText: string;
|
---|
71 | /** Whether the close button currently has focus. */
|
---|
72 | _closeButtonFocused: boolean;
|
---|
73 | /** Portal with projected action buttons. */
|
---|
74 | _actionsPortal: TemplatePortal | null;
|
---|
75 | constructor(elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, _globalModel: MatDateSelectionModel<S, D>, _dateAdapter: DateAdapter<D>, _rangeSelectionStrategy: MatDateRangeSelectionStrategy<D>, intl: MatDatepickerIntl);
|
---|
76 | ngOnInit(): void;
|
---|
77 | ngAfterViewInit(): void;
|
---|
78 | ngOnDestroy(): void;
|
---|
79 | _handleUserSelection(event: MatCalendarUserEvent<D | null>): void;
|
---|
80 | _startExitAnimation(): void;
|
---|
81 | _getSelected(): D | DateRange<D> | null;
|
---|
82 | /** Applies the current pending selection to the global model. */
|
---|
83 | _applyPendingSelection(): void;
|
---|
84 | }
|
---|
85 | /** Form control that can be associated with a datepicker. */
|
---|
86 | export interface MatDatepickerControl<D> {
|
---|
87 | getStartValue(): D | null;
|
---|
88 | getThemePalette(): ThemePalette;
|
---|
89 | min: D | null;
|
---|
90 | max: D | null;
|
---|
91 | disabled: boolean;
|
---|
92 | dateFilter: DateFilterFn<D>;
|
---|
93 | getConnectedOverlayOrigin(): ElementRef;
|
---|
94 | getOverlayLabelId(): string | null;
|
---|
95 | stateChanges: Observable<void>;
|
---|
96 | }
|
---|
97 | /** A datepicker that can be attached to a {@link MatDatepickerControl}. */
|
---|
98 | export interface MatDatepickerPanel<C extends MatDatepickerControl<D>, S, D = ExtractDateTypeFromSelection<S>> {
|
---|
99 | /** Stream that emits whenever the date picker is closed. */
|
---|
100 | closedStream: EventEmitter<void>;
|
---|
101 | /** Color palette to use on the datepicker's calendar. */
|
---|
102 | color: ThemePalette;
|
---|
103 | /** The input element the datepicker is associated with. */
|
---|
104 | datepickerInput: C;
|
---|
105 | /** Whether the datepicker pop-up should be disabled. */
|
---|
106 | disabled: boolean;
|
---|
107 | /** The id for the datepicker's calendar. */
|
---|
108 | id: string;
|
---|
109 | /** Whether the datepicker is open. */
|
---|
110 | opened: boolean;
|
---|
111 | /** Stream that emits whenever the date picker is opened. */
|
---|
112 | openedStream: EventEmitter<void>;
|
---|
113 | /** Emits when the datepicker's state changes. */
|
---|
114 | stateChanges: Subject<void>;
|
---|
115 | /** Opens the datepicker. */
|
---|
116 | open(): void;
|
---|
117 | /** Register an input with the datepicker. */
|
---|
118 | registerInput(input: C): MatDateSelectionModel<S, D>;
|
---|
119 | }
|
---|
120 | /** Base class for a datepicker. */
|
---|
121 | export declare abstract class MatDatepickerBase<C extends MatDatepickerControl<D>, S, D = ExtractDateTypeFromSelection<S>> implements MatDatepickerPanel<C, S, D>, OnDestroy, OnChanges {
|
---|
122 | private _overlay;
|
---|
123 | private _ngZone;
|
---|
124 | private _viewContainerRef;
|
---|
125 | private _dateAdapter;
|
---|
126 | private _dir;
|
---|
127 | private _model;
|
---|
128 | private _scrollStrategy;
|
---|
129 | private _inputStateChanges;
|
---|
130 | /** An input indicating the type of the custom header component for the calendar, if set. */
|
---|
131 | calendarHeaderComponent: ComponentType<any>;
|
---|
132 | /** The date to open the calendar to initially. */
|
---|
133 | get startAt(): D | null;
|
---|
134 | set startAt(value: D | null);
|
---|
135 | private _startAt;
|
---|
136 | /** The view that the calendar should start in. */
|
---|
137 | startView: 'month' | 'year' | 'multi-year';
|
---|
138 | /** Color palette to use on the datepicker's calendar. */
|
---|
139 | get color(): ThemePalette;
|
---|
140 | set color(value: ThemePalette);
|
---|
141 | _color: ThemePalette;
|
---|
142 | /**
|
---|
143 | * Whether the calendar UI is in touch mode. In touch mode the calendar opens in a dialog rather
|
---|
144 | * than a dropdown and elements have more padding to allow for bigger touch targets.
|
---|
145 | */
|
---|
146 | get touchUi(): boolean;
|
---|
147 | set touchUi(value: boolean);
|
---|
148 | private _touchUi;
|
---|
149 | /** Whether the datepicker pop-up should be disabled. */
|
---|
150 | get disabled(): boolean;
|
---|
151 | set disabled(value: boolean);
|
---|
152 | private _disabled;
|
---|
153 | /** Preferred position of the datepicker in the X axis. */
|
---|
154 | xPosition: DatepickerDropdownPositionX;
|
---|
155 | /** Preferred position of the datepicker in the Y axis. */
|
---|
156 | yPosition: DatepickerDropdownPositionY;
|
---|
157 | /**
|
---|
158 | * Whether to restore focus to the previously-focused element when the calendar is closed.
|
---|
159 | * Note that automatic focus restoration is an accessibility feature and it is recommended that
|
---|
160 | * you provide your own equivalent, if you decide to turn it off.
|
---|
161 | */
|
---|
162 | get restoreFocus(): boolean;
|
---|
163 | set restoreFocus(value: boolean);
|
---|
164 | private _restoreFocus;
|
---|
165 | /**
|
---|
166 | * Emits selected year in multiyear view.
|
---|
167 | * This doesn't imply a change on the selected date.
|
---|
168 | */
|
---|
169 | readonly yearSelected: EventEmitter<D>;
|
---|
170 | /**
|
---|
171 | * Emits selected month in year view.
|
---|
172 | * This doesn't imply a change on the selected date.
|
---|
173 | */
|
---|
174 | readonly monthSelected: EventEmitter<D>;
|
---|
175 | /**
|
---|
176 | * Emits when the current view changes.
|
---|
177 | */
|
---|
178 | readonly viewChanged: EventEmitter<MatCalendarView>;
|
---|
179 | /** Function that can be used to add custom CSS classes to dates. */
|
---|
180 | dateClass: MatCalendarCellClassFunction<D>;
|
---|
181 | /** Emits when the datepicker has been opened. */
|
---|
182 | readonly openedStream: EventEmitter<void>;
|
---|
183 | /** Emits when the datepicker has been closed. */
|
---|
184 | readonly closedStream: EventEmitter<void>;
|
---|
185 | /**
|
---|
186 | * Classes to be passed to the date picker panel.
|
---|
187 | * Supports string and string array values, similar to `ngClass`.
|
---|
188 | */
|
---|
189 | get panelClass(): string | string[];
|
---|
190 | set panelClass(value: string | string[]);
|
---|
191 | private _panelClass;
|
---|
192 | /** Whether the calendar is open. */
|
---|
193 | get opened(): boolean;
|
---|
194 | set opened(value: boolean);
|
---|
195 | private _opened;
|
---|
196 | /** The id for the datepicker calendar. */
|
---|
197 | id: string;
|
---|
198 | /** The minimum selectable date. */
|
---|
199 | _getMinDate(): D | null;
|
---|
200 | /** The maximum selectable date. */
|
---|
201 | _getMaxDate(): D | null;
|
---|
202 | _getDateFilter(): DateFilterFn<D>;
|
---|
203 | /** A reference to the overlay into which we've rendered the calendar. */
|
---|
204 | private _overlayRef;
|
---|
205 | /** Reference to the component instance rendered in the overlay. */
|
---|
206 | private _componentRef;
|
---|
207 | /** The element that was focused before the datepicker was opened. */
|
---|
208 | private _focusedElementBeforeOpen;
|
---|
209 | /** Unique class that will be added to the backdrop so that the test harnesses can look it up. */
|
---|
210 | private _backdropHarnessClass;
|
---|
211 | /** Currently-registered actions portal. */
|
---|
212 | private _actionsPortal;
|
---|
213 | /** The input element this datepicker is associated with. */
|
---|
214 | datepickerInput: C;
|
---|
215 | /** Emits when the datepicker's state changes. */
|
---|
216 | readonly stateChanges: Subject<void>;
|
---|
217 | constructor(
|
---|
218 | /**
|
---|
219 | * @deprecated `_dialog` parameter is no longer being used and it will be removed.
|
---|
220 | * @breaking-change 13.0.0
|
---|
221 | */
|
---|
222 | _dialog: any, _overlay: Overlay, _ngZone: NgZone, _viewContainerRef: ViewContainerRef, scrollStrategy: any, _dateAdapter: DateAdapter<D>, _dir: Directionality,
|
---|
223 | /**
|
---|
224 | * @deprecated No longer being used. To be removed.
|
---|
225 | * @breaking-change 13.0.0
|
---|
226 | */
|
---|
227 | _document: any, _model: MatDateSelectionModel<S, D>);
|
---|
228 | ngOnChanges(changes: SimpleChanges): void;
|
---|
229 | ngOnDestroy(): void;
|
---|
230 | /** Selects the given date */
|
---|
231 | select(date: D): void;
|
---|
232 | /** Emits the selected year in multiyear view */
|
---|
233 | _selectYear(normalizedYear: D): void;
|
---|
234 | /** Emits selected month in year view */
|
---|
235 | _selectMonth(normalizedMonth: D): void;
|
---|
236 | /** Emits changed view */
|
---|
237 | _viewChanged(view: MatCalendarView): void;
|
---|
238 | /**
|
---|
239 | * Register an input with this datepicker.
|
---|
240 | * @param input The datepicker input to register with this datepicker.
|
---|
241 | * @returns Selection model that the input should hook itself up to.
|
---|
242 | */
|
---|
243 | registerInput(input: C): MatDateSelectionModel<S, D>;
|
---|
244 | /**
|
---|
245 | * Registers a portal containing action buttons with the datepicker.
|
---|
246 | * @param portal Portal to be registered.
|
---|
247 | */
|
---|
248 | registerActions(portal: TemplatePortal): void;
|
---|
249 | /**
|
---|
250 | * Removes a portal containing action buttons from the datepicker.
|
---|
251 | * @param portal Portal to be removed.
|
---|
252 | */
|
---|
253 | removeActions(portal: TemplatePortal): void;
|
---|
254 | /** Open the calendar. */
|
---|
255 | open(): void;
|
---|
256 | /** Close the calendar. */
|
---|
257 | close(): void;
|
---|
258 | /** Applies the current pending selection on the overlay to the model. */
|
---|
259 | _applyPendingSelection(): void;
|
---|
260 | /** Forwards relevant values from the datepicker to the datepicker content inside the overlay. */
|
---|
261 | protected _forwardContentValues(instance: MatDatepickerContent<S, D>): void;
|
---|
262 | /** Opens the overlay with the calendar. */
|
---|
263 | private _openOverlay;
|
---|
264 | /** Destroys the current overlay. */
|
---|
265 | private _destroyOverlay;
|
---|
266 | /** Gets a position strategy that will open the calendar as a dropdown. */
|
---|
267 | private _getDialogStrategy;
|
---|
268 | /** Gets a position strategy that will open the calendar as a dropdown. */
|
---|
269 | private _getDropdownStrategy;
|
---|
270 | /** Sets the positions of the datepicker in dropdown mode based on the current configuration. */
|
---|
271 | private _setConnectedPositions;
|
---|
272 | /** Gets an observable that will emit when the overlay is supposed to be closed. */
|
---|
273 | private _getCloseStream;
|
---|
274 | static ngAcceptInputType_disabled: BooleanInput;
|
---|
275 | static ngAcceptInputType_opened: BooleanInput;
|
---|
276 | static ngAcceptInputType_touchUi: BooleanInput;
|
---|
277 | static ngAcceptInputType_restoreFocus: BooleanInput;
|
---|
278 | }
|
---|
279 | export {};
|
---|