app-decorators-todomvc
Version:
Todomvc with app-decorators
163 lines (138 loc) • 7.25 kB
JavaScript
System.register(['app-decorators/src/libs/random-storage', 'app-decorators/src/libs/customelement', 'app-decorators/src/libs/element-to-function', 'app-decorators', './dom', './utils'], function (_export, _context) {
"use strict";
var _storage, _Register, _elementToFunc, component, view, on, _remove, toggleClass, trigger, _createClass, _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _class3, _temp, TodoItem;
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;
view = _appDecorators.view;
on = _appDecorators.on;
}, function (_dom) {
_remove = _dom.remove;
toggleClass = _dom.toggleClass;
}, function (_utils) {
trigger = _utils.trigger;
}],
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('TodoItem', TodoItem = (_dec = view({
"compiler": [7, ">= 4.0.0"],
"main": function main(container, depth0, helpers, partials, data) {
var helper;
return "\n <div class=\"view\">\n <input class=\"toggle\" type=\"checkbox\">\n <label>" + container.escapeExpression((helper = (helper = helpers.text || (depth0 != null ? depth0.text : depth0)) != null ? helper : helpers.helperMissing, typeof helper === "function" ? helper.call(depth0 != null ? depth0 : container.nullContext || {}, {
"name": "text",
"hash": {},
"data": data
}) : helper)) + "</label>\n <button class=\"destroy\"></button>\n </div>\n <input class=\"edit\" value=\"abc\">\n";
},
"useData": true
}), _dec2 = component({
name: 'todo-item',
extends: 'li'
}), _dec3 = on('change li input[type="checkbox"]'), _dec4 = on('click li button.destroy'), _dec(_class = _dec2(_class = (_class2 = (_temp = _class3 = function (_elementToFunc2) {
_inherits(TodoItem, _elementToFunc2);
function TodoItem() {
_classCallCheck(this, TodoItem);
return _possibleConstructorReturn(this, (TodoItem.__proto__ || Object.getPrototypeOf(TodoItem)).apply(this, arguments));
}
_createClass(TodoItem, [{
key: 'onCompleted',
value: function onCompleted() {
trigger.call(this, 'complete');
}
}, {
key: 'onDeleted',
value: function onDeleted() {
trigger.call(this, 'delete');
}
}, {
key: 'complete',
value: function complete() {
toggleClass.call(this, 'completed');
}
}, {
key: 'remove',
value: function remove() {
_remove.call(this);
}
}], [{
key: 'extends',
get: function get() {
return 'li';
}
}]);
return TodoItem;
}(_elementToFunc(HTMLLIElement)), _class3.$$componentName = 'TodoItem', _temp), (_applyDecoratedDescriptor(_class2.prototype, 'onCompleted', [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, 'onCompleted'), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, 'onDeleted', [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, 'onDeleted'), _class2.prototype)), _class2)) || _class) || _class));
_Register.Register.customElement(TodoItem, _storage.storage.get(TodoItem).get('@component'));
_export('TodoItem', TodoItem);
}
};
});