UNPKG

app-decorators-todomvc

Version:
142 lines (117 loc) 5.84 kB
System.register(['app-decorators/src/libs/random-storage', 'app-decorators/src/libs/customelement', 'app-decorators/src/libs/element-to-function', 'app-decorators', './utils', './dom'], function (_export, _context) { "use strict"; var _storage, _Register, _elementToFunc, component, on, trigger, attribute, _createClass, _dec, _dec2, _class, _desc, _value, _class2, _class3, _temp, TodoNew; 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; } function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object['ke' + 'ys'](descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object['define' + 'Property'](target, property, desc); desc = null; } return desc; } return { setters: [function (_appDecoratorsSrcLibsRandomStorage) { _storage = _appDecoratorsSrcLibsRandomStorage; }, function (_appDecoratorsSrcLibsCustomelement) { _Register = _appDecoratorsSrcLibsCustomelement; }, function (_appDecoratorsSrcLibsElementToFunction) { _elementToFunc = _appDecoratorsSrcLibsElementToFunction.default; }, function (_appDecorators) { component = _appDecorators.component; on = _appDecorators.on; }, function (_utils) { trigger = _utils.trigger; }, function (_dom) { attribute = _dom.attribute; }], execute: function () { _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); _export('TodoNew', TodoNew = (_dec = component({ name: 'todo-new', extends: 'input' }), _dec2 = on('keypress'), _dec(_class = (_class2 = (_temp = _class3 = function (_elementToFunc2) { _inherits(TodoNew, _elementToFunc2); function TodoNew() { _classCallCheck(this, TodoNew); return _possibleConstructorReturn(this, (TodoNew.__proto__ || Object.getPrototypeOf(TodoNew)).apply(this, arguments)); } _createClass(TodoNew, [{ key: 'onKeypress', value: function onKeypress(_ref) { var keyCode = _ref.keyCode; if (keyCode !== 13 || this.value === '') { return; } var selector = attribute.call(this, 'target'); var scope = document.querySelector(selector); trigger.call(scope, 'new-item', this.value); this.value = ''; } }], [{ key: 'extends', get: function get() { return 'input'; } }]); return TodoNew; }(_elementToFunc(HTMLInputElement)), _class3.$$componentName = 'TodoNew', _temp), (_applyDecoratedDescriptor(_class2.prototype, 'onKeypress', [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, 'onKeypress'), _class2.prototype)), _class2)) || _class)); _Register.Register.customElement(TodoNew, _storage.storage.get(TodoNew).get('@component')); _export('TodoNew', TodoNew); } }; });