UNPKG

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