UNPKG

@angular-mdc/web

Version:
79 lines (78 loc) 3.22 kB
import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, OnDestroy, Provider } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; import { MDCSwitchFoundation } from '@material/switch'; import { MDCComponent } from '@angular-mdc/web/base'; import { MdcRipple, MDCRippleCapableSurface } from '@angular-mdc/web/ripple'; import { MdcFormField, MdcFormFieldControl } from '@angular-mdc/web/form-field'; export declare const MDC_SWITCH_CONTROL_VALUE_ACCESSOR: Provider; /** Change event object emitted by MdcSwitch. */ export declare class MdcSwitchChange { /** The source MdcSwitch of the event. */ source: MdcSwitch; /** The new `checked` value of the switch. */ checked: boolean; constructor( /** The source MdcSwitch of the event. */ source: MdcSwitch, /** The new `checked` value of the switch. */ checked: boolean); } export declare class MdcSwitch extends MDCComponent<MDCSwitchFoundation> implements MdcFormFieldControl<any>, AfterViewInit, ControlValueAccessor, OnDestroy, MDCRippleCapableSurface { private _changeDetectorRef; ripple: MdcRipple; elementRef: ElementRef<HTMLElement>; private _parentFormField; private _uniqueId; private _initialized; _root: Element; id: string; name: string | null; tabIndex: number; /** The value attribute of the native input element */ value: string | null; get checked(): boolean; set checked(value: boolean); private _checked; get disabled(): boolean; set disabled(value: boolean); private _disabled; get required(): boolean; set required(value: boolean); private _required; /** Used to set the aria-label attribute on the underlying input element. */ ariaLabel: string | null; /** Used to set the aria-labelledby attribute on the underlying input element. */ ariaLabelledby: string | null; readonly change: EventEmitter<MdcSwitchChange>; _inputElement: ElementRef<HTMLInputElement>; thumbUnderlay: ElementRef<HTMLElement>; /** View to model callback called when value changes */ private _onChange; /** View to model callback called when control has been touched */ private _onTouched; get inputId(): string; getDefaultFoundation(): any; constructor(_changeDetectorRef: ChangeDetectorRef, ripple: MdcRipple, elementRef: ElementRef<HTMLElement>, _parentFormField: MdcFormField); ngAfterViewInit(): void; ngOnDestroy(): void; _asyncBuildFoundation(): Promise<void>; onChange(evt: Event): void; onInputClick(evt: Event): void; onBlur(): void; writeValue(value: any): void; registerOnChange(fn: any): void; registerOnTouched(fn: any): void; /** Toggles the checked state of the switch. */ toggle(): void; setDisabledState(disabled: boolean): void; focus(): void; private _createRipple; /** * Emits a change event on the `change` output. Also notifies the FormControl about the change. */ private _emitChangeEvent; /** Retrieves the DOM element of the component input. */ private _getInputElement; /** Retrieves the DOM element of the component host. */ private _getHostElement; }