@up-group-ui/react-controls
Version:
Up shared react controls
50 lines • 2.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var React = (0, tslib_1.__importStar)(require("react"));
var UpDefaultCellFormatter_1 = require("./UpDefaultCellFormatter");
var utils_1 = require("../../../Common/utils");
var UpDataGridCell = (function (_super) {
(0, 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 = (0, jsx_runtime_1.jsx)(InjectedComponent, (0, tslib_1.__assign)({}, renderProps, { children: children }), void 0);
}
else if (render) {
renderInnercell = render(renderProps);
}
else if (children != null && (0, utils_1.isFunction)(children)) {
var childrenAsFunction = children;
renderInnercell = childrenAsFunction(renderProps);
}
else {
renderInnercell = ((0, jsx_runtime_1.jsx)(UpDefaultCellFormatter_1.UpCellFormatter, (0, tslib_1.__assign)({ value: this.props.value, column: this.props.column }, { children: this.props.children }), void 0));
}
var cellStyle = {};
if (this.props.actions && this.props.actions.length > 0) {
cellStyle = { marginBottom: '8px' };
}
return ((0, jsx_runtime_1.jsxs)("td", (0, tslib_1.__assign)({ className: "up-data-grid-cell" }, { children: [(0, jsx_runtime_1.jsx)("div", (0, tslib_1.__assign)({ style: cellStyle }, { children: renderInnercell }), void 0), (0, jsx_runtime_1.jsx)("div", (0, tslib_1.__assign)({ className: "row-actions" }, { children: this.props.actions &&
this.props.actions.map(function (action) {
return ((0, jsx_runtime_1.jsx)("p", (0, tslib_1.__assign)({ className: "row-action" + (action.type === 'delete' ? '-delete' : ''), onClick: function (event) { return action.action(_this.props.value); } }, { children: action.description }), action.type));
}) }), void 0)] }), void 0));
};
return UpDataGridCell;
}(React.Component));
exports.default = UpDataGridCell;
//# sourceMappingURL=UpDataGridCell.js.map