UNPKG

@angular-mdc/web

Version:
78 lines (77 loc) 3.38 kB
import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, QueryList } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; import { MdcRadio, MdcRadioChange } from './radio'; /** * Provider Expression that allows mdc-radio-group to register as a ControlValueAccessor. This * allows it to support [(ngModel)] and ngControl. */ export declare const MDC_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any; export declare class MdcRadioGroup implements AfterContentInit, ControlValueAccessor { private _changeDetectorRef; elementRef: ElementRef<HTMLElement>; private _name; /** Selected value for the radio group. */ private _value; /** Whether the `value` has been set to its initial value. */ private _isInitialized; _radios: QueryList<MdcRadio>; /** Name of the radio button group. All radio buttons inside this group will use this name. */ get name(): string; set name(value: string); /** * Value for the radio-group. Should equal the value of the selected radio button if there is * a corresponding radio button with a matching value. If there is not such a corresponding * radio button, this value persists to be applied in case a new radio button is added with a * matching value. */ get value(): any; set value(newValue: any); /** * The currently selected radio button. If set to a new radio button, the radio group value * will be updated to match the new selected button. */ get selected(): MdcRadio | null; set selected(selected: MdcRadio | null); private _selected; get required(): boolean; set required(value: boolean); private _required; get disabled(): boolean; set disabled(value: boolean); private _disabled; _checkSelectedRadioButton(): void; /** The method to be called in order to update ngModel */ _controlValueAccessorChangeFn: (value: any) => void; /** onTouch function registered via registerOnTouch (ControlValueAccessor). */ onTouched: () => any; readonly change: EventEmitter<MdcRadioChange>; constructor(_changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef<HTMLElement>); ngAfterContentInit(): void; _touch(): void; private _updateRadioButtonNames; /** Updates the `selected` radio button from the internal _value state. */ private _updateSelectedRadioFromValue; private _markRadiosForCheck; private _updateDisableRadioState; /** Sets the model value. Implemented as part of ControlValueAccessor. */ writeValue(value: any): void; /** * Registers a callback to be triggered when the model value changes. * Implemented as part of ControlValueAccessor. * @param fn Callback to be registered. */ registerOnChange(fn: (value: any) => void): void; /** * Registers a callback to be triggered when the control is touched. * Implemented as part of ControlValueAccessor. * @param fn Callback to be registered. */ registerOnTouched(fn: any): void; /** * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor. * @param isDisabled Whether the control should be disabled. */ setDisabledState(isDisabled: boolean): void; /** Dispatch change event with current selection and group value. */ emitChangeEvent(): void; }