react-pagination-new
Version:
A simple and customizable pagination component for React applications.
23 lines (22 loc) • 6.7 kB
JavaScript
(function(m,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("react")):typeof define=="function"&&define.amd?define(["react"],i):(m=typeof globalThis<"u"?globalThis:m||self,m.Pagination=i(m.React))})(this,function(m){"use strict";var i={exports:{}},b={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var h;function W(){if(h)return b;h=1;var c=Symbol.for("react.transitional.element"),E=Symbol.for("react.fragment");function f(d,n,s){var p=null;if(s!==void 0&&(p=""+s),n.key!==void 0&&(p=""+n.key),"key"in n){s={};for(var v in n)v!=="key"&&(s[v]=n[v])}else s=n;return n=s.ref,{$$typeof:c,type:d,key:p,ref:n!==void 0?n:null,props:s}}return b.Fragment=E,b.jsx=f,b.jsxs=f,b}var _={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var j;function U(){return j||(j=1,process.env.NODE_ENV!=="production"&&function(){function c(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case X:return"Profiler";case G:return"StrictMode";case Q:return"Suspense";case K:return"SuspenseList";case re:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case V:return"Portal";case H:return(e.displayName||"Context")+".Provider";case B:return(e._context.displayName||"Context")+".Consumer";case Z:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ee:return r=e.displayName||null,r!==null?r:c(e.type)||"Memo";case Y:r=e._payload,e=e._init;try{return c(e(r))}catch{}}return null}function E(e){return""+e}function f(e){try{E(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,o=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),E(e)}}function d(e){if(e===k)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===Y)return"<...>";try{var r=c(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function n(){var e=O.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function p(e){if(I.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function v(e,r){function t(){F||(F=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function J(){var e=c(this.type);return $[e]||($[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function z(e,r,t,o,l,u,P,g){return t=u.ref,e={$$typeof:C,type:e,key:r,props:u,_owner:l},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:J}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:g}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function y(e,r,t,o,l,u,P,g){var a=r.children;if(a!==void 0)if(o)if(ne(a)){for(o=0;o<a.length;o++)N(a[o]);Object.freeze&&Object.freeze(a)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else N(a);if(I.call(r,"key")){a=c(e);var R=Object.keys(r).filter(function(oe){return oe!=="key"});o=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",M[a+o]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,o,a,R,a),M[a+o]=!0)}if(a=null,t!==void 0&&(f(t),a=""+t),p(r)&&(f(r.key),a=""+r.key),"key"in r){t={};for(var S in r)S!=="key"&&(t[S]=r[S])}else t=r;return a&&v(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),z(e,a,u,l,n(),t,P,g)}function N(e){typeof e=="object"&&e!==null&&e.$$typeof===C&&e._store&&(e._store.validated=1)}var T=m,C=Symbol.for("react.transitional.element"),V=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),H=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),O=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,ne=Array.isArray,A=console.createTask?console.createTask:function(){return null};T={"react-stack-bottom-frame":function(e){return e()}};var F,$={},D=T["react-stack-bottom-frame"].bind(T,s)(),L=A(d(s)),M={};_.Fragment=k,_.jsx=function(e,r,t,o,l){var u=1e4>O.recentlyCreatedOwnerStacks++;return y(e,r,t,!1,o,l,u?Error("react-stack-top-frame"):D,u?A(d(e)):L)},_.jsxs=function(e,r,t,o,l){var u=1e4>O.recentlyCreatedOwnerStacks++;return y(e,r,t,!0,o,l,u?Error("react-stack-top-frame"):D,u?A(d(e)):L)}}()),_}var x;function q(){return x||(x=1,process.env.NODE_ENV==="production"?i.exports=W():i.exports=U()),i.exports}var w=q();return({totalPages:c,currentPage:E,onPageChange:f})=>{const d=Array.from({length:c},(n,s)=>s+1);return w.jsx("div",{className:"pagination",children:d.map(n=>w.jsx("button",{className:`page-button ${n===E?"active":""}`,onClick:()=>f(n),children:n},n))})}});