@darkobits/formation
Version:
59 lines (48 loc) • 3.18 kB
JavaScript
;
var _config = require('../../etc/config');
var _constants = require('../../etc/constants');
var _FormationControl2 = require('../../classes/FormationControl');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // -----------------------------------------------------------------------------
// ----- Textarea Component ----------------------------------------------------
// -----------------------------------------------------------------------------
/**
* This component creates a textarea control and a label. The label is
* transcluded.
*
* Implements the following bindings:
* - `config`: Configuration object.
* - `name`: Name of the control.
* - `placeholder`: Control placeholder, implemented as a null option.
* - `ng-disabled`: If truthy, will disable the control.
*
* @module Textarea
*
* @example
*
* <my-form name="myForm">
* <my-textarea name="myTextarea"
* config="vm.myTextareaConfig">
* Enter some text:
* </my-textarea>
* </my-form>
*/
var TextareaControl = function (_FormationControl) {
_inherits(TextareaControl, _FormationControl);
function TextareaControl() {
_classCallCheck(this, TextareaControl);
return _possibleConstructorReturn(this, (TextareaControl.__proto__ || Object.getPrototypeOf(TextareaControl)).apply(this, arguments));
}
return TextareaControl;
}(_FormationControl2.FormationControl);
(0, _config.registerControl)('Textarea', {
bindings: {
name: '@',
placeholder: '@'
},
transclude: true,
controller: TextareaControl,
controllerAs: 'Textarea',
template: '\n <label for="{{::Textarea.getControlId() }}"\n ng-class="{\n \'has-error\': Input.getErrors(),\n \'is-pending\': Input.' + _constants.NG_MODEL_CTRL + '.$pending,\n \'is-disabled\': Textarea.isDisabled()\n }"\n ng-transclude>\n </label>\n <textarea id="{{::Textarea.getControlId() }}"\n type="{{::Textarea.type }}"\n name="{{::Textarea.name }}"\n placeholder="{{::Textarea.placeholder }}"\n ng-model="Textarea.$ngModelGetterSetter"\n ng-class="{\n \'has-error\': Textarea.getErrors(),\n \'is-pending\': Textarea.' + _constants.NG_MODEL_CTRL + '.$pending,\n \'is-disabled\': Textarea.isDisabled()\n }"\n ng-disabled="Textarea.isDisabled()">\n '
});