UNPKG

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