UNPKG

5.1 kBTypeScriptView Raw
1import { AfterContentInit, EventEmitter, OnInit, QueryList, ModuleWithProviders } from '@angular/core';
2import { ControlValueAccessor } from '@angular/forms';
3import { MdUniqueSelectionDispatcher } from '@angular2-material/core';
4export { MdUniqueSelectionDispatcher } from '@angular2-material/core';
5/**
6 * Provider Expression that allows md-radio-group to register as a ControlValueAccessor. This
7 * allows it to support [(ngModel)] and ngControl.
8 */
9export declare const MD_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any;
10/** A simple change event emitted by either MdRadioButton or MdRadioGroup. */
11export declare class MdRadioChange {
12 source: MdRadioButton;
13 value: any;
14}
15export declare class MdRadioGroup implements AfterContentInit, ControlValueAccessor {
16 /**
17 * Selected value for group. Should equal the value of the selected radio button if there *is*
18 * a corresponding radio button with a matching value. If there is *not* such a corresponding
19 * radio button, this value persists to be applied in case a new radio button is added with a
20 * matching value.
21 */
22 private _value;
23 /** The HTML name attribute applied to radio buttons in this group. */
24 private _name;
25 /** Disables all individual radio buttons assigned to this group. */
26 private _disabled;
27 /** The currently selected radio button. Should match value. */
28 private _selected;
29 /** Whether the `value` has been set to its initial value. */
30 private _isInitialized;
31 /** The method to be called in order to update ngModel */
32 private _controlValueAccessorChangeFn;
33 /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
34 onTouched: () => any;
35 /** Event emitted when the group value changes. */
36 change: EventEmitter<MdRadioChange>;
37 /** Child radio buttons. */
38 _radios: QueryList<MdRadioButton>;
39 name: string;
40 align: 'start' | 'end';
41 disabled: boolean;
42 value: any;
43 selected: MdRadioButton;
44 /**
45 * Initialize properties once content children are available.
46 * This allows us to propagate relevant attributes to associated buttons.
47 * TODO: internal
48 */
49 ngAfterContentInit(): void;
50 /**
51 * Mark this group as being "touched" (for ngModel). Meant to be called by the contained
52 * radio buttons upon their blur.
53 */
54 _touch(): void;
55 private _updateRadioButtonNames();
56 /** Updates the `selected` radio button from the internal _value state. */
57 private _updateSelectedRadioFromValue();
58 /** Dispatch change event with current selection and group value. */
59 private _emitChangeEvent();
60 /**
61 * Implemented as part of ControlValueAccessor.
62 * TODO: internal
63 */
64 writeValue(value: any): void;
65 /**
66 * Implemented as part of ControlValueAccessor.
67 * TODO: internal
68 */
69 registerOnChange(fn: (value: any) => void): void;
70 /**
71 * Implemented as part of ControlValueAccessor.
72 * TODO: internal
73 */
74 registerOnTouched(fn: any): void;
75}
76export declare class MdRadioButton implements OnInit {
77 radioDispatcher: MdUniqueSelectionDispatcher;
78 _isFocused: boolean;
79 /** Whether this radio is checked. */
80 private _checked;
81 /** The unique ID for the radio button. */
82 id: string;
83 /** Analog to HTML 'name' attribute used to group radios for unique selection. */
84 name: string;
85 /** Used to set the 'aria-label' attribute on the underlying input element. */
86 ariaLabel: string;
87 /** The 'aria-labelledby' attribute takes precedence as the element's text alternative. */
88 ariaLabelledby: string;
89 /** Whether this radio is disabled. */
90 private _disabled;
91 /** Value assigned to this radio.*/
92 private _value;
93 /** The parent radio group. May or may not be present. */
94 radioGroup: MdRadioGroup;
95 /** Event emitted when the group value changes. */
96 change: EventEmitter<MdRadioChange>;
97 constructor(radioGroup: MdRadioGroup, radioDispatcher: MdUniqueSelectionDispatcher);
98 readonly inputId: string;
99 checked: boolean;
100 /** MdRadioGroup reads this to assign its own value. */
101 value: any;
102 private _align;
103 align: 'start' | 'end';
104 disabled: boolean;
105 /** TODO: internal */
106 ngOnInit(): void;
107 /** Dispatch change event with current value. */
108 private _emitChangeEvent();
109 /**
110 * We use a hidden native input field to handle changes to focus state via keyboard navigation,
111 * with visual rendering done separately. The native element is kept in sync with the overall
112 * state of the component.
113 */
114 _onInputFocus(): void;
115 /** TODO: internal */
116 _onInputBlur(): void;
117 /** TODO: internal */
118 _onInputClick(event: Event): void;
119 /**
120 * Triggered when the radio button received a click or the input recognized any change.
121 * Clicking on a label element, will trigger a change event on the associated input.
122 * TODO: internal
123 */
124 _onInputChange(event: Event): void;
125}
126export declare class MdRadioModule {
127 static forRoot(): ModuleWithProviders;
128}