1 | import { ChangeDetectorRef, ComponentFactoryResolver, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, Renderer2, SimpleChanges, TemplateRef, ViewContainerRef } from '@angular/core';
|
2 | import { TranslationWidth } from '@angular/common';
|
3 | import { AbstractControl, ControlValueAccessor, ValidationErrors, Validator } from '@angular/forms';
|
4 | import { PlacementArray } from '../util/positioning';
|
5 | import { NgbDateAdapter } from './adapters/ngb-date-adapter';
|
6 | import { NgbDatepickerNavigateEvent } from './datepicker';
|
7 | import { DayTemplateContext } from './datepicker-day-template-context';
|
8 | import { NgbCalendar } from './ngb-calendar';
|
9 | import { NgbDate } from './ngb-date';
|
10 | import { NgbDateParserFormatter } from './ngb-date-parser-formatter';
|
11 | import { NgbDateStruct } from './ngb-date-struct';
|
12 | import { NgbInputDatepickerConfig } from './datepicker-input-config';
|
13 | /**
|
14 | * A directive that allows to stick a datepicker popup to an input field.
|
15 | *
|
16 | * Manages interaction with the input field itself, does value formatting and provides forms integration.
|
17 | */
|
18 | export declare class NgbInputDatepicker implements OnChanges, OnDestroy, ControlValueAccessor, Validator {
|
19 | private _parserFormatter;
|
20 | private _elRef;
|
21 | private _vcRef;
|
22 | private _renderer;
|
23 | private _cfr;
|
24 | private _ngZone;
|
25 | private _calendar;
|
26 | private _dateAdapter;
|
27 | private _document;
|
28 | private _changeDetector;
|
29 | static ngAcceptInputType_autoClose: boolean | string;
|
30 | static ngAcceptInputType_disabled: boolean | '';
|
31 | static ngAcceptInputType_navigation: string;
|
32 | static ngAcceptInputType_outsideDays: string;
|
33 | static ngAcceptInputType_weekdays: boolean | number;
|
34 | private _cRef;
|
35 | private _disabled;
|
36 | private _elWithFocus;
|
37 | private _model;
|
38 | private _inputValue;
|
39 | private _showWeekdays;
|
40 | private _zoneSubscription;
|
41 | /**
|
42 | * Indicates whether the datepicker popup should be closed automatically after date selection / outside click or not.
|
43 | *
|
44 | * * `true` - the popup will close on both date selection and outside click.
|
45 | * * `false` - the popup can only be closed manually via `close()` or `toggle()` methods.
|
46 | * * `"inside"` - the popup will close on date selection, but not outside clicks.
|
47 | * * `"outside"` - the popup will close only on the outside click and not on date selection/inside clicks.
|
48 | *
|
49 | * @since 3.0.0
|
50 | */
|
51 | autoClose: boolean | 'inside' | 'outside';
|
52 | /**
|
53 | * An optional class applied to the datepicker popup element.
|
54 | *
|
55 | * @since 9.1.0
|
56 | */
|
57 | datepickerClass: string;
|
58 | /**
|
59 | * The reference to a custom template for the day.
|
60 | *
|
61 | * Allows to completely override the way a day 'cell' in the calendar is displayed.
|
62 | *
|
63 | * See [`DayTemplateContext`](#/components/datepicker/api#DayTemplateContext) for the data you get inside.
|
64 | */
|
65 | dayTemplate: TemplateRef<DayTemplateContext>;
|
66 | /**
|
67 | * The callback to pass any arbitrary data to the template cell via the
|
68 | * [`DayTemplateContext`](#/components/datepicker/api#DayTemplateContext)'s `data` parameter.
|
69 | *
|
70 | * `current` is the month that is currently displayed by the datepicker.
|
71 | *
|
72 | * @since 3.3.0
|
73 | */
|
74 | dayTemplateData: (date: NgbDate, current?: {
|
75 | year: number;
|
76 | month: number;
|
77 | }) => any;
|
78 | /**
|
79 | * The number of months to display.
|
80 | */
|
81 | displayMonths: number;
|
82 | /**
|
83 | * The first day of the week.
|
84 | *
|
85 | * With default calendar we use ISO 8601: 'weekday' is 1=Mon ... 7=Sun.
|
86 | */
|
87 | firstDayOfWeek: number;
|
88 | /**
|
89 | * The reference to the custom template for the datepicker footer.
|
90 | *
|
91 | * @since 3.3.0
|
92 | */
|
93 | footerTemplate: TemplateRef<any>;
|
94 | /**
|
95 | * The callback to mark some dates as disabled.
|
96 | *
|
97 | * It is called for each new date when navigating to a different month.
|
98 | *
|
99 | * `current` is the month that is currently displayed by the datepicker.
|
100 | */
|
101 | markDisabled: (date: NgbDate, current?: {
|
102 | year: number;
|
103 | month: number;
|
104 | }) => boolean;
|
105 | /**
|
106 | * The earliest date that can be displayed or selected. Also used for form validation.
|
107 | *
|
108 | * If not provided, 'year' select box will display 10 years before the current month.
|
109 | */
|
110 | minDate: NgbDateStruct;
|
111 | /**
|
112 | * The latest date that can be displayed or selected. Also used for form validation.
|
113 | *
|
114 | * If not provided, 'year' select box will display 10 years after the current month.
|
115 | */
|
116 | maxDate: NgbDateStruct;
|
117 | /**
|
118 | * Navigation type.
|
119 | *
|
120 | * * `"select"` - select boxes for month and navigation arrows
|
121 | * * `"arrows"` - only navigation arrows
|
122 | * * `"none"` - no navigation visible at all
|
123 | */
|
124 | navigation: 'select' | 'arrows' | 'none';
|
125 | /**
|
126 | * The way of displaying days that don't belong to the current month.
|
127 | *
|
128 | * * `"visible"` - days are visible
|
129 | * * `"hidden"` - days are hidden, white space preserved
|
130 | * * `"collapsed"` - days are collapsed, so the datepicker height might change between months
|
131 | *
|
132 | * For the 2+ months view, days in between months are never shown.
|
133 | */
|
134 | outsideDays: 'visible' | 'collapsed' | 'hidden';
|
135 | /**
|
136 | * The preferred placement of the datepicker popup.
|
137 | *
|
138 | * Possible values are `"top"`, `"top-left"`, `"top-right"`, `"bottom"`, `"bottom-left"`,
|
139 | * `"bottom-right"`, `"left"`, `"left-top"`, `"left-bottom"`, `"right"`, `"right-top"`,
|
140 | * `"right-bottom"`
|
141 | *
|
142 | * Accepts an array of strings or a string with space separated possible values.
|
143 | *
|
144 | * The default order of preference is `"bottom-left bottom-right top-left top-right"`
|
145 | *
|
146 | * Please see the [positioning overview](#/positioning) for more details.
|
147 | */
|
148 | placement: PlacementArray;
|
149 | /**
|
150 | * If `true`, when closing datepicker will focus element that was focused before datepicker was opened.
|
151 | *
|
152 | * Alternatively you could provide a selector or an `HTMLElement` to focus. If the element doesn't exist or invalid,
|
153 | * we'll fallback to focus document body.
|
154 | *
|
155 | * @since 5.2.0
|
156 | */
|
157 | restoreFocus: true | string | HTMLElement;
|
158 | /**
|
159 | * If `true`, weekdays will be displayed.
|
160 | *
|
161 | * @deprecated 9.1.0, please use 'weekdays' instead
|
162 | */
|
163 | set showWeekdays(weekdays: boolean);
|
164 | get showWeekdays(): boolean;
|
165 | /**
|
166 | * If `true`, week numbers will be displayed.
|
167 | */
|
168 | showWeekNumbers: boolean;
|
169 | /**
|
170 | * The date to open calendar with.
|
171 | *
|
172 | * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
|
173 | * If nothing or invalid date is provided, calendar will open with current month.
|
174 | *
|
175 | * You could use `navigateTo(date)` method as an alternative.
|
176 | */
|
177 | startDate: {
|
178 | year: number;
|
179 | month: number;
|
180 | day?: number;
|
181 | };
|
182 | /**
|
183 | * A selector specifying the element the datepicker popup should be appended to.
|
184 | *
|
185 | * Currently only supports `"body"`.
|
186 | */
|
187 | container: string;
|
188 | /**
|
189 | * A css selector or html element specifying the element the datepicker popup should be positioned against.
|
190 | *
|
191 | * By default the input is used as a target.
|
192 | *
|
193 | * @since 4.2.0
|
194 | */
|
195 | positionTarget: string | HTMLElement;
|
196 | /**
|
197 | * The way weekdays should be displayed.
|
198 | *
|
199 | * * `true` - weekdays are displayed using default width
|
200 | * * `false` - weekdays are not displayed
|
201 | * * `TranslationWidth` - weekdays are displayed using specified width
|
202 | *
|
203 | * @since 9.1.0
|
204 | */
|
205 | weekdays: TranslationWidth | boolean;
|
206 | /**
|
207 | * An event emitted when user selects a date using keyboard or mouse.
|
208 | *
|
209 | * The payload of the event is currently selected `NgbDate`.
|
210 | *
|
211 | * @since 1.1.1
|
212 | */
|
213 | dateSelect: EventEmitter<NgbDate>;
|
214 | /**
|
215 | * Event emitted right after the navigation happens and displayed month changes.
|
216 | *
|
217 | * See [`NgbDatepickerNavigateEvent`](#/components/datepicker/api#NgbDatepickerNavigateEvent) for the payload info.
|
218 | */
|
219 | navigate: EventEmitter<NgbDatepickerNavigateEvent>;
|
220 | /**
|
221 | * An event fired after closing datepicker window.
|
222 | *
|
223 | * @since 4.2.0
|
224 | */
|
225 | closed: EventEmitter<void>;
|
226 | get disabled(): any;
|
227 | set disabled(value: any);
|
228 | private _onChange;
|
229 | private _onTouched;
|
230 | private _validatorChange;
|
231 | constructor(_parserFormatter: NgbDateParserFormatter, _elRef: ElementRef<HTMLInputElement>, _vcRef: ViewContainerRef, _renderer: Renderer2, _cfr: ComponentFactoryResolver, _ngZone: NgZone, _calendar: NgbCalendar, _dateAdapter: NgbDateAdapter<any>, _document: any, _changeDetector: ChangeDetectorRef, config: NgbInputDatepickerConfig);
|
232 | registerOnChange(fn: (value: any) => any): void;
|
233 | registerOnTouched(fn: () => any): void;
|
234 | registerOnValidatorChange(fn: () => void): void;
|
235 | setDisabledState(isDisabled: boolean): void;
|
236 | validate(c: AbstractControl): ValidationErrors | null;
|
237 | writeValue(value: any): void;
|
238 | manualDateChange(value: string, updateView?: boolean): void;
|
239 | isOpen(): boolean;
|
240 | /**
|
241 | * Opens the datepicker popup.
|
242 | *
|
243 | * If the related form control contains a valid date, the corresponding month will be opened.
|
244 | */
|
245 | open(): void;
|
246 | /**
|
247 | * Closes the datepicker popup.
|
248 | */
|
249 | close(): void;
|
250 | /**
|
251 | * Toggles the datepicker popup.
|
252 | */
|
253 | toggle(): void;
|
254 | /**
|
255 | * Navigates to the provided date.
|
256 | *
|
257 | * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
|
258 | * If nothing or invalid date provided calendar will open current month.
|
259 | *
|
260 | * Use the `[startDate]` input as an alternative.
|
261 | */
|
262 | navigateTo(date?: {
|
263 | year: number;
|
264 | month: number;
|
265 | day?: number;
|
266 | }): void;
|
267 | onBlur(): void;
|
268 | onFocus(): void;
|
269 | ngOnChanges(changes: SimpleChanges): void;
|
270 | ngOnDestroy(): void;
|
271 | private _applyDatepickerInputs;
|
272 | private _applyPopupClass;
|
273 | private _applyPopupStyling;
|
274 | private _subscribeForDatepickerOutputs;
|
275 | private _writeModelValue;
|
276 | private _fromDateStruct;
|
277 | private _updatePopupPosition;
|
278 | }
|