@progress/kendo-react-data-tools
Version:
Includes React Pager & React Filter component, an intuitive interface to create complex filter descriptions. KendoReact Data Tools package
63 lines (62 loc) • 2.14 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use client";
import * as l from "react";
import { classNames as D } from "@progress/kendo-react-common";
import { Button as M } from "@progress/kendo-react-buttons";
import { pagerPage as y, pagerMoreButtonLabel as z } from "../messages/index.mjs";
import { useLocalization as E } from "@progress/kendo-react-intl";
import { getL10NMessage as C, translateMessage as p } from "./utils.mjs";
const I = "...", F = (t) => {
const c = E(), { messagesMap: i, size: u, totalPages: P, navigatable: m, pagerNumericButtonsRef: h } = t, v = C(y, i), N = C(z, i), g = p(c, N), d = (e, n) => {
e.preventDefault(), t.pageChange(n, e);
}, b = (e, n) => /* @__PURE__ */ l.createElement(
M,
{
fillMode: "flat",
themeColor: "primary",
size: u,
rounded: null,
role: "button",
"aria-label": n,
onClick: (x) => d(x, e),
tabIndex: m ? -1 : void 0
},
I
);
let a = 1;
const o = t.currentPage, r = t.buttonCount;
if (o > r) {
const e = o % r;
a = e === 0 ? o - r + 1 : o - e + 1;
}
const s = Math.min(a + t.buttonCount - 1, t.totalPages), L = a > 1 && b(a - 1, g), k = s < P && b(s + 1, g), f = [];
for (let e = a; e <= s; e++)
f.push(e);
const B = f.map((e) => /* @__PURE__ */ l.createElement(
M,
{
className: D({ "k-selected": o === e }),
key: e,
fillMode: "flat",
themeColor: "primary",
size: u,
rounded: null,
role: "button",
"aria-label": p(c, v) + " " + e,
"aria-current": o === e ? !0 : void 0,
onClick: (n) => d(n, e),
tabIndex: m ? -1 : void 0
},
e
));
return /* @__PURE__ */ l.createElement("div", { className: "k-pager-numbers", ref: h }, L, B, k);
};
export {
F as PagerNumericButtons
};