UNPKG

12.3 kBTypeScriptView Raw
1import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, Injector, NgZone, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef } from '@angular/core';
2import { ControlValueAccessor } from '@angular/forms';
3import { TranslationWidth } from '@angular/common';
4import { NgbCalendar } from './ngb-calendar';
5import { NgbDate } from './ngb-date';
6import { NgbDatepickerService } from './datepicker-service';
7import { DatepickerViewModel, DayViewModel, MonthViewModel, NavigationEvent } from './datepicker-view-model';
8import { DayTemplateContext } from './datepicker-day-template-context';
9import { NgbDatepickerConfig } from './datepicker-config';
10import { NgbDateAdapter } from './adapters/ngb-date-adapter';
11import { NgbDateStruct } from './ngb-date-struct';
12import { NgbDatepickerI18n } from './datepicker-i18n';
13import { NgbDatepickerKeyboardService } from './datepicker-keyboard-service';
14import { ContentTemplateContext } from './datepicker-content-template-context';
15import * as i0 from "@angular/core";
16/**
17 * An event emitted right before the navigation happens and the month displayed by the datepicker changes.
18 */
19export interface NgbDatepickerNavigateEvent {
20 /**
21 * The currently displayed month.
22 */
23 current: {
24 year: number;
25 month: number;
26 } | null;
27 /**
28 * The month we're navigating to.
29 */
30 next: {
31 year: number;
32 month: number;
33 };
34 /**
35 * Calling this function will prevent navigation from happening.
36 *
37 * @since 4.1.0
38 */
39 preventDefault: () => void;
40}
41/**
42 * An interface that represents the readonly public state of the datepicker.
43 *
44 * Accessible via the `datepicker.state` getter
45 *
46 * @since 5.2.0
47 */
48export interface NgbDatepickerState {
49 /**
50 * The earliest date that can be displayed or selected
51 */
52 readonly minDate: NgbDate | null;
53 /**
54 * The latest date that can be displayed or selected
55 */
56 readonly maxDate: NgbDate | null;
57 /**
58 * The first visible date of currently displayed months
59 */
60 readonly firstDate: NgbDate;
61 /**
62 * The last visible date of currently displayed months
63 */
64 readonly lastDate: NgbDate;
65 /**
66 * The date currently focused by the datepicker
67 */
68 readonly focusedDate: NgbDate;
69 /**
70 * First dates of months currently displayed by the datepicker
71 *
72 * @since 5.3.0
73 */
74 readonly months: NgbDate[];
75}
76/**
77 * A directive that marks the content template that customizes the way datepicker months are displayed
78 *
79 * @since 5.3.0
80 */
81export declare class NgbDatepickerContent {
82 templateRef: TemplateRef<any>;
83 constructor(templateRef: TemplateRef<any>);
84 static ɵfac: i0.ɵɵFactoryDeclaration<NgbDatepickerContent, never>;
85 static ɵdir: i0.ɵɵDirectiveDeclaration<NgbDatepickerContent, "ng-template[ngbDatepickerContent]", never, {}, {}, never, never, true, never>;
86}
87/**
88 * A component that renders one month including all the days, weekdays and week numbers. Can be used inside
89 * the `<ng-template ngbDatepickerMonths></ng-template>` when you want to customize months layout.
90 *
91 * For a usage example, see [custom month layout demo](#/components/datepicker/examples#custommonth)
92 *
93 * @since 5.3.0
94 */
95export declare class NgbDatepickerMonth {
96 i18n: NgbDatepickerI18n;
97 datepicker: NgbDatepicker;
98 private _keyboardService;
99 private _service;
100 /**
101 * The first date of month to be rendered.
102 *
103 * This month must one of the months present in the
104 * [datepicker state](#/components/datepicker/api#NgbDatepickerState).
105 */
106 set month(month: NgbDateStruct);
107 viewModel: MonthViewModel;
108 constructor(i18n: NgbDatepickerI18n, datepicker: NgbDatepicker, _keyboardService: NgbDatepickerKeyboardService, _service: NgbDatepickerService);
109 onKeyDown(event: KeyboardEvent): void;
110 doSelect(day: DayViewModel): void;
111 static ɵfac: i0.ɵɵFactoryDeclaration<NgbDatepickerMonth, never>;
112 static ɵcmp: i0.ɵɵComponentDeclaration<NgbDatepickerMonth, "ngb-datepicker-month", never, { "month": { "alias": "month"; "required": false; }; }, {}, never, never, true, never>;
113}
114/**
115 * A highly configurable component that helps you with selecting calendar dates.
116 *
117 * `NgbDatepicker` is meant to be displayed inline on a page or put inside a popup.
118 */
119export declare class NgbDatepicker implements AfterViewInit, OnDestroy, OnChanges, OnInit, ControlValueAccessor {
120 private _service;
121 private _calendar;
122 private _i18n;
123 private _elementRef;
124 private _ngbDateAdapter;
125 private _ngZone;
126 static ngAcceptInputType_autoClose: boolean | string;
127 static ngAcceptInputType_navigation: string;
128 static ngAcceptInputType_outsideDays: string;
129 static ngAcceptInputType_weekdays: boolean | number;
130 model: DatepickerViewModel;
131 private _defaultDayTemplate;
132 private _contentEl;
133 protected injector: Injector;
134 private _controlValue;
135 private _destroyed$;
136 private _publicState;
137 /**
138 * The reference to a custom content template.
139 *
140 * Allows to completely override the way datepicker displays months.
141 *
142 * See [`NgbDatepickerContent`](#/components/datepicker/api#NgbDatepickerContent) and
143 * [`ContentTemplateContext`](#/components/datepicker/api#ContentTemplateContext) for more details.
144 *
145 * @since 14.2.0
146 */
147 contentTemplate: TemplateRef<ContentTemplateContext>;
148 contentTemplateFromContent?: NgbDatepickerContent;
149 /**
150 * The reference to a custom template for the day.
151 *
152 * Allows to completely override the way a day 'cell' in the calendar is displayed.
153 *
154 * See [`DayTemplateContext`](#/components/datepicker/api#DayTemplateContext) for the data you get inside.
155 */
156 dayTemplate: TemplateRef<DayTemplateContext>;
157 /**
158 * The callback to pass any arbitrary data to the template cell via the
159 * [`DayTemplateContext`](#/components/datepicker/api#DayTemplateContext)'s `data` parameter.
160 *
161 * `current` is the month that is currently displayed by the datepicker.
162 *
163 * @since 3.3.0
164 */
165 dayTemplateData: (date: NgbDate, current?: {
166 year: number;
167 month: number;
168 }) => any;
169 /**
170 * The number of months to display.
171 */
172 displayMonths: number;
173 /**
174 * The first day of the week.
175 *
176 * With default calendar we use ISO 8601: 'weekday' is 1=Mon ... 7=Sun.
177 */
178 firstDayOfWeek: number;
179 /**
180 * The reference to the custom template for the datepicker footer.
181 *
182 * @since 3.3.0
183 */
184 footerTemplate: TemplateRef<any>;
185 /**
186 * The callback to mark some dates as disabled.
187 *
188 * It is called for each new date when navigating to a different month.
189 *
190 * `current` is the month that is currently displayed by the datepicker.
191 */
192 markDisabled: (date: NgbDate, current?: {
193 year: number;
194 month: number;
195 }) => boolean;
196 /**
197 * The latest date that can be displayed or selected.
198 *
199 * If not provided, 'year' select box will display 10 years after the current month.
200 */
201 maxDate: NgbDateStruct;
202 /**
203 * The earliest date that can be displayed or selected.
204 *
205 * If not provided, 'year' select box will display 10 years before the current month.
206 */
207 minDate: NgbDateStruct;
208 /**
209 * Navigation type.
210 *
211 * * `"select"` - select boxes for month and navigation arrows
212 * * `"arrows"` - only navigation arrows
213 * * `"none"` - no navigation visible at all
214 */
215 navigation: 'select' | 'arrows' | 'none';
216 /**
217 * The way of displaying days that don't belong to the current month.
218 *
219 * * `"visible"` - days are visible
220 * * `"hidden"` - days are hidden, white space preserved
221 * * `"collapsed"` - days are collapsed, so the datepicker height might change between months
222 *
223 * For the 2+ months view, days in between months are never shown.
224 */
225 outsideDays: 'visible' | 'collapsed' | 'hidden';
226 /**
227 * If `true`, week numbers will be displayed.
228 */
229 showWeekNumbers: boolean;
230 /**
231 * The date to open calendar with.
232 *
233 * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
234 * If nothing or invalid date is provided, calendar will open with current month.
235 *
236 * You could use `navigateTo(date)` method as an alternative.
237 */
238 startDate: {
239 year: number;
240 month: number;
241 day?: number;
242 };
243 /**
244 * The way weekdays should be displayed.
245 *
246 * * `true` - weekdays are displayed using default width
247 * * `false` - weekdays are not displayed
248 * * `TranslationWidth` - weekdays are displayed using specified width
249 *
250 * @since 9.1.0
251 */
252 weekdays: TranslationWidth | boolean;
253 /**
254 * An event emitted right before the navigation happens and displayed month changes.
255 *
256 * See [`NgbDatepickerNavigateEvent`](#/components/datepicker/api#NgbDatepickerNavigateEvent) for the payload info.
257 */
258 navigate: EventEmitter<NgbDatepickerNavigateEvent>;
259 /**
260 * An event emitted when user selects a date using keyboard or mouse.
261 *
262 * The payload of the event is currently selected `NgbDate`.
263 *
264 * @since 5.2.0
265 */
266 dateSelect: EventEmitter<NgbDate>;
267 onChange: (_: any) => void;
268 onTouched: () => void;
269 constructor(_service: NgbDatepickerService, _calendar: NgbCalendar, _i18n: NgbDatepickerI18n, config: NgbDatepickerConfig, cd: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>, _ngbDateAdapter: NgbDateAdapter<any>, _ngZone: NgZone);
270 /**
271 * Returns the readonly public state of the datepicker
272 *
273 * @since 5.2.0
274 */
275 get state(): NgbDatepickerState;
276 /**
277 * Returns the calendar service used in the specific datepicker instance.
278 *
279 * @since 5.3.0
280 */
281 get calendar(): NgbCalendar;
282 /**
283 * Returns the i18n service used in the specific datepicker instance.
284 *
285 * @since 14.2.0
286 */
287 get i18n(): NgbDatepickerI18n;
288 /**
289 * Focuses on given date.
290 */
291 focusDate(date?: NgbDateStruct | null): void;
292 /**
293 * Selects focused date.
294 */
295 focusSelect(): void;
296 focus(): void;
297 /**
298 * Navigates to the provided date.
299 *
300 * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
301 * If nothing or invalid date provided calendar will open current month.
302 *
303 * Use the `[startDate]` input as an alternative.
304 */
305 navigateTo(date?: {
306 year: number;
307 month: number;
308 day?: number;
309 }): void;
310 ngAfterViewInit(): void;
311 ngOnDestroy(): void;
312 ngOnInit(): void;
313 ngOnChanges(changes: SimpleChanges): void;
314 onDateSelect(date: NgbDate): void;
315 onNavigateDateSelect(date: NgbDate): void;
316 onNavigateEvent(event: NavigationEvent): void;
317 registerOnChange(fn: (value: any) => any): void;
318 registerOnTouched(fn: () => any): void;
319 setDisabledState(disabled: boolean): void;
320 writeValue(value: any): void;
321 static ɵfac: i0.ɵɵFactoryDeclaration<NgbDatepicker, never>;
322 static ɵcmp: i0.ɵɵComponentDeclaration<NgbDatepicker, "ngb-datepicker", ["ngbDatepicker"], { "contentTemplate": { "alias": "contentTemplate"; "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; }; "maxDate": { "alias": "maxDate"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "navigation": { "alias": "navigation"; "required": false; }; "outsideDays": { "alias": "outsideDays"; "required": false; }; "showWeekNumbers": { "alias": "showWeekNumbers"; "required": false; }; "startDate": { "alias": "startDate"; "required": false; }; "weekdays": { "alias": "weekdays"; "required": false; }; }, { "navigate": "navigate"; "dateSelect": "dateSelect"; }, ["contentTemplateFromContent"], never, true, never>;
323}