UNPKG

@idares-ui/react

Version:
36 lines 1.42 kB
import * as React from "react"; import { useContext } from "react"; import { MainContext } from "../../utils/context"; import { NextButton, PreviousButton } from "./fragments"; import { AtFirstThreeComponent, AtLastThreeComponent, AtWithinComponent, } from "./states"; /** * Pagination full mode * * STATES (Page Position) * * - AtFirstThree => 1 | 2 | 3 * - AtWithin => FirstThree < PAGE < LastThree * - AtLastThree => numberOfPages - 2 | numberOfPages - 1 | numberOfPages * * @returns Full Pagination Component */ export var FullMode = function () { var _a = useContext(MainContext), numberOfPages = _a.numberOfPages, page = _a.page; var AtFirstThree = page <= 3; var AtWithin = page >= 4 && page < numberOfPages - 2; var AtLastThree = page >= numberOfPages - 2; var renderState = function () { if (AtFirstThree) return React.createElement(AtFirstThreeComponent, null); if (AtWithin) return React.createElement(AtWithinComponent, null); if (AtLastThree) return React.createElement(AtLastThreeComponent, null); return React.createElement(React.Fragment, null); }; return (React.createElement(React.Fragment, null, React.createElement(PreviousButton, null), renderState(), React.createElement(NextButton, null))); }; //# sourceMappingURL=index.js.map