@arche-mc2/arche-controls
Version:
We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get
109 lines • 4.79 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var typestyle_1 = require("typestyle");
var UpTreeView = (function (_super) {
tslib_1.__extends(UpTreeView, _super);
function UpTreeView(p, c) {
var _this = _super.call(this, p, c) || this;
_this.onBranchClick = function (data, branchId) {
_this.setState({ selectedBranchId: branchId });
if (_this.props.onBranchClick) {
_this.props.onBranchClick(data);
}
};
_this.state = {
selectedBranchId: ""
};
return _this;
}
UpTreeView.prototype.render = function () {
return (React.createElement(SubMenu, { showInvisible: this.props.showInvisible, selectedBranchId: this.state.selectedBranchId, childMenuItems: this.props.childMenuItems, onBranchClick: this.onBranchClick }));
};
return UpTreeView;
}(React.Component));
exports.default = UpTreeView;
;
var SubMenu = (function (_super) {
tslib_1.__extends(SubMenu, _super);
function SubMenu(p, c) {
var _this = _super.call(this, p, c) || this;
_this.state = {};
return _this;
}
SubMenu.prototype.render = function () {
var _this = this;
if (this.props.childMenuItems == null || this.props.childMenuItems.length == 0) {
return null;
}
var localId = this.props.branchId != null ? this.props.branchId + "-" : "";
var lis = this.props.childMenuItems.map(function (v, i) {
return (React.createElement(SubItems, { showInvisible: _this.props.showInvisible, branchId: localId + i.toString(), selectedBranchId: _this.props.selectedBranchId, key: i, id: v.id, onBranchClick: _this.props.onBranchClick, text: v.text, isVisible: v.isVisible, isSelected: v.isSelected, childMenuItems: v.childMenuItems }));
});
var s = {
listStyle: "none",
marginTop: 0
};
return (React.createElement("ul", { style: s }, lis));
};
return SubMenu;
}(React.Component));
exports.SubMenu = SubMenu;
;
var SubItems = (function (_super) {
tslib_1.__extends(SubItems, _super);
function SubItems(p, c) {
var _this = _super.call(this, p, c) || this;
_this.onExpandClick = function (e) {
_this.setState({ expand: !_this.state.expand });
e.preventDefault();
e.stopPropagation();
return false;
};
_this.onClickA = function (e) {
var data = {
id: _this.props.id,
text: _this.props.text,
isSelected: _this.props.isSelected,
isVisible: _this.props.isVisible,
childMenuItems: _this.props.childMenuItems
};
_this.props.onBranchClick(data, _this.props.branchId);
};
_this.state = {
expand: false
};
return _this;
}
Object.defineProperty(SubItems.prototype, "anyChild", {
get: function () {
return this.props.childMenuItems != null && this.props.childMenuItems.length != 0;
},
enumerable: true,
configurable: true
});
SubItems.prototype.render = function () {
var styleBranch = typestyle_1.style({
display: this.props.isVisible === false && this.props.showInvisible !== true ? "none" : "inherit",
$nest: {
"&>span": {
color: this.props.isVisible === false ? "#7F7F7F" : "inherit",
border: this.props.branchId == this.props.selectedBranchId ? "1px solid #116FAA" : "",
borderRadius: 5
},
"&>span:hover": {
border: "1px solid #116FAA",
}
}
});
return (React.createElement("li", { className: styleBranch },
React.createElement("i", { className: (this.state.expand ? "pe-7s-angle-down" : "pe-7s-angle-right"), style: { visibility: this.anyChild ? "visible" : "hidden" }, onClick: this.onExpandClick }),
React.createElement("span", { onClick: this.onClickA }, this.props.text),
this.anyChild === true && this.state.expand === true ? (React.createElement(SubMenu, { showInvisible: this.props.showInvisible, selectedBranchId: this.props.selectedBranchId, branchId: this.props.branchId, onBranchClick: this.props.onBranchClick, childMenuItems: this.props.childMenuItems })) : null));
};
return SubItems;
}(React.Component));
exports.SubItems = SubItems;
;
//# sourceMappingURL=UpTreeView.js.map