UNPKG

@veracity/vui

Version:

Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.

59 lines (57 loc) 1.7 kB
import { cs } from "../utils/styles.js"; import { useStyleConfig } from "../core/theme.js"; import vui from "../core/vui.js"; import { Box } from "../box/box.js"; import { T } from "../t/t.js"; import { Input } from "../input/input.js"; import { usePaginationContext } from "./context.js"; import { jsx, jsxs } from "react/jsx-runtime"; //#region src/pagination/paginationGoToPage.tsx /** Displays a number input, which allows quickly jumping between pages. */ const PaginationGoToPage = vui((props, ref) => { const { className, ...rest } = props; const { onPageChange, pageCount } = usePaginationContext(); const styles = useStyleConfig("Pagination", usePaginationContext()); const onChange = (e) => { const value = +e.target.value; if (value >= 1 && value <= pageCount) onPageChange(Math.floor(value)); else if (value > pageCount) onPageChange(pageCount); else onPageChange(1); }; return /* @__PURE__ */ jsxs(Box, { centerV: true, className: cs("vui-paginationGoToPage", className), lineHeight: "normal", ref, ...styles.goToPage, ...rest, children: [ /* @__PURE__ */ jsx(T, { size: "sm", variant: "navigation", fontWeight: "medium", children: "Go\xA0to" }), /* @__PURE__ */ jsx(Input, { max: pageCount, min: 1, mx: 1, onChange, size: "sm", type: "number", w: 56 }), /* @__PURE__ */ jsx(T, { size: "sm", variant: "navigation", fontWeight: "medium", children: "Page" }) ] }); }); PaginationGoToPage.displayName = "PaginationGoToPage"; //#endregion export { PaginationGoToPage, PaginationGoToPage as default }; globalThis.__vuiVersion__ = "5.3.1" //# sourceMappingURL=paginationGoToPage.js.map