kea-react
Version:
Componentes comunes de react
46 lines (45 loc) • 2.14 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var cell_1 = require("./cell");
var text_1 = require("../simpleGrid/text");
var async_1 = require("../../async");
/**Obtiene el nodo de react que se va a mostrar en un elemento TD */
function getView(view, key, data, sharedValue, onDrillDown, string) {
var effectiveView = view || cell_1.defaultCellView;
var effectiveString = text_1.getEffectiveString(data, string);
var element = effectiveView(data, sharedValue, function (path) { return onDrillDown(key, path); }, effectiveString);
if (typeof element == "string") {
return React.createElement("span", null, element);
}
else {
return element;
}
}
/**Una fila del grid */
var GridRow = /** @class */ (function (_super) {
__extends(GridRow, _super);
function GridRow() {
return _super !== null && _super.apply(this, arguments) || this;
}
GridRow.prototype.render = function () {
var props = this.props;
return (React.createElement("tr", null, props.columns.map(function (x) { return ({ data: props.value.cell[x.key || x.title], title: x.title, key: x.key }); }).map(function (x) {
return React.createElement("td", { key: x.key, style: x.data.style && x.data.style(props.sharedValue) }, async_1.async(x.data.data, function (data) {
return getView(x.data.view, x.key, data, props.sharedValue, props.onDrillDown, x.data.string);
}));
})));
};
return GridRow;
}(React.PureComponent));
exports.GridRow = GridRow;