UNPKG

innotec-materials

Version:

Innotec Materials is an UI framework who's desgined for all products of Innotec GmbH. Innotec Materials is based on Angular 2 an bootstrap.

103 lines 4 kB
"use strict"; 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); }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var noop = function () { }; var CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR = { provide: forms_1.NG_VALUE_ACCESSOR, useExisting: core_1.forwardRef(function () { return InputComponent; }), multi: true }; var InputComponent = (function () { function InputComponent() { this.fieldtype = 'text'; this._value = ''; this._onTouchedCallback = noop; this._onChangeCallback = noop; this.inputlabelclass = 'empty'; } Object.defineProperty(InputComponent.prototype, "value", { get: function () { if (!this._value) { return ''; } return this._value; }, set: function (v) { if (v !== this._value) { this._value = v; this.setCssClass(); this._onChangeCallback(v); } }, enumerable: true, configurable: true }); ; InputComponent.prototype.onTouched = function () { this._onTouchedCallback(); }; InputComponent.prototype.writeValue = function (value) { this._value = value; }; InputComponent.prototype.registerOnChange = function (fn) { this._onChangeCallback = fn; }; InputComponent.prototype.registerOnTouched = function (fn) { this._onTouchedCallback = fn; }; InputComponent.prototype.setCssClass = function () { if (this.value && this.value.length > 0) { this.inputlabelclass = 'filled inputlabel'; } else { this.inputlabelclass = 'empty inputlabel'; } }; InputComponent.prototype.ngOnInit = function () { var _this = this; this.inputlabelclass = 'empty inputlabel'; if (!this.pattern) { this.pattern = '[a-zA-Z0-9\s\D]+'; } setTimeout(function () { _this.setCssClass(); }, 0); }; __decorate([ core_1.Input(), __metadata("design:type", String) ], InputComponent.prototype, "placeholder", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], InputComponent.prototype, "fieldtype", void 0); __decorate([ core_1.Input(), __metadata("design:type", Object) ], InputComponent.prototype, "pattern", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], InputComponent.prototype, "title", void 0); InputComponent = __decorate([ core_1.Component({ selector: 'md-input', template: "\n <div class=\"container\"><input class=\"input_field\" [type]=\"fieldtype\" [pattern]=\"pattern\" [title]=\"title\" placeholder=\" \" [(ngModel)]=\"value\"/><label [class]=\"inputlabelclass\" for=\"inputfield\">{{ placeholder }}</label></div>\n ", providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR] }), __metadata("design:paramtypes", []) ], InputComponent); return InputComponent; }()); exports.InputComponent = InputComponent; //# sourceMappingURL=input.component.js.map