update minimal pagination
This commit is contained in:
parent
36b003914e
commit
b8ff72ff4e
65
dist/remote/Pagination.js
vendored
65
dist/remote/Pagination.js
vendored
@ -122,39 +122,39 @@ function ue({
|
|||||||
level: D = "full",
|
level: D = "full",
|
||||||
...v
|
...v
|
||||||
}) {
|
}) {
|
||||||
const { React: n, Button: $, HStack: E, IconButton: y, Input: q, Text: c } = T(), { useCallback: S, useEffect: W, useMemo: J, useRef: Q, useState: L } = n, A = ae(D), f = U[A], r = A === "simple", k = A === "minimal", z = Number(d), Y = Number.isFinite(z) && z > 0 ? z : 10, M = Number(e), B = Number.isFinite(M) && M > 0 ? M : 0, j = Number(g), i = Number.isFinite(j) && j > 0 ? Math.ceil(j) : Math.ceil(B / Y), s = H(t, i), [w, m] = L(
|
const { React: n, Button: $, HStack: E, IconButton: y, Input: q, Text: c } = T(), { useCallback: k, useEffect: W, useMemo: J, useRef: Q, useState: L } = n, A = ae(D), f = U[A], r = A === "simple", _ = A === "minimal", z = Number(d), Y = Number.isFinite(z) && z > 0 ? z : 10, M = Number(e), B = Number.isFinite(M) && M > 0 ? M : 0, j = Number(g), i = Number.isFinite(j) && j > 0 ? Math.ceil(j) : Math.ceil(B / Y), s = H(t, i), [w, m] = L(
|
||||||
r ? "" : u(s)
|
r ? "" : u(s)
|
||||||
), [C, P] = L(!1), [h, p] = L(null), _ = Q(null), l = h ?? s, G = B > 0, Z = J(() => r || i <= 0 ? [] : Array.from(
|
), [C, P] = L(!1), [h, p] = L(null), x = Q(null), l = h ?? s, G = B > 0, Z = J(() => r || i <= 0 ? [] : Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
f.getPageNumbers({
|
f.getPageNumbers({
|
||||||
currentPage: s,
|
currentPage: s,
|
||||||
totalPages: i
|
totalPages: i
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
).filter((o) => o >= 1 && o <= i).sort((o, a) => o - a), [f, r, s, i]), I = S(() => {
|
).filter((o) => o >= 1 && o <= i).sort((o, a) => o - a), [f, r, s, i]), I = k(() => {
|
||||||
m(r ? "" : u(s)), P(!1), p(null);
|
m(r ? "" : u(s)), P(!1), p(null);
|
||||||
}, [r, s]), x = S(
|
}, [r, s]), S = k(
|
||||||
(o) => {
|
(o) => {
|
||||||
const a = H(o, i);
|
const a = H(o, i);
|
||||||
P(!1), m(r ? "" : u(s)), p(null), a !== s && b?.(a);
|
P(!1), m(r ? "" : u(s)), p(null), a !== s && b?.(a);
|
||||||
},
|
},
|
||||||
[r, b, s, i]
|
[r, b, s, i]
|
||||||
), N = S(() => {
|
), N = k(() => {
|
||||||
if (!w) {
|
if (!w) {
|
||||||
I(), _.current?.blur();
|
I(), x.current?.blur();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const o = parseInt(V(w), 10);
|
const o = parseInt(V(w), 10);
|
||||||
if (Number.isNaN(o)) {
|
if (Number.isNaN(o)) {
|
||||||
I(), _.current?.blur();
|
I(), x.current?.blur();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const a = H(o, i);
|
const a = H(o, i);
|
||||||
if (r) {
|
if (r) {
|
||||||
P(!1), m(""), a !== s ? (p(a), b?.(a)) : p(null), _.current?.blur();
|
P(!1), m(""), a !== s ? (p(a), b?.(a)) : p(null), x.current?.blur();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a !== s ? (p(a), m(u(a)), b?.(a)) : (m(u(s)), P(!1), p(null)), _.current?.blur();
|
a !== s ? (p(a), m(u(a)), b?.(a)) : (m(u(s)), P(!1), p(null)), x.current?.blur();
|
||||||
}, [
|
}, [
|
||||||
w,
|
w,
|
||||||
r,
|
r,
|
||||||
@ -162,9 +162,9 @@ function ue({
|
|||||||
I,
|
I,
|
||||||
s,
|
s,
|
||||||
i
|
i
|
||||||
]), ee = S(() => {
|
]), ee = k(() => {
|
||||||
p(null), m(""), P(!0);
|
p(null), m(""), P(!0);
|
||||||
}, []), te = S((o) => {
|
}, []), te = k((o) => {
|
||||||
const a = o.target.value, re = V(a).replace(/\D/g, "");
|
const a = o.target.value, re = V(a).replace(/\D/g, "");
|
||||||
m(u(re));
|
m(u(re));
|
||||||
}, []);
|
}, []);
|
||||||
@ -179,7 +179,7 @@ function ue({
|
|||||||
}
|
}
|
||||||
C || m(u(s));
|
C || m(u(s));
|
||||||
}, [C, r, h, s]), W(() => {
|
}, [C, r, h, s]), W(() => {
|
||||||
r && C && _.current?.focus();
|
r && C && x.current?.focus();
|
||||||
}, [C, r]), W(() => {
|
}, [C, r]), W(() => {
|
||||||
if (!C || !w || !r && h !== null) return;
|
if (!C || !w || !r && h !== null) return;
|
||||||
const o = setTimeout(() => {
|
const o = setTimeout(() => {
|
||||||
@ -188,7 +188,7 @@ function ue({
|
|||||||
return () => clearTimeout(o);
|
return () => clearTimeout(o);
|
||||||
}, [N, w, C, r, h]), i <= 0) return null;
|
}, [N, w, C, r, h]), i <= 0) return null;
|
||||||
const F = () => n.createElement(q, {
|
const F = () => n.createElement(q, {
|
||||||
ref: _,
|
ref: x,
|
||||||
type: "text",
|
type: "text",
|
||||||
inputMode: "numeric",
|
inputMode: "numeric",
|
||||||
placeholder: "صفحه",
|
placeholder: "صفحه",
|
||||||
@ -210,10 +210,11 @@ function ue({
|
|||||||
},
|
},
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
color: "#1D2939",
|
color: "#1D2939",
|
||||||
fontSize: k ? "sm" : void 0,
|
fontSize: _ ? "sm" : void 0,
|
||||||
fontWeight: k ? "700" : void 0,
|
fontWeight: _ ? "700" : void 0,
|
||||||
h: k ? "30px" : void 0,
|
_placeholder: _ ? { fontWeight: "400" } : void 0,
|
||||||
minH: k ? "30px" : void 0,
|
h: _ ? "28px" : void 0,
|
||||||
|
minH: _ ? "28px" : void 0,
|
||||||
px: 1,
|
px: 1,
|
||||||
minW: 0,
|
minW: 0,
|
||||||
dir: "ltr"
|
dir: "ltr"
|
||||||
@ -226,12 +227,12 @@ function ue({
|
|||||||
bg: a ? "#4B49AC" : "#e6e6f1",
|
bg: a ? "#4B49AC" : "#e6e6f1",
|
||||||
color: a ? "#e6e6f1" : "#4B49AC",
|
color: a ? "#e6e6f1" : "#4B49AC",
|
||||||
_hover: { bg: a ? "#4B49AC" : "#cbcbe8" },
|
_hover: { bg: a ? "#4B49AC" : "#cbcbe8" },
|
||||||
onClick: r && a ? ee : () => x(o),
|
onClick: r && a ? ee : () => S(o),
|
||||||
variant: "soft"
|
variant: "soft"
|
||||||
},
|
},
|
||||||
u(o)
|
u(o)
|
||||||
), ne = r && i > 1 && l !== 1, oe = r && i > 1 && l !== i;
|
), ne = r && i > 1 && l !== 1, oe = r && i > 1 && l !== i;
|
||||||
return k ? n.createElement(
|
return _ ? n.createElement(
|
||||||
E,
|
E,
|
||||||
{
|
{
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
@ -250,14 +251,14 @@ function ue({
|
|||||||
{ spacing: 2, alignItems: "center", justifyContent: "center" },
|
{ spacing: 2, alignItems: "center", justifyContent: "center" },
|
||||||
n.createElement(y, {
|
n.createElement(y, {
|
||||||
size: "sm",
|
size: "sm",
|
||||||
w: "28px",
|
w: "24px",
|
||||||
h: "28px",
|
h: "24px",
|
||||||
minW: "28px",
|
minW: "24px",
|
||||||
minH: "28px",
|
minH: "24px",
|
||||||
bg: "#e6e6f1",
|
bg: "#e6e6f1",
|
||||||
color: "#4B49AC",
|
color: "#4B49AC",
|
||||||
_hover: { bg: "#cbcbe8" },
|
_hover: { bg: "#cbcbe8" },
|
||||||
onClick: () => x(l - 1),
|
onClick: () => S(l - 1),
|
||||||
isDisabled: l === 1,
|
isDisabled: l === 1,
|
||||||
icon: n.createElement(K, { width: "16", height: "16" }),
|
icon: n.createElement(K, { width: "16", height: "16" }),
|
||||||
"aria-label": "صفحه قبلی"
|
"aria-label": "صفحه قبلی"
|
||||||
@ -277,21 +278,21 @@ function ue({
|
|||||||
cursor: i > 0 ? "pointer" : "default",
|
cursor: i > 0 ? "pointer" : "default",
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
i > 0 && x(i);
|
i > 0 && S(i);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
u(i)
|
u(i)
|
||||||
),
|
),
|
||||||
n.createElement(y, {
|
n.createElement(y, {
|
||||||
size: "sm",
|
size: "sm",
|
||||||
w: "28px",
|
w: "24px",
|
||||||
h: "28px",
|
h: "24px",
|
||||||
minW: "28px",
|
minW: "24px",
|
||||||
minH: "28px",
|
minH: "24px",
|
||||||
bg: "#e6e6f1",
|
bg: "#e6e6f1",
|
||||||
color: "#4B49AC",
|
color: "#4B49AC",
|
||||||
_hover: { bg: "#cbcbe8" },
|
_hover: { bg: "#cbcbe8" },
|
||||||
onClick: () => x(l + 1),
|
onClick: () => S(l + 1),
|
||||||
isDisabled: l === i,
|
isDisabled: l === i,
|
||||||
icon: n.createElement(O, { width: "16", height: "16" }),
|
icon: n.createElement(O, { width: "16", height: "16" }),
|
||||||
"aria-label": "صفحه بعدی"
|
"aria-label": "صفحه بعدی"
|
||||||
@ -345,7 +346,7 @@ function ue({
|
|||||||
bg: "#e6e6f1",
|
bg: "#e6e6f1",
|
||||||
color: "#4B49AC",
|
color: "#4B49AC",
|
||||||
_hover: { bg: "#cbcbe8" },
|
_hover: { bg: "#cbcbe8" },
|
||||||
onClick: () => x(l - 1),
|
onClick: () => S(l - 1),
|
||||||
isDisabled: l === 1,
|
isDisabled: l === 1,
|
||||||
icon: n.createElement(K),
|
icon: n.createElement(K),
|
||||||
"aria-label": "صفحه قبلی"
|
"aria-label": "صفحه قبلی"
|
||||||
@ -373,7 +374,7 @@ function ue({
|
|||||||
bg: "#e6e6f1",
|
bg: "#e6e6f1",
|
||||||
color: "#4B49AC",
|
color: "#4B49AC",
|
||||||
_hover: { bg: "#cbcbe8" },
|
_hover: { bg: "#cbcbe8" },
|
||||||
onClick: () => x(l + 1),
|
onClick: () => S(l + 1),
|
||||||
isDisabled: l === i,
|
isDisabled: l === i,
|
||||||
icon: n.createElement(O),
|
icon: n.createElement(O),
|
||||||
"aria-label": "صفحه بعدی"
|
"aria-label": "صفحه بعدی"
|
||||||
|
|||||||
@ -392,8 +392,9 @@ function RemotePagination({
|
|||||||
color: "#1D2939",
|
color: "#1D2939",
|
||||||
fontSize: isMinimal ? "sm" : undefined,
|
fontSize: isMinimal ? "sm" : undefined,
|
||||||
fontWeight: isMinimal ? "700" : undefined,
|
fontWeight: isMinimal ? "700" : undefined,
|
||||||
h: isMinimal ? "30px" : undefined,
|
_placeholder: isMinimal ? { fontWeight: "400" } : undefined,
|
||||||
minH: isMinimal ? "30px" : undefined,
|
h: isMinimal ? "28px" : undefined,
|
||||||
|
minH: isMinimal ? "28px" : undefined,
|
||||||
px: 1,
|
px: 1,
|
||||||
minW: 0,
|
minW: 0,
|
||||||
dir: "ltr",
|
dir: "ltr",
|
||||||
@ -440,10 +441,10 @@ function RemotePagination({
|
|||||||
{ spacing: 2, alignItems: "center", justifyContent: "center" },
|
{ spacing: 2, alignItems: "center", justifyContent: "center" },
|
||||||
React.createElement(IconButton, {
|
React.createElement(IconButton, {
|
||||||
size: "sm",
|
size: "sm",
|
||||||
w: "28px",
|
w: "24px",
|
||||||
h: "28px",
|
h: "24px",
|
||||||
minW: "28px",
|
minW: "24px",
|
||||||
minH: "28px",
|
minH: "24px",
|
||||||
bg: "#e6e6f1",
|
bg: "#e6e6f1",
|
||||||
color: "#4B49AC",
|
color: "#4B49AC",
|
||||||
_hover: { bg: "#cbcbe8" },
|
_hover: { bg: "#cbcbe8" },
|
||||||
@ -476,10 +477,10 @@ function RemotePagination({
|
|||||||
),
|
),
|
||||||
React.createElement(IconButton, {
|
React.createElement(IconButton, {
|
||||||
size: "sm",
|
size: "sm",
|
||||||
w: "28px",
|
w: "24px",
|
||||||
h: "28px",
|
h: "24px",
|
||||||
minW: "28px",
|
minW: "24px",
|
||||||
minH: "28px",
|
minH: "24px",
|
||||||
bg: "#e6e6f1",
|
bg: "#e6e6f1",
|
||||||
color: "#4B49AC",
|
color: "#4B49AC",
|
||||||
_hover: { bg: "#cbcbe8" },
|
_hover: { bg: "#cbcbe8" },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user