moh-common-lib
Version:
A library of Angular components, services, and styles for B.C. Government Ministry of Health (MoH).
66 lines (65 loc) • 2.35 kB
TypeScript
import { OnInit, EventEmitter, SimpleChanges, OnChanges } from '@angular/core';
import { ControlValueAccessor, NgControl } from '@angular/forms';
import { ErrorMessage } from '../../models/error-message.interface';
import { AbstractFormControl } from '../../models/abstract-form-control';
export declare class DateComponent extends AbstractFormControl implements OnInit, ControlValueAccessor, OnChanges {
controlDir: NgControl;
private injectedValidators;
date: Date;
dateChange: EventEmitter<Date>;
label: string;
/** Can be one of: "future", "past". "future" includes today, "past" does not. */
restrictDate: 'future' | 'past' | 'any';
_year: string;
_month: string;
_day: string;
_dateRangeStart: Date;
_dateRangeEnd: Date;
/**
* The earliest valid date that can be used.
* Do NOT combine with restrictDates, as they set the same underlying values.
*/
dateRangeStart: Date;
/**
* The latest valid date that can be used.
* Do NOT combine with restrictDates, as they set the same underlying values.
*/
dateRangeEnd: Date;
monthList: string[];
monthLabelforId: string;
dayLabelforId: string;
yearLabelforId: string;
_defaultErrMsg: ErrorMessage;
private today;
private tomorrow;
isRequired: boolean;
constructor(controlDir: NgControl, injectedValidators: any[]);
ngOnChanges(changes: SimpleChanges): void;
ngOnInit(): void;
readonly month: number;
readonly day: number;
readonly year: number;
/**
* Handles creating / destroying date and emitting changes based on user behaviour.
*/
private processDate;
/**
* Returns true if and only if the day/month/year fields are all filled out.
*/
private canCreateDate;
private _triggerOnChange;
/** Convert string to numeric value or null if not */
private getNumericValue;
private setDisplayVariables;
writeValue(value: Date): void;
onBlurDay(value: string): void;
onBlurYear(value: string): void;
onBlurMonth(value: string): void;
/**
* Validates the DateComponent instance itself, using internal private variables.
*
*/
private validateSelf;
private validateRange;
private validateDistantDates;
}