source: trip-planner-front/node_modules/@angular/material/datepicker/datepicker-input-base.d.ts@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 6.6 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { BooleanInput } from '@angular/cdk/coercion';
9import { ElementRef, EventEmitter, OnDestroy, AfterViewInit, OnChanges, SimpleChanges } from '@angular/core';
10import { AbstractControl, ControlValueAccessor, ValidationErrors, Validator, ValidatorFn } from '@angular/forms';
11import { DateAdapter, MatDateFormats } from '@angular/material/core';
12import { Subject } from 'rxjs';
13import { ExtractDateTypeFromSelection, MatDateSelectionModel, DateSelectionModelChange } from './date-selection-model';
14/**
15 * An event used for datepicker input and change events. We don't always have access to a native
16 * input or change event because the event may have been triggered by the user clicking on the
17 * calendar popup. For consistency, we always use MatDatepickerInputEvent instead.
18 */
19export declare class MatDatepickerInputEvent<D, S = unknown> {
20 /** Reference to the datepicker input component that emitted the event. */
21 target: MatDatepickerInputBase<S, D>;
22 /** Reference to the native input element associated with the datepicker input. */
23 targetElement: HTMLElement;
24 /** The new value for the target datepicker input. */
25 value: D | null;
26 constructor(
27 /** Reference to the datepicker input component that emitted the event. */
28 target: MatDatepickerInputBase<S, D>,
29 /** Reference to the native input element associated with the datepicker input. */
30 targetElement: HTMLElement);
31}
32/** Function that can be used to filter out dates from a calendar. */
33export declare type DateFilterFn<D> = (date: D | null) => boolean;
34/** Base class for datepicker inputs. */
35export declare abstract class MatDatepickerInputBase<S, D = ExtractDateTypeFromSelection<S>> implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy, Validator {
36 protected _elementRef: ElementRef<HTMLInputElement>;
37 _dateAdapter: DateAdapter<D>;
38 private _dateFormats;
39 /** Whether the component has been initialized. */
40 private _isInitialized;
41 /** The value of the input. */
42 get value(): D | null;
43 set value(value: D | null);
44 protected _model: MatDateSelectionModel<S, D> | undefined;
45 /** Whether the datepicker-input is disabled. */
46 get disabled(): boolean;
47 set disabled(value: boolean);
48 private _disabled;
49 /** Emits when a `change` event is fired on this `<input>`. */
50 readonly dateChange: EventEmitter<MatDatepickerInputEvent<D, S>>;
51 /** Emits when an `input` event is fired on this `<input>`. */
52 readonly dateInput: EventEmitter<MatDatepickerInputEvent<D, S>>;
53 /** Emits when the internal state has changed */
54 readonly stateChanges: Subject<void>;
55 _onTouched: () => void;
56 _validatorOnChange: () => void;
57 private _cvaOnChange;
58 private _valueChangesSubscription;
59 private _localeSubscription;
60 /**
61 * Since the value is kept on the model which is assigned in an Input,
62 * we might get a value before we have a model. This property keeps track
63 * of the value until we have somewhere to assign it.
64 */
65 private _pendingValue;
66 /** The form control validator for whether the input parses. */
67 private _parseValidator;
68 /** The form control validator for the date filter. */
69 private _filterValidator;
70 /** The form control validator for the min date. */
71 private _minValidator;
72 /** The form control validator for the max date. */
73 private _maxValidator;
74 /** Gets the base validator functions. */
75 protected _getValidators(): ValidatorFn[];
76 /** Gets the minimum date for the input. Used for validation. */
77 abstract _getMinDate(): D | null;
78 /** Gets the maximum date for the input. Used for validation. */
79 abstract _getMaxDate(): D | null;
80 /** Gets the date filter function. Used for validation. */
81 protected abstract _getDateFilter(): DateFilterFn<D> | undefined;
82 /** Registers a date selection model with the input. */
83 _registerModel(model: MatDateSelectionModel<S, D>): void;
84 /** Opens the popup associated with the input. */
85 protected abstract _openPopup(): void;
86 /** Assigns a value to the input's model. */
87 protected abstract _assignValueToModel(model: D | null): void;
88 /** Converts a value from the model into a native value for the input. */
89 protected abstract _getValueFromModel(modelValue: S): D | null;
90 /** Combined form control validator for this input. */
91 protected abstract _validator: ValidatorFn | null;
92 /** Predicate that determines whether the input should handle a particular change event. */
93 protected abstract _shouldHandleChangeEvent(event: DateSelectionModelChange<S>): boolean;
94 /** Whether the last value set on the input was valid. */
95 protected _lastValueValid: boolean;
96 constructor(_elementRef: ElementRef<HTMLInputElement>, _dateAdapter: DateAdapter<D>, _dateFormats: MatDateFormats);
97 ngAfterViewInit(): void;
98 ngOnChanges(changes: SimpleChanges): void;
99 ngOnDestroy(): void;
100 /** @docs-private */
101 registerOnValidatorChange(fn: () => void): void;
102 /** @docs-private */
103 validate(c: AbstractControl): ValidationErrors | null;
104 writeValue(value: D): void;
105 registerOnChange(fn: (value: any) => void): void;
106 registerOnTouched(fn: () => void): void;
107 setDisabledState(isDisabled: boolean): void;
108 _onKeydown(event: KeyboardEvent): void;
109 _onInput(value: string): void;
110 _onChange(): void;
111 /** Handles blur events on the input. */
112 _onBlur(): void;
113 /** Formats a value and sets it on the input element. */
114 protected _formatValue(value: D | null): void;
115 /** Assigns a value to the model. */
116 private _assignValue;
117 /** Whether a value is considered valid. */
118 private _isValidValue;
119 /**
120 * Checks whether a parent control is disabled. This is in place so that it can be overridden
121 * by inputs extending this one which can be placed inside of a group that can be disabled.
122 */
123 protected _parentDisabled(): boolean;
124 /** Programmatically assigns a value to the input. */
125 protected _assignValueProgrammatically(value: D | null): void;
126 /** Gets whether a value matches the current date filter. */
127 _matchesFilter(value: D | null): boolean;
128 static ngAcceptInputType_value: any;
129 static ngAcceptInputType_disabled: BooleanInput;
130}
131/**
132 * Checks whether the `SimpleChanges` object from an `ngOnChanges`
133 * callback has any changes, accounting for date objects.
134 */
135export declare function dateInputsHaveChanged(changes: SimpleChanges, adapter: DateAdapter<unknown>): boolean;
Note: See TracBrowser for help on using the repository browser.