import ngModule from '../../module'; import Input from '../../lib/input'; import './style.scss'; export default class Textfield extends Input { constructor($element, $scope, $attrs, vnTemplate) { super($element, $scope); vnTemplate.normalizeInputAttrs($attrs); this._value = null; this.type = $attrs.type || 'text'; this.showActions = false; this.hasInfo = Boolean($attrs.info); this.info = $attrs.info || null; this.hasFocus = false; this.hasMouseIn = false; componentHandler.upgradeElement($element[0].firstChild); } get value() { return this._value; } set value(value) { this._value = (value === undefined || value === '') ? null : value; this.input.value = this._value; this.hasValue = Boolean(this._value); this.mdlUpdate(); } set vnTabIndex(value) { this.input.tabindex = value; } clear() { this.value = null; this.input.focus(); } mdlUpdate() { let mdlElement = this.element.firstChild.MaterialTextfield; if (mdlElement) mdlElement.updateClasses_(); } } Textfield.$inject = ['$element', '$scope', '$attrs', 'vnTemplate']; ngModule.component('vnTextfield', { template: require('./textfield.html'), controller: Textfield, bindings: { value: '=model', label: '@?', name: '@?', disabled: '