UNPKG

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