UNPKG

kea-react

Version:

Componentes comunes de react

65 lines (64 loc) 2.73 kB
"use strict"; 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 card = require("./card"); /**Cabecera de una tabla estilizada */ var TableHeader = /** @class */ (function (_super) { __extends(TableHeader, _super); function TableHeader() { return _super !== null && _super.apply(this, arguments) || this; } TableHeader.prototype.render = function () { return (React.createElement("tr", { className: "w3-indigo" }, this.props.children)); }; return TableHeader; }(React.Component)); exports.TableHeader = TableHeader; /**Componente para un listado general de elementos. Ponga los elementos <tr /> de la tabla en los hijos del elemento*/ var Table = /** @class */ (function (_super) { __extends(Table, _super); function Table(props) { return _super.call(this, props) || this; } Object.defineProperty(Table.prototype, "items", { get: function () { return this.props.items || this.props.children; }, enumerable: true, configurable: true }); Object.defineProperty(Table.prototype, "TablaVacia", { get: function () { var items = this.items; return !items || items.length == 0; }, enumerable: true, configurable: true }); Table.prototype.componentWillReceiveProps = function (props) { if (props.children) { console.warn("No mande los hijos de la tabla como hijos del elemento, utilice props.items"); } }; Table.prototype.render = function () { var items = this.items; return (this.TablaVacia ? React.createElement(card.Card, { Header: "Lista vacía" }, "No hay elementos que mostrar.") : React.createElement("div", { className: "table-responsive" }, React.createElement("table", { className: "table table-striped table-hover table-condensed" }, React.createElement("thead", null, this.props.header), React.createElement("tbody", null, items)))); }; return Table; }(React.PureComponent)); exports.Table = Table;