1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms')) :
|
3 | typeof define === 'function' && define.amd ? define('primeng/radiobutton', ['exports', '@angular/core', '@angular/common', '@angular/forms'], factory) :
|
4 | (global = global || self, factory((global.primeng = global.primeng || {}, global.primeng.radiobutton = {}), global.ng.core, global.ng.common, global.ng.forms));
|
5 | }(this, (function (exports, core, common, forms) { 'use strict';
|
6 |
|
7 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
8 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
9 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
10 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
11 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
12 | };
|
13 | var RADIO_VALUE_ACCESSOR = {
|
14 | provide: forms.NG_VALUE_ACCESSOR,
|
15 | useExisting: core.forwardRef(function () { return RadioButton; }),
|
16 | multi: true
|
17 | };
|
18 | var RadioButton = (function () {
|
19 | function RadioButton(cd) {
|
20 | this.cd = cd;
|
21 | this.onClick = new core.EventEmitter();
|
22 | this.onFocus = new core.EventEmitter();
|
23 | this.onBlur = new core.EventEmitter();
|
24 | this.onModelChange = function () { };
|
25 | this.onModelTouched = function () { };
|
26 | }
|
27 | RadioButton.prototype.handleClick = function (event, radioButton, focus) {
|
28 | event.preventDefault();
|
29 | if (this.disabled) {
|
30 | return;
|
31 | }
|
32 | this.select(event);
|
33 | if (focus) {
|
34 | radioButton.focus();
|
35 | }
|
36 | };
|
37 | RadioButton.prototype.select = function (event) {
|
38 | if (!this.disabled) {
|
39 | this.inputViewChild.nativeElement.checked = true;
|
40 | this.checked = true;
|
41 | this.onModelChange(this.value);
|
42 | this.onClick.emit(event);
|
43 | }
|
44 | };
|
45 | RadioButton.prototype.writeValue = function (value) {
|
46 | this.checked = (value == this.value);
|
47 | if (this.inputViewChild && this.inputViewChild.nativeElement) {
|
48 | this.inputViewChild.nativeElement.checked = this.checked;
|
49 | }
|
50 | this.cd.markForCheck();
|
51 | };
|
52 | RadioButton.prototype.registerOnChange = function (fn) {
|
53 | this.onModelChange = fn;
|
54 | };
|
55 | RadioButton.prototype.registerOnTouched = function (fn) {
|
56 | this.onModelTouched = fn;
|
57 | };
|
58 | RadioButton.prototype.setDisabledState = function (val) {
|
59 | this.disabled = val;
|
60 | };
|
61 | RadioButton.prototype.onInputFocus = function (event) {
|
62 | this.focused = true;
|
63 | this.onFocus.emit(event);
|
64 | };
|
65 | RadioButton.prototype.onInputBlur = function (event) {
|
66 | this.focused = false;
|
67 | this.onModelTouched();
|
68 | this.onBlur.emit(event);
|
69 | };
|
70 | RadioButton.prototype.onChange = function (event) {
|
71 | this.select(event);
|
72 | };
|
73 | RadioButton.prototype.focus = function () {
|
74 | this.inputViewChild.nativeElement.focus();
|
75 | };
|
76 | RadioButton.ctorParameters = function () { return [
|
77 | { type: core.ChangeDetectorRef }
|
78 | ]; };
|
79 | __decorate([
|
80 | core.Input()
|
81 | ], RadioButton.prototype, "value", void 0);
|
82 | __decorate([
|
83 | core.Input()
|
84 | ], RadioButton.prototype, "name", void 0);
|
85 | __decorate([
|
86 | core.Input()
|
87 | ], RadioButton.prototype, "disabled", void 0);
|
88 | __decorate([
|
89 | core.Input()
|
90 | ], RadioButton.prototype, "label", void 0);
|
91 | __decorate([
|
92 | core.Input()
|
93 | ], RadioButton.prototype, "tabindex", void 0);
|
94 | __decorate([
|
95 | core.Input()
|
96 | ], RadioButton.prototype, "inputId", void 0);
|
97 | __decorate([
|
98 | core.Input()
|
99 | ], RadioButton.prototype, "ariaLabelledBy", void 0);
|
100 | __decorate([
|
101 | core.Input()
|
102 | ], RadioButton.prototype, "style", void 0);
|
103 | __decorate([
|
104 | core.Input()
|
105 | ], RadioButton.prototype, "styleClass", void 0);
|
106 | __decorate([
|
107 | core.Input()
|
108 | ], RadioButton.prototype, "labelStyleClass", void 0);
|
109 | __decorate([
|
110 | core.Output()
|
111 | ], RadioButton.prototype, "onClick", void 0);
|
112 | __decorate([
|
113 | core.Output()
|
114 | ], RadioButton.prototype, "onFocus", void 0);
|
115 | __decorate([
|
116 | core.Output()
|
117 | ], RadioButton.prototype, "onBlur", void 0);
|
118 | __decorate([
|
119 | core.ViewChild('rb')
|
120 | ], RadioButton.prototype, "inputViewChild", void 0);
|
121 | RadioButton = __decorate([
|
122 | core.Component({
|
123 | selector: 'p-radioButton',
|
124 | template: "\n <div [ngStyle]=\"style\" [ngClass]=\"'ui-radiobutton ui-widget'\" [class]=\"styleClass\">\n <div class=\"ui-helper-hidden-accessible\">\n <input #rb type=\"radio\" [attr.id]=\"inputId\" [attr.name]=\"name\" [attr.value]=\"value\" [attr.tabindex]=\"tabindex\" [attr.aria-labelledby]=\"ariaLabelledBy\"\n [checked]=\"checked\" (change)=\"onChange($event)\" (focus)=\"onInputFocus($event)\" (blur)=\"onInputBlur($event)\" [disabled]=\"disabled\">\n </div>\n <div (click)=\"handleClick($event, rb, true)\" role=\"radio\" [attr.aria-checked]=\"checked\"\n [ngClass]=\"{'ui-radiobutton-box ui-widget ui-state-default':true,\n 'ui-state-active':rb.checked,'ui-state-disabled':disabled,'ui-state-focus':focused}\">\n <span class=\"ui-radiobutton-icon ui-clickable\" [ngClass]=\"{'pi pi-circle-on':rb.checked}\"></span>\n </div>\n </div>\n <label (click)=\"select($event)\" [class]=\"labelStyleClass\"\n [ngClass]=\"{'ui-radiobutton-label':true, 'ui-label-active':rb.checked, 'ui-label-disabled':disabled, 'ui-label-focus':focused}\"\n *ngIf=\"label\" [attr.for]=\"inputId\">{{label}}</label>\n ",
|
125 | providers: [RADIO_VALUE_ACCESSOR],
|
126 | changeDetection: core.ChangeDetectionStrategy.Default
|
127 | })
|
128 | ], RadioButton);
|
129 | return RadioButton;
|
130 | }());
|
131 | var RadioButtonModule = (function () {
|
132 | function RadioButtonModule() {
|
133 | }
|
134 | RadioButtonModule = __decorate([
|
135 | core.NgModule({
|
136 | imports: [common.CommonModule],
|
137 | exports: [RadioButton],
|
138 | declarations: [RadioButton]
|
139 | })
|
140 | ], RadioButtonModule);
|
141 | return RadioButtonModule;
|
142 | }());
|
143 |
|
144 | exports.RADIO_VALUE_ACCESSOR = RADIO_VALUE_ACCESSOR;
|
145 | exports.RadioButton = RadioButton;
|
146 | exports.RadioButtonModule = RadioButtonModule;
|
147 |
|
148 | Object.defineProperty(exports, '__esModule', { value: true });
|
149 |
|
150 | })));
|
151 |
|