@dhutaryan/ngx-mat-timepicker
Version:
Angular timepicker to add time which is based on material design and Angular material.
94 lines (93 loc) • 4.46 kB
TypeScript
import { AfterContentInit, AfterViewChecked, EventEmitter } from '@angular/core';
import { ThemePalette } from '@angular/material/core';
import { TimeAdapter } from './adapter';
import { MatTimePeriodType } from './time-period';
import * as i0 from "@angular/core";
export declare abstract class MatTimeFaceBase<T> implements AfterContentInit, AfterViewChecked {
protected _timeAdapter: TimeAdapter<T>;
/** The currently selected time. */
get selected(): T | null;
set selected(value: T | null);
private _selected;
/** The minimum selectable time. */
get minTime(): T | null;
set minTime(value: T | null);
private _minTime;
/** The maximum selectable time. */
get maxTime(): T | null;
set maxTime(value: T | null);
private _maxTime;
/** Step over minutes. */
get minuteInterval(): number;
set minuteInterval(value: number);
private _minuteInterval;
/** Whether the clock uses 12 hour format. */
isMeridiem: boolean;
/** Color palette. */
color: ThemePalette;
/** Emits when any hour, minute or period is selected. */
_userSelection: EventEmitter<T>;
selectedChange: EventEmitter<T>;
selectedHour: number;
selectedMinute: number;
period: MatTimePeriodType;
disabledPeriod: MatTimePeriodType | null;
availableMinutes: number[];
availableHours: number[];
/**
* Used for scheduling that focus should be moved to the active cell on the next tick.
* We need to schedule it, rather than do it immediately, because we have to wait
* for Angular to re-evaluate the view children.
*/
private _moveFocusOnNextTick;
constructor(_timeAdapter: TimeAdapter<T>);
ngAfterContentInit(): void;
ngAfterViewChecked(): void;
/**
* Focuses the active cell after or input the microtask queue is empty.
*
* Adding a 0ms setTimeout seems to fix Voiceover losing focus when pressing PageUp/PageDown.
*
* Determined a 0ms by gradually increasing duration from 0 and testing two use cases with screen
* reader enabled:
*
* 1. Pressing PageUp/PageDown repeatedly with pausing between each key press.
* 2. Pressing and holding the PageDown key with repeated keys enabled.
*
* Test 1 worked roughly 95-99% of the time with 0ms and got a little bit better as the duration
* increased. Test 2 got slightly better until the duration was long enough to interfere with
* repeated keys. If the repeated key speed was faster than the timeout duration, then pressing
* and holding pagedown caused the entire page to scroll.
*
* Since repeated key speed can verify across machines, determined that any duration could
* potentially interfere with repeated keys. 0ms would be best because it almost entirely
* eliminates the focus being lost in Voiceover without causing unintended side effects.
* Adding delay also complicates writing tests.
*/
abstract focusActiveCell(): void;
/** Handles hour selection. */
_onHourSelected(hour: number): void;
/** Handles minute selection. */
_onMinuteSelected(minute: number): void;
/** Handles period changing. */
_onPeriodChanged(period: MatTimePeriodType): void;
_getAvailableHours(): number[];
_onKeydown(event: KeyboardEvent, view: 'hour' | 'minute'): void;
private _handleHourKeydown;
private _handleMinuteKeydown;
/** Gets a correct hours based on meridiem and period. */
private _getHourBasedOnPeriod;
private _timeSelected;
/** Sets min hour. */
private _setMinHour;
/** Sets max hour. */
private _setMaxHour;
/** Sets min minute. */
private _setMinMinute;
/** Sets max minute. */
private _setMaxMinute;
/** Sets disabled period. */
private _setDisabledPeriod;
static ɵfac: i0.ɵɵFactoryDeclaration<MatTimeFaceBase<any>, [{ optional: true; }]>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MatTimeFaceBase<any>, never, never, { "selected": { "alias": "selected"; "required": false; }; "minTime": { "alias": "minTime"; "required": false; }; "maxTime": { "alias": "maxTime"; "required": false; }; "minuteInterval": { "alias": "minuteInterval"; "required": false; }; "isMeridiem": { "alias": "isMeridiem"; "required": false; }; "color": { "alias": "color"; "required": false; }; }, { "_userSelection": "_userSelection"; "selectedChange": "selectedChange"; }, never, never, true, never>;
}