UNPKG

ayongui

Version:
122 lines (121 loc) 3.41 kB
import { j as t } from "../../../react/jsx-runtime.mjs"; import { useState as S, useRef as R, useMemo as E, useEffect as z } from "react"; import D from "../select/index.mjs"; import J from "../input/index.mjs"; import "../icon/index.module.less.mjs"; import L from "../icon/components/previous-frame/index.mjs"; import Q from "../icon/components/advance-frame/index.mjs"; import "../icon/components/loading-frame/loading.module.less.mjs"; import s from "./index.module.less.mjs"; import j from "../../config/style.module.less.mjs"; import V from "./list/index.mjs"; const ee = (N) => { const { pageSize: P, current: q, total: d = 10, size: i = "default", disabled: n = !1, pageSizeOptions: m = [10, 20, 50, 100], showQuickJumper: C = !1, showSizeChanger: b = !1, hideOnSinglePage: v = !1, onSizeChange: y = (e) => { }, onCurrentChange: $ = (e) => { } } = N, c = { default: { padding: "6px 13px", fontSize: "14px" }, small: { padding: "2px 8px", fontSize: "14px" } }, f = { default: { padding: "8px 9px", fontSize: "12px" }, small: { padding: "4px 5px", fontSize: "12px" } }, [a, w] = S(P || m[0]), [r, u] = S(1), B = R(null), M = () => { const e = [], l = Math.ceil(d / a); for (let p = 1; p <= l; p++) e.push({ label: p, index: p }); return e; }, o = E(() => M(), [d, a]), g = (e) => { n || u(Number(e)); }, A = (e) => { e && w(Number(e)); }, I = () => m.reduce((e, l) => (e.push({ label: `${l}条/页`, value: l }), e), []), x = () => { n || r === 1 || u((e) => --e); }, h = () => { n || r === o.length || u((e) => ++e); }, k = (e) => { g(e); }, O = (e) => !e || isNaN(e) || e < 1 || e > o.length; return z(() => { $(r); }, [r]), z(() => { y(a); }, [a]), v && o.length <= 1 ? "" : /* @__PURE__ */ t.jsxs("div", { className: `${s.pageMain}`, children: [ /* @__PURE__ */ t.jsx("div", { className: s.total }), /* @__PURE__ */ t.jsx( "div", { style: f[i], className: `${s.prevBtn} ${n ? j.disabled : ""}`, onClick: x, children: /* @__PURE__ */ t.jsx(L, {}) } ), /* @__PURE__ */ t.jsx( V, { ref: B, total: d, styleSzie: c[i], onPrev: x, onNext: h, pageArr: o, defaultPageSize: a, handleCurrentPage: g, selectedIndex: r, disabled: n } ), /* @__PURE__ */ t.jsx( "div", { style: f[i], className: `${s.nextBtn} ${n ? j.disabled : ""}`, onClick: h, children: /* @__PURE__ */ t.jsx(Q, {}) } ), b && /* @__PURE__ */ t.jsx( D, { disabled: n, style: { padding: c[i] }, onChange: A, className: s.selectPageSize, options: I(), defaultValue: a } ), C && /* @__PURE__ */ t.jsxs("div", { className: s.jumpBox, children: [ /* @__PURE__ */ t.jsx("span", { style: { whiteSpace: "nowrap" }, children: "跳至" }), /* @__PURE__ */ t.jsx( J, { style: { padding: c[i], margin: "0 10px" }, disabled: n, onChangeBefore: O, value: r, className: s.pageSizeInput, onBlur: k } ), /* @__PURE__ */ t.jsx("span", { children: " 页 " }) ] }) ] }); }; export { ee as default };