uikit/dist/chunks/Pagination-DjllHYU8.js
Mohamadzadeh 1d78c19b1b
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 50s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 6s
change pagination icons
2026-07-09 16:18:10 +03:30

197 lines
5.5 KiB
JavaScript

import { jsxs as a, jsx as n } from "react/jsx-runtime";
import { forwardRef as D, useState as k, useRef as L, useEffect as y } from "react";
import { HStack as v, Text as u, IconButton as B, Button as S, Input as W } from "@chakra-ui/react";
import { toFaDigits as t, toEnDigits as C } from "../utils.js";
const A = D(
({ size: i = 24, title: o, children: h, ...l }, r) => /* @__PURE__ */ a(
"svg",
{
ref: r,
xmlns: "http://www.w3.org/2000/svg",
width: i,
height: i,
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round",
...l,
children: [
o && /* @__PURE__ */ n("title", { children: o }),
/* @__PURE__ */ n("path", { d: "m15 18-6-6 6-6" }),
h
]
}
)
);
A.displayName = "ChevronLeft";
const I = D(
({ size: i = 24, title: o, children: h, ...l }, r) => /* @__PURE__ */ a(
"svg",
{
ref: r,
xmlns: "http://www.w3.org/2000/svg",
width: i,
height: i,
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round",
...l,
children: [
o && /* @__PURE__ */ n("title", { children: o }),
/* @__PURE__ */ n("path", { d: "m9 18 6-6-6-6" }),
h
]
}
)
);
I.displayName = "ChevronRight";
const T = ({
currentPage: i,
totalPages: o,
totalCount: h,
onPageChange: l
}) => {
const [r, s] = k(t(i)), [w, p] = k(!1), [m, f] = k(null), x = L(null), N = Array.from(
/* @__PURE__ */ new Set([1, i, i + 1, o])
).filter((e) => e >= 1 && e <= o).sort((e, c) => e - c);
y(() => {
if (m !== null) {
i === m && (f(null), p(!1), s(t(i)));
return;
}
w || s(t(i));
}, [i, w, m]), y(() => {
if (!w || !r || m !== null) return;
const e = parseInt(C(r), 10);
if (isNaN(e)) return;
const c = setTimeout(() => {
var b;
const d = Math.min(Math.max(e, 1), o);
d !== i ? (f(d), s(t(d)), l(d)) : (p(!1), s(t(i))), (b = x.current) == null || b.blur();
}, 1e3);
return () => clearTimeout(c);
}, [
r,
w,
m,
o,
i,
l
]);
const j = () => {
var d, b;
const e = parseInt(C(r), 10);
if (isNaN(e)) {
s(t(i)), p(!1), f(null), (d = x.current) == null || d.blur();
return;
}
const c = Math.min(Math.max(e, 1), o);
c !== i ? (f(c), s(t(c)), l(c)) : (s(t(i)), p(!1), f(null)), (b = x.current) == null || b.blur();
};
return o === 0 || !h ? null : /* @__PURE__ */ a(
v,
{
justifyContent: "space-around",
backgroundColor: "white",
py: "10px",
px: "16px",
rounded: "lg",
border: "1px",
borderColor: "blue.200",
w: "100%",
children: [
/* @__PURE__ */ a(v, { spacing: 2, whiteSpace: "nowrap", children: [
/* @__PURE__ */ n(u, { fontWeight: "bold", children: "صفحه" }),
/* @__PURE__ */ n(u, { children: t(i) }),
/* @__PURE__ */ n(u, { fontWeight: "bold", children: "از" }),
/* @__PURE__ */ n(u, { children: t(o) })
] }),
/* @__PURE__ */ a(v, { spacing: 2, alignItems: "center", justifyContent: "center", children: [
/* @__PURE__ */ n(
B,
{
size: "md",
bg: "#e6e6f1",
color: "#4B49AC",
_hover: { bg: "#cbcbe8" },
onClick: () => l(i - 1),
isDisabled: i === 1,
icon: /* @__PURE__ */ n(I, {}),
"aria-label": "صفحه قبلی"
}
),
N.map((e) => /* @__PURE__ */ n(
S,
{
size: "md",
bg: i === e ? "#4B49AC" : "#e6e6f1",
color: i === e ? "#e6e6f1" : "#4B49AC",
_hover: { bg: i === e ? "#4B49AC" : "#cbcbe8" },
onClick: () => l(e),
variant: "soft",
children: t(e)
},
e
)),
/* @__PURE__ */ n(
B,
{
size: "md",
bg: "#e6e6f1",
color: "#4B49AC",
_hover: { bg: "#cbcbe8" },
onClick: () => l(i + 1),
isDisabled: i === o,
icon: /* @__PURE__ */ n(A, {}),
"aria-label": "صفحه بعدی"
}
),
/* @__PURE__ */ n(
W,
{
ref: x,
type: "text",
inputMode: "numeric",
placeholder: "صفحه",
w: "100px",
value: r,
onFocus: () => {
p(!0), f(null), s("");
},
onChange: (e) => {
const c = e.target.value, d = C(c).replace(/\D/g, "");
s(t(d));
},
onBlur: () => {
r || (s(t(i)), p(!1), f(null));
},
onKeyDown: (e) => {
e.key === "Enter" && j();
},
textAlign: "center",
color: "#1D2939",
px: 1,
minW: 0,
dir: "ltr"
}
)
] }),
/* @__PURE__ */ a(v, { spacing: 2, whiteSpace: "nowrap", children: [
/* @__PURE__ */ n(u, { fontWeight: "bold", children: "تعداد کل:" }),
/* @__PURE__ */ n(u, { children: t(h) })
] })
]
}
);
};
export {
I as C,
T as P,
A as a
};