@rubenpazch/pagination 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/Pagination.d.ts +7 -2
- package/dist/Pagination.d.ts.map +1 -1
- package/dist/PaginationItem.d.ts.map +1 -1
- package/dist/index.cjs.js +14 -10
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +14 -10
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
1
|
# Pagination
|
|
2
2
|
|
|
3
3
|
Generated component package.
|
|
4
|
+
|
|
5
|
+
<!-- catalogo:inicio (generado por pnpm catalogo, no editar) -->
|
|
6
|
+
|
|
7
|
+
Paginación con variantes, tamaños y formas; incluye PaginationItem.
|
|
8
|
+
|
|
9
|
+
- **Usar cuando:** Listados paginados en el servidor (tablas, resultados de búsqueda).
|
|
10
|
+
- **Evitar cuando:** Pocas páginas que caben en una sola vista.
|
|
11
|
+
|
|
12
|
+
Se recomienda instalar el paquete completo `@rubenpazch/ui` (incluye este). Por separado:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @rubenpazch/pagination
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Pagination
|
|
19
|
+
|
|
20
|
+
| Prop | Tipo | Req. | Por defecto | Descripción |
|
|
21
|
+
| ----------------- | -------------------------------------------------------------- | ---- | ------------ | ----------------------------------------------------------------------------------- |
|
|
22
|
+
| `aria-label` | `string` | | `Paginación` | Nombre accesible de la navegación (por defecto "Paginación"). |
|
|
23
|
+
| `boundaryCount` | `number` | | `1` | Number of always visible pages at the beginning and end |
|
|
24
|
+
| `count` | `number` | | `1` | Total number of pages |
|
|
25
|
+
| `defaultPage` | `number` | | `1` | Default page if uncontrolled |
|
|
26
|
+
| `disabled` | `boolean` | | `false` | If true, the component is disabled |
|
|
27
|
+
| `hideNextButton` | `boolean` | | `false` | If true, hide the next-page button |
|
|
28
|
+
| `hidePrevButton` | `boolean` | | `false` | If true, hide the previous-page button |
|
|
29
|
+
| `onChange` | `(event: ChangeEvent<unknown, Element>, page: number) => void` | | | Al cambiar de página, estilo MUI: (evento, página). Se mantiene por compatibilidad. |
|
|
30
|
+
| `onPageChange` | `(page: number) => void` | | | Al cambiar de página (recibe solo el número). Preferido sobre onChange. |
|
|
31
|
+
| `page` | `number` | | | The current page (1-based) |
|
|
32
|
+
| `renderItem` | `(item: PaginationItemType) => ReactNode` | | | Custom render function for items |
|
|
33
|
+
| `shape` | `"rounded" \| "circular"` | | `rounded` | The shape of the pagination items |
|
|
34
|
+
| `showFirstButton` | `boolean` | | `false` | If true, show the first-page button |
|
|
35
|
+
| `showLastButton` | `boolean` | | `false` | If true, show the last-page button |
|
|
36
|
+
| `siblingCount` | `number` | | `1` | Number of always visible pages before and after the current page |
|
|
37
|
+
| `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | | `medium` | The size of the pagination component |
|
|
38
|
+
| `variant` | `"text" \| "outlined"` | | `text` | The variant to use |
|
|
39
|
+
|
|
40
|
+
## PaginationItem
|
|
41
|
+
|
|
42
|
+
| Prop | Tipo | Req. | Por defecto | Descripción |
|
|
43
|
+
| ---------- | ------------------------------------------------------------------------------------------- | ---- | ----------- | ------------------------------------ |
|
|
44
|
+
| `page` | `number` | sí | | The page number |
|
|
45
|
+
| `type` | `"page" \| "next" \| "previous" \| "first" \| "last" \| "start-ellipsis" \| "end-ellipsis"` | sí | | The type of pagination item |
|
|
46
|
+
| `selected` | `boolean` | | `false` | If true, the item is selected/active |
|
|
47
|
+
| `shape` | `"rounded" \| "circular"` | | `rounded` | The shape of the pagination items |
|
|
48
|
+
| `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | | `medium` | The size of the component |
|
|
49
|
+
| `variant` | `"text" \| "outlined"` | | `text` | The variant to use |
|
|
50
|
+
|
|
51
|
+
Tipos: `PaginationProps`, `PaginationShape`, `PaginationSize`, `PaginationVariant`, `PaginationItemType`, `PaginationItemProps`.
|
|
52
|
+
|
|
53
|
+
<!-- catalogo:fin -->
|
package/dist/Pagination.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export type PaginationShape = "rounded" | "circular";
|
|
3
|
-
|
|
3
|
+
/** Tamaño: sm, md, lg (estándar) o small, medium, large. */
|
|
4
|
+
export type PaginationSize = "small" | "medium" | "large" | "sm" | "md" | "lg";
|
|
4
5
|
export type PaginationVariant = "text" | "outlined";
|
|
5
6
|
export interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
|
|
6
7
|
/** Total number of pages */
|
|
@@ -9,8 +10,12 @@ export interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>,
|
|
|
9
10
|
page?: number;
|
|
10
11
|
/** Default page if uncontrolled */
|
|
11
12
|
defaultPage?: number;
|
|
12
|
-
/**
|
|
13
|
+
/** Al cambiar de página (recibe solo el número). Preferido sobre onChange. */
|
|
14
|
+
onPageChange?: (page: number) => void;
|
|
15
|
+
/** Al cambiar de página, estilo MUI: (evento, página). Se mantiene por compatibilidad. */
|
|
13
16
|
onChange?: (event: React.ChangeEvent<unknown>, page: number) => void;
|
|
17
|
+
/** Nombre accesible de la navegación (por defecto "Paginación"). */
|
|
18
|
+
"aria-label"?: string;
|
|
14
19
|
/** If true, the component is disabled */
|
|
15
20
|
disabled?: boolean;
|
|
16
21
|
/** If true, hide the next-page button */
|
package/dist/Pagination.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../src/Pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../src/Pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,CAAC;AACrD,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/E,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,CAAC;AAEpD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EACjC,UAAU,CACX;IACC,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yCAAyC;IACzC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,6CAA6C;IAC7C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0CAA0C;IAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yCAAyC;IACzC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8DAA8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,yBAAyB;IACzB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,uCAAuC;IACvC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC5D;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EACA,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,gBAAgB,GAChB,cAAc,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAC/D;AAgID,QAAA,MAAM,UAAU,qFAkHf,CAAC;AAIF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginationItem.d.ts","sourceRoot":"","sources":["../src/PaginationItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PaginationItem.d.ts","sourceRoot":"","sources":["../src/PaginationItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAC7C,MAAM,CACP;IACC,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,EACA,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,gBAAgB,GAChB,cAAc,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,gCAAgC;IAChC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,yBAAyB;IACzB,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAWD,QAAA,MAAM,cAAc,+FAwInB,CAAC;AAIF,eAAe,cAAc,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
+
var shared = require('@rubenpazch/shared');
|
|
4
5
|
|
|
5
6
|
function _interopNamespaceDefault(e) {
|
|
6
7
|
var n = Object.create(null);
|
|
@@ -443,7 +444,7 @@ function requireJsxRuntime () {
|
|
|
443
444
|
|
|
444
445
|
var jsxRuntimeExports = requireJsxRuntime();
|
|
445
446
|
|
|
446
|
-
var r
|
|
447
|
+
var t,r={exports:{}},o={};var l,n,a={};
|
|
447
448
|
/**
|
|
448
449
|
* @license React
|
|
449
450
|
* react-jsx-runtime.development.js
|
|
@@ -452,7 +453,7 @@ var r,o={exports:{}},t={};var l,n,a={};
|
|
|
452
453
|
*
|
|
453
454
|
* This source code is licensed under the MIT license found in the
|
|
454
455
|
* LICENSE file in the root directory of this source tree.
|
|
455
|
-
*/function i(){return l||(l=1,"production"!==process.env.NODE_ENV&&function(){function e(s){if(null==s)return null;if("function"==typeof s)return s.$$typeof===M?null:s.displayName||s.name||null;if("string"==typeof s)return s;switch(s){case
|
|
456
|
+
*/function i(){return l||(l=1,"production"!==process.env.NODE_ENV&&function(){function e(s){if(null==s)return null;if("function"==typeof s)return s.$$typeof===M?null:s.displayName||s.name||null;if("string"==typeof s)return s;switch(s){case u:return "Fragment";case v:return "Profiler";case x:return "StrictMode";case f:return "Suspense";case C:return "SuspenseList";case N:return "Activity"}if("object"==typeof s)switch("number"==typeof s.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case g:return "Portal";case j:return s.displayName||"Context";case p:return (s._context.displayName||"Context")+".Consumer";case k:var t=s.render;return (s=s.displayName)||(s=""!==(s=t.displayName||t.name||"")?"ForwardRef("+s+")":"ForwardRef"),s;case L:return null!==(t=s.displayName||null)?t:e(s.type)||"Memo";case y:t=s._payload,s=s._init;try{return e(s(t))}catch(e){}}return null}function t(e){return ""+e}function r(e){try{t(e);var s=!1;}catch(e){s=true;}if(s){var r=(s=console).error,o="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),t(e)}}function o(s){if(s===u)return "<>";if("object"==typeof s&&null!==s&&s.$$typeof===y)return "<...>";try{var t=e(s);return t?"<"+t+">":"<...>"}catch(e){return "<...>"}}function l(){return Error("react-stack-top-frame")}function n(){var s=e(this.type);return B[s]||(B[s]=true,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.")),void 0!==(s=this.props.ref)?s:null}function i(s,t,o,l,a,i){var c,m=t.children;if(void 0!==m)if(l)if(z(m)){for(l=0;l<m.length;l++)h(m[l]);Object.freeze&&Object.freeze(m);}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 h(m);if(b.call(t,"key")){m=e(s);var g=Object.keys(t).filter(function(e){return "key"!==e});l=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",W[m+l]||(g=0<g.length?"{"+g.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',l,m,g,m),W[m+l]=true);}if(m=null,void 0!==o&&(r(o),m=""+o),function(e){if(b.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return false}return void 0!==e.key}(t)&&(r(t.key),m=""+t.key),"key"in t)for(var u in o={},t)"key"!==u&&(o[u]=t[u]);else o=t;return m&&function(e,s){function t(){d||(d=true,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)",s));}t.isReactWarning=true,Object.defineProperty(e,"key",{get:t,configurable:true});}(o,"function"==typeof s?s.displayName||s.name||"Unknown":s),function(e,s,t,r,o,l){var a=t.ref;return e={$$typeof:w,type:e,key:s,props:t,_owner:r},null!==(void 0!==a?a:null)?Object.defineProperty(e,"ref",{enumerable:false,get:n}):Object.defineProperty(e,"ref",{enumerable:false,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:false,enumerable:false,writable:true,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:false,enumerable:false,writable:true,value:null}),Object.defineProperty(e,"_debugStack",{configurable:false,enumerable:false,writable:true,value:o}),Object.defineProperty(e,"_debugTask",{configurable:false,enumerable:false,writable:true,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(s,m,o,null===(c=$.A)?null:c.getOwner(),a,i)}function h(e){c(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===y&&("fulfilled"===e._payload.status?c(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1));}function c(e){return "object"==typeof e&&null!==e&&e.$$typeof===w}var d,m=React,w=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),p=Symbol.for("react.consumer"),j=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),$=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,b=Object.prototype.hasOwnProperty,z=Array.isArray,H=console.createTask?console.createTask:function(){return null},B={},V=(m={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(m,l)(),Z=H(o(l)),W={};a.Fragment=u,a.jsx=function(e,s,t){var r=1e4>$.recentlyCreatedOwnerStacks++;return i(e,s,t,false,r?Error("react-stack-top-frame"):V,r?H(o(e)):Z)},a.jsxs=function(e,s,t){var r=1e4>$.recentlyCreatedOwnerStacks++;return i(e,s,t,true,r?Error("react-stack-top-frame"):V,r?H(o(e)):Z)};}()),a}var h=(n||(n=1,"production"===process.env.NODE_ENV?r.exports=function(){if(t)return o;t=1;var e=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function r(s,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var l in r={},t)"key"!==l&&(r[l]=t[l]);else r=t;return t=r.ref,{$$typeof:e,type:s,key:o,ref:void 0!==t?t:null,props:r}}return o.Fragment=s,o.jsx=r,o.jsxs=r,o}():r.exports=i()),r.exports);const C={sm:16,md:20,lg:28},L=({size:e="md",direction:s="right",...t})=>{const r=C[e],o="left"===s;return h.jsx("svg",{width:r,height:r,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",...t,children:h.jsxs("g",{transform:o?"scale(-1,1) translate(-20,0)":void 0,children:[h.jsx("path",{d:"M7.22 5.22a.75.75 0 011.06 0l4 4a.75.75 0 010 1.06l-4 4a.75.75 0 11-1.06-1.06L10.94 10 7.22 6.28a.75.75 0 010-1.06z"}),h.jsx("path",{d:"M15.25 4a.75.75 0 10-1.5 0v12a.75.75 0 101.5 0V4z"})]})})},y=({className:e="",size:s="md",color:t="currentColor",direction:r="down"})=>{const o={sm:16,md:20,lg:24};return h.jsx("svg",{width:o[s],height:o[s],className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]} ${{up:"rotate-180",down:"",left:"rotate-90",right:"-rotate-90"}[r]} ${e}`,fill:"none",stroke:t,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M6 9l6 6 6-6"})})};const ds={outlined:"material-symbols-outlined",rounded:"material-symbols-rounded",sharp:"material-symbols-sharp"},ms=React__namespace.forwardRef(({name:e,variant:s="outlined",size:t="md",fill:r=0,weight:o=400,grade:l=0,opticalSize:n=24,style:a,className:i,...c},d)=>{const m=(e=>"number"==typeof e?e:"sm"===e?16:"md"===e?20:24)(t),w=`"FILL" ${r}, "wght" ${o}, "GRAD" ${l}, "opsz" ${n}`;return h.jsx("span",{ref:d,"aria-hidden":"true",className:ds[s]+(i?` ${i}`:""),style:{fontVariationSettings:w,fontSize:m,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",...a},...c,children:e})});ms.displayName="MaterialIcon";
|
|
456
457
|
|
|
457
458
|
function styleInject(css, ref) {
|
|
458
459
|
if ( ref === void 0 ) ref = {};
|
|
@@ -491,7 +492,8 @@ const iconSizeMap = {
|
|
|
491
492
|
medium: "md",
|
|
492
493
|
large: "lg",
|
|
493
494
|
};
|
|
494
|
-
const PaginationItem = React.forwardRef(({ page, type, selected = false, disabled = false, shape = "rounded", size = "medium", variant = "text", className, ...props }, ref) => {
|
|
495
|
+
const PaginationItem = React.forwardRef(({ page, type, selected = false, disabled = false, shape = "rounded", size: sizeProp = "medium", variant = "text", className, ...props }, ref) => {
|
|
496
|
+
const size = shared.toLegacySize(sizeProp);
|
|
495
497
|
// Ellipsis are not interactive
|
|
496
498
|
if (type === "start-ellipsis" || type === "end-ellipsis") {
|
|
497
499
|
// Use ASCII ellipsis to keep output portable across environments
|
|
@@ -530,14 +532,14 @@ const PaginationItem = React.forwardRef(({ page, type, selected = false, disable
|
|
|
530
532
|
};
|
|
531
533
|
const classes = classNames$1(styles$1.item, styles$1.button, styles$1[`size-${size}`], styles$1[`shape-${shape}`], styles$1[`variant-${variant}`], selected && styles$1.selected, disabled && styles$1.disabled, isNavigationButton && styles$1.navigation, className);
|
|
532
534
|
return (jsxRuntimeExports.jsx("button", { ref: ref, type: "button", className: classes, disabled: disabled, "aria-label": type === "first"
|
|
533
|
-
? "
|
|
535
|
+
? "Ir a la primera página"
|
|
534
536
|
: type === "last"
|
|
535
|
-
? "
|
|
537
|
+
? "Ir a la última página"
|
|
536
538
|
: type === "next"
|
|
537
|
-
? "
|
|
539
|
+
? "Página siguiente"
|
|
538
540
|
: type === "previous"
|
|
539
|
-
? "
|
|
540
|
-
: `
|
|
541
|
+
? "Página anterior"
|
|
542
|
+
: `Página ${page}`, "aria-current": selected ? "page" : undefined, ...props, children: getButtonContent() }));
|
|
541
543
|
});
|
|
542
544
|
PaginationItem.displayName = "PaginationItem";
|
|
543
545
|
|
|
@@ -620,7 +622,8 @@ const usePagination = (props) => {
|
|
|
620
622
|
}
|
|
621
623
|
return items;
|
|
622
624
|
};
|
|
623
|
-
const Pagination = React.forwardRef(({ count = 1, page: controlledPage, defaultPage = 1, onChange, disabled = false, hideNextButton = false, hidePrevButton = false, showFirstButton = false, showLastButton = false, boundaryCount = 1, siblingCount = 1, shape = "rounded", size = "medium", variant = "text", renderItem, className, ...props }, ref) => {
|
|
625
|
+
const Pagination = React.forwardRef(({ count = 1, page: controlledPage, defaultPage = 1, onChange, onPageChange, "aria-label": ariaLabel = "Paginación", disabled = false, hideNextButton = false, hidePrevButton = false, showFirstButton = false, showLastButton = false, boundaryCount = 1, siblingCount = 1, shape = "rounded", size: sizeProp = "medium", variant = "text", renderItem, className, ...props }, ref) => {
|
|
626
|
+
const size = shared.toLegacySize(sizeProp);
|
|
624
627
|
const [page, setPage] = React.useState(defaultPage);
|
|
625
628
|
const currentPage = controlledPage ?? page;
|
|
626
629
|
const handleClick = (event, value) => {
|
|
@@ -630,6 +633,7 @@ const Pagination = React.forwardRef(({ count = 1, page: controlledPage, defaultP
|
|
|
630
633
|
if (onChange) {
|
|
631
634
|
onChange(event, value);
|
|
632
635
|
}
|
|
636
|
+
onPageChange?.(value);
|
|
633
637
|
};
|
|
634
638
|
const items = usePagination({
|
|
635
639
|
count,
|
|
@@ -642,7 +646,7 @@ const Pagination = React.forwardRef(({ count = 1, page: controlledPage, defaultP
|
|
|
642
646
|
hidePrevButton,
|
|
643
647
|
});
|
|
644
648
|
const classes = classNames(styles.root, className);
|
|
645
|
-
return (jsxRuntimeExports.jsx("nav", { ref: ref, className: classes, ...props, children: jsxRuntimeExports.jsx("ul", { className: styles.ul, children: items.map((item, index) => {
|
|
649
|
+
return (jsxRuntimeExports.jsx("nav", { ref: ref, className: classes, "aria-label": ariaLabel, ...props, children: jsxRuntimeExports.jsx("ul", { className: styles.ul, children: items.map((item, index) => {
|
|
646
650
|
const isDisabled = disabled || item.disabled;
|
|
647
651
|
if (renderItem) {
|
|
648
652
|
return (jsxRuntimeExports.jsx("li", { children: renderItem({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
type PaginationShape = "rounded" | "circular";
|
|
4
|
-
|
|
4
|
+
/** Tamaño: sm, md, lg (estándar) o small, medium, large. */
|
|
5
|
+
type PaginationSize = "small" | "medium" | "large" | "sm" | "md" | "lg";
|
|
5
6
|
type PaginationVariant = "text" | "outlined";
|
|
6
7
|
interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
|
|
7
8
|
/** Total number of pages */
|
|
@@ -10,8 +11,12 @@ interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>, "onCha
|
|
|
10
11
|
page?: number;
|
|
11
12
|
/** Default page if uncontrolled */
|
|
12
13
|
defaultPage?: number;
|
|
13
|
-
/**
|
|
14
|
+
/** Al cambiar de página (recibe solo el número). Preferido sobre onChange. */
|
|
15
|
+
onPageChange?: (page: number) => void;
|
|
16
|
+
/** Al cambiar de página, estilo MUI: (evento, página). Se mantiene por compatibilidad. */
|
|
14
17
|
onChange?: (event: React.ChangeEvent<unknown>, page: number) => void;
|
|
18
|
+
/** Nombre accesible de la navegación (por defecto "Paginación"). */
|
|
19
|
+
"aria-label"?: string;
|
|
15
20
|
/** If true, the component is disabled */
|
|
16
21
|
disabled?: boolean;
|
|
17
22
|
/** If true, hide the next-page button */
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
+
import { toLegacySize } from '@rubenpazch/shared';
|
|
3
4
|
|
|
4
5
|
var jsxRuntime = {exports: {}};
|
|
5
6
|
|
|
@@ -423,7 +424,7 @@ function requireJsxRuntime () {
|
|
|
423
424
|
|
|
424
425
|
var jsxRuntimeExports = requireJsxRuntime();
|
|
425
426
|
|
|
426
|
-
var r
|
|
427
|
+
var t,r={exports:{}},o={};var l,n,a={};
|
|
427
428
|
/**
|
|
428
429
|
* @license React
|
|
429
430
|
* react-jsx-runtime.development.js
|
|
@@ -432,7 +433,7 @@ var r,o={exports:{}},t={};var l,n,a={};
|
|
|
432
433
|
*
|
|
433
434
|
* This source code is licensed under the MIT license found in the
|
|
434
435
|
* LICENSE file in the root directory of this source tree.
|
|
435
|
-
*/function i(){return l||(l=1,"production"!==process.env.NODE_ENV&&function(){function e(s){if(null==s)return null;if("function"==typeof s)return s.$$typeof===M?null:s.displayName||s.name||null;if("string"==typeof s)return s;switch(s){case
|
|
436
|
+
*/function i(){return l||(l=1,"production"!==process.env.NODE_ENV&&function(){function e(s){if(null==s)return null;if("function"==typeof s)return s.$$typeof===M?null:s.displayName||s.name||null;if("string"==typeof s)return s;switch(s){case u:return "Fragment";case v:return "Profiler";case x:return "StrictMode";case f:return "Suspense";case C:return "SuspenseList";case N:return "Activity"}if("object"==typeof s)switch("number"==typeof s.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case g:return "Portal";case j:return s.displayName||"Context";case p:return (s._context.displayName||"Context")+".Consumer";case k:var t=s.render;return (s=s.displayName)||(s=""!==(s=t.displayName||t.name||"")?"ForwardRef("+s+")":"ForwardRef"),s;case L:return null!==(t=s.displayName||null)?t:e(s.type)||"Memo";case y:t=s._payload,s=s._init;try{return e(s(t))}catch(e){}}return null}function t(e){return ""+e}function r(e){try{t(e);var s=!1;}catch(e){s=true;}if(s){var r=(s=console).error,o="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),t(e)}}function o(s){if(s===u)return "<>";if("object"==typeof s&&null!==s&&s.$$typeof===y)return "<...>";try{var t=e(s);return t?"<"+t+">":"<...>"}catch(e){return "<...>"}}function l(){return Error("react-stack-top-frame")}function n(){var s=e(this.type);return B[s]||(B[s]=true,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.")),void 0!==(s=this.props.ref)?s:null}function i(s,t,o,l,a,i){var c,m=t.children;if(void 0!==m)if(l)if(z(m)){for(l=0;l<m.length;l++)h(m[l]);Object.freeze&&Object.freeze(m);}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 h(m);if(b.call(t,"key")){m=e(s);var g=Object.keys(t).filter(function(e){return "key"!==e});l=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",W[m+l]||(g=0<g.length?"{"+g.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',l,m,g,m),W[m+l]=true);}if(m=null,void 0!==o&&(r(o),m=""+o),function(e){if(b.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return false}return void 0!==e.key}(t)&&(r(t.key),m=""+t.key),"key"in t)for(var u in o={},t)"key"!==u&&(o[u]=t[u]);else o=t;return m&&function(e,s){function t(){d||(d=true,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)",s));}t.isReactWarning=true,Object.defineProperty(e,"key",{get:t,configurable:true});}(o,"function"==typeof s?s.displayName||s.name||"Unknown":s),function(e,s,t,r,o,l){var a=t.ref;return e={$$typeof:w,type:e,key:s,props:t,_owner:r},null!==(void 0!==a?a:null)?Object.defineProperty(e,"ref",{enumerable:false,get:n}):Object.defineProperty(e,"ref",{enumerable:false,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:false,enumerable:false,writable:true,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:false,enumerable:false,writable:true,value:null}),Object.defineProperty(e,"_debugStack",{configurable:false,enumerable:false,writable:true,value:o}),Object.defineProperty(e,"_debugTask",{configurable:false,enumerable:false,writable:true,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(s,m,o,null===(c=$.A)?null:c.getOwner(),a,i)}function h(e){c(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===y&&("fulfilled"===e._payload.status?c(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1));}function c(e){return "object"==typeof e&&null!==e&&e.$$typeof===w}var d,m=React__default,w=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),p=Symbol.for("react.consumer"),j=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),$=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,b=Object.prototype.hasOwnProperty,z=Array.isArray,H=console.createTask?console.createTask:function(){return null},B={},V=(m={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(m,l)(),Z=H(o(l)),W={};a.Fragment=u,a.jsx=function(e,s,t){var r=1e4>$.recentlyCreatedOwnerStacks++;return i(e,s,t,false,r?Error("react-stack-top-frame"):V,r?H(o(e)):Z)},a.jsxs=function(e,s,t){var r=1e4>$.recentlyCreatedOwnerStacks++;return i(e,s,t,true,r?Error("react-stack-top-frame"):V,r?H(o(e)):Z)};}()),a}var h=(n||(n=1,"production"===process.env.NODE_ENV?r.exports=function(){if(t)return o;t=1;var e=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function r(s,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var l in r={},t)"key"!==l&&(r[l]=t[l]);else r=t;return t=r.ref,{$$typeof:e,type:s,key:o,ref:void 0!==t?t:null,props:r}}return o.Fragment=s,o.jsx=r,o.jsxs=r,o}():r.exports=i()),r.exports);const C={sm:16,md:20,lg:28},L=({size:e="md",direction:s="right",...t})=>{const r=C[e],o="left"===s;return h.jsx("svg",{width:r,height:r,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",...t,children:h.jsxs("g",{transform:o?"scale(-1,1) translate(-20,0)":void 0,children:[h.jsx("path",{d:"M7.22 5.22a.75.75 0 011.06 0l4 4a.75.75 0 010 1.06l-4 4a.75.75 0 11-1.06-1.06L10.94 10 7.22 6.28a.75.75 0 010-1.06z"}),h.jsx("path",{d:"M15.25 4a.75.75 0 10-1.5 0v12a.75.75 0 101.5 0V4z"})]})})},y=({className:e="",size:s="md",color:t="currentColor",direction:r="down"})=>{const o={sm:16,md:20,lg:24};return h.jsx("svg",{width:o[s],height:o[s],className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]} ${{up:"rotate-180",down:"",left:"rotate-90",right:"-rotate-90"}[r]} ${e}`,fill:"none",stroke:t,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M6 9l6 6 6-6"})})};const ds={outlined:"material-symbols-outlined",rounded:"material-symbols-rounded",sharp:"material-symbols-sharp"},ms=React.forwardRef(({name:e,variant:s="outlined",size:t="md",fill:r=0,weight:o=400,grade:l=0,opticalSize:n=24,style:a,className:i,...c},d)=>{const m=(e=>"number"==typeof e?e:"sm"===e?16:"md"===e?20:24)(t),w=`"FILL" ${r}, "wght" ${o}, "GRAD" ${l}, "opsz" ${n}`;return h.jsx("span",{ref:d,"aria-hidden":"true",className:ds[s]+(i?` ${i}`:""),style:{fontVariationSettings:w,fontSize:m,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",...a},...c,children:e})});ms.displayName="MaterialIcon";
|
|
436
437
|
|
|
437
438
|
function styleInject(css, ref) {
|
|
438
439
|
if ( ref === void 0 ) ref = {};
|
|
@@ -471,7 +472,8 @@ const iconSizeMap = {
|
|
|
471
472
|
medium: "md",
|
|
472
473
|
large: "lg",
|
|
473
474
|
};
|
|
474
|
-
const PaginationItem = React__default.forwardRef(({ page, type, selected = false, disabled = false, shape = "rounded", size = "medium", variant = "text", className, ...props }, ref) => {
|
|
475
|
+
const PaginationItem = React__default.forwardRef(({ page, type, selected = false, disabled = false, shape = "rounded", size: sizeProp = "medium", variant = "text", className, ...props }, ref) => {
|
|
476
|
+
const size = toLegacySize(sizeProp);
|
|
475
477
|
// Ellipsis are not interactive
|
|
476
478
|
if (type === "start-ellipsis" || type === "end-ellipsis") {
|
|
477
479
|
// Use ASCII ellipsis to keep output portable across environments
|
|
@@ -510,14 +512,14 @@ const PaginationItem = React__default.forwardRef(({ page, type, selected = false
|
|
|
510
512
|
};
|
|
511
513
|
const classes = classNames$1(styles$1.item, styles$1.button, styles$1[`size-${size}`], styles$1[`shape-${shape}`], styles$1[`variant-${variant}`], selected && styles$1.selected, disabled && styles$1.disabled, isNavigationButton && styles$1.navigation, className);
|
|
512
514
|
return (jsxRuntimeExports.jsx("button", { ref: ref, type: "button", className: classes, disabled: disabled, "aria-label": type === "first"
|
|
513
|
-
? "
|
|
515
|
+
? "Ir a la primera página"
|
|
514
516
|
: type === "last"
|
|
515
|
-
? "
|
|
517
|
+
? "Ir a la última página"
|
|
516
518
|
: type === "next"
|
|
517
|
-
? "
|
|
519
|
+
? "Página siguiente"
|
|
518
520
|
: type === "previous"
|
|
519
|
-
? "
|
|
520
|
-
: `
|
|
521
|
+
? "Página anterior"
|
|
522
|
+
: `Página ${page}`, "aria-current": selected ? "page" : undefined, ...props, children: getButtonContent() }));
|
|
521
523
|
});
|
|
522
524
|
PaginationItem.displayName = "PaginationItem";
|
|
523
525
|
|
|
@@ -600,7 +602,8 @@ const usePagination = (props) => {
|
|
|
600
602
|
}
|
|
601
603
|
return items;
|
|
602
604
|
};
|
|
603
|
-
const Pagination = React__default.forwardRef(({ count = 1, page: controlledPage, defaultPage = 1, onChange, disabled = false, hideNextButton = false, hidePrevButton = false, showFirstButton = false, showLastButton = false, boundaryCount = 1, siblingCount = 1, shape = "rounded", size = "medium", variant = "text", renderItem, className, ...props }, ref) => {
|
|
605
|
+
const Pagination = React__default.forwardRef(({ count = 1, page: controlledPage, defaultPage = 1, onChange, onPageChange, "aria-label": ariaLabel = "Paginación", disabled = false, hideNextButton = false, hidePrevButton = false, showFirstButton = false, showLastButton = false, boundaryCount = 1, siblingCount = 1, shape = "rounded", size: sizeProp = "medium", variant = "text", renderItem, className, ...props }, ref) => {
|
|
606
|
+
const size = toLegacySize(sizeProp);
|
|
604
607
|
const [page, setPage] = React__default.useState(defaultPage);
|
|
605
608
|
const currentPage = controlledPage ?? page;
|
|
606
609
|
const handleClick = (event, value) => {
|
|
@@ -610,6 +613,7 @@ const Pagination = React__default.forwardRef(({ count = 1, page: controlledPage,
|
|
|
610
613
|
if (onChange) {
|
|
611
614
|
onChange(event, value);
|
|
612
615
|
}
|
|
616
|
+
onPageChange?.(value);
|
|
613
617
|
};
|
|
614
618
|
const items = usePagination({
|
|
615
619
|
count,
|
|
@@ -622,7 +626,7 @@ const Pagination = React__default.forwardRef(({ count = 1, page: controlledPage,
|
|
|
622
626
|
hidePrevButton,
|
|
623
627
|
});
|
|
624
628
|
const classes = classNames(styles.root, className);
|
|
625
|
-
return (jsxRuntimeExports.jsx("nav", { ref: ref, className: classes, ...props, children: jsxRuntimeExports.jsx("ul", { className: styles.ul, children: items.map((item, index) => {
|
|
629
|
+
return (jsxRuntimeExports.jsx("nav", { ref: ref, className: classes, "aria-label": ariaLabel, ...props, children: jsxRuntimeExports.jsx("ul", { className: styles.ul, children: items.map((item, index) => {
|
|
626
630
|
const isDisabled = disabled || item.disabled;
|
|
627
631
|
if (renderItem) {
|
|
628
632
|
return (jsxRuntimeExports.jsx("li", { children: renderItem({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubenpazch/pagination",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Pagination component",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"**/*.css"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@rubenpazch/icons": "6.
|
|
23
|
+
"@rubenpazch/icons": "6.2.0",
|
|
24
|
+
"@rubenpazch/shared": "5.2.0"
|
|
24
25
|
},
|
|
25
26
|
"exports": {
|
|
26
27
|
".": {
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"react": "^19.0.0",
|
|
34
35
|
"react-dom": "^19.0.0",
|
|
35
|
-
"@rubenpazch/tokens": "0.
|
|
36
|
+
"@rubenpazch/tokens": "0.4.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@rollup/plugin-commonjs": "^29.0.3",
|
|
@@ -57,6 +58,12 @@
|
|
|
57
58
|
"publishConfig": {
|
|
58
59
|
"access": "public"
|
|
59
60
|
},
|
|
61
|
+
"lbyte": {
|
|
62
|
+
"categoria": "navegacion",
|
|
63
|
+
"resumen": "Paginación con variantes, tamaños y formas; incluye PaginationItem.",
|
|
64
|
+
"usarCuando": "Listados paginados en el servidor (tablas, resultados de búsqueda).",
|
|
65
|
+
"evitarCuando": "Pocas páginas que caben en una sola vista."
|
|
66
|
+
},
|
|
60
67
|
"scripts": {
|
|
61
68
|
"build": "rollup -c",
|
|
62
69
|
"test": "jest --passWithNoTests"
|