UNPKG

13.4 kBTypeScriptView Raw
1import { ComponentFactoryResolver, ComponentRef, OnChanges, ElementRef, EventEmitter, OnDestroy, Type, OnInit, SimpleChanges } from '@angular/core';
2import { Observable, ReplaySubject, Subject } from 'rxjs';
3import { NbOverlayRef } from '../cdk/overlay/mapping';
4import { NbAdjustableConnectedPositionStrategy, NbAdjustment, NbAdjustmentValues, NbPositionBuilderService } from '../cdk/overlay/overlay-position';
5import { NbOverlayService } from '../cdk/overlay/overlay-service';
6import { NbTriggerStrategy, NbTriggerStrategyBuilderService } from '../cdk/overlay/overlay-trigger';
7import { NbDatepickerContainerComponent } from './datepicker-container.component';
8import { NbCalendarRange, NbCalendarRangeComponent } from '../calendar/calendar-range.component';
9import { NbCalendarComponent } from '../calendar/calendar.component';
10import { NbCalendarCell, NbCalendarSize, NbCalendarViewMode, NbCalendarSizeValues, NbCalendarViewModeValues } from '../calendar-kit/model';
11import { NbDateService } from '../calendar-kit/services/date.service';
12import { NbDatepicker, NbPickerValidatorConfig } from './datepicker.directive';
13import { NbBooleanInput } from '../helpers';
14import * as i0 from "@angular/core";
15/**
16 * The `NbBasePicker` component concentrates overlay manipulation logic.
17 * */
18export declare abstract class NbBasePicker<D, T, P> extends NbDatepicker<T, D> {
19 protected overlay: NbOverlayService;
20 protected positionBuilder: NbPositionBuilderService;
21 protected triggerStrategyBuilder: NbTriggerStrategyBuilderService;
22 protected cfr: ComponentFactoryResolver;
23 protected dateService: NbDateService<D>;
24 protected dateServiceOptions: any;
25 /**
26 * Datepicker date format. Can be used only with date adapters (moment, date-fns) since native date
27 * object doesn't support formatting.
28 * */
29 abstract format: string;
30 /**
31 * Defines if we should render previous and next months
32 * in the current month view.
33 * */
34 abstract boundingMonth: boolean;
35 /**
36 * Defines starting view for calendar.
37 * */
38 abstract startView: NbCalendarViewMode;
39 /**
40 * Minimum available date for selection.
41 * */
42 abstract min: D;
43 /**
44 * Maximum available date for selection.
45 * */
46 abstract max: D;
47 /**
48 * Predicate that decides which cells will be disabled.
49 * */
50 abstract filter: (D: any) => boolean;
51 /**
52 * Custom day cell component. Have to implement `NbCalendarCell` interface.
53 * */
54 abstract dayCellComponent: Type<NbCalendarCell<D, T>>;
55 /**
56 * Custom month cell component. Have to implement `NbCalendarCell` interface.
57 * */
58 abstract monthCellComponent: Type<NbCalendarCell<D, T>>;
59 /**
60 * Custom year cell component. Have to implement `NbCalendarCell` interface.
61 * */
62 abstract yearCellComponent: Type<NbCalendarCell<D, T>>;
63 /**
64 * Size of the calendar and entire components.
65 * Can be 'medium' which is default or 'large'.
66 * */
67 abstract size: NbCalendarSize;
68 /**
69 * Depending on this date a particular month is selected in the calendar
70 */
71 abstract visibleDate: D;
72 /**
73 * Hide picker when a date or a range is selected, `true` by default
74 * @type {boolean}
75 */
76 abstract hideOnSelect: boolean;
77 /**
78 * Determines should we show calendar navigation or not.
79 * @type {boolean}
80 */
81 abstract showNavigation: boolean;
82 /**
83 * Sets symbol used as a header for week numbers column
84 * */
85 abstract weekNumberSymbol: string;
86 /**
87 * Determines should we show week numbers column.
88 * False by default.
89 * */
90 abstract showWeekNumber: boolean;
91 /**
92 * Sets first day of the week, it can be 1 if week starts from monday and 0 if from sunday and so on.
93 * `undefined` means that default locale setting will be used.
94 * */
95 abstract firstDayOfWeek: number | undefined;
96 readonly formatChanged$: Subject<void>;
97 /**
98 * Calendar component class that has to be instantiated inside overlay.
99 * */
100 protected abstract pickerClass: Type<P>;
101 /**
102 * Overlay reference object.
103 * */
104 protected ref: NbOverlayRef;
105 /**
106 * Datepicker container that contains instantiated picker.
107 * */
108 protected container: ComponentRef<NbDatepickerContainerComponent>;
109 /**
110 * Positioning strategy used by overlay.
111 * */
112 protected positionStrategy: NbAdjustableConnectedPositionStrategy;
113 /**
114 * Trigger strategy used by overlay
115 * */
116 protected triggerStrategy: NbTriggerStrategy;
117 /**
118 * HTML input reference to which datepicker connected.
119 * */
120 protected hostRef: ElementRef;
121 protected init$: ReplaySubject<void>;
122 /**
123 * Stream of picker changes. Required to be the subject because picker hides and shows and picker
124 * change stream becomes recreated.
125 * */
126 protected onChange$: Subject<T>;
127 /**
128 * Reference to the picker instance itself.
129 * */
130 protected pickerRef: ComponentRef<any>;
131 protected overlayOffset: number;
132 protected adjustment: NbAdjustment;
133 protected destroy$: Subject<void>;
134 /**
135 * Queue contains the last value that was applied to the picker when it was hidden.
136 * This value will be passed to the picker as soon as it shown.
137 * */
138 protected queue: T | undefined;
139 protected blur$: Subject<void>;
140 protected constructor(overlay: NbOverlayService, positionBuilder: NbPositionBuilderService, triggerStrategyBuilder: NbTriggerStrategyBuilderService, cfr: ComponentFactoryResolver, dateService: NbDateService<D>, dateServiceOptions: any);
141 /**
142 * Returns picker instance.
143 * */
144 get picker(): any;
145 /**
146 * Stream of picker value changes.
147 * */
148 get valueChange(): Observable<T>;
149 get isShown(): boolean;
150 get init(): Observable<void>;
151 /**
152 * Emits when datepicker looses focus.
153 */
154 get blur(): Observable<void>;
155 protected abstract get pickerValueChange(): Observable<T>;
156 /**
157 * Datepicker knows nothing about host html input element.
158 * So, attach method attaches datepicker to the host input element.
159 * */
160 attach(hostRef: ElementRef): void;
161 getValidatorConfig(): NbPickerValidatorConfig<D>;
162 show(): void;
163 shouldHide(): boolean;
164 hide(): void;
165 protected abstract writeQueue(): any;
166 protected createOverlay(): void;
167 protected openDatepicker(): void;
168 protected createPositionStrategy(): NbAdjustableConnectedPositionStrategy;
169 protected subscribeOnPositionChange(): void;
170 protected createTriggerStrategy(): NbTriggerStrategy;
171 protected subscribeOnTriggers(): void;
172 protected instantiatePicker(): void;
173 /**
174 * Subscribes on picker value changes and emit data through this.onChange$ subject.
175 * */
176 protected subscribeOnValueChange(): void;
177 protected patchWithInputs(): void;
178 protected checkFormat(): void;
179}
180export declare class NbBasePickerComponent<D, T, P> extends NbBasePicker<D, T, P> implements OnInit, OnChanges, OnDestroy {
181 /**
182 * Datepicker date format. Can be used only with date adapters (moment, date-fns) since native date
183 * object doesn't support formatting.
184 * */
185 format: string;
186 /**
187 * Defines if we should render previous and next months
188 * in the current month view.
189 * */
190 boundingMonth: boolean;
191 /**
192 * Defines starting view for calendar.
193 * */
194 startView: NbCalendarViewMode;
195 static ngAcceptInputType_startView: NbCalendarViewModeValues;
196 /**
197 * Minimum available date for selection.
198 * */
199 min: D;
200 /**
201 * Maximum available date for selection.
202 * */
203 max: D;
204 /**
205 * Predicate that decides which cells will be disabled.
206 * */
207 filter: (D: any) => boolean;
208 /**
209 * Custom day cell component. Have to implement `NbCalendarCell` interface.
210 * */
211 dayCellComponent: Type<NbCalendarCell<D, T>>;
212 /**
213 * Custom month cell component. Have to implement `NbCalendarCell` interface.
214 * */
215 monthCellComponent: Type<NbCalendarCell<D, T>>;
216 /**
217 * Custom year cell component. Have to implement `NbCalendarCell` interface.
218 * */
219 yearCellComponent: Type<NbCalendarCell<D, T>>;
220 /**
221 * Size of the calendar and entire components.
222 * Can be 'medium' which is default or 'large'.
223 * */
224 size: NbCalendarSize;
225 static ngAcceptInputType_size: NbCalendarSizeValues;
226 /**
227 * Depending on this date a particular month is selected in the calendar
228 */
229 visibleDate: D;
230 /**
231 * Hide picker when a date or a range is selected, `true` by default
232 * @type {boolean}
233 */
234 hideOnSelect: boolean;
235 /**
236 * Determines should we show calendars navigation or not.
237 * @type {boolean}
238 */
239 showNavigation: boolean;
240 /**
241 * Sets symbol used as a header for week numbers column
242 * */
243 weekNumberSymbol: string;
244 /**
245 * Determines should we show week numbers column.
246 * False by default.
247 * */
248 get showWeekNumber(): boolean;
249 set showWeekNumber(value: boolean);
250 protected _showWeekNumber: boolean;
251 static ngAcceptInputType_showWeekNumber: NbBooleanInput;
252 firstDayOfWeek: number | undefined;
253 /**
254 * Determines picker overlay offset (in pixels).
255 * */
256 overlayOffset: number;
257 adjustment: NbAdjustment;
258 static ngAcceptInputType_adjustment: NbAdjustmentValues;
259 constructor(document: any, positionBuilder: NbPositionBuilderService, triggerStrategyBuilder: NbTriggerStrategyBuilderService, overlay: NbOverlayService, cfr: ComponentFactoryResolver, dateService: NbDateService<D>, dateServiceOptions: any);
260 ngOnInit(): void;
261 ngOnChanges(changes: SimpleChanges): void;
262 ngOnDestroy(): void;
263 protected pickerClass: Type<P>;
264 protected get pickerValueChange(): Observable<T>;
265 get value(): T;
266 set value(value: T);
267 protected writeQueue(): void;
268 static ɵfac: i0.ɵɵFactoryDeclaration<NbBasePickerComponent<any, any, any>, [null, null, null, null, null, null, { optional: true; }]>;
269 static ɵcmp: i0.ɵɵComponentDeclaration<NbBasePickerComponent<any, any, any>, "ng-component", never, { "format": { "alias": "format"; "required": false; }; "boundingMonth": { "alias": "boundingMonth"; "required": false; }; "startView": { "alias": "startView"; "required": false; }; "min": { "alias": "min"; "required": false; }; "max": { "alias": "max"; "required": false; }; "filter": { "alias": "filter"; "required": false; }; "dayCellComponent": { "alias": "dayCellComponent"; "required": false; }; "monthCellComponent": { "alias": "monthCellComponent"; "required": false; }; "yearCellComponent": { "alias": "yearCellComponent"; "required": false; }; "size": { "alias": "size"; "required": false; }; "visibleDate": { "alias": "visibleDate"; "required": false; }; "hideOnSelect": { "alias": "hideOnSelect"; "required": false; }; "showNavigation": { "alias": "showNavigation"; "required": false; }; "weekNumberSymbol": { "alias": "weekNumberSymbol"; "required": false; }; "showWeekNumber": { "alias": "showWeekNumber"; "required": false; }; "firstDayOfWeek": { "alias": "firstDayOfWeek"; "required": false; }; "overlayOffset": { "alias": "overlayOffset"; "required": false; }; "adjustment": { "alias": "adjustment"; "required": false; }; }, {}, never, never, false, never>;
270}
271/**
272 * The DatePicker components itself.
273 * Provides a proxy to `NbCalendar` options as well as custom picker options.
274 */
275export declare class NbDatepickerComponent<D> extends NbBasePickerComponent<D, D, NbCalendarComponent<D>> {
276 protected pickerClass: Type<NbCalendarComponent<D>>;
277 /**
278 * Date which will be rendered as selected.
279 * */
280 set date(date: D);
281 /**
282 * Emits date when selected.
283 * */
284 get dateChange(): EventEmitter<D>;
285 get value(): D;
286 set value(date: D);
287 protected get pickerValueChange(): Observable<D>;
288 protected writeQueue(): void;
289 static ɵfac: i0.ɵɵFactoryDeclaration<NbDatepickerComponent<any>, never>;
290 static ɵcmp: i0.ɵɵComponentDeclaration<NbDatepickerComponent<any>, "nb-datepicker", never, { "date": { "alias": "date"; "required": false; }; }, { "dateChange": "dateChange"; }, never, never, false, never>;
291}
292/**
293 * The RangeDatePicker components itself.
294 * Provides a proxy to `NbCalendarRange` options as well as custom picker options.
295 */
296export declare class NbRangepickerComponent<D> extends NbBasePickerComponent<D, NbCalendarRange<D>, NbCalendarRangeComponent<D>> {
297 protected pickerClass: Type<NbCalendarRangeComponent<D>>;
298 /**
299 * Range which will be rendered as selected.
300 * */
301 set range(range: NbCalendarRange<D>);
302 /**
303 * Emits range when start selected and emits again when end selected.
304 * */
305 get rangeChange(): EventEmitter<NbCalendarRange<D>>;
306 get value(): NbCalendarRange<D>;
307 set value(range: NbCalendarRange<D>);
308 protected get pickerValueChange(): Observable<NbCalendarRange<D>>;
309 shouldHide(): boolean;
310 protected writeQueue(): void;
311 static ɵfac: i0.ɵɵFactoryDeclaration<NbRangepickerComponent<any>, never>;
312 static ɵcmp: i0.ɵɵComponentDeclaration<NbRangepickerComponent<any>, "nb-rangepicker", never, { "range": { "alias": "range"; "required": false; }; }, { "rangeChange": "rangeChange"; }, never, never, false, never>;
313}