ngb-time-adapter.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { NgbTimeStruct } from './ngb-time-struct';
  2. export 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. */
  16. export 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): NgbTimeStruct;
  21. /**
  22. * Converts an internal `NgbTimeStruct` time to a user-model time of type `T`.
  23. */
  24. abstract toModel(time: NgbTimeStruct): T;
  25. }
  26. export declare class NgbTimeStructAdapter extends NgbTimeAdapter<NgbTimeStruct> {
  27. /**
  28. * Converts a NgbTimeStruct value into NgbTimeStruct value
  29. */
  30. fromModel(time: NgbTimeStruct): NgbTimeStruct;
  31. /**
  32. * Converts a NgbTimeStruct value into NgbTimeStruct value
  33. */
  34. toModel(time: NgbTimeStruct): NgbTimeStruct;
  35. }