UNPKG

@coko/client

Version:

Client side common code for coko apps

83 lines (78 loc) 1.92 kB
import { noop as e } from "../../toolkit/funcs.js"; import { grid as t } from "../../toolkit/themeHelper.js"; import "../../toolkit/index.js"; import n from "./Spin.js"; import r from "./Search.js"; import i from "./Pagination.js"; import { useEffect as a, useMemo as o, useState as s } from "react"; import c from "styled-components"; import { jsx as l, jsxs as u } from "react/jsx-runtime"; import { Table as d } from "antd"; //#region src/ui/common/Table.tsx var f = c.div` display: flex; flex-direction: column; > div:last-child { flex-grow: 1; .ant-spin-nested-loading, .ant-spin-container, .ant-table-wrapper { height: 100%; } .ant-table { height: calc(100% - ${t(16)}); } } `, p = c.div` display: flex; justify-content: center; margin-bottom: ${t(3)}; > span { max-width: 1200px; } `, m = c(i)` padding: ${t(4)} 0; text-align: right; `, h = (t) => { let { className: i, children: c, loading: h = !1, showSearch: g = !1, searchLoading: _ = !1, onSearch: v = e, searchPlaceholder: y, dataSource: b, pagination: x, ...S } = t, C = o(() => ({ current: 1, pageSize: 10, ...x }), [x]), [w, T] = s(C.current), [E, D] = s(C.pageSize); a(() => { T(C.current), D(C.pageSize); }, [C]); let O = { ...C, current: w, pageSize: E }, k = (e) => (t, n) => { T(t), D(n), x && x[e] && x[e](t, n); }, A = k("onChange"), j = k("onShowSizeChange"); return /* @__PURE__ */ u(f, { className: i, children: [ g && /* @__PURE__ */ l(p, { children: /* @__PURE__ */ l(r, { loading: _, onSearch: v, placeholder: y }) }), /* @__PURE__ */ l(n, { spinning: h, children: /* @__PURE__ */ l(d, { ...S, dataSource: b, pagination: !1, children: c }) }), x && /* @__PURE__ */ l(m, { onChange: A, onShowSizeChange: j, pagination: O }) ] }); }; //#endregion export { h as default };