kea-react
Version:
Componentes comunes de react
71 lines (70 loc) • 3.45 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 __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var botones_1 = require("../../../botones");
var modal_1 = require("../../../modal");
var table_1 = require("../../../table");
var index_1 = require("../../index");
var ArrayCell = /** @class */ (function (_super) {
__extends(ArrayCell, _super);
function ArrayCell(props) {
var _this = _super.call(this, props) || this;
_this.state = {};
return _this;
}
ArrayCell.prototype.render = function () {
var _this = this;
var _a = this.props, value = _a.value, columns = _a.columns, itemToString = _a.itemToString, separator = _a.separator, string = _a.string;
var toString = itemToString || index_1.cellToText;
var text = string;
return ((value && value.length > 0) ?
(React.createElement("span", null,
React.createElement(botones_1.Link, { style: "success", iconClass: "fa fa-list", onClick: function () { return _this.setState({ showListModal: true }); } }),
text,
this.state.showListModal &&
React.createElement(ArrayCellModal, __assign({}, this.props, { onClose: function () { return _this.setState({ showListModal: false }); } })))) : React.createElement("span", null));
};
return ArrayCell;
}(React.PureComponent));
exports.ArrayCell = ArrayCell;
/**Modal que muestra el contenido del arreglo */
var ArrayCellModal = /** @class */ (function (_super) {
__extends(ArrayCellModal, _super);
function ArrayCellModal() {
return _super !== null && _super.apply(this, arguments) || this;
}
ArrayCellModal.prototype.render = function () {
var columns = this.props.columns || [
{
cell: function (x) { return index_1.cellToText(x); },
title: ""
}
];
var header = React.createElement("tr", null, columns.map(function (x) { return x.title; }).map(function (x) { return React.createElement("th", null, x); }));
var row = function (item) {
return React.createElement("tr", null, columns.map(function (x) { return x.cell(item); }).map(function (x) { return React.createElement("td", null, x); }));
};
var rows = (this.props.value || []).map(row);
return (React.createElement(modal_1.Modal, { buttonsWithKey: [], onClose: this.props.onClose, title: "Detalle" },
React.createElement(table_1.Table, { header: header, items: rows })));
};
return ArrayCellModal;
}(React.PureComponent));