UNPKG

@angular-mdc/web

Version:
152 lines (151 loc) 6.48 kB
import { AfterViewInit, ChangeDetectorRef, DoCheck, ElementRef, EventEmitter, InjectionToken, OnDestroy } from '@angular/core'; import { ControlValueAccessor, FormGroupDirective, NgControl, NgForm } from '@angular/forms'; import { Platform } from '@angular/cdk/platform'; import { MDCComponent } from '@angular-mdc/web/base'; import { MdcRipple, MDCRippleCapableSurface } from '@angular-mdc/web/ripple'; import { MdcNotchedOutline } from '@angular-mdc/web/notched-outline'; import { MdcFloatingLabel } from '@angular-mdc/web/floating-label'; import { MdcMenu } from '@angular-mdc/web/menu'; import { MdcLineRipple } from '@angular-mdc/web/line-ripple'; import { MdcFormField, ErrorStateMatcher, CanUpdateErrorState, CanUpdateErrorStateCtor } from '@angular-mdc/web/form-field'; import { MdcSelectAnchor, MdcSelectIcon, MdcSelectedText } from './select-directives'; import { MDCSelectHelperText } from './select-helper-text'; import { MDCSelectFoundation } from '@material/select'; /** * Represents the default options for mdc-select that can be configured * using an `MDC_SELECT_DEFAULT_OPTIONS` injection token. */ export interface MdcSelectDefaultOptions { outlined?: boolean; } /** * Injection token that can be used to configure the default options for all * mdc-select usage within an app. */ export declare const MDC_SELECT_DEFAULT_OPTIONS: InjectionToken<MdcSelectDefaultOptions>; declare class MdcSelectBase extends MDCComponent<MDCSelectFoundation> { _elementRef: ElementRef<HTMLElement>; _defaultErrorStateMatcher: ErrorStateMatcher; _parentForm: NgForm; _parentFormGroup: FormGroupDirective; ngControl: NgControl; constructor(_elementRef: ElementRef<HTMLElement>, _defaultErrorStateMatcher: ErrorStateMatcher, _parentForm: NgForm, _parentFormGroup: FormGroupDirective, ngControl: NgControl); } declare const _MdcSelectMixinBase: CanUpdateErrorStateCtor & typeof MdcSelectBase; export declare class MdcSelectChange { source: MdcSelect; index: number; value: any; constructor(source: MdcSelect, index: number, value: any); } export declare class MdcSelect extends _MdcSelectMixinBase implements AfterViewInit, DoCheck, OnDestroy, ControlValueAccessor, CanUpdateErrorState, MDCRippleCapableSurface { private _platform; private _changeDetectorRef; elementRef: ElementRef<HTMLElement>; _defaultErrorStateMatcher: ErrorStateMatcher; private _parentFormField; private _ripple; ngControl: NgControl; private _defaults?; /** Emits whenever the component is destroyed. */ private _destroyed; private _uniqueId; private _initialized; _root: Element; id: string; name?: string; /** Placeholder to be shown if no value has been selected. */ placeholder?: string; get disabled(): boolean; set disabled(value: boolean); private _disabled; get floatLabel(): boolean; set floatLabel(value: boolean); private _floatLabel; get outlined(): boolean; set outlined(value: boolean); private _outlined; get required(): boolean; set required(value: boolean); private _required; get valid(): boolean | undefined; set valid(value: boolean | undefined); private _valid?; compareWith: (o1: any, o2: any) => boolean; /** Value of the select */ get value(): any; set value(newValue: any); private _value; get helperText(): MDCSelectHelperText | undefined; set helperText(helperText: MDCSelectHelperText | undefined); private _helperText?; get _hasPlaceholder(): boolean; /** An object used to control when error messages are shown. */ errorStateMatcher?: ErrorStateMatcher; /** Event emitted when the selected value has been changed by the user. */ readonly selectionChange: EventEmitter<MdcSelectChange>; /** * Event that emits whenever the raw value of the select changes. This is here primarily * to facilitate the two-way binding for the `value` input. */ readonly valueChange: EventEmitter<{ index: number; value: any; }>; readonly blur: EventEmitter<any>; readonly _onFocus: EventEmitter<boolean>; _floatingLabel?: MdcFloatingLabel; _lineRipple?: MdcLineRipple; _notchedOutline?: MdcNotchedOutline; _selectAnchor: MdcSelectAnchor; _selectedText: MdcSelectedText; _menu: MdcMenu; leadingIcon?: MdcSelectIcon; /** View to model callback called when value changes */ _onChange: (value: any) => void; /** View to model callback called when select has been touched */ _onTouched: () => void; getDefaultFoundation(): any; private _getSelectAdapterMethods; private _getCommonAdapterMethods; private _getOutlineAdapterMethods; private _getLabelAdapterMethods; /** Returns a map of all subcomponents to subfoundations.*/ private _getFoundationMap; constructor(_platform: Platform, _changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef<HTMLElement>, _defaultErrorStateMatcher: ErrorStateMatcher, _parentFormField: MdcFormField, _ripple: MdcRipple, ngControl: NgControl, _parentForm: NgForm, _parentFormGroup: FormGroupDirective, _defaults?: MdcSelectDefaultOptions | undefined); ngAfterViewInit(): void; ngOnDestroy(): void; /** Override MdcSelectBase destroy method */ destroy(): void; ngDoCheck(): void; writeValue(value: any): void; registerOnChange(fn: (value: any) => void): void; registerOnTouched(fn: any): void; onFocus(): void; onBlur(): void; onClick(evt: MouseEvent | TouchEvent): void; onKeydown(evt: KeyboardEvent): void; getSelectedIndex(): number; focus(): void; setSelectedIndex(index: number): void; setSelectionByValue(value: any, isUserInput?: boolean, index?: number): void; setDisabledState(disabled: boolean): void; get _hasValue(): boolean; /** Initialize Select internal state based on the environment state */ private layout; private _initializeSelection; /** Set the default options. */ private _setDefaultGlobalOptions; _asyncBuildFoundation(): Promise<void>; _asyncInitFoundation(): Promise<void>; private _selectBuilder; private _subscribeToMenuEvents; private _blur; private _getFloatingLabel; /** * Calculates where the line ripple should start based on the x coordinate within the component. */ private _getNormalizedXCoordinate; private _createRipple; } export {};