UNPKG

playtpus_ui

Version:
30 lines 2.27 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var react_1 = __importDefault(require("react")); var __1 = require("../../"); var pagination_1 = __importDefault(require("../../hooks/pagination")); var List = function (_a) { var _b = _a.loading, loading = _b === void 0 ? false : _b, _c = _a.error, error = _c === void 0 ? false : _c, pagination = _a.pagination, list = _a.list, _d = _a.loader, loader = _d === void 0 ? react_1.default.createElement(__1.Loader.Spinner, { color: 'inherit' }) : _d, _e = _a.emptyText, emptyText = _e === void 0 ? "No Data" : _e, _f = _a.empty, empty = _f === void 0 ? react_1.default.createElement(__1.Empty, { text: emptyText, color: "white", style: { marginTop: 0 } }) : _f, map = _a.map; var _g = pagination_1.default(list.length, pagination ? pagination.items : 0), page = _g.page, canGoBack = _g.canGoBack, canGoForward = _g.canGoForward, actions = _g.actions, needsPagination = _g.needsPagination; if (loading) return loader; else if ((list === null || list === void 0 ? void 0 : list.length) === 0) return empty; if (pagination) { return react_1.default.createElement(react_1.default.Fragment, null, list .filter(function (_, i) { return (pagination.items * (page + 1) >= (i + 1)) && (i >= (pagination.items * page)); }) .map(map), needsPagination && react_1.default.createElement("div", { style: { placeSelf: 'end', gridColumn: '1/-1', height: '100%' } }, react_1.default.createElement("i", { onClick: actions.backward, style: { color: !canGoBack ? 'gray' : '' }, className: 'fa fa-chevron-left' }), "\u00A0 \u00A0", react_1.default.createElement("i", { style: { color: !canGoForward ? 'gray' : '' }, className: 'fa fa-chevron-right', onClick: actions.forward }))); } return react_1.default.createElement(react_1.default.Fragment, null, list.map(map ? map : function (el) { return el; })); }; exports.default = List; //# sourceMappingURL=index.js.map