@m4l/components 9.1.90 → 9.1.91

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.
@@ -48,7 +48,7 @@ import { PagerProps } from './types';
48
48
  * ```
49
49
  * @author cesar - automatic
50
50
  * @createdAt 2025-01-15 17:01:04 - automatic
51
- * @updatedAt 2025-01-21 15:32:35 - automatic
51
+ * @updatedAt 2025-01-29 08:56:53 - automatic
52
52
  * @updatedUser cesar - automatic
53
53
  */
54
54
  export declare function Pager(props: PagerProps): import("react/jsx-runtime").JSX.Element;
@@ -13,8 +13,8 @@ function Pager(props) {
13
13
  page = 0,
14
14
  onPageChange,
15
15
  onRowsPerPageChange,
16
- labelRows = "Filas por página",
17
- labelOf = "de",
16
+ labelRows,
17
+ labelOf,
18
18
  size = "medium"
19
19
  } = props;
20
20
  const totalPages = useMemo(() => Math.max(1, Math.ceil(totalRecords / rowsPerPage)), [totalRecords, rowsPerPage]);
@@ -24,9 +24,12 @@ function Pager(props) {
24
24
  const currentPage = useMemo(() => {
25
25
  return Math.max(0, Math.min(page, totalPages - 1));
26
26
  }, [page, totalPages]);
27
- const formattedLabelDisplayedRows = useMemo(() => {
28
- return totalRecords === 0 ? `${getLabel(PAGER_DICTIONARY.no_records)}` : `${getLabel(PAGER_DICTIONARY.page)} ${currentPage + 1} ${labelOf} ${totalPages}`;
29
- }, [currentPage, totalPages, labelOf, totalRecords, getLabel]);
27
+ const memoizedLabelOf = useMemo(() => {
28
+ return labelOf ?? getLabel(PAGER_DICTIONARY.of);
29
+ }, [labelOf, getLabel]);
30
+ const memoizedLabelTotalRows = useMemo(() => {
31
+ return labelRows ?? getLabel(PAGER_DICTIONARY.total_rows);
32
+ }, [labelRows, getLabel]);
30
33
  const handleChangeRowsPerPage = (option) => {
31
34
  if (onRowsPerPageChange && option.value !== void 0) {
32
35
  onRowsPerPageChange(option.value);
@@ -47,11 +50,11 @@ function Pager(props) {
47
50
  rowsPerPageOptions,
48
51
  count: totalRecords,
49
52
  rowsPerPage,
50
- labelRowsPerPage: labelRows,
51
53
  page: currentPage,
52
54
  onPageChange: handleChangePage,
53
55
  onRowsPerPageChange: handleChangeRowsPerPage,
54
- labelDisplayedRows: () => formattedLabelDisplayedRows
56
+ labelOf: memoizedLabelOf,
57
+ labelTotalRows: memoizedLabelTotalRows
55
58
  }
56
59
  ) });
57
60
  }
@@ -8,5 +8,6 @@ export declare const PAGER_DICTIONARY: {
8
8
  readonly page: "pager.page";
9
9
  readonly no_records: "pager.no_records";
10
10
  readonly total_rows: "pager.total_rows";
11
+ readonly rows: "pager.rows";
11
12
  };
12
13
  export declare function getPagerComponentsDictionary(): string[];
@@ -7,7 +7,8 @@ const PAGER_DICTIONARY = {
7
7
  of: "pager.of",
8
8
  page: "pager.page",
9
9
  no_records: "pager.no_records",
10
- total_rows: "pager.total_rows"
10
+ total_rows: "pager.total_rows",
11
+ rows: "pager.rows"
11
12
  };
12
13
  function getPagerComponentsDictionary() {
13
14
  return ["pager"];
@@ -3,7 +3,7 @@ import { CustomTablePaginationProps } from './types';
3
3
  * CustomTablePagination component
4
4
  * @author cesar - automatic
5
5
  * @createdAt 2025-01-15 17:13:29 - automatic
6
- * @updatedAt 2025-01-22 12:52:40 - automatic
6
+ * @updatedAt 2025-01-28 14:04:43 - automatic
7
7
  * @updatedUser cesar - automatic
8
8
  */
9
9
  export declare const CustomTablePagination: (props: CustomTablePaginationProps) => import("react/jsx-runtime").JSX.Element;
@@ -13,7 +13,9 @@ const CustomTablePagination = (props) => {
13
13
  rowsPerPageOptions = [10, 25, 50, 100],
14
14
  onRowsPerPageChange,
15
15
  onPageChange,
16
- size
16
+ size,
17
+ labelOf,
18
+ labelTotalRows
17
19
  } = props;
18
20
  const [localRowsPerPage, setLocalRowsPerPage] = useState(rowsPerPage);
19
21
  const [localPage, setLocalPage] = useState(Math.max(0, page));
@@ -32,13 +34,17 @@ const CustomTablePagination = (props) => {
32
34
  const currentPage = useMemo(() => {
33
35
  return Math.max(0, Math.min(localPage, totalPages - 1));
34
36
  }, [localPage, totalPages]);
37
+ const memoizedLabelPage = useMemo(() => getLabel(PAGER_DICTIONARY.page), [getLabel]);
38
+ const memoizedLabelRows = useMemo(() => getLabel(PAGER_DICTIONARY.rows), [getLabel]);
39
+ const memoizedLabelRowsPerPage = useMemo(() => getLabel(PAGER_DICTIONARY.rows_per_page), [getLabel]);
40
+ const memoizedLabelNoRecords = useMemo(() => getLabel(PAGER_DICTIONARY.no_records), [getLabel]);
35
41
  const formattedLabelDisplayedRows = useMemo(() => {
36
42
  if (countTotal === 0) {
37
- return `${getLabel(PAGER_DICTIONARY.no_records)}`;
43
+ return memoizedLabelNoRecords;
38
44
  }
39
45
  const displayedPage = currentPage === 1 ? 1 : currentPage + 1;
40
- return `${getLabel(PAGER_DICTIONARY.page)} ${displayedPage} ${getLabel(PAGER_DICTIONARY.of)} ${totalPages}`;
41
- }, [currentPage, totalPages, countTotal, getLabel]);
46
+ return `${memoizedLabelPage} ${displayedPage} ${labelOf} ${totalPages}`;
47
+ }, [currentPage, totalPages, countTotal, labelOf, memoizedLabelPage, memoizedLabelNoRecords]);
42
48
  const handleChangeRowsPerPage = (option) => {
43
49
  const selectedValue = Number(option.id);
44
50
  const newTotalPages = Math.ceil(countTotal / selectedValue);
@@ -46,7 +52,7 @@ const CustomTablePagination = (props) => {
46
52
  setLocalRowsPerPage(selectedValue);
47
53
  setLocalPage(newPage);
48
54
  if (onRowsPerPageChange) {
49
- onRowsPerPageChange({ id: selectedValue, value: selectedValue, label: `${selectedValue} filas` });
55
+ onRowsPerPageChange({ id: selectedValue, value: selectedValue, label: `${selectedValue} ${memoizedLabelRows}` });
50
56
  }
51
57
  if (onPageChange) {
52
58
  onPageChange(null, newPage);
@@ -54,9 +60,9 @@ const CustomTablePagination = (props) => {
54
60
  };
55
61
  return /* @__PURE__ */ jsxs(Fragment, { children: [
56
62
  rowsPerPageOptions?.length > 1 ? /* @__PURE__ */ jsxs(Fragment, { children: [
57
- /* @__PURE__ */ jsx(TotalRowStyled, { skeletonWidth: 50, size, variant: "body", children: `${getLabel(PAGER_DICTIONARY.total_rows)}: ${countTotal}` }),
63
+ /* @__PURE__ */ jsx(TotalRowStyled, { skeletonWidth: 50, size, variant: "body", children: `${labelTotalRows}: ${countTotal}` }),
58
64
  /* @__PURE__ */ jsxs(LabelSelectContainerStyled, { children: [
59
- /* @__PURE__ */ jsx(RowsPerPageStyled, { skeletonWidth: 50, size, variant: "body", children: `${getLabel(PAGER_DICTIONARY.rows_per_page)}:` }),
65
+ /* @__PURE__ */ jsx(RowsPerPageStyled, { skeletonWidth: 50, size, variant: "body", children: `${memoizedLabelRowsPerPage}:` }),
60
66
  /* @__PURE__ */ jsx(
61
67
  Select,
62
68
  {
@@ -1,9 +1,46 @@
1
1
  import { LabelDisplayedRowsArgs, TablePaginationProps } from '@mui/material';
2
2
  import { selectOption } from '../../types';
3
3
  export type CustomTablePaginationProps = {
4
+ /**
5
+ * Label for the rows per page select.
6
+ * @deprecated Use `slotProps.select` instead.
7
+ * @createdAt 2025-01-27 15:42:54 - automatic
8
+ */
9
+ labelOf: string;
10
+ /**
11
+ * List of rows per page options.
12
+ * @author cesar - automatic
13
+ * @createdAt 2025-01-27 15:42:54 - automatic
14
+ * @updatedAt 2025-01-28 14:04:43 - automatic
15
+ * @updatedUser cesar - automatic
16
+ */
4
17
  rowsPerPageOptions: number[];
5
18
  onPageChange: (_event: unknown, newPage: number) => void;
6
- labelRowsPerPage: string;
19
+ /**
20
+ * Label rows per page.
21
+ * @deprecated Use `slotProps.select` instead.
22
+ * @createdAt 2025-01-27 15:42:54 - automatic
23
+ */
24
+ labelRowsPerPage?: string;
25
+ /**
26
+ * Label total rows.
27
+ * @createdAt 2025-01-27 17:28:22 - automatic
28
+ */
29
+ labelTotalRows?: string;
30
+ /**
31
+ * Total number of rows.
32
+ * @author cesar - automatic
33
+ * @createdAt 2025-01-27 15:42:54 - automatic
34
+ * @updatedAt 2025-01-28 14:04:43 - automatic
35
+ * @updatedUser cesar - automatic
36
+ */
7
37
  onRowsPerPageChange: (option: selectOption<number>) => void;
38
+ /**
39
+ * Labe displayed rows.
40
+ * @author cesar - automatic
41
+ * @createdAt 2025-01-27 15:42:54 - automatic
42
+ * @updatedAt 2025-01-28 14:04:43 - automatic
43
+ * @updatedUser cesar - automatic
44
+ */
8
45
  labelDisplayedRows?: (paginationInfo: LabelDisplayedRowsArgs) => string;
9
46
  } & Omit<TablePaginationProps, 'onPageChange' | 'onRowsPerPageChange' | 'ActionsComponent' | 'labelDisplayedRows'>;
@@ -1,9 +1,9 @@
1
1
  import { PagerActionsProps } from './types';
2
2
  /**
3
- * TODO: Documentar
3
+ * PagerActions component is a subcomponent of the Pager component that allows the user to navigate between different pages.
4
4
  * @author cesar - automatic
5
5
  * @createdAt 2025-01-15 17:13:29 - automatic
6
- * @updatedAt 2025-01-21 14:06:55 - automatic
6
+ * @updatedAt 2025-01-27 08:17:21 - automatic
7
7
  * @updatedUser cesar - automatic
8
8
  */
9
9
  export declare function PagerActions(props: PagerActionsProps): import("react/jsx-runtime").JSX.Element;
@@ -12,7 +12,20 @@ export interface PagerProps {
12
12
  page: number;
13
13
  onPageChange: (newPage: number) => void;
14
14
  onRowsPerPageChange: (newRowsPerPage: number) => void;
15
+ /**
16
+ * Label rows per page.
17
+ * @deprecated Use `slotProps.select` instead.
18
+ * @createdAt 2025-01-27 15:42:54 - automatic
19
+ * @author cesar - automatic
20
+ * @updatedAt 2025-01-27 15:51:21 - automatic
21
+ * @updatedUser cesar - automatic
22
+ */
15
23
  labelRows?: string;
24
+ /**
25
+ * Label for the rows per page select.
26
+ * @deprecated Use `slotProps.select` instead.
27
+ * @createdAt 2025-01-27 15:42:54 - automatic
28
+ */
16
29
  labelOf?: string;
17
30
  size?: Extract<Sizes, 'small' | 'medium'>;
18
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.1.90",
3
+ "version": "9.1.91",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0"