UNPKG

11.6 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 | number;
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 _controlValue;
130 private _publicState;
131 /**
132 * The reference to a custom content template.
133 *
134 * Allows to completely override the way datepicker displays months.
135 *
136 * See [`NgbDatepickerContent`](#/components/datepicker/api#NgbDatepickerContent) and
137 * [`ContentTemplateContext`](#/components/datepicker/api#ContentTemplateContext) for more details.
138 *
139 * @since 14.2.0
140 */
141 contentTemplate: TemplateRef<ContentTemplateContext>;
142 contentTemplateFromContent?: NgbDatepickerContent;
143 /**
144 * The reference to a custom template for the day.
145 *
146 * Allows to completely override the way a day 'cell' in the calendar is displayed.
147 *
148 * See [`DayTemplateContext`](#/components/datepicker/api#DayTemplateContext) for the data you get inside.
149 */
150 dayTemplate: TemplateRef<DayTemplateContext>;
151 /**
152 * The callback to pass any arbitrary data to the template cell via the
153 * [`DayTemplateContext`](#/components/datepicker/api#DayTemplateContext)'s `data` parameter.
154 *
155 * `current` is the month that is currently displayed by the datepicker.
156 *
157 * @since 3.3.0
158 */
159 dayTemplateData: (date: NgbDateStruct, current?: {
160 year: number;
161 month: number;
162 } | undefined) => any;
163 /**
164 * The number of months to display.
165 */
166 displayMonths: number;
167 /**
168 * The first day of the week.
169 *
170 * With default calendar we use ISO 8601: 'weekday' is 1=Mon ... 7=Sun.
171 */
172 firstDayOfWeek: number;
173 /**
174 * The reference to the custom template for the datepicker footer.
175 *
176 * @since 3.3.0
177 */
178 footerTemplate: TemplateRef<any>;
179 /**
180 * The callback to mark some dates as disabled.
181 *
182 * It is called for each new date when navigating to a different month.
183 *
184 * `current` is the month that is currently displayed by the datepicker.
185 */
186 markDisabled: (date: NgbDateStruct, current?: {
187 year: number;
188 month: number;
189 } | undefined) => boolean;
190 /**
191 * The latest date that can be displayed or selected.
192 *
193 * If not provided, 'year' select box will display 10 years after the current month.
194 */
195 maxDate: NgbDateStruct;
196 /**
197 * The earliest date that can be displayed or selected.
198 *
199 * If not provided, 'year' select box will display 10 years before the current month.
200 */
201 minDate: NgbDateStruct;
202 /**
203 * Navigation type.
204 *
205 * * `"select"` - select boxes for month and navigation arrows
206 * * `"arrows"` - only navigation arrows
207 * * `"none"` - no navigation visible at all
208 */
209 navigation: "select" | "none" | "arrows";
210 /**
211 * The way of displaying days that don't belong to the current month.
212 *
213 * * `"visible"` - days are visible
214 * * `"hidden"` - days are hidden, white space preserved
215 * * `"collapsed"` - days are collapsed, so the datepicker height might change between months
216 *
217 * For the 2+ months view, days in between months are never shown.
218 */
219 outsideDays: "visible" | "collapsed" | "hidden";
220 /**
221 * If `true`, week numbers will be displayed.
222 */
223 showWeekNumbers: boolean;
224 /**
225 * The date to open calendar with.
226 *
227 * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
228 * If nothing or invalid date is provided, calendar will open with current month.
229 *
230 * You could use `navigateTo(date)` method as an alternative.
231 */
232 startDate: {
233 year: number;
234 month: number;
235 day?: number | undefined;
236 };
237 /**
238 * The way weekdays should be displayed.
239 *
240 * * `true` - weekdays are displayed using default width
241 * * `false` - weekdays are not displayed
242 * * `TranslationWidth` - weekdays are displayed using specified width
243 *
244 * @since 9.1.0
245 */
246 weekdays: boolean | import("@angular/common").TranslationWidth;
247 /**
248 * An event emitted right before the navigation happens and displayed month changes.
249 *
250 * See [`NgbDatepickerNavigateEvent`](#/components/datepicker/api#NgbDatepickerNavigateEvent) for the payload info.
251 */
252 navigate: EventEmitter<NgbDatepickerNavigateEvent>;
253 /**
254 * An event emitted when user selects a date using keyboard or mouse.
255 *
256 * The payload of the event is currently selected `NgbDate`.
257 *
258 * @since 5.2.0
259 */
260 dateSelect: EventEmitter<NgbDate>;
261 onChange: (_: any) => void;
262 onTouched: () => void;
263 constructor();
264 /**
265 * Returns the readonly public state of the datepicker
266 *
267 * @since 5.2.0
268 */
269 get state(): NgbDatepickerState;
270 /**
271 * Returns the calendar service used in the specific datepicker instance.
272 *
273 * @since 5.3.0
274 */
275 get calendar(): NgbCalendar;
276 /**
277 * Returns the i18n service used in the specific datepicker instance.
278 *
279 * @since 14.2.0
280 */
281 get i18n(): NgbDatepickerI18n;
282 /**
283 * Focuses on given date.
284 */
285 focusDate(date?: NgbDateStruct | null): void;
286 /**
287 * Selects focused date.
288 */
289 focusSelect(): void;
290 focus(): void;
291 /**
292 * Navigates to the provided date.
293 *
294 * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
295 * If nothing or invalid date provided calendar will open current month.
296 *
297 * Use the `[startDate]` input as an alternative.
298 */
299 navigateTo(date?: {
300 year: number;
301 month: number;
302 day?: number;
303 }): void;
304 ngAfterViewInit(): void;
305 ngOnInit(): void;
306 ngOnChanges(changes: SimpleChanges): void;
307 onDateSelect(date: NgbDate): void;
308 onNavigateDateSelect(date: NgbDate): void;
309 onNavigateEvent(event: NavigationEvent): void;
310 registerOnChange(fn: (value: any) => any): void;
311 registerOnTouched(fn: () => any): void;
312 setDisabledState(disabled: boolean): void;
313 writeValue(value: any): void;
314 static ɵfac: i0.ɵɵFactoryDeclaration<NgbDatepicker, never>;
315 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>;
316}