geoiq-frontend-ui-kit
Version:
This project is a UI kit for GeoIQ's frontend. It's built with React, TypeScript, and Vite.
92 lines (91 loc) • 2.68 kB
JavaScript
import e from "react";
import { Pagination as u, PaginationContent as N, PaginationItem as o, PaginationPrevious as b, PaginationNext as C, PaginationEllipsis as y } from "./index.es138.js";
import { Button as r } from "./index.es7.js";
import { Typography as p } from "./index.es17.js";
const B = ({
firstPage: i,
lastPage: n,
currPage: t,
onPageChange: m,
siblingCount: d = 1
}) => {
const k = () => {
t > i && m(t - 1);
}, h = () => {
t < n && m(t + 1);
}, v = () => {
m(i);
}, x = () => {
m(n);
}, E = (l, a) => {
const s = Math.floor((l + a) / 2);
m(s);
}, f = () => {
const l = [], a = Math.max(t - d, i + 1), s = Math.min(t + d, n - 1);
l.push(
/* @__PURE__ */ e.createElement(o, { key: i }, /* @__PURE__ */ e.createElement(
r,
{
variant: t === i ? "secondary" : "teritiary",
size: "sm",
onClick: v
},
/* @__PURE__ */ e.createElement(p, { variant: "body4", className: "p-2 text-light-1" }, i)
))
), a > i + 1 && l.push(
/* @__PURE__ */ e.createElement(o, { key: "ellipsis-start" }, /* @__PURE__ */ e.createElement(
y,
{
onClick: () => E(i + 1, a - 1)
}
))
);
for (let c = a; c <= s; c++)
l.push(
/* @__PURE__ */ e.createElement(o, { key: c }, /* @__PURE__ */ e.createElement(
r,
{
variant: t === c ? "secondary" : "teritiary",
size: "sm",
onClick: () => m(c)
},
/* @__PURE__ */ e.createElement(p, { variant: "body4", className: "p-2 text-light-1" }, c)
))
);
return s < n - 1 && l.push(
/* @__PURE__ */ e.createElement(o, { key: "ellipsis-end" }, /* @__PURE__ */ e.createElement(
y,
{
onClick: () => E(s + 1, n - 1)
}
))
), n > 1 && l.push(
/* @__PURE__ */ e.createElement(o, { key: n }, /* @__PURE__ */ e.createElement(
r,
{
variant: t === n ? "secondary" : "teritiary",
size: "sm",
onClick: x
},
/* @__PURE__ */ e.createElement(p, { variant: "body4", className: "p-2 text-light-1" }, n)
))
), l;
};
return /* @__PURE__ */ e.createElement(u, null, /* @__PURE__ */ e.createElement(N, null, /* @__PURE__ */ e.createElement(o, null, /* @__PURE__ */ e.createElement(
b,
{
disabled: t === i,
onClick: k
}
)), f(), /* @__PURE__ */ e.createElement(o, null, /* @__PURE__ */ e.createElement(
C,
{
disabled: t === n,
onClick: h
}
))));
};
export {
B as default
};
//# sourceMappingURL=index.es64.js.map