UNPKG

bia-framework

Version:

Bia Framework to work with angular 2

126 lines 5.77 kB
"use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var core_1 = require("@angular/core"); var common_1 = require("@angular/common"); var RippleEffect_1 = require("../ripple-effect/RippleEffect"); var CoreControlFormBase_1 = require("../odisseia-form/CoreControlFormBase"); var odisseia_form_1 = require("../odisseia-form/odisseia-form"); var objectOrArrayPipe_1 = require("../../pipes/objectOrArrayPipe"); var core_icon_1 = require("../core-icon/core-icon"); var CoreRadioButton = (function (_super) { __extends(CoreRadioButton, _super); function CoreRadioButton(hostForm) { var _this = this; _super.call(this, hostForm); this.hostForm = hostForm; this.bindChange = new core_1.EventEmitter(); this.onSelect = function (item, index) { var newValue = null; if (_this.selectedValuePath) newValue = _this.source[index][_this.selectedValuePath]; else newValue = _this.source[index]; _this.rippleEffect.toArray()[index].showEffect(null); if (_this.isInForm() && _this.control != null) _this.control.updateValue(newValue); }; this.getIndexFromBind = function () { if (_this.bind != null && _this.source != null) { if (_this.selectedValuePath != null) { var i = null; _this.source.forEach(function (item, index) { if (item[_this.selectedValuePath] != null && item[_this.selectedValuePath] == _this.bind) i = index; }); return i; } else { var e = null; _this.source.forEach(function (item, index) { if (item == _this.bind) e = index; }); return e; } } return null; }; } Object.defineProperty(CoreRadioButton.prototype, "bind", { get: function () { return this._bind; }, set: function (value) { this._bind = value; this.bindChange.emit(value); this.selectedIndex = this.getIndexFromBind(); }, enumerable: true, configurable: true }); CoreRadioButton.prototype.ngOnInit = function () { this.selectedIndex = this.getIndexFromBind(); return undefined; }; __decorate([ core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object]) ], CoreRadioButton.prototype, "bind", null); __decorate([ core_1.Output(), __metadata('design:type', Object) ], CoreRadioButton.prototype, "bindChange", void 0); __decorate([ core_1.Input(), __metadata('design:type', Array) ], CoreRadioButton.prototype, "source", void 0); __decorate([ core_1.Input("selected-value-path"), __metadata('design:type', String) ], CoreRadioButton.prototype, "selectedValuePath", void 0); __decorate([ core_1.Input("show-value-path"), __metadata('design:type', String) ], CoreRadioButton.prototype, "showValuePath", void 0); __decorate([ core_1.Input(), __metadata('design:type', String) ], CoreRadioButton.prototype, "color", void 0); __decorate([ core_1.ViewChildren(RippleEffect_1.RippleEffect), __metadata('design:type', core_1.QueryList) ], CoreRadioButton.prototype, "rippleEffect", void 0); CoreRadioButton = __decorate([ core_1.Component({ selector: 'core-radio-button', pipes: [objectOrArrayPipe_1.ObjectOrArrayPipe], encapsulation: core_1.ViewEncapsulation.None, templateUrl: "node_modules/bia-framework/components/core-radio-button/core-radio-button.template.html", styleUrls: ["node_modules/bia-framework/components/core-radio-button/core-radio-button.style.css"], directives: [core_icon_1.CoreIcon, RippleEffect_1.RippleEffect, common_1.NgFor] }), __param(0, core_1.Optional()), __param(0, core_1.Host()), __metadata('design:paramtypes', [odisseia_form_1.CoreForm]) ], CoreRadioButton); return CoreRadioButton; }(CoreControlFormBase_1.CoreControlFormBase)); exports.CoreRadioButton = CoreRadioButton; //# sourceMappingURL=core-radio-button.js.map