UNPKG

1.56 kBTypeScriptView Raw
1import { NgbDateStruct } from '../ngb-date-struct';
2export declare function NGB_DATEPICKER_DATE_ADAPTER_FACTORY(): NgbDateStructAdapter;
3/**
4 * An abstract service that does the conversion between the internal datepicker `NgbDateStruct` model and
5 * any provided user date model `D`, ex. a string, a native date, etc.
6 *
7 * The adapter is used **only** for conversion when binding datepicker to a form control,
8 * ex. `[(ngModel)]="userDateModel"`. Here `userDateModel` can be of any type.
9 *
10 * The default datepicker implementation assumes we use `NgbDateStruct` as a user model.
11 *
12 * See the [date format overview](#/components/datepicker/overview#date-model) for more details
13 * and the [custom adapter demo](#/components/datepicker/examples#adapter) for an example.
14 */
15export declare abstract class NgbDateAdapter<D> {
16 /**
17 * Converts a user-model date of type `D` to an `NgbDateStruct` for internal use.
18 */
19 abstract fromModel(value: D | null): NgbDateStruct | null;
20 /**
21 * Converts an internal `NgbDateStruct` date to a user-model date of type `D`.
22 */
23 abstract toModel(date: NgbDateStruct | null): D | null;
24}
25export declare class NgbDateStructAdapter extends NgbDateAdapter<NgbDateStruct> {
26 /**
27 * Converts a NgbDateStruct value into NgbDateStruct value
28 */
29 fromModel(date: NgbDateStruct | null): NgbDateStruct | null;
30 /**
31 * Converts a NgbDateStruct value into NgbDateStruct value
32 */
33 toModel(date: NgbDateStruct | null): NgbDateStruct | null;
34}