ayongui
Version:
99 lines (98 loc) • 3.45 kB
JavaScript
import { j as s } from "../../../../react/jsx-runtime.mjs";
import C, { useState as P, useImperativeHandle as M } from "react";
import i from "../index.module.less.mjs";
import F from "../../../config/style.module.less.mjs";
import "../../icon/index.module.less.mjs";
import R from "../../icon/components/doubleright-frame/index.mjs";
import y from "../../icon/components/doubleleft-frame/index.mjs";
import "../../icon/components/loading-frame/loading.module.less.mjs";
const J = C.forwardRef(({
total: N,
styleSzie: c,
pageArr: e,
defaultPageSize: f,
disabled: u,
selectedIndex: a,
handleCurrentPage: r,
onPrev: b,
onNext: g
}, k) => {
const [m, j] = P(10), o = (n) => {
let t = i.pageNumItem;
return u && (t += ` ${F.disabled}`), a === n.index && (t += ` ${i.selected}`), t;
}, p = () => {
const n = m + 1, t = Math.ceil(N / f);
n + 2 <= t && j(n);
}, v = () => {
const n = m - 1;
n >= 1 && j(n);
};
M(k, () => ({ handleSkipForward: p, handleSkipBackward: v }));
const w = () => {
var n, t;
if (e.length <= 10)
return e.map((l) => /* @__PURE__ */ s.jsx(
"div",
{
style: c,
className: o(l),
onClick: () => r(l.index),
children: /* @__PURE__ */ s.jsx("span", { children: l.label })
},
l.index
));
{
let l = Math.max(1, m - 3), x = Math.min(e.length, m + 2);
(a < l || a > x) && (l = Math.max(1, a - 2), x = Math.min(e.length, a + 3));
const h = e.slice(l - 1, x);
return /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
((n = h[0]) == null ? void 0 : n.label) !== 1 && /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
/* @__PURE__ */ s.jsx("div", { style: c, className: o({ index: 1 }), onClick: () => r(1), children: "1" }),
m > 6 && /* @__PURE__ */ s.jsxs("div", { className: i.rightNext, children: [
/* @__PURE__ */ s.jsx("span", { className: i.booth, children: " ..." }),
/* @__PURE__ */ s.jsxs("span", { className: i.arrowhead, children: [
" ",
/* @__PURE__ */ s.jsx(y, { onClick: () => b(3) })
] })
] })
] }),
h.map((d) => /* @__PURE__ */ s.jsx(
"div",
{
style: c,
className: o(d),
onClick: () => r(d.index),
children: /* @__PURE__ */ s.jsx("span", { children: d.label })
},
d.index
)),
((t = h[h.length - 1]) == null ? void 0 : t.label) !== e.length && /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
a <= e.length - 5 && /* @__PURE__ */ s.jsxs("div", { style: c, className: i.rightNext, children: [
/* @__PURE__ */ s.jsx("span", { className: i.booth, children: " ..." }),
/* @__PURE__ */ s.jsxs("span", { className: i.arrowhead, children: [
" ",
/* @__PURE__ */ s.jsx(
R,
{
onClick: () => g(3)
}
)
] })
] }),
/* @__PURE__ */ s.jsx(
"div",
{
className: o({ index: e.length }),
onClick: () => r(e.length),
children: e.length
}
)
] })
] });
}
};
return /* @__PURE__ */ s.jsx("div", { className: i.pageNumList, children: w() });
});
export {
J as default
};