UNPKG

11.5 kBTypeScriptView Raw
1import { EventEmitter, OnChanges, OnDestroy, SimpleChanges, TemplateRef } from '@angular/core';
2import { AbstractControl, ControlValueAccessor, ValidationErrors, Validator } from '@angular/forms';
3import { NgbDatepickerNavigateEvent } from './datepicker';
4import { DayTemplateContext } from './datepicker-day-template-context';
5import { NgbDate } from './ngb-date';
6import { NgbDateStruct } from './ngb-date-struct';
7import { ContentTemplateContext } from './datepicker-content-template-context';
8import * as i0 from "@angular/core";
9/**
10 * A directive that allows to stick a datepicker popup to an input field.
11 *
12 * Manages interaction with the input field itself, does value formatting and provides forms integration.
13 */
14export declare class NgbInputDatepicker implements OnChanges, OnDestroy, ControlValueAccessor, Validator {
15 static ngAcceptInputType_autoClose: boolean | string;
16 static ngAcceptInputType_disabled: boolean | '';
17 static ngAcceptInputType_navigation: string;
18 static ngAcceptInputType_outsideDays: string;
19 static ngAcceptInputType_weekdays: boolean | string;
20 private _parserFormatter;
21 private _elRef;
22 private _vcRef;
23 private _ngZone;
24 private _calendar;
25 private _dateAdapter;
26 private _document;
27 private _changeDetector;
28 private _injector;
29 private _config;
30 private _cRef;
31 private _disabled;
32 private _elWithFocus;
33 private _model;
34 private _inputValue;
35 private _afterRenderRef;
36 private _positioning;
37 private _destroyCloseHandlers$;
38 /**
39 * Indicates whether the datepicker popup should be closed automatically after date selection / outside click or not.
40 *
41 * * `true` - the popup will close on both date selection and outside click.
42 * * `false` - the popup can only be closed manually via `close()` or `toggle()` methods.
43 * * `"inside"` - the popup will close on date selection, but not outside clicks.
44 * * `"outside"` - the popup will close only on the outside click and not on date selection/inside clicks.
45 *
46 * @since 3.0.0
47 */
48 autoClose: boolean | "inside" | "outside";
49 /**
50 * The reference to a custom content template.
51 *
52 * Allows to completely override the way datepicker.
53 *
54 * See [`NgbDatepickerContent`](#/components/datepicker/api#NgbDatepickerContent) for more details.
55 *
56 * @since 14.2.0
57 */
58 contentTemplate: TemplateRef<ContentTemplateContext>;
59 /**
60 * An optional class applied to the datepicker popup element.
61 *
62 * @since 9.1.0
63 */
64 datepickerClass: string;
65 /**
66 * The reference to a custom template for the day.
67 *
68 * Allows to completely override the way a day 'cell' in the calendar is displayed.
69 *
70 * See [`DayTemplateContext`](#/components/datepicker/api#DayTemplateContext) for the data you get inside.
71 */
72 dayTemplate: TemplateRef<DayTemplateContext>;
73 /**
74 * The callback to pass any arbitrary data to the template cell via the
75 * [`DayTemplateContext`](#/components/datepicker/api#DayTemplateContext)'s `data` parameter.
76 *
77 * `current` is the month that is currently displayed by the datepicker.
78 *
79 * @since 3.3.0
80 */
81 dayTemplateData: (date: NgbDate, current?: {
82 year: number;
83 month: number;
84 }) => any;
85 /**
86 * The number of months to display.
87 */
88 displayMonths: number;
89 /**
90 * The first day of the week.
91 *
92 * With default calendar we use ISO 8601: 'weekday' is 1=Mon ... 7=Sun.
93 */
94 firstDayOfWeek: number;
95 /**
96 * The reference to the custom template for the datepicker footer.
97 *
98 * @since 3.3.0
99 */
100 footerTemplate: TemplateRef<any>;
101 /**
102 * The callback to mark some dates as disabled.
103 *
104 * It is called for each new date when navigating to a different month.
105 *
106 * `current` is the month that is currently displayed by the datepicker.
107 */
108 markDisabled: (date: NgbDate, current?: {
109 year: number;
110 month: number;
111 }) => boolean;
112 /**
113 * The earliest date that can be displayed or selected. Also used for form validation.
114 *
115 * If not provided, 'year' select box will display 10 years before the current month.
116 */
117 minDate: NgbDateStruct;
118 /**
119 * The latest date that can be displayed or selected. Also used for form validation.
120 *
121 * If not provided, 'year' select box will display 10 years after the current month.
122 */
123 maxDate: NgbDateStruct;
124 /**
125 * Navigation type.
126 *
127 * * `"select"` - select boxes for month and navigation arrows
128 * * `"arrows"` - only navigation arrows
129 * * `"none"` - no navigation visible at all
130 */
131 navigation: 'select' | 'arrows' | 'none';
132 /**
133 * The way of displaying days that don't belong to the current month.
134 *
135 * * `"visible"` - days are visible
136 * * `"hidden"` - days are hidden, white space preserved
137 * * `"collapsed"` - days are collapsed, so the datepicker height might change between months
138 *
139 * For the 2+ months view, days in between months are never shown.
140 */
141 outsideDays: 'visible' | 'collapsed' | 'hidden';
142 /**
143 * The preferred placement of the datepicker popup, among the [possible values](#/guides/positioning#api).
144 *
145 * The default order of preference is `"bottom-start bottom-end top-start top-end"`
146 *
147 * Please see the [positioning overview](#/positioning) for more details.
148 */
149 placement: import("../util/positioning").PlacementArray;
150 /**
151 * Allows to change default Popper options when positioning the popup.
152 * Receives current popper options and returns modified ones.
153 *
154 * @since 13.1.0
155 */
156 popperOptions: (options: Partial<import("@popperjs/core").Options>) => Partial<import("@popperjs/core").Options>;
157 /**
158 * If `true`, when closing datepicker will focus element that was focused before datepicker was opened.
159 *
160 * Alternatively you could provide a selector or an `HTMLElement` to focus. If the element doesn't exist or invalid,
161 * we'll fallback to focus document body.
162 *
163 * @since 5.2.0
164 */
165 restoreFocus: true | string | HTMLElement;
166 /**
167 * If `true`, week numbers will be displayed.
168 */
169 showWeekNumbers: boolean;
170 /**
171 * The date to open calendar with.
172 *
173 * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
174 * If nothing or invalid date is provided, calendar will open with current month.
175 *
176 * You could use `navigateTo(date)` method as an alternative.
177 */
178 startDate: {
179 year: number;
180 month: number;
181 day?: number;
182 };
183 /**
184 * A selector specifying the element the datepicker popup should be appended to.
185 *
186 * Currently only supports `"body"`.
187 */
188 container: "body" | null;
189 /**
190 * A css selector or html element specifying the element the datepicker popup should be positioned against.
191 *
192 * By default the input is used as a target.
193 *
194 * @since 4.2.0
195 */
196 positionTarget: string | HTMLElement;
197 /**
198 * The way weekdays should be displayed.
199 *
200 * * `true` - weekdays are displayed using default width
201 * * `false` - weekdays are not displayed
202 * * `"short" | "long" | "narrow"` - weekdays are displayed using specified width
203 *
204 * @since 9.1.0
205 */
206 weekdays: Exclude<Intl.DateTimeFormatOptions['weekday'], undefined> | boolean;
207 /**
208 * An event emitted when user selects a date using keyboard or mouse.
209 *
210 * The payload of the event is currently selected `NgbDate`.
211 *
212 * @since 1.1.1
213 */
214 dateSelect: EventEmitter<NgbDate>;
215 /**
216 * Event emitted right after the navigation happens and displayed month changes.
217 *
218 * See [`NgbDatepickerNavigateEvent`](#/components/datepicker/api#NgbDatepickerNavigateEvent) for the payload info.
219 */
220 navigate: EventEmitter<NgbDatepickerNavigateEvent>;
221 /**
222 * An event fired after closing datepicker window.
223 *
224 * @since 4.2.0
225 */
226 closed: EventEmitter<void>;
227 get disabled(): any;
228 set disabled(value: any);
229 private _onChange;
230 private _onTouched;
231 private _validatorChange;
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 _setCloseHandlers;
278 static ɵfac: i0.ɵɵFactoryDeclaration<NgbInputDatepicker, never>;
279 static ɵdir: i0.ɵɵDirectiveDeclaration<NgbInputDatepicker, "input[ngbDatepicker]", ["ngbDatepicker"], { "autoClose": { "alias": "autoClose"; "required": false; }; "contentTemplate": { "alias": "contentTemplate"; "required": false; }; "datepickerClass": { "alias": "datepickerClass"; "required": false; }; "dayTemplate": { "alias": "dayTemplate"; "required": false; }; "dayTemplateData": { "alias": "dayTemplateData"; "required": false; }; "displayMonths": { "alias": "displayMonths"; "required": false; }; "firstDayOfWeek": { "alias": "firstDayOfWeek"; "required": false; }; "footerTemplate": { "alias": "footerTemplate"; "required": false; }; "markDisabled": { "alias": "markDisabled"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "navigation": { "alias": "navigation"; "required": false; }; "outsideDays": { "alias": "outsideDays"; "required": false; }; "placement": { "alias": "placement"; "required": false; }; "popperOptions": { "alias": "popperOptions"; "required": false; }; "restoreFocus": { "alias": "restoreFocus"; "required": false; }; "showWeekNumbers": { "alias": "showWeekNumbers"; "required": false; }; "startDate": { "alias": "startDate"; "required": false; }; "container": { "alias": "container"; "required": false; }; "positionTarget": { "alias": "positionTarget"; "required": false; }; "weekdays": { "alias": "weekdays"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "dateSelect": "dateSelect"; "navigate": "navigate"; "closed": "closed"; }, never, never, true, never>;
280}