-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyang-react.js
More file actions
70 lines (63 loc) · 2.2 KB
/
yang-react.js
File metadata and controls
70 lines (63 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Generated by CoffeeScript 1.10.0
(function() {
var React, Yang,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Yang = require('yang-js');
React = require('react');
module.exports = (require('./yang-react.yang')).bind({
'extension(component)': function() {
return {
global: true,
scope: {
action: '0..n',
container: '0..n'
},
resolve: function() {
this["extends"](['render'].map((function(_this) {
return function(x) {
if (_this.locate("action(" + x + ")") == null) {
return _this.constructor.parse("action " + x + ";");
}
};
})(this)));
return this["extends"](['props', 'state'].map((function(_this) {
return function(x) {
if (_this.locate("container(" + x + ")") == null) {
return _this.constructor.parse("container " + x + ";");
}
};
})(this)));
},
construct: function(data, ctx) {
var component, k, ref, schema, v;
this.debug("making React.Component class");
schema = this;
component = (function(superClass) {
extend(_Class, superClass);
function _Class(props) {
var k, v;
_Class.__super__.constructor.apply(this, arguments);
this.state = {};
schema.apply(this);
for (k in this) {
if (!hasProp.call(this, k)) continue;
v = this[k];
if (v instanceof Function) {
this[k] = v.bind(this);
}
}
}
return _Class;
})(React.Component);
ref = this.apply(data);
for (k in ref) {
v = ref[k];
component.prototype[k] = v;
}
return component;
}
};
}
});
}).call(this);