UNPKG

ukelli-ui

Version:

Base on React's UI lib. Make frontend's dev simpler and faster.

52 lines (51 loc) 2.06 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { 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 extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import React from 'react'; import MapperFilter from './mapper-filter'; /** * 卡片式表格渲染模版 * * @export * @class CardTable * @extends {MapperFilter} */ var CardTable = /** @class */ (function (_super) { __extends(CardTable, _super); function CardTable() { return _super !== null && _super.apply(this, arguments) || this; } CardTable.prototype.render = function () { var _this = this; var records = this.props.records; var columns = this.getColumns(); if (!Array.isArray(records)) { console.error('records 必须为 []'); return null; } return (React.createElement("div", { className: "record-items" }, records.map(function (record, idx) { return (React.createElement("div", { className: "item", key: idx }, columns.map(function (mapper, _idx) { if (!mapper) return null; var key = mapper.key; var currText = record[key]; var resultText = _this.mapperFilter(mapper, record, idx); var title = _this.titleFilter(mapper, _idx); var tdKey = key + "_" + currText; return (React.createElement("div", { key: tdKey }, React.createElement("span", { className: "title" }, title), React.createElement("span", { className: "content" }, resultText))); }))); }))); }; return CardTable; }(MapperFilter)); export default CardTable;