@rubenpazch/pagination 3.2.5 → 3.4.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 CHANGED
@@ -17,37 +17,43 @@ npm install @rubenpazch/pagination
17
17
 
18
18
  ## Pagination
19
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 |
20
+ | Prop | Tipo | Req. | Por defecto | Descripción |
21
+ | -------------------- | -------------------------------------------------------------- | ---- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- |
22
+ | `aria-label` | `string` | | | 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
+ | `compactOnMobile` | `boolean` | | `false` | En pantallas angostas (< 640 px) oculta los números y muestra solo anterior/siguiente con el indicador "3 / 10". |
25
+ | `count` | `number` | | `1` | Total number of pages |
26
+ | `defaultPage` | `number` | | `1` | Default page if uncontrolled |
27
+ | `disabled` | `boolean` | | `false` | If true, the component is disabled |
28
+ | `hideNextButton` | `boolean` | | `false` | If true, hide the next-page button |
29
+ | `hidePrevButton` | `boolean` | | `false` | If true, hide the previous-page button |
30
+ | `hideWhenSinglePage` | `boolean` | | `false` | No muestra nada cuando hay una sola página (o ninguna). |
31
+ | `labels` | `Partial<PaginationLabels>` | | | Textos de la interfaz; por defecto en español. |
32
+ | `onChange` | `(event: ChangeEvent<unknown, Element>, page: number) => void` | | | Al cambiar de página, estilo MUI: (evento, página). Se mantiene por compatibilidad. |
33
+ | `onPageChange` | `(page: number) => void` | | | Al cambiar de página (recibe solo el número). Preferido sobre onChange. |
34
+ | `page` | `number` | | | The current page (1-based) |
35
+ | `pageSize` | `number` | | | Registros por página, para calcular el rango del resumen. |
36
+ | `renderItem` | `(item: PaginationItemType) => ReactNode` | | | Custom render function for items |
37
+ | `shape` | `"rounded" \| "circular"` | | `rounded` | The shape of the pagination items |
38
+ | `showFirstButton` | `boolean` | | `false` | If true, show the first-page button |
39
+ | `showLastButton` | `boolean` | | `false` | If true, show the last-page button |
40
+ | `siblingCount` | `number` | | `1` | Number of always visible pages before and after the current page |
41
+ | `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | | `medium` | The size of the pagination component |
42
+ | `totalCount` | `number` | | | Total de registros. Muestra un resumen junto a la paginación: "Mostrando 1–50 de 230" si se indica `pageSize`, o "230 en total". |
43
+ | `variant` | `"text" \| "outlined"` | | `text` | The variant to use |
39
44
 
40
45
  ## PaginationItem
41
46
 
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`.
47
+ | Prop | Tipo | Req. | Por defecto | Descripción |
48
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---- | ----------- | ----------------------------------------------------------------------------------------- |
49
+ | `page` | `number` | sí | | The page number |
50
+ | `type` | `"page" \| "next" \| "previous" \| "first" \| "last" \| "start-ellipsis" \| "end-ellipsis"` | sí | | The type of pagination item |
51
+ | `labels` | `Partial<{ label: string; first: string; last: string; next: string; previous: string; page: string; summaryRange: string; summaryTotal: string; mobilePage: string; }>` | | | Textos (por defecto, los del idioma activo): `first`, `last`, `next`, `previous`, `page`. |
52
+ | `selected` | `boolean` | | `false` | If true, the item is selected/active |
53
+ | `shape` | `"rounded" \| "circular"` | | `rounded` | The shape of the pagination items |
54
+ | `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | | `medium` | The size of the component |
55
+ | `variant` | `"text" \| "outlined"` | | `text` | The variant to use |
56
+
57
+ Tipos: `PaginationProps`, `PaginationShape`, `PaginationSize`, `PaginationVariant`, `PaginationItemType`, `PaginationLabels`, `PaginationItemProps`.
52
58
 
53
59
  <!-- catalogo:fin -->
@@ -3,6 +3,24 @@ export type PaginationShape = "rounded" | "circular";
3
3
  /** Tamaño: sm, md, lg (estándar) o small, medium, large. */
4
4
  export type PaginationSize = "small" | "medium" | "large" | "sm" | "md" | "lg";
5
5
  export type PaginationVariant = "text" | "outlined";
6
+ export interface PaginationLabels {
7
+ /** Nombre del `<nav>` (si no se pasa `aria-label`). */
8
+ label: string;
9
+ /** Botones (lectores de pantalla); `page` lleva `{page}`. */
10
+ first: string;
11
+ last: string;
12
+ next: string;
13
+ previous: string;
14
+ page: string;
15
+ /** Con `pageSize`: `{from}`, `{to}` y `{total}`. */
16
+ summaryRange: string;
17
+ /** Sin `pageSize`: `{total}`. */
18
+ summaryTotal: string;
19
+ /** Indicador del celular con `compactOnMobile`: `{page}` y `{count}`. */
20
+ mobilePage: string;
21
+ }
22
+ /** Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos. */
23
+ export declare const DEFAULT_PAGINATION_LABELS: PaginationLabels;
6
24
  export interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
7
25
  /** Total number of pages */
8
26
  count?: number;
@@ -38,6 +56,22 @@ export interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>,
38
56
  variant?: PaginationVariant;
39
57
  /** Custom render function for items */
40
58
  renderItem?: (item: PaginationItemType) => React.ReactNode;
59
+ /**
60
+ * Total de registros. Muestra un resumen junto a la paginación:
61
+ * "Mostrando 1–50 de 230" si se indica `pageSize`, o "230 en total".
62
+ */
63
+ totalCount?: number;
64
+ /** Registros por página, para calcular el rango del resumen. */
65
+ pageSize?: number;
66
+ /**
67
+ * En pantallas angostas (< 640 px) oculta los números y muestra solo
68
+ * anterior/siguiente con el indicador "3 / 10".
69
+ */
70
+ compactOnMobile?: boolean;
71
+ /** No muestra nada cuando hay una sola página (o ninguna). */
72
+ hideWhenSinglePage?: boolean;
73
+ /** Textos de la interfaz; por defecto en español. */
74
+ labels?: Partial<PaginationLabels>;
41
75
  }
42
76
  export interface PaginationItemType {
43
77
  page: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../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K,CAAC,SAAS,CAAC;IAC3D;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qDAAqD;IACrD,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpC;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,qFA0Kf,CAAC;AAIF,eAAe,UAAU,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { type UiMessages } from "@rubenpazch/shared";
2
3
  import type { PaginationShape, PaginationSize, PaginationVariant } from "./Pagination";
3
4
  export interface PaginationItemProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type"> {
4
5
  /** The page number */
@@ -13,6 +14,8 @@ export interface PaginationItemProps extends Omit<React.ButtonHTMLAttributes<HTM
13
14
  size?: PaginationSize;
14
15
  /** The variant to use */
15
16
  variant?: PaginationVariant;
17
+ /** Textos (por defecto, los del idioma activo): `first`, `last`, `next`, `previous`, `page`. */
18
+ labels?: Partial<UiMessages["pagination"]>;
16
19
  }
17
20
  declare const PaginationItem: React.ForwardRefExoticComponent<PaginationItemProps & React.RefAttributes<HTMLButtonElement>>;
18
21
  export default PaginationItem;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"PaginationItem.d.ts","sourceRoot":"","sources":["../src/PaginationItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAE5B,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;IAC5B,gGAAgG;IAChG,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;CAC5C;AAWD,QAAA,MAAM,cAAc,+FA0InB,CAAC;AAIF,eAAe,cAAc,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -496,7 +496,8 @@ const iconSizeMap = {
496
496
  medium: "md",
497
497
  large: "lg",
498
498
  };
499
- const PaginationItem = React.forwardRef(({ page, type, selected = false, disabled = false, shape = "rounded", size: sizeProp = "medium", variant = "text", className, ...props }, ref) => {
499
+ const PaginationItem = React.forwardRef(({ page, type, selected = false, disabled = false, shape = "rounded", size: sizeProp = "medium", variant = "text", className, labels, ...props }, ref) => {
500
+ const t = shared.useUiMessages("pagination", labels);
500
501
  const size = shared.toLegacySize(sizeProp);
501
502
  // Ellipsis are not interactive
502
503
  if (type === "start-ellipsis" || type === "end-ellipsis") {
@@ -536,21 +537,24 @@ const PaginationItem = React.forwardRef(({ page, type, selected = false, disable
536
537
  };
537
538
  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);
538
539
  return (jsxRuntimeExports.jsx("button", { ref: ref, type: "button", className: classes, disabled: disabled, "aria-label": type === "first"
539
- ? "Ir a la primera página"
540
+ ? t.first
540
541
  : type === "last"
541
- ? "Ir a la última página"
542
+ ? t.last
542
543
  : type === "next"
543
- ? "Página siguiente"
544
+ ? t.next
544
545
  : type === "previous"
545
- ? "Página anterior"
546
- : `Página ${page}`, "aria-current": selected ? "page" : undefined, ...props, children: getButtonContent() }));
546
+ ? t.previous
547
+ : shared.formatMessage(t.page, { page }), "aria-current": selected ? "page" : undefined, ...props, children: getButtonContent() }));
547
548
  });
548
549
  PaginationItem.displayName = "PaginationItem";
549
550
 
550
- var css_248z = "/* Pagination root */\n.Pagination-module_root__aWgof {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.Pagination-module_ul__MfLr5 {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0;\n margin: 0;\n list-style: none;\n gap: 4px;\n}\n";
551
- var styles = {"root":"Pagination-module_root__aWgof","ul":"Pagination-module_ul__MfLr5"};
551
+ var css_248z = "/* Pagination root */\n.Pagination-module_root__aWgof {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.Pagination-module_ul__MfLr5 {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0;\n margin: 0;\n list-style: none;\n gap: 4px;\n}\n\n.Pagination-module_root__aWgof {\n flex-wrap: wrap;\n gap: var(--lb-space-3);\n}\n\n/* Resumen \"Mostrando 1–50 de 230\" */\n.Pagination-module_summary__BlA-j {\n margin: 0;\n font-size: var(--lb-font-size-sm);\n color: var(--lb-color-muted-foreground);\n}\n\n/* Indicador \"3 / 10\": solo en el celular con compactOnMobile */\n.Pagination-module_mobilePage__GRZee {\n display: none;\n padding: 0 var(--lb-space-3);\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-foreground);\n}\n\n@media (max-width: 639px) {\n .Pagination-module_compactOnMobile__jNDTZ .Pagination-module_numbered__5gmrn {\n display: none;\n }\n\n .Pagination-module_compactOnMobile__jNDTZ .Pagination-module_mobilePage__GRZee {\n display: list-item;\n list-style: none;\n }\n}\n";
552
+ var styles = {"root":"Pagination-module_root__aWgof","ul":"Pagination-module_ul__MfLr5","summary":"Pagination-module_summary__BlA-j","mobilePage":"Pagination-module_mobilePage__GRZee","compactOnMobile":"Pagination-module_compactOnMobile__jNDTZ","numbered":"Pagination-module_numbered__5gmrn"};
552
553
  styleInject(css_248z);
553
554
 
555
+ /** Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos. */
556
+ shared.uiMessagesEs.pagination;
557
+ const interpolate = (template, values) => template.replace(/\{(\w+)\}/g, (_, key) => String(values[key] ?? ""));
554
558
  const classNames = (...classes) => classes.filter(Boolean).join(" ");
555
559
  // Utility to generate pagination items
556
560
  const usePagination = (props) => {
@@ -626,7 +630,7 @@ const usePagination = (props) => {
626
630
  }
627
631
  return items;
628
632
  };
629
- 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) => {
633
+ const Pagination = React.forwardRef(({ count = 1, page: controlledPage, defaultPage = 1, onChange, onPageChange, "aria-label": ariaLabelProp, disabled = false, hideNextButton = false, hidePrevButton = false, showFirstButton = false, showLastButton = false, boundaryCount = 1, siblingCount = 1, shape = "rounded", size: sizeProp = "medium", variant = "text", renderItem, className, totalCount, pageSize, compactOnMobile = false, hideWhenSinglePage = false, labels: labelsProp, ...props }, ref) => {
630
634
  const size = shared.toLegacySize(sizeProp);
631
635
  const [page, setPage] = React.useState(defaultPage);
632
636
  const currentPage = controlledPage ?? page;
@@ -649,50 +653,78 @@ const Pagination = React.forwardRef(({ count = 1, page: controlledPage, defaultP
649
653
  hideNextButton,
650
654
  hidePrevButton,
651
655
  });
652
- const classes = classNames(styles.root, className);
653
- return (jsxRuntimeExports.jsx("nav", { ref: ref, className: classes, "aria-label": ariaLabel, ...props, children: jsxRuntimeExports.jsx("ul", { className: styles.ul, children: items.map((item, index) => {
654
- const isDisabled = disabled || item.disabled;
655
- if (renderItem) {
656
- return (jsxRuntimeExports.jsx("li", { children: renderItem({
657
- ...item,
658
- disabled: isDisabled,
659
- onClick: (e) => {
660
- if (!isDisabled && item.type === "page") {
661
- handleClick(e, item.page);
662
- }
663
- else if (!isDisabled && item.type === "next") {
664
- handleClick(e, Math.min(count, currentPage + 1));
665
- }
666
- else if (!isDisabled && item.type === "previous") {
667
- handleClick(e, Math.max(1, currentPage - 1));
668
- }
669
- else if (!isDisabled && item.type === "first") {
670
- handleClick(e, 1);
671
- }
672
- else if (!isDisabled && item.type === "last") {
673
- handleClick(e, count);
674
- }
675
- },
676
- }) }, index));
677
- }
678
- return (jsxRuntimeExports.jsx("li", { children: jsxRuntimeExports.jsx(PaginationItem, { ...item, disabled: isDisabled, shape: shape, size: size, variant: variant, onClick: (e) => {
679
- if (!isDisabled && item.type === "page") {
680
- handleClick(e, item.page);
681
- }
682
- else if (!isDisabled && item.type === "next") {
683
- handleClick(e, Math.min(count, currentPage + 1));
684
- }
685
- else if (!isDisabled && item.type === "previous") {
686
- handleClick(e, Math.max(1, currentPage - 1));
687
- }
688
- else if (!isDisabled && item.type === "first") {
689
- handleClick(e, 1);
690
- }
691
- else if (!isDisabled && item.type === "last") {
692
- handleClick(e, count);
693
- }
694
- } }) }, index));
695
- }) }) }));
656
+ const labels = shared.useUiMessages("pagination", labelsProp);
657
+ const { intlLocale } = shared.useUiLocale();
658
+ const ariaLabel = ariaLabelProp ?? labels.label;
659
+ const classes = classNames(styles.root, compactOnMobile ? styles.compactOnMobile : undefined, className);
660
+ if (hideWhenSinglePage && count <= 1)
661
+ return null;
662
+ let summary;
663
+ if (totalCount !== undefined) {
664
+ if (pageSize && pageSize > 0) {
665
+ const from = totalCount === 0 ? 0 : (currentPage - 1) * pageSize + 1;
666
+ const to = Math.min(currentPage * pageSize, totalCount);
667
+ summary = interpolate(labels.summaryRange, {
668
+ from: from.toLocaleString(intlLocale),
669
+ to: to.toLocaleString(intlLocale),
670
+ total: totalCount.toLocaleString(intlLocale),
671
+ });
672
+ }
673
+ else {
674
+ summary = interpolate(labels.summaryTotal, {
675
+ total: totalCount.toLocaleString(intlLocale),
676
+ });
677
+ }
678
+ }
679
+ const isNumbered = (type) => type === "page" || type === "start-ellipsis" || type === "end-ellipsis";
680
+ const mobileIndicator = compactOnMobile ? (jsxRuntimeExports.jsx("li", { className: styles.mobilePage, "aria-hidden": "true", children: interpolate(labels.mobilePage, { page: currentPage, count }) })) : null;
681
+ return (jsxRuntimeExports.jsxs("nav", { ref: ref, className: classes, "aria-label": ariaLabel, ...props, children: [summary && (jsxRuntimeExports.jsx("p", { className: styles.summary, "aria-live": "polite", children: summary })), jsxRuntimeExports.jsx("ul", { className: styles.ul, children: items.map((item, index) => {
682
+ const isDisabled = disabled || item.disabled;
683
+ const itemClass = isNumbered(item.type)
684
+ ? styles.numbered
685
+ : undefined;
686
+ const after = item.type === "previous" ? mobileIndicator : null;
687
+ if (renderItem) {
688
+ return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx("li", { className: itemClass, children: renderItem({
689
+ ...item,
690
+ disabled: isDisabled,
691
+ onClick: (e) => {
692
+ if (!isDisabled && item.type === "page") {
693
+ handleClick(e, item.page);
694
+ }
695
+ else if (!isDisabled && item.type === "next") {
696
+ handleClick(e, Math.min(count, currentPage + 1));
697
+ }
698
+ else if (!isDisabled && item.type === "previous") {
699
+ handleClick(e, Math.max(1, currentPage - 1));
700
+ }
701
+ else if (!isDisabled && item.type === "first") {
702
+ handleClick(e, 1);
703
+ }
704
+ else if (!isDisabled && item.type === "last") {
705
+ handleClick(e, count);
706
+ }
707
+ },
708
+ }) }), after] }, index));
709
+ }
710
+ return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx("li", { className: itemClass, children: jsxRuntimeExports.jsx(PaginationItem, { ...item, labels: labelsProp, disabled: isDisabled, shape: shape, size: size, variant: variant, onClick: (e) => {
711
+ if (!isDisabled && item.type === "page") {
712
+ handleClick(e, item.page);
713
+ }
714
+ else if (!isDisabled && item.type === "next") {
715
+ handleClick(e, Math.min(count, currentPage + 1));
716
+ }
717
+ else if (!isDisabled && item.type === "previous") {
718
+ handleClick(e, Math.max(1, currentPage - 1));
719
+ }
720
+ else if (!isDisabled && item.type === "first") {
721
+ handleClick(e, 1);
722
+ }
723
+ else if (!isDisabled && item.type === "last") {
724
+ handleClick(e, count);
725
+ }
726
+ } }) }), after] }, index));
727
+ }) })] }));
696
728
  });
697
729
  Pagination.displayName = "Pagination";
698
730
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,26 @@
1
1
  import React from 'react';
2
+ import { UiMessages } from '@rubenpazch/shared';
2
3
 
3
4
  type PaginationShape = "rounded" | "circular";
4
5
  /** Tamaño: sm, md, lg (estándar) o small, medium, large. */
5
6
  type PaginationSize = "small" | "medium" | "large" | "sm" | "md" | "lg";
6
7
  type PaginationVariant = "text" | "outlined";
8
+ interface PaginationLabels {
9
+ /** Nombre del `<nav>` (si no se pasa `aria-label`). */
10
+ label: string;
11
+ /** Botones (lectores de pantalla); `page` lleva `{page}`. */
12
+ first: string;
13
+ last: string;
14
+ next: string;
15
+ previous: string;
16
+ page: string;
17
+ /** Con `pageSize`: `{from}`, `{to}` y `{total}`. */
18
+ summaryRange: string;
19
+ /** Sin `pageSize`: `{total}`. */
20
+ summaryTotal: string;
21
+ /** Indicador del celular con `compactOnMobile`: `{page}` y `{count}`. */
22
+ mobilePage: string;
23
+ }
7
24
  interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
8
25
  /** Total number of pages */
9
26
  count?: number;
@@ -39,6 +56,22 @@ interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>, "onCha
39
56
  variant?: PaginationVariant;
40
57
  /** Custom render function for items */
41
58
  renderItem?: (item: PaginationItemType) => React.ReactNode;
59
+ /**
60
+ * Total de registros. Muestra un resumen junto a la paginación:
61
+ * "Mostrando 1–50 de 230" si se indica `pageSize`, o "230 en total".
62
+ */
63
+ totalCount?: number;
64
+ /** Registros por página, para calcular el rango del resumen. */
65
+ pageSize?: number;
66
+ /**
67
+ * En pantallas angostas (< 640 px) oculta los números y muestra solo
68
+ * anterior/siguiente con el indicador "3 / 10".
69
+ */
70
+ compactOnMobile?: boolean;
71
+ /** No muestra nada cuando hay una sola página (o ninguna). */
72
+ hideWhenSinglePage?: boolean;
73
+ /** Textos de la interfaz; por defecto en español. */
74
+ labels?: Partial<PaginationLabels>;
42
75
  }
43
76
  interface PaginationItemType {
44
77
  page: number;
@@ -62,8 +95,10 @@ interface PaginationItemProps extends Omit<React.ButtonHTMLAttributes<HTMLButton
62
95
  size?: PaginationSize;
63
96
  /** The variant to use */
64
97
  variant?: PaginationVariant;
98
+ /** Textos (por defecto, los del idioma activo): `first`, `last`, `next`, `previous`, `page`. */
99
+ labels?: Partial<UiMessages["pagination"]>;
65
100
  }
66
101
  declare const PaginationItem: React.ForwardRefExoticComponent<PaginationItemProps & React.RefAttributes<HTMLButtonElement>>;
67
102
 
68
103
  export { Pagination, PaginationItem };
69
- export type { PaginationItemProps, PaginationItemType, PaginationProps, PaginationShape, PaginationSize, PaginationVariant };
104
+ export type { PaginationItemProps, PaginationItemType, PaginationLabels, PaginationProps, PaginationShape, PaginationSize, PaginationVariant };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EACV,eAAe,EACf,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EACV,eAAe,EACf,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { toLegacySize } from '@rubenpazch/shared';
2
+ import { useUiMessages, toLegacySize, formatMessage, uiMessagesEs, useUiLocale } from '@rubenpazch/shared';
3
3
 
4
4
  var jsxRuntime = {exports: {}};
5
5
 
@@ -494,7 +494,8 @@ const iconSizeMap = {
494
494
  medium: "md",
495
495
  large: "lg",
496
496
  };
497
- const PaginationItem = React.forwardRef(({ page, type, selected = false, disabled = false, shape = "rounded", size: sizeProp = "medium", variant = "text", className, ...props }, ref) => {
497
+ const PaginationItem = React.forwardRef(({ page, type, selected = false, disabled = false, shape = "rounded", size: sizeProp = "medium", variant = "text", className, labels, ...props }, ref) => {
498
+ const t = useUiMessages("pagination", labels);
498
499
  const size = toLegacySize(sizeProp);
499
500
  // Ellipsis are not interactive
500
501
  if (type === "start-ellipsis" || type === "end-ellipsis") {
@@ -534,21 +535,24 @@ const PaginationItem = React.forwardRef(({ page, type, selected = false, disable
534
535
  };
535
536
  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);
536
537
  return (jsxRuntimeExports.jsx("button", { ref: ref, type: "button", className: classes, disabled: disabled, "aria-label": type === "first"
537
- ? "Ir a la primera página"
538
+ ? t.first
538
539
  : type === "last"
539
- ? "Ir a la última página"
540
+ ? t.last
540
541
  : type === "next"
541
- ? "Página siguiente"
542
+ ? t.next
542
543
  : type === "previous"
543
- ? "Página anterior"
544
- : `Página ${page}`, "aria-current": selected ? "page" : undefined, ...props, children: getButtonContent() }));
544
+ ? t.previous
545
+ : formatMessage(t.page, { page }), "aria-current": selected ? "page" : undefined, ...props, children: getButtonContent() }));
545
546
  });
546
547
  PaginationItem.displayName = "PaginationItem";
547
548
 
548
- var css_248z = "/* Pagination root */\n.Pagination-module_root__aWgof {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.Pagination-module_ul__MfLr5 {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0;\n margin: 0;\n list-style: none;\n gap: 4px;\n}\n";
549
- var styles = {"root":"Pagination-module_root__aWgof","ul":"Pagination-module_ul__MfLr5"};
549
+ var css_248z = "/* Pagination root */\n.Pagination-module_root__aWgof {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.Pagination-module_ul__MfLr5 {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0;\n margin: 0;\n list-style: none;\n gap: 4px;\n}\n\n.Pagination-module_root__aWgof {\n flex-wrap: wrap;\n gap: var(--lb-space-3);\n}\n\n/* Resumen \"Mostrando 1–50 de 230\" */\n.Pagination-module_summary__BlA-j {\n margin: 0;\n font-size: var(--lb-font-size-sm);\n color: var(--lb-color-muted-foreground);\n}\n\n/* Indicador \"3 / 10\": solo en el celular con compactOnMobile */\n.Pagination-module_mobilePage__GRZee {\n display: none;\n padding: 0 var(--lb-space-3);\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-foreground);\n}\n\n@media (max-width: 639px) {\n .Pagination-module_compactOnMobile__jNDTZ .Pagination-module_numbered__5gmrn {\n display: none;\n }\n\n .Pagination-module_compactOnMobile__jNDTZ .Pagination-module_mobilePage__GRZee {\n display: list-item;\n list-style: none;\n }\n}\n";
550
+ var styles = {"root":"Pagination-module_root__aWgof","ul":"Pagination-module_ul__MfLr5","summary":"Pagination-module_summary__BlA-j","mobilePage":"Pagination-module_mobilePage__GRZee","compactOnMobile":"Pagination-module_compactOnMobile__jNDTZ","numbered":"Pagination-module_numbered__5gmrn"};
550
551
  styleInject(css_248z);
551
552
 
553
+ /** Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos. */
554
+ uiMessagesEs.pagination;
555
+ const interpolate = (template, values) => template.replace(/\{(\w+)\}/g, (_, key) => String(values[key] ?? ""));
552
556
  const classNames = (...classes) => classes.filter(Boolean).join(" ");
553
557
  // Utility to generate pagination items
554
558
  const usePagination = (props) => {
@@ -624,7 +628,7 @@ const usePagination = (props) => {
624
628
  }
625
629
  return items;
626
630
  };
627
- 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) => {
631
+ const Pagination = React.forwardRef(({ count = 1, page: controlledPage, defaultPage = 1, onChange, onPageChange, "aria-label": ariaLabelProp, disabled = false, hideNextButton = false, hidePrevButton = false, showFirstButton = false, showLastButton = false, boundaryCount = 1, siblingCount = 1, shape = "rounded", size: sizeProp = "medium", variant = "text", renderItem, className, totalCount, pageSize, compactOnMobile = false, hideWhenSinglePage = false, labels: labelsProp, ...props }, ref) => {
628
632
  const size = toLegacySize(sizeProp);
629
633
  const [page, setPage] = React.useState(defaultPage);
630
634
  const currentPage = controlledPage ?? page;
@@ -647,50 +651,78 @@ const Pagination = React.forwardRef(({ count = 1, page: controlledPage, defaultP
647
651
  hideNextButton,
648
652
  hidePrevButton,
649
653
  });
650
- const classes = classNames(styles.root, className);
651
- return (jsxRuntimeExports.jsx("nav", { ref: ref, className: classes, "aria-label": ariaLabel, ...props, children: jsxRuntimeExports.jsx("ul", { className: styles.ul, children: items.map((item, index) => {
652
- const isDisabled = disabled || item.disabled;
653
- if (renderItem) {
654
- return (jsxRuntimeExports.jsx("li", { children: renderItem({
655
- ...item,
656
- disabled: isDisabled,
657
- onClick: (e) => {
658
- if (!isDisabled && item.type === "page") {
659
- handleClick(e, item.page);
660
- }
661
- else if (!isDisabled && item.type === "next") {
662
- handleClick(e, Math.min(count, currentPage + 1));
663
- }
664
- else if (!isDisabled && item.type === "previous") {
665
- handleClick(e, Math.max(1, currentPage - 1));
666
- }
667
- else if (!isDisabled && item.type === "first") {
668
- handleClick(e, 1);
669
- }
670
- else if (!isDisabled && item.type === "last") {
671
- handleClick(e, count);
672
- }
673
- },
674
- }) }, index));
675
- }
676
- return (jsxRuntimeExports.jsx("li", { children: jsxRuntimeExports.jsx(PaginationItem, { ...item, disabled: isDisabled, shape: shape, size: size, variant: variant, onClick: (e) => {
677
- if (!isDisabled && item.type === "page") {
678
- handleClick(e, item.page);
679
- }
680
- else if (!isDisabled && item.type === "next") {
681
- handleClick(e, Math.min(count, currentPage + 1));
682
- }
683
- else if (!isDisabled && item.type === "previous") {
684
- handleClick(e, Math.max(1, currentPage - 1));
685
- }
686
- else if (!isDisabled && item.type === "first") {
687
- handleClick(e, 1);
688
- }
689
- else if (!isDisabled && item.type === "last") {
690
- handleClick(e, count);
691
- }
692
- } }) }, index));
693
- }) }) }));
654
+ const labels = useUiMessages("pagination", labelsProp);
655
+ const { intlLocale } = useUiLocale();
656
+ const ariaLabel = ariaLabelProp ?? labels.label;
657
+ const classes = classNames(styles.root, compactOnMobile ? styles.compactOnMobile : undefined, className);
658
+ if (hideWhenSinglePage && count <= 1)
659
+ return null;
660
+ let summary;
661
+ if (totalCount !== undefined) {
662
+ if (pageSize && pageSize > 0) {
663
+ const from = totalCount === 0 ? 0 : (currentPage - 1) * pageSize + 1;
664
+ const to = Math.min(currentPage * pageSize, totalCount);
665
+ summary = interpolate(labels.summaryRange, {
666
+ from: from.toLocaleString(intlLocale),
667
+ to: to.toLocaleString(intlLocale),
668
+ total: totalCount.toLocaleString(intlLocale),
669
+ });
670
+ }
671
+ else {
672
+ summary = interpolate(labels.summaryTotal, {
673
+ total: totalCount.toLocaleString(intlLocale),
674
+ });
675
+ }
676
+ }
677
+ const isNumbered = (type) => type === "page" || type === "start-ellipsis" || type === "end-ellipsis";
678
+ const mobileIndicator = compactOnMobile ? (jsxRuntimeExports.jsx("li", { className: styles.mobilePage, "aria-hidden": "true", children: interpolate(labels.mobilePage, { page: currentPage, count }) })) : null;
679
+ return (jsxRuntimeExports.jsxs("nav", { ref: ref, className: classes, "aria-label": ariaLabel, ...props, children: [summary && (jsxRuntimeExports.jsx("p", { className: styles.summary, "aria-live": "polite", children: summary })), jsxRuntimeExports.jsx("ul", { className: styles.ul, children: items.map((item, index) => {
680
+ const isDisabled = disabled || item.disabled;
681
+ const itemClass = isNumbered(item.type)
682
+ ? styles.numbered
683
+ : undefined;
684
+ const after = item.type === "previous" ? mobileIndicator : null;
685
+ if (renderItem) {
686
+ return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx("li", { className: itemClass, children: renderItem({
687
+ ...item,
688
+ disabled: isDisabled,
689
+ onClick: (e) => {
690
+ if (!isDisabled && item.type === "page") {
691
+ handleClick(e, item.page);
692
+ }
693
+ else if (!isDisabled && item.type === "next") {
694
+ handleClick(e, Math.min(count, currentPage + 1));
695
+ }
696
+ else if (!isDisabled && item.type === "previous") {
697
+ handleClick(e, Math.max(1, currentPage - 1));
698
+ }
699
+ else if (!isDisabled && item.type === "first") {
700
+ handleClick(e, 1);
701
+ }
702
+ else if (!isDisabled && item.type === "last") {
703
+ handleClick(e, count);
704
+ }
705
+ },
706
+ }) }), after] }, index));
707
+ }
708
+ return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx("li", { className: itemClass, children: jsxRuntimeExports.jsx(PaginationItem, { ...item, labels: labelsProp, disabled: isDisabled, shape: shape, size: size, variant: variant, onClick: (e) => {
709
+ if (!isDisabled && item.type === "page") {
710
+ handleClick(e, item.page);
711
+ }
712
+ else if (!isDisabled && item.type === "next") {
713
+ handleClick(e, Math.min(count, currentPage + 1));
714
+ }
715
+ else if (!isDisabled && item.type === "previous") {
716
+ handleClick(e, Math.max(1, currentPage - 1));
717
+ }
718
+ else if (!isDisabled && item.type === "first") {
719
+ handleClick(e, 1);
720
+ }
721
+ else if (!isDisabled && item.type === "last") {
722
+ handleClick(e, count);
723
+ }
724
+ } }) }), after] }, index));
725
+ }) })] }));
694
726
  });
695
727
  Pagination.displayName = "Pagination";
696
728
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/pagination",
3
- "version": "3.2.5",
3
+ "version": "3.4.0",
4
4
  "description": "Pagination component",
5
5
  "private": false,
6
6
  "main": "dist/index.cjs.js",
@@ -20,8 +20,8 @@
20
20
  "**/*.css"
21
21
  ],
22
22
  "dependencies": {
23
- "@rubenpazch/shared": "5.3.0",
24
- "@rubenpazch/icons": "6.5.0"
23
+ "@rubenpazch/icons": "6.6.1",
24
+ "@rubenpazch/shared": "5.4.0"
25
25
  },
26
26
  "exports": {
27
27
  ".": {