/*Downloaded from https://www.codeseek.co/-dan/a-pen-by-dan-XgKbep */
var _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; }; }();
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; }
var Node = function (_React$Component) {
_inherits(Node, _React$Component);
function Node(props) {
_classCallCheck(this, Node);
return _possibleConstructorReturn(this, (Node.__proto__ || Object.getPrototypeOf(Node)).call(this, props));
}
_createClass(Node, [{
key: "render",
value: function render() {
if (this.props.node) {
return React.createElement(
"li",
{ className: "node" },
React.createElement(
"div",
{ className: "info" },
this.props.node.name
),
React.createElement(
"ul",
{ className: "level" },
this.props.node.parents.map(function (n) {
return React.createElement(Node, { node: n });
})
)
);
} else {
return "";
}
}
}]);
return Node;
}(React.Component);
var Tree = function (_React$Component2) {
_inherits(Tree, _React$Component2);
function Tree(props) {
_classCallCheck(this, Tree);
return _possibleConstructorReturn(this, (Tree.__proto__ || Object.getPrototypeOf(Tree)).call(this, props));
}
_createClass(Tree, [{
key: "render",
value: function render() {
return React.createElement(
"ul",
{ className: "root" },
this.props.tree && React.createElement(Node, { root: true, node: this.props.tree })
);
}
}]);
return Tree;
}(React.Component);
var Application = function (_React$Component3) {
_inherits(Application, _React$Component3);
function Application(props) {
_classCallCheck(this, Application);
var _this3 = _possibleConstructorReturn(this, (Application.__proto__ || Object.getPrototypeOf(Application)).call(this, props));
_this3.state = {
tree: {
name: 'Dan Handrea',
parents: [{
name: 'Vasile Handrea',
parents: [{ name: 'Eugen Handrea', parents: [{ name: 'Gheorghe Handrea', parents: [] }, { name: 'Elena Handrea', parents: [] }] }, { name: 'Ioana Handrea', parents: [{ name: 'Vasile Roșu', parents: [] }, { name: 'Ioana Roșu', parents: [] }] }]
}, {
name: 'Rozalia Handrea (Ioniță)',
parents: [{ name: 'Ioniță Mihai', parents: [{ name: 'Ion Ioniță', parents: [] }, { name: 'Frăsina Ioniță', parents: [] }] }, { name: 'Ionită Elisaveta', parents: [{ name: 'Gheorghe Panfil', parents: [] }, { name: 'Ioana Panfil', parents: [] }] }]
}]
}
};
return _this3;
}
_createClass(Application, [{
key: "render",
value: function render() {
return React.createElement(Tree, { tree: this.state.tree });
}
}]);
return Application;
}(React.Component);
ReactDOM.render(React.createElement(Application, null), document.getElementById('app'));