@dhutaryan/ngx-mat-timepicker
Version:
Angular timepicker to add time which is based on material design and Angular material.
113 lines (112 loc) • 6.02 kB
TypeScript
import { BooleanInput } from '@angular/cdk/coercion';
import { ElementRef, EventEmitter, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import { AbstractControl, ControlValueAccessor, ValidationErrors, Validator, ValidatorFn } from '@angular/forms';
import { Subject } from 'rxjs';
import { TimeAdapter } from './adapter';
import { ExtractTimeTypeFromSelection, MatTimeSelectionModel, TimeSelectionModelChange } from './time-selection-model';
import * as i0 from "@angular/core";
/**
* An event used for timepicker input and change events. We don't always have access to a native
* input or change event because the event may have been triggered by the user clicking on the
* clock popup. For consistency, we always use MatTimepickerInputEvent instead.
*/
export declare class MatTimepickerInputEvent<D, S = unknown> {
/** Reference to the timepicker input component that emitted the event. */
target: MatTimepickerInputBase<S, D>;
/** Reference to the native input element associated with the timepicker input. */
targetElement: HTMLElement;
/** The new value for the target timepicker input. */
value: D | null;
constructor(
/** Reference to the timepicker input component that emitted the event. */
target: MatTimepickerInputBase<S, D>,
/** Reference to the native input element associated with the timepicker input. */
targetElement: HTMLElement);
}
export declare abstract class MatTimepickerInputBase<S, T = ExtractTimeTypeFromSelection<S>> implements OnChanges, OnDestroy, ControlValueAccessor, Validator {
protected _elementRef: ElementRef<HTMLInputElement>;
_timeAdapter: TimeAdapter<T>;
/** The value of the input. */
get value(): T | null;
set value(value: any);
protected _model: MatTimeSelectionModel<S, T> | undefined;
/** Whether the timepicker-input is disabled. */
get disabled(): boolean;
set disabled(value: BooleanInput);
private _disabled;
/** Emits when a change event is fired on this <input>. */
readonly timeChange: EventEmitter<MatTimepickerInputEvent<T, S>>;
/** Emits when an input event is fired on this <input>. */
readonly timeInput: EventEmitter<MatTimepickerInputEvent<T, S>>;
/** Gets the minimum time for the input. Used for validation. */
abstract _getMinTime(): T | null;
/** Gets the maximum time for the input. Used for validation. */
abstract _getMaxTime(): T | null;
/** Combined form control validator for this input. */
protected abstract _validator: ValidatorFn | null;
/** Whether the component has been initialized. */
private _isInitialized;
/**
* Since the value is kept on the model which is assigned in an Input,
* we might get a value before we have a model. This property keeps track
* of the value until we have somewhere to assign it.
*/
private _pendingValue;
/** Emits when the internal state has changed */
readonly stateChanges: Subject<void>;
_onTouched: () => void;
_validatorOnChange: () => void;
private _cvaOnChange;
private _valueChangesSubscription;
constructor(_elementRef: ElementRef<HTMLInputElement>, _timeAdapter: TimeAdapter<T>);
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
/** Registers a time selection model with the input. */
_registerModel(model: MatTimeSelectionModel<S, T>): void;
_onInput(value: string): void;
/** Handles change event on the input. */
_onChange(): void;
/** Handles blur event on the input. */
_onBlur(): void;
/** Implemented as part of ControlValueAccessor. */
writeValue(value: T | null): void;
/** Implemented as part of ControlValueAccessor. */
registerOnChange(fn: any): void;
/** Implemented as part of ControlValueAccessor. */
registerOnTouched(fn: () => void): void;
/** Implemented as part of ControlValueAccessor. */
setDisabledState?(isDisabled: boolean): void;
registerOnValidatorChange(fn: () => void): void;
validate(c: AbstractControl): ValidationErrors | null;
/** Whether the last value set on the input was valid. */
protected _lastValueValid: boolean;
/** Assigns a value to the input's model. */
protected abstract _assignValueToModel(model: T | null): void;
/** Converts a value from the model into a native value for the input. */
protected abstract _getValueFromModel(modelValue: S): T | null;
/** Predicate that determines whether the input should handle a particular change event. */
protected abstract _shouldHandleChangeEvent(event: TimeSelectionModelChange<S>): boolean;
/** Programmatically assigns a value to the input. */
protected _assignValueProgrammatically(value: T | null): void;
/** Formats a value and sets it on the input element. */
protected _formatValue(value: T | null): void;
/** Gets the base validator functions. */
protected _getValidators(): ValidatorFn[];
/** Whether a value is considered valid. */
private _isValidValue;
/** Assigns a value to the model. */
private _assignValue;
/** The form control validator for whether the input parses. */
private _parseValidator;
/** The form control validator for the min time. */
private _minValidator;
/** The form control validator for the max time. */
private _maxValidator;
static ɵfac: i0.ɵɵFactoryDeclaration<MatTimepickerInputBase<any, any>, [null, { optional: true; }]>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MatTimepickerInputBase<any, any>, never, never, { "value": { "alias": "value"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "timeChange": "timeChange"; "timeInput": "timeInput"; }, never, never, true, never>;
}
/**
* Checks whether the `SimpleChanges` object from an `ngOnChanges`
* callback has any changes, accounting for time objects.
*/
export declare function timeInputsHaveChanged(changes: SimpleChanges, adapter: TimeAdapter<unknown>): boolean;