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OnInit,\n Optional,\n Output,\n QueryList,\n ViewEncapsulation,\n forwardRef,\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\nimport {\n NG_VALUE_ACCESSOR,\n ControlValueAccessor\n} from '@angular/forms';\nimport {MdUniqueSelectionDispatcher} from '@angular2-material/core';\n\n\n// Re-exports.\nexport {MdUniqueSelectionDispatcher} from '@angular2-material/core';\n\n\n\n/**\n * Provider Expression that allows md-radio-group to register as a ControlValueAccessor. This\n * allows it to support [(ngModel)] and ngControl.\n */\nexport const MD_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => MdRadioGroup),\n multi: true\n};\n\n// TODO(mtlin):\n// Ink ripple is currently placeholder.\n// Determine motion spec for button transitions.\n// Design review.\n// RTL\n// Support forms API.\n// Use ChangeDetectionStrategy.OnPush\n\nvar _uniqueIdCounter = 0;\n\n/** A simple change event emitted by either MdRadioButton or MdRadioGroup. */\nexport class MdRadioChange {\n source: MdRadioButton;\n value: any;\n}\n\n@Directive({\n selector: 'md-radio-group',\n providers: [MD_RADIO_GROUP_CONTROL_VALUE_ACCESSOR],\n host: {\n 'role': 'radiogroup',\n },\n})\nexport class MdRadioGroup implements AfterContentInit, ControlValueAccessor {\n /**\n * Selected value for group. Should equal the value of the selected radio button if there *is*\n * a corresponding radio button with a matching value. If there is *not* such a corresponding\n * radio button, this value persists to be applied in case a new radio button is added with a\n * matching value.\n */\n private _value: any = null;\n\n /** The HTML name attribute applied to radio buttons in this group. */\n private _name: string = `md-radio-group-${_uniqueIdCounter++}`;\n\n /** Disables all individual radio buttons assigned to this group. */\n private _disabled: boolean = false;\n\n /** The currently selected radio button. Should match value. */\n private _selected: MdRadioButton = null;\n\n /** Whether the `value` has been set to its initial value. */\n private _isInitialized: boolean = false;\n\n /** The method to be called in order to update ngModel */\n private _controlValueAccessorChangeFn: (value: any) => void = (value) => {};\n\n /** onTouch function registered via registerOnTouch (ControlValueAccessor). */\n onTouched: () => any = () => {};\n\n /** Event emitted when the group value changes. */\n @Output()\n change: EventEmitter<MdRadioChange> = new EventEmitter<MdRadioChange>();\n\n /** Child radio buttons. */\n @ContentChildren(forwardRef(() => MdRadioButton))\n _radios: QueryList<MdRadioButton> = null;\n\n @Input()\n get name(): string {\n return this._name;\n }\n\n set name(value: string) {\n this._name = value;\n this._updateRadioButtonNames();\n }\n\n @Input() align: 'start' | 'end';\n\n @Input()\n get disabled(): boolean {\n return this._disabled;\n }\n\n set disabled(value) {\n // The presence of *any* disabled value makes the component disabled, *except* for false.\n this._disabled = (value != null && value !== false) ? true : null;\n }\n\n @Input()\n get value(): any {\n return this._value;\n }\n\n set value(newValue: any) {\n if (this._value != newValue) {\n // Set this before proceeding to ensure no circular loop occurs with selection.\n this._value = newValue;\n\n this._updateSelectedRadioFromValue();\n\n // Only fire a change event if this isn't the first time the value is ever set.\n if (this._isInitialized) {\n this._emitChangeEvent();\n }\n }\n }\n\n @Input()\n get selected() {\n return this._selected;\n }\n\n set selected(selected: MdRadioButton) {\n this._selected = selected;\n this.value = selected ? selected.value : null;\n\n if (selected && !selected.checked) {\n selected.checked = true;\n }\n }\n\n /**\n * Initialize properties once content children are available.\n * This allows us to propagate relevant attributes to associated buttons.\n * TODO: internal\n */\n ngAfterContentInit() {\n // Mark this component as initialized in AfterContentInit because the initial value can\n // possibly be set by NgModel on MdRadioGroup, and it is possible that the OnInit of the\n // NgModel occurs *after* the OnInit of the MdRadioGroup.\n this._isInitialized = true;\n }\n\n /**\n * Mark this group as being \"touched\" (for ngModel). Meant to be called by the contained\n * radio buttons upon their blur.\n */\n _touch() {\n if (this.onTouched) {\n this.onTouched();\n }\n }\n\n private _updateRadioButtonNames(): void {\n if (this._radios) {\n this._radios.forEach(radio => {\n radio.name = this.name;\n });\n }\n }\n\n /** Updates the `selected` radio button from the internal _value state. */\n private _updateSelectedRadioFromValue(): void {\n // If the value already matches the selected radio, do nothing.\n let isAlreadySelected = this._selected != null && this._selected.value == this._value;\n\n if (this._radios != null && !isAlreadySelected) {\n let matchingRadio = this._radios.filter(radio => radio.value == this._value)[0];\n\n if (matchingRadio) {\n this.selected = matchingRadio;\n } else if (this.value == null) {\n this.selected = null;\n this._radios.forEach(radio => { radio.checked = false; });\n }\n }\n }\n\n /** Dispatch change event with current selection and group value. */\n private _emitChangeEvent(): void {\n let event = new MdRadioChange();\n event.source = this._selected;\n event.value = this._value;\n this._controlValueAccessorChangeFn(event.value);\n this.change.emit(event);\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n * TODO: internal\n */\n writeValue(value: any) {\n this.value = value;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n * TODO: internal\n */\n registerOnChange(fn: (value: any) => void) {\n this._controlValueAccessorChangeFn = fn;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n * TODO: internal\n */\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n}\n\n\n@Component({\n moduleId: module.id,\n selector: 'md-radio-button',\n templateUrl: 'radio.html',\n styleUrls: ['radio.css'],\n encapsulation: ViewEncapsulation.None\n})\nexport class MdRadioButton implements OnInit {\n\n @HostBinding('class.md-radio-focused')\n _isFocused: boolean;\n\n /** Whether this radio is checked. */\n private _checked: boolean = false;\n\n /** The unique ID for the radio button. */\n @HostBinding('id')\n @Input()\n id: string = `md-radio-${_uniqueIdCounter++}`;\n\n /** Analog to HTML 'name' attribute used to group radios for unique selection. */\n @Input()\n name: string;\n\n /** Used to set the 'aria-label' attribute on the underlying input element. */\n @Input('aria-label') ariaLabel: string;\n\n /** The 'aria-labelledby' attribute takes precedence as the element's text alternative. */\n @Input('aria-labelledby') ariaLabelledby: string;\n\n /** Whether this radio is disabled. */\n private _disabled: boolean;\n\n /** Value assigned to this radio.*/\n private _value: any = null;\n\n /** The parent radio group. May or may not be present. */\n radioGroup: MdRadioGroup;\n\n /** Event emitted when the group value changes. */\n @Output()\n change: EventEmitter<MdRadioChange> = new EventEmitter<MdRadioChange>();\n\n constructor(@Optional() radioGroup: MdRadioGroup,\n public radioDispatcher: MdUniqueSelectionDispatcher) {\n // Assertions. Ideally these should be stripped out by the compiler.\n // TODO(jelbourn): Assert that there's no name binding AND a parent radio group.\n\n this.radioGroup = radioGroup;\n\n radioDispatcher.listen((id: string, name: string) => {\n if (id != this.id && name == this.name) {\n this.checked = false;\n }\n });\n }\n\n get inputId(): string {\n return `${this.id}-input`;\n }\n\n @HostBinding('class.md-radio-checked')\n @Input()\n get checked(): boolean {\n return this._checked;\n }\n\n set checked(newCheckedState: boolean) {\n if (newCheckedState) {\n // Notify all radio buttons with the same name to un-check.\n this.radioDispatcher.notify(this.id, this.name);\n }\n\n this._checked = newCheckedState;\n\n if (newCheckedState && this.radioGroup && this.radioGroup.value != this.value) {\n this.radioGroup.selected = this;\n }\n }\n\n /** MdRadioGroup reads this to assign its own value. */\n @Input()\n get value(): any {\n return this._value;\n }\n\n set value(value: any) {\n if (this._value != value) {\n if (this.radioGroup != null && this.checked) {\n this.radioGroup.value = value;\n }\n this._value = value;\n }\n }\n\n private _align: 'start' | 'end';\n\n @Input()\n get align(): 'start' | 'end' {\n return this._align || (this.radioGroup != null && this.radioGroup.align) || 'start';\n }\n\n set align(value: 'start' | 'end') {\n this._align = value;\n }\n\n @HostBinding('class.md-radio-disabled')\n @Input()\n get disabled(): boolean {\n return this._disabled || (this.radioGroup != null && this.radioGroup.disabled);\n }\n\n set disabled(value: boolean) {\n // The presence of *any* disabled value makes the component disabled, *except* for false.\n this._disabled = (value != null && value !== false) ? true : null;\n }\n\n /** TODO: internal */\n ngOnInit() {\n if (this.radioGroup) {\n // If the radio is inside a radio group, determine if it should be checked\n this.checked = this.radioGroup.value === this._value;\n // Copy name from parent radio group\n this.name = this.radioGroup.name;\n }\n }\n\n /** Dispatch change event with current value. */\n private _emitChangeEvent(): void {\n let event = new MdRadioChange();\n event.source = this;\n event.value = this._value;\n this.change.emit(event);\n }\n\n /**\n * We use a hidden native input field to handle changes to focus state via keyboard navigation,\n * with visual rendering done separately. The native element is kept in sync with the overall\n * state of the component.\n */\n _onInputFocus() {\n this._isFocused = true;\n }\n\n /** TODO: internal */\n _onInputBlur() {\n this._isFocused = false;\n\n if (this.radioGroup) {\n this.radioGroup._touch();\n }\n }\n\n /** TODO: internal */\n _onInputClick(event: Event) {\n // We have to stop propagation for click events on the visual hidden input element.\n // By default, when a user clicks on a label element, a generated click event will be\n // dispatched on the associated input element. Since we are using a label element as our\n // root container, the click event on the `radio-button` will be executed twice.\n // The real click event will bubble up, and the generated click event also tries to bubble up.\n // This will lead to multiple click events.\n // Preventing bubbling for the second event will solve that issue.\n event.stopPropagation();\n }\n\n /**\n * Triggered when the radio button received a click or the input recognized any change.\n * Clicking on a label element, will trigger a change event on the associated input.\n * TODO: internal\n */\n _onInputChange(event: Event) {\n // We always have to stop propagation on the change event.\n // Otherwise the change event, from the input element, will bubble up and\n // emit its event object to the `change` output.\n event.stopPropagation();\n\n this.checked = true;\n this._emitChangeEvent();\n\n if (this.radioGroup) {\n this.radioGroup._touch();\n }\n }\n}\n\n\n@NgModule({\n exports: [MdRadioGroup, MdRadioButton],\n declarations: [MdRadioGroup, MdRadioButton],\n})\nexport class MdRadioModule {\n static forRoot(): ModuleWithProviders {\n return {\n ngModule: MdRadioModule,\n providers: [MdUniqueSelectionDispatcher],\n };\n }\n}\n"],"sourceRoot":"/source/"}
\No newline at end of file