@ng-bootstrap/ng-bootstrap
Version:
Angular powered Bootstrap
35 lines (34 loc) • 1.52 kB
TypeScript
import { NgbDateStruct } from '../ngb-date-struct';
export declare function NGB_DATEPICKER_DATE_ADAPTER_FACTORY(): NgbDateStructAdapter;
/**
* An abstract service that does the conversion between the internal datepicker `NgbDateStruct` model and
* any provided user date model `D`, ex. a string, a native date, etc.
*
* The adapter is used **only** for conversion when binding datepicker to a form control,
* ex. `[(ngModel)]="userDateModel"`. Here `userDateModel` can be of any type.
*
* The default datepicker implementation assumes we use `NgbDateStruct` as a user model.
*
* See the [date format overview](#/components/datepicker/overview#date-model) for more details
* and the [custom adapter demo](#/components/datepicker/examples#adapter) for an example.
*/
export declare abstract class NgbDateAdapter<D> {
/**
* Converts a user-model date of type `D` to an `NgbDateStruct` for internal use.
*/
abstract fromModel(value: D | null): NgbDateStruct | null;
/**
* Converts an internal `NgbDateStruct` date to a user-model date of type `D`.
*/
abstract toModel(date: NgbDateStruct | null): D | null;
}
export declare class NgbDateStructAdapter extends NgbDateAdapter<NgbDateStruct> {
/**
* Converts a NgbDateStruct value into NgbDateStruct value
*/
fromModel(date: NgbDateStruct | null): NgbDateStruct | null;
/**
* Converts a NgbDateStruct value into NgbDateStruct value
*/
toModel(date: NgbDateStruct | null): NgbDateStruct | null;
}