-
+
+ Date Range:
+
+
+
+
+ Value: {{ dateRange.value }}
diff --git a/pdb-js/src/app/components/datepicker/date-picker.component.ts b/pdb-js/src/app/components/datepicker/date-picker.component.ts
index 9fb227a..256798a 100644
--- a/pdb-js/src/app/components/datepicker/date-picker.component.ts
+++ b/pdb-js/src/app/components/datepicker/date-picker.component.ts
@@ -1,15 +1,43 @@
-import { Component } from "@angular/core";
-import { FormControl, FormGroup, Validators } from "@angular/forms";
+import {
+ Component,
+ EventEmitter,
+ forwardRef,
+ Input,
+ Output,
+} from "@angular/core";
+import {
+ ControlValueAccessor,
+ FormControl,
+ NG_VALUE_ACCESSOR,
+ Validators,
+} from "@angular/forms";
export type DateType = "quick" | "relative" | "absolute";
-export type DateValue = { type: DateType; value: string; display: string };
+export class DateValue {
+ constructor(
+ public type: DateType,
+ public value: string,
+ public display: string,
+ ) {}
+}
+
+export class DatePickerChange {
+ constructor(public value: DateValue) {}
+}
@Component({
selector: "app-date-picker",
templateUrl: "./date-picker.component.html",
+ providers: [
+ {
+ provide: NG_VALUE_ACCESSOR,
+ useExisting: forwardRef(() => DatePickerComponent),
+ multi: true,
+ },
+ ],
})
-export class DatePickerComponent {
+export class DatePickerComponent implements ControlValueAccessor {
isOpen = false;
relativeTimeRangeUnit = "relativeTimeRangeMinutes";
@@ -25,39 +53,88 @@ export class DatePickerComponent {
years: 0,
};
- dateRangeFormGroup = new FormGroup({
- dateRange: new FormControl