@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
50 lines • 2.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var UpDefaultCellFormatter_1 = require("./UpDefaultCellFormatter");
var utils_1 = require("../../../Common/utils");
var UpDataGridCell = (function (_super) {
tslib_1.__extends(UpDataGridCell, _super);
function UpDataGridCell(props, context) {
var _this = _super.call(this, props, context) || this;
_this.getApi = function () {
return { value: _this.props.value, column: _this.props.column };
};
_this.state = {
isSelected: false
};
return _this;
}
UpDataGridCell.prototype.render = function () {
var _this = this;
var _a = this.props, InjectedComponent = _a.component, children = _a.children, render = _a.render;
var renderProps = this.getApi();
var renderInnercell;
if (InjectedComponent) {
renderInnercell = (React.createElement(InjectedComponent, tslib_1.__assign({}, renderProps), children));
}
else if (render) {
renderInnercell = render(renderProps);
}
else if (children != null && utils_1.isFunction(children)) {
var childrenAsFunction = children;
renderInnercell = childrenAsFunction(renderProps);
}
else {
renderInnercell = React.createElement(UpDefaultCellFormatter_1.UpCellFormatter, { value: this.props.value, column: this.props.column }, this.props.children);
}
var cellStyle = {};
if (this.props.actions && this.props.actions.length > 0) {
cellStyle = { marginBottom: '8px' };
}
return (React.createElement("td", { className: "up-data-grid-cell" },
React.createElement("div", { style: cellStyle }, renderInnercell),
React.createElement("div", { className: "row-actions" }, this.props.actions && this.props.actions.map(function (action) {
return React.createElement("p", { key: action.type, className: "row-action" + (action.type === 'delete' ? '-delete' : ''), onClick: function (event) { return action.action(_this.props.value); } }, action.description);
}))));
};
return UpDataGridCell;
}(React.Component));
exports.default = UpDataGridCell;
//# sourceMappingURL=UpDataGridCell.js.map