@m4l/components 9.1.80 → 9.1.82
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/components/DataGrid/dictionary.d.ts +1 -1
- package/components/DataGrid/dictionary.js +1 -1
- package/components/DataGrid/styles.js +1 -0
- package/components/DataGrid/subcomponents/Actions/index.d.ts +4 -0
- package/components/DataGrid/subcomponents/Actions/index.js +2 -5
- package/components/DataGrid/subcomponents/Actions/types.d.ts +1 -1
- package/components/Pager/Pager.d.ts +55 -0
- package/components/Pager/Pager.js +60 -0
- package/components/Pager/Pager.styles.d.ts +2 -0
- package/components/Pager/Pager.styles.js +129 -0
- package/components/Pager/constants.d.ts +1 -0
- package/components/Pager/constants.js +4 -0
- package/components/Pager/dicctionary.d.ts +12 -0
- package/components/Pager/dicctionary.js +18 -0
- package/components/Pager/slots/PagerEnum.d.ts +10 -0
- package/components/Pager/slots/PagerEnum.js +14 -0
- package/components/Pager/slots/PagerSlots.d.ts +7 -0
- package/components/Pager/slots/PagerSlots.js +42 -0
- package/components/Pager/slots/index.d.ts +2 -0
- package/components/Pager/slots/index.js +1 -0
- package/components/Pager/subcomponents/CustomTablePagination/CustomTablePagination.d.ts +9 -0
- package/components/Pager/subcomponents/CustomTablePagination/CustomTablePagination.js +92 -0
- package/components/{mui_extended/Pager → Pager}/subcomponents/CustomTablePagination/types.d.ts +4 -5
- package/components/{mui_extended/Pager/subcomponents/PagerActions/index.d.ts → Pager/subcomponents/PagerActions/PagerActions.d.ts} +4 -0
- package/components/{mui_extended/Pager/subcomponents/PagerActions/index.js → Pager/subcomponents/PagerActions/PagerActions.js} +15 -7
- package/components/{mui_extended/Pager → Pager}/subcomponents/PagerActions/types.d.ts +2 -2
- package/components/Pager/tests/Pager.test.d.ts +1 -0
- package/components/Pager/types.d.ts +25 -0
- package/components/ToastContainer/ToastContainer.js +3 -4
- package/components/hook-form/RHFSelect/slots/RHFSlots.js +1 -1
- package/components/mui_extended/Select/Select.styles.js +17 -10
- package/components/mui_extended/index.d.ts +3 -3
- package/index.js +2 -2
- package/package.json +1 -1
- package/components/mui_extended/Pager/classes/constants.d.ts +0 -1
- package/components/mui_extended/Pager/classes/constants.js +0 -4
- package/components/mui_extended/Pager/classes/index.d.ts +0 -25
- package/components/mui_extended/Pager/classes/index.js +0 -55
- package/components/mui_extended/Pager/classes/types.d.ts +0 -18
- package/components/mui_extended/Pager/dicctionary.d.ts +0 -3
- package/components/mui_extended/Pager/dicctionary.js +0 -6
- package/components/mui_extended/Pager/index.d.ts +0 -6
- package/components/mui_extended/Pager/index.js +0 -49
- package/components/mui_extended/Pager/styles.d.ts +0 -1
- package/components/mui_extended/Pager/styles.js +0 -7
- package/components/mui_extended/Pager/subcomponents/CustomTablePagination/index.d.ts +0 -5
- package/components/mui_extended/Pager/subcomponents/CustomTablePagination/index.js +0 -96
- package/components/mui_extended/Pager/types.d.ts +0 -13
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* TODO: Documentar
|
|
3
3
|
* @author cesar - automatic
|
|
4
4
|
* @createdAt 2024-11-24 17:06:31 - automatic
|
|
5
|
-
* @updatedAt
|
|
5
|
+
* @updatedAt 2025-01-21 14:06:55 - automatic
|
|
6
6
|
* @updatedUser cesar - automatic
|
|
7
7
|
*/
|
|
8
8
|
export declare function getDataGridComponentsDictionary(): string[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as getModalDialogComponentsDictionary } from "../mui_extended/Dialog/dictionary.js";
|
|
2
|
-
import { g as getPagerComponentsDictionary } from "../
|
|
2
|
+
import { g as getPagerComponentsDictionary } from "../Pager/dicctionary.js";
|
|
3
3
|
function getDataGridComponentsDictionary() {
|
|
4
4
|
return ["data_grid"].concat(getPagerComponentsDictionary()).concat(getModalDialogComponentsDictionary());
|
|
5
5
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { InternalActionsProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* TODO: Documentar
|
|
4
|
+
* @author cesar - automatic
|
|
5
|
+
* @createdAt 2025-01-15 17:01:04 - automatic
|
|
6
|
+
* @updatedAt 2025-01-21 15:33:55 - automatic
|
|
7
|
+
* @updatedUser cesar - automatic
|
|
4
8
|
*/
|
|
5
9
|
export declare function Actions(props: InternalActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { P as Pager } from "../../../
|
|
2
|
+
import { P as Pager } from "../../../Pager/Pager.js";
|
|
3
3
|
import { F as Filter } from "./subcomponents/Filter/index.js";
|
|
4
4
|
import { S as Settings } from "./subcomponents/Settings/index.js";
|
|
5
5
|
import { R as RowsCount } from "./subcomponents/RowsCount/index.js";
|
|
6
6
|
import { D as Density } from "./subcomponents/Density/index.js";
|
|
7
7
|
import { u as useDataGrid } from "../../hooks/useDataGrid.js";
|
|
8
8
|
import { useResponsiveContainerStore } from "@m4l/graphics";
|
|
9
|
-
import {
|
|
9
|
+
import { useModuleDictionary } from "@m4l/core";
|
|
10
10
|
import { d as dictionary } from "../../dictionary.js";
|
|
11
11
|
import { shallow } from "zustand/shallow";
|
|
12
12
|
import { M as MobileMenuActions } from "./subcomponents/MobileMenuActions/index.js";
|
|
13
13
|
function Actions(props) {
|
|
14
14
|
const isXs = useResponsiveContainerStore((state) => state.isXs, shallow);
|
|
15
15
|
const { rowHeights, classes } = useDataGrid();
|
|
16
|
-
const isSkeleton = useModuleSkeleton();
|
|
17
16
|
const { getLabel } = useModuleDictionary();
|
|
18
17
|
const {
|
|
19
18
|
withRowsCount = true,
|
|
@@ -30,8 +29,6 @@ function Actions(props) {
|
|
|
30
29
|
{
|
|
31
30
|
...pagerOptions,
|
|
32
31
|
totalRecords: pagerOptions.totalRecords,
|
|
33
|
-
isSkeleton,
|
|
34
|
-
isXs,
|
|
35
32
|
labelRows: getLabel(dictionary.LABEL_ROWS_PER_PAGE),
|
|
36
33
|
labelOf: getLabel(dictionary.LABEL_OF)
|
|
37
34
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PagerProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* El componente `Pager` es un componente de paginación que permite navegar entre diferentes páginas
|
|
4
|
+
* y controlar la cantidad de filas mostradas por página en una tabla o lista de registros.
|
|
5
|
+
* ### Funcionalidades principales:
|
|
6
|
+
* - Permite cambiar la página actual mediante el evento `onPageChange`.
|
|
7
|
+
* - Ofrece un menú desplegable para seleccionar la cantidad de filas mostradas por página.
|
|
8
|
+
* - Muestra el total de registros y la página actual de forma descriptiva.
|
|
9
|
+
*
|
|
10
|
+
* ### Propiedades:
|
|
11
|
+
* - **`totalRecords`**: Número total de registros disponibles para paginar.
|
|
12
|
+
* - **`rowsPerPageOptions`**: Opciones disponibles para la cantidad de filas por página (e.g., [5, 10, 25]).
|
|
13
|
+
* - **`rowsPerPage`**: Cantidad actual de filas por página.
|
|
14
|
+
* - **`page`**: Página actualmente seleccionada (índice basado en cero).
|
|
15
|
+
* - **`onPageChange`**: Función que se invoca cuando el usuario cambia de página.
|
|
16
|
+
* - **`onRowsPerPageChange`**: Función que se invoca cuando el usuario selecciona una nueva cantidad de filas por página.
|
|
17
|
+
* - **`labelRows`**: Etiqueta para el selector de filas por página.
|
|
18
|
+
* - **`labelOf`**: Etiqueta utilizada entre la página actual y el total de páginas.
|
|
19
|
+
* - **`size`**: Tamaño del componente (`small` o `medium`).
|
|
20
|
+
*
|
|
21
|
+
* ### Dependencias:
|
|
22
|
+
* - **`useComponentSize:`** Hook para determinar el tamaño del componente basado en el entorno o configuración.
|
|
23
|
+
* @param {PagerProps} props - Propiedades del componente.
|
|
24
|
+
* @param {number} props.totalRecords - Número total de registros disponibles.
|
|
25
|
+
* @param {number[]} props.rowsPerPageOptions - Opciones de filas por página disponibles.
|
|
26
|
+
* @param {number} props.rowsPerPage - Cantidad actual de filas por página.
|
|
27
|
+
* @param {number} props.page - Página actualmente seleccionada.
|
|
28
|
+
* @param {Function} props.onPageChange - Función que se invoca cuando el usuario cambia de página.
|
|
29
|
+
* @param {Function} props.onRowsPerPageChange - Función que se invoca cuando el usuario cambia la cantidad de filas por página.
|
|
30
|
+
* @param {string} props.labelRows - Etiqueta para el selector de filas por página.
|
|
31
|
+
* @param {string} props.labelOf - Etiqueta para mostrar entre la página actual y el total de páginas.
|
|
32
|
+
* @param {'small' | 'medium'} props.size - Tamaño del componente.
|
|
33
|
+
* @returns {JSX.Element} Elemento JSX que representa el componente de paginación.
|
|
34
|
+
*
|
|
35
|
+
* ### Ejemplo de uso:
|
|
36
|
+
* ```tsx
|
|
37
|
+
* <Pager
|
|
38
|
+
* totalRecords={100}
|
|
39
|
+
* rowsPerPageOptions={[5, 10, 20]}
|
|
40
|
+
* rowsPerPage={10}
|
|
41
|
+
* page={0}
|
|
42
|
+
* onPageChange={(newPage) => console.log('Nueva página:', newPage)}
|
|
43
|
+
* onRowsPerPageChange={(newRows) => console.log('Filas por página:', newRows)}
|
|
44
|
+
* labelRows="Filas por página"
|
|
45
|
+
* labelOf="de"
|
|
46
|
+
* size="medium"
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
* @author cesar - automatic
|
|
50
|
+
* @createdAt 2025-01-15 17:01:04 - automatic
|
|
51
|
+
* @updatedAt 2025-01-21 15:32:35 - automatic
|
|
52
|
+
* @updatedUser cesar - automatic
|
|
53
|
+
*/
|
|
54
|
+
export declare function Pager(props: PagerProps): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
export default Pager;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { C as CustomTablePagination } from "./subcomponents/CustomTablePagination/CustomTablePagination.js";
|
|
4
|
+
import { u as useComponentSize } from "../../hooks/useComponentSize/useComponentSize.js";
|
|
5
|
+
import { useModuleDictionary } from "@m4l/core";
|
|
6
|
+
import { P as PAGER_DICTIONARY } from "./dicctionary.js";
|
|
7
|
+
import { P as PagerRootStyled } from "./slots/PagerSlots.js";
|
|
8
|
+
function Pager(props) {
|
|
9
|
+
const {
|
|
10
|
+
totalRecords = 0,
|
|
11
|
+
rowsPerPageOptions = [5, 10, 25],
|
|
12
|
+
rowsPerPage = 25,
|
|
13
|
+
page = 0,
|
|
14
|
+
onPageChange,
|
|
15
|
+
onRowsPerPageChange,
|
|
16
|
+
labelRows = "Filas por página",
|
|
17
|
+
labelOf = "de",
|
|
18
|
+
size = "medium"
|
|
19
|
+
} = props;
|
|
20
|
+
const totalPages = useMemo(() => Math.max(1, Math.ceil(totalRecords / rowsPerPage)), [totalRecords, rowsPerPage]);
|
|
21
|
+
const { currentSize } = useComponentSize(size);
|
|
22
|
+
const { getLabel } = useModuleDictionary();
|
|
23
|
+
const normalizedSize = currentSize === "large" ? "medium" : currentSize;
|
|
24
|
+
const currentPage = useMemo(() => {
|
|
25
|
+
return Math.max(0, Math.min(page, totalPages - 1));
|
|
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]);
|
|
30
|
+
const handleChangeRowsPerPage = (option) => {
|
|
31
|
+
if (onRowsPerPageChange && option.value !== void 0) {
|
|
32
|
+
onRowsPerPageChange(option.value);
|
|
33
|
+
}
|
|
34
|
+
if (onPageChange) {
|
|
35
|
+
onPageChange(0);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handleChangePage = (_event, newPage) => {
|
|
39
|
+
if (onPageChange) {
|
|
40
|
+
onPageChange(newPage);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsx(PagerRootStyled, { size: normalizedSize, role: "Pager-root", children: /* @__PURE__ */ jsx(
|
|
44
|
+
CustomTablePagination,
|
|
45
|
+
{
|
|
46
|
+
size,
|
|
47
|
+
rowsPerPageOptions,
|
|
48
|
+
count: totalRecords,
|
|
49
|
+
rowsPerPage,
|
|
50
|
+
labelRowsPerPage: labelRows,
|
|
51
|
+
page: currentPage,
|
|
52
|
+
onPageChange: handleChangePage,
|
|
53
|
+
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
54
|
+
labelDisplayedRows: () => formattedLabelDisplayedRows
|
|
55
|
+
}
|
|
56
|
+
) });
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
Pager as P
|
|
60
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const CONTAINER_QUERY_NAME = "container";
|
|
2
|
+
const pagerStyles = {
|
|
3
|
+
/**
|
|
4
|
+
* Root Pager Styles
|
|
5
|
+
* @author cesar - automatic
|
|
6
|
+
* @createdAt 2025-01-15 16:56:00 - automatic
|
|
7
|
+
* @updatedAt 2025-01-22 15:38:32 - automatic
|
|
8
|
+
* @updatedUser cesar - automatic
|
|
9
|
+
*/
|
|
10
|
+
root: ({ theme }) => ({
|
|
11
|
+
display: "flex",
|
|
12
|
+
flexDirection: "row",
|
|
13
|
+
justifyContent: "space-between",
|
|
14
|
+
alignItems: "baseline",
|
|
15
|
+
whiteSpace: "nowrap",
|
|
16
|
+
overflow: "hidden",
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
gap: theme.vars.size.baseSpacings.sp2,
|
|
19
|
+
[`@container ${CONTAINER_QUERY_NAME} (max-width: 400px)`]: {
|
|
20
|
+
overflowX: "auto",
|
|
21
|
+
whiteSpace: "nowrap",
|
|
22
|
+
flexWrap: "nowrap",
|
|
23
|
+
WebkitOverflowScrolling: "touch"
|
|
24
|
+
},
|
|
25
|
+
"& .M4LSelect-skeletonSelect": {
|
|
26
|
+
width: theme.vars.size.baseSpacings.sp14
|
|
27
|
+
},
|
|
28
|
+
"& .M4LTypography-skeleton": {
|
|
29
|
+
height: theme.vars.size.baseSpacings.sp8
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
/**
|
|
33
|
+
* Rows Per Page Container Styles
|
|
34
|
+
* @author cesar - automatic
|
|
35
|
+
* @createdAt 2025-01-16 15:54:48 - automatic
|
|
36
|
+
* @updatedAt 2025-01-22 15:38:32 - automatic
|
|
37
|
+
* @updatedUser cesar - automatic
|
|
38
|
+
*/
|
|
39
|
+
rowsPerPageContainer: () => ({
|
|
40
|
+
display: "flex",
|
|
41
|
+
flexDirection: "row",
|
|
42
|
+
alignItems: "center"
|
|
43
|
+
}),
|
|
44
|
+
/**
|
|
45
|
+
* Label Select Container Styles
|
|
46
|
+
* @author cesar - automatic
|
|
47
|
+
* @createdAt 2025-01-16 16:41:03 - automatic
|
|
48
|
+
* @updatedAt 2025-01-22 15:38:32 - automatic
|
|
49
|
+
* @updatedUser cesar - automatic
|
|
50
|
+
*/
|
|
51
|
+
labelSelectContainer: ({ theme }) => ({
|
|
52
|
+
display: "flex",
|
|
53
|
+
flexDirection: "row",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
gap: theme.vars.size.baseSpacings.sp2
|
|
56
|
+
}),
|
|
57
|
+
/**
|
|
58
|
+
* Actions Container Styles
|
|
59
|
+
* @author cesar - automatic
|
|
60
|
+
* @createdAt 2025-01-16 16:22:21 - automatic
|
|
61
|
+
* @updatedAt 2025-01-22 15:38:32 - automatic
|
|
62
|
+
* @updatedUser cesar - automatic
|
|
63
|
+
*/
|
|
64
|
+
actionsContainer: ({ theme }) => ({
|
|
65
|
+
display: "flex",
|
|
66
|
+
flexDirection: "row",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
gap: theme.vars.size.baseSpacings.sp2
|
|
69
|
+
}),
|
|
70
|
+
/**
|
|
71
|
+
* Pager Icons Container Styles
|
|
72
|
+
* @author cesar - automatic
|
|
73
|
+
* @createdAt 2025-01-16 16:41:03 - automatic
|
|
74
|
+
* @updatedAt 2025-01-22 15:38:32 - automatic
|
|
75
|
+
* @updatedUser cesar - automatic
|
|
76
|
+
*/
|
|
77
|
+
pagerIcons: ({ theme }) => ({
|
|
78
|
+
display: "flex",
|
|
79
|
+
flexDirection: "row",
|
|
80
|
+
alignItems: "center",
|
|
81
|
+
gap: theme.vars.size.baseSpacings["sp0-5"]
|
|
82
|
+
}),
|
|
83
|
+
/**
|
|
84
|
+
* Total Filas elipsis Styles
|
|
85
|
+
* @author cesar - automatic
|
|
86
|
+
* @createdAt 2025-01-20 08:53:24 - automatic
|
|
87
|
+
* @updatedAt 2025-01-22 15:38:32 - automatic
|
|
88
|
+
* @updatedUser cesar - automatic
|
|
89
|
+
*/
|
|
90
|
+
totalRow: () => ({
|
|
91
|
+
textOverflow: "ellipsis",
|
|
92
|
+
whiteSpace: "nowrap",
|
|
93
|
+
overflow: "hidden",
|
|
94
|
+
[`@container ${CONTAINER_QUERY_NAME} (max-width: 400px)`]: {
|
|
95
|
+
display: "none"
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
/**
|
|
99
|
+
* Rows Per Page Styles
|
|
100
|
+
* @author cesar - automatic
|
|
101
|
+
* @createdAt 2025-01-22 12:52:40 - automatic
|
|
102
|
+
* @updatedAt 2025-01-22 15:38:32 - automatic
|
|
103
|
+
* @updatedUser cesar - automatic
|
|
104
|
+
*/
|
|
105
|
+
rowsPerPage: () => ({
|
|
106
|
+
[`@container ${CONTAINER_QUERY_NAME} (max-width: 400px)`]: {
|
|
107
|
+
display: "none"
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
/**
|
|
111
|
+
* Page Counter Styles
|
|
112
|
+
* @author cesar - automatic
|
|
113
|
+
* @createdAt 2025-01-22 12:52:40 - automatic
|
|
114
|
+
* @updatedAt 2025-01-22 15:38:32 - automatic
|
|
115
|
+
* @updatedUser cesar - automatic
|
|
116
|
+
*/
|
|
117
|
+
pageCounter: () => ({
|
|
118
|
+
[`& @container ${CONTAINER_QUERY_NAME} (max-width: 200px)`]: {
|
|
119
|
+
overflow: "hidden",
|
|
120
|
+
whiteSpace: "nowrap",
|
|
121
|
+
textOverflow: "ellipsis",
|
|
122
|
+
maxWidth: "100%",
|
|
123
|
+
display: "inline-block"
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
};
|
|
127
|
+
export {
|
|
128
|
+
pagerStyles as p
|
|
129
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PAGER_KEY_COMPONENT = "M4LPager";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const PAGER_DICTIONARY: {
|
|
2
|
+
readonly rows_per_page: "pager.rows_per_page";
|
|
3
|
+
readonly first: "pager.first";
|
|
4
|
+
readonly previous: "pager.previous";
|
|
5
|
+
readonly before: "pager.before";
|
|
6
|
+
readonly last: "pager.last";
|
|
7
|
+
readonly of: "pager.of";
|
|
8
|
+
readonly page: "pager.page";
|
|
9
|
+
readonly no_records: "pager.no_records";
|
|
10
|
+
readonly total_rows: "pager.total_rows";
|
|
11
|
+
};
|
|
12
|
+
export declare function getPagerComponentsDictionary(): string[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const PAGER_DICTIONARY = {
|
|
2
|
+
rows_per_page: "pager.rows_per_page",
|
|
3
|
+
first: "pager.first",
|
|
4
|
+
previous: "pager.previous",
|
|
5
|
+
before: "pager.before",
|
|
6
|
+
last: "pager.last",
|
|
7
|
+
of: "pager.of",
|
|
8
|
+
page: "pager.page",
|
|
9
|
+
no_records: "pager.no_records",
|
|
10
|
+
total_rows: "pager.total_rows"
|
|
11
|
+
};
|
|
12
|
+
function getPagerComponentsDictionary() {
|
|
13
|
+
return ["pager"];
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
PAGER_DICTIONARY as P,
|
|
17
|
+
getPagerComponentsDictionary as g
|
|
18
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum PagerSlots {
|
|
2
|
+
root = "root",
|
|
3
|
+
rowsPerPageContainer = "rowsPerPageContainer",
|
|
4
|
+
actionsContainer = "actionsContainer",
|
|
5
|
+
labelSelectContainer = "labelSelectContainer",
|
|
6
|
+
pagerIcons = "pagerIcons",
|
|
7
|
+
totalRow = "totalRow",
|
|
8
|
+
rowsPerPage = "rowsPerPage",
|
|
9
|
+
pageCounter = "pageCounter"
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var PagerSlots = /* @__PURE__ */ ((PagerSlots2) => {
|
|
2
|
+
PagerSlots2["root"] = "root";
|
|
3
|
+
PagerSlots2["rowsPerPageContainer"] = "rowsPerPageContainer";
|
|
4
|
+
PagerSlots2["actionsContainer"] = "actionsContainer";
|
|
5
|
+
PagerSlots2["labelSelectContainer"] = "labelSelectContainer";
|
|
6
|
+
PagerSlots2["pagerIcons"] = "pagerIcons";
|
|
7
|
+
PagerSlots2["totalRow"] = "totalRow";
|
|
8
|
+
PagerSlots2["rowsPerPage"] = "rowsPerPage";
|
|
9
|
+
PagerSlots2["pageCounter"] = "pageCounter";
|
|
10
|
+
return PagerSlots2;
|
|
11
|
+
})(PagerSlots || {});
|
|
12
|
+
export {
|
|
13
|
+
PagerSlots as P
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PagerRootStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').HTMLAttributes<HTMLDivElement> | keyof import('react').ClassAttributes<HTMLDivElement>>, {}>;
|
|
2
|
+
export declare const ActionsContainerStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').HTMLAttributes<HTMLDivElement> | keyof import('react').ClassAttributes<HTMLDivElement>>, {}>;
|
|
3
|
+
export declare const LabelSelectContainerStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').HTMLAttributes<HTMLDivElement> | keyof import('react').ClassAttributes<HTMLDivElement>>, {}>;
|
|
4
|
+
export declare const PagerIconsStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').HTMLAttributes<HTMLDivElement> | keyof import('react').ClassAttributes<HTMLDivElement>>, {}>;
|
|
5
|
+
export declare const TotalRowStyled: import('@emotion/styled').StyledComponent<Pick<import('../../mui_extended/Typography/types').TypographyProps, keyof import('../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, {}, {}>;
|
|
6
|
+
export declare const RowsPerPageStyled: import('@emotion/styled').StyledComponent<Pick<import('../../mui_extended/Typography/types').TypographyProps, keyof import('../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, {}, {}>;
|
|
7
|
+
export declare const PageCounterStyled: import('@emotion/styled').StyledComponent<Pick<import('../../mui_extended/Typography/types').TypographyProps, keyof import('../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, {}, {}>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { styled } from "@mui/material/styles";
|
|
2
|
+
import { P as PAGER_KEY_COMPONENT } from "../constants.js";
|
|
3
|
+
import { p as pagerStyles } from "../Pager.styles.js";
|
|
4
|
+
import { P as PagerSlots } from "./PagerEnum.js";
|
|
5
|
+
import { T as Typography } from "../../mui_extended/Typography/Typography.js";
|
|
6
|
+
const PagerRootStyled = styled("div", {
|
|
7
|
+
name: PAGER_KEY_COMPONENT,
|
|
8
|
+
slot: PagerSlots.root
|
|
9
|
+
})(pagerStyles?.root);
|
|
10
|
+
const ActionsContainerStyled = styled("div", {
|
|
11
|
+
name: PAGER_KEY_COMPONENT,
|
|
12
|
+
slot: PagerSlots.actionsContainer
|
|
13
|
+
})(pagerStyles?.actionsContainer);
|
|
14
|
+
const LabelSelectContainerStyled = styled("div", {
|
|
15
|
+
name: PAGER_KEY_COMPONENT,
|
|
16
|
+
slot: PagerSlots.labelSelectContainer
|
|
17
|
+
})(pagerStyles?.labelSelectContainer);
|
|
18
|
+
const PagerIconsStyled = styled("div", {
|
|
19
|
+
name: PAGER_KEY_COMPONENT,
|
|
20
|
+
slot: PagerSlots.pagerIcons
|
|
21
|
+
})(pagerStyles?.pagerIcons);
|
|
22
|
+
const TotalRowStyled = styled(Typography, {
|
|
23
|
+
name: PAGER_KEY_COMPONENT,
|
|
24
|
+
slot: PagerSlots.totalRow
|
|
25
|
+
})(pagerStyles?.totalRow);
|
|
26
|
+
const RowsPerPageStyled = styled(Typography, {
|
|
27
|
+
name: PAGER_KEY_COMPONENT,
|
|
28
|
+
slot: PagerSlots.rowsPerPage
|
|
29
|
+
})(pagerStyles?.rowsPerPage);
|
|
30
|
+
const PageCounterStyled = styled(Typography, {
|
|
31
|
+
name: PAGER_KEY_COMPONENT,
|
|
32
|
+
slot: PagerSlots.pageCounter
|
|
33
|
+
})(pagerStyles?.pageCounter);
|
|
34
|
+
export {
|
|
35
|
+
ActionsContainerStyled as A,
|
|
36
|
+
LabelSelectContainerStyled as L,
|
|
37
|
+
PagerRootStyled as P,
|
|
38
|
+
RowsPerPageStyled as R,
|
|
39
|
+
TotalRowStyled as T,
|
|
40
|
+
PageCounterStyled as a,
|
|
41
|
+
PagerIconsStyled as b
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CustomTablePaginationProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* CustomTablePagination component
|
|
4
|
+
* @author cesar - automatic
|
|
5
|
+
* @createdAt 2025-01-15 17:13:29 - automatic
|
|
6
|
+
* @updatedAt 2025-01-22 12:52:40 - automatic
|
|
7
|
+
* @updatedUser cesar - automatic
|
|
8
|
+
*/
|
|
9
|
+
export declare const CustomTablePagination: (props: CustomTablePaginationProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { P as PagerActions } from "../PagerActions/PagerActions.js";
|
|
3
|
+
import { useState, useMemo, useEffect } from "react";
|
|
4
|
+
import { useModuleDictionary } from "@m4l/core";
|
|
5
|
+
import { P as PAGER_DICTIONARY } from "../../dicctionary.js";
|
|
6
|
+
import { T as TotalRowStyled, L as LabelSelectContainerStyled, R as RowsPerPageStyled, A as ActionsContainerStyled, a as PageCounterStyled } from "../../slots/PagerSlots.js";
|
|
7
|
+
import { S as Select } from "../../../mui_extended/Select/Select.js";
|
|
8
|
+
const CustomTablePagination = (props) => {
|
|
9
|
+
const {
|
|
10
|
+
count: countTotal,
|
|
11
|
+
page,
|
|
12
|
+
rowsPerPage = 25,
|
|
13
|
+
rowsPerPageOptions = [10, 25, 50, 100],
|
|
14
|
+
onRowsPerPageChange,
|
|
15
|
+
onPageChange,
|
|
16
|
+
size
|
|
17
|
+
} = props;
|
|
18
|
+
const [localRowsPerPage, setLocalRowsPerPage] = useState(rowsPerPage);
|
|
19
|
+
const [localPage, setLocalPage] = useState(Math.max(0, page));
|
|
20
|
+
const { getLabel } = useModuleDictionary();
|
|
21
|
+
const totalPages = useMemo(() => {
|
|
22
|
+
return Math.max(1, Math.ceil(countTotal / localRowsPerPage));
|
|
23
|
+
}, [countTotal, localRowsPerPage]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setLocalPage(Math.max(0, Math.min(page, totalPages - 1)));
|
|
26
|
+
}, [page, totalPages]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (rowsPerPageOptions.includes(rowsPerPage)) {
|
|
29
|
+
setLocalRowsPerPage(rowsPerPage);
|
|
30
|
+
}
|
|
31
|
+
}, [rowsPerPage, rowsPerPageOptions]);
|
|
32
|
+
const currentPage = useMemo(() => {
|
|
33
|
+
return Math.max(0, Math.min(localPage, totalPages - 1));
|
|
34
|
+
}, [localPage, totalPages]);
|
|
35
|
+
const formattedLabelDisplayedRows = useMemo(() => {
|
|
36
|
+
if (countTotal === 0) {
|
|
37
|
+
return `${getLabel(PAGER_DICTIONARY.no_records)}`;
|
|
38
|
+
}
|
|
39
|
+
const displayedPage = currentPage === 1 ? 1 : currentPage + 1;
|
|
40
|
+
return `${getLabel(PAGER_DICTIONARY.page)} ${displayedPage} ${getLabel(PAGER_DICTIONARY.of)} ${totalPages}`;
|
|
41
|
+
}, [currentPage, totalPages, countTotal, getLabel]);
|
|
42
|
+
const handleChangeRowsPerPage = (option) => {
|
|
43
|
+
const selectedValue = Number(option.id);
|
|
44
|
+
const newTotalPages = Math.ceil(countTotal / selectedValue);
|
|
45
|
+
const newPage = Math.min(currentPage, newTotalPages - 1);
|
|
46
|
+
setLocalRowsPerPage(selectedValue);
|
|
47
|
+
setLocalPage(newPage);
|
|
48
|
+
if (onRowsPerPageChange) {
|
|
49
|
+
onRowsPerPageChange({ id: selectedValue, value: selectedValue, label: `${selectedValue} filas` });
|
|
50
|
+
}
|
|
51
|
+
if (onPageChange) {
|
|
52
|
+
onPageChange(null, newPage);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
56
|
+
rowsPerPageOptions?.length > 1 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
57
|
+
/* @__PURE__ */ jsx(TotalRowStyled, { skeletonWidth: 50, size, variant: "body", children: `${getLabel(PAGER_DICTIONARY.total_rows)}: ${countTotal}` }),
|
|
58
|
+
/* @__PURE__ */ jsxs(LabelSelectContainerStyled, { children: [
|
|
59
|
+
/* @__PURE__ */ jsx(RowsPerPageStyled, { skeletonWidth: 50, size, variant: "body", children: `${getLabel(PAGER_DICTIONARY.rows_per_page)}:` }),
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
Select,
|
|
62
|
+
{
|
|
63
|
+
size,
|
|
64
|
+
value: rowsPerPageOptions.includes(localRowsPerPage) ? localRowsPerPage.toString() : rowsPerPageOptions[0].toString(),
|
|
65
|
+
onChange: (option) => handleChangeRowsPerPage(option),
|
|
66
|
+
options: rowsPerPageOptions.map((item) => ({
|
|
67
|
+
id: item.toString(),
|
|
68
|
+
value: item.toString(),
|
|
69
|
+
label: item.toString()
|
|
70
|
+
}))
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
] })
|
|
74
|
+
] }) : null,
|
|
75
|
+
/* @__PURE__ */ jsxs(ActionsContainerStyled, { children: [
|
|
76
|
+
/* @__PURE__ */ jsx(PageCounterStyled, { skeletonWidth: 50, size, variant: "body", children: formattedLabelDisplayedRows }),
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
PagerActions,
|
|
79
|
+
{
|
|
80
|
+
size,
|
|
81
|
+
count: countTotal,
|
|
82
|
+
page: currentPage,
|
|
83
|
+
rowsPerPage: localRowsPerPage,
|
|
84
|
+
onPageChange: (_, newPage) => setLocalPage(newPage)
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] })
|
|
88
|
+
] });
|
|
89
|
+
};
|
|
90
|
+
export {
|
|
91
|
+
CustomTablePagination as C
|
|
92
|
+
};
|
package/components/{mui_extended/Pager → Pager}/subcomponents/CustomTablePagination/types.d.ts
RENAMED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { LabelDisplayedRowsArgs,
|
|
2
|
-
import {
|
|
1
|
+
import { LabelDisplayedRowsArgs, TablePaginationProps } from '@mui/material';
|
|
2
|
+
import { selectOption } from '../../types';
|
|
3
3
|
export type CustomTablePaginationProps = {
|
|
4
4
|
rowsPerPageOptions: number[];
|
|
5
5
|
onPageChange: (_event: unknown, newPage: number) => void;
|
|
6
6
|
labelRowsPerPage: string;
|
|
7
|
-
|
|
8
|
-
onRowsPerPageChange: (event: SelectChangeEvent<unknown>) => void;
|
|
7
|
+
onRowsPerPageChange: (option: selectOption<number>) => void;
|
|
9
8
|
labelDisplayedRows?: (paginationInfo: LabelDisplayedRowsArgs) => string;
|
|
10
|
-
} & Omit<TablePaginationProps, 'onPageChange' | 'onRowsPerPageChange' | '
|
|
9
|
+
} & Omit<TablePaginationProps, 'onPageChange' | 'onRowsPerPageChange' | 'ActionsComponent' | 'labelDisplayedRows'>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { PagerActionsProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* TODO: Documentar
|
|
4
|
+
* @author cesar - automatic
|
|
5
|
+
* @createdAt 2025-01-15 17:13:29 - automatic
|
|
6
|
+
* @updatedAt 2025-01-21 14:06:55 - automatic
|
|
7
|
+
* @updatedUser cesar - automatic
|
|
4
8
|
*/
|
|
5
9
|
export declare function PagerActions(props: PagerActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { I as IconButton } from "../../../IconButton/IconButton.js";
|
|
2
|
+
import { I as IconButton } from "../../../mui_extended/IconButton/IconButton.js";
|
|
3
3
|
import { useEnvironment } from "@m4l/core";
|
|
4
|
+
import { b as PagerIconsStyled } from "../../slots/PagerSlots.js";
|
|
4
5
|
function PagerActions(props) {
|
|
5
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
size,
|
|
8
|
+
count,
|
|
9
|
+
page,
|
|
10
|
+
rowsPerPage,
|
|
11
|
+
onPageChange
|
|
12
|
+
//classes
|
|
13
|
+
} = props;
|
|
6
14
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
7
15
|
const handleFirstPageButtonClick = (event) => {
|
|
8
16
|
onPageChange(event, 0);
|
|
@@ -16,48 +24,48 @@ function PagerActions(props) {
|
|
|
16
24
|
const handleLastPageButtonClick = (event) => {
|
|
17
25
|
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
|
18
26
|
};
|
|
19
|
-
return /* @__PURE__ */ jsxs(
|
|
27
|
+
return /* @__PURE__ */ jsxs(PagerIconsStyled, { children: [
|
|
20
28
|
/* @__PURE__ */ jsx(
|
|
21
29
|
IconButton,
|
|
22
30
|
{
|
|
31
|
+
size,
|
|
23
32
|
dictionaryTooltipId: "pager.first",
|
|
24
33
|
onClick: handleFirstPageButtonClick,
|
|
25
34
|
disabled: page === 0,
|
|
26
35
|
"aria-label": "first page",
|
|
27
|
-
className: classes.actionIconFirstPage,
|
|
28
36
|
src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/first.svg`
|
|
29
37
|
}
|
|
30
38
|
),
|
|
31
39
|
/* @__PURE__ */ jsx(
|
|
32
40
|
IconButton,
|
|
33
41
|
{
|
|
42
|
+
size,
|
|
34
43
|
dictionaryTooltipId: "pager.previous",
|
|
35
44
|
onClick: handleBackButtonClick,
|
|
36
45
|
disabled: page === 0,
|
|
37
46
|
"aria-label": "first page",
|
|
38
|
-
className: classes.actionIconPrevious,
|
|
39
47
|
src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/previous.svg`
|
|
40
48
|
}
|
|
41
49
|
),
|
|
42
50
|
/* @__PURE__ */ jsx(
|
|
43
51
|
IconButton,
|
|
44
52
|
{
|
|
53
|
+
size,
|
|
45
54
|
dictionaryTooltipId: "pager.next",
|
|
46
55
|
onClick: handleNextButtonClick,
|
|
47
56
|
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
|
48
57
|
"aria-label": "next page",
|
|
49
|
-
className: classes.actionIconNextPage,
|
|
50
58
|
src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/next.svg`
|
|
51
59
|
}
|
|
52
60
|
),
|
|
53
61
|
/* @__PURE__ */ jsx(
|
|
54
62
|
IconButton,
|
|
55
63
|
{
|
|
64
|
+
size,
|
|
56
65
|
dictionaryTooltipId: "pager.last",
|
|
57
66
|
onClick: handleLastPageButtonClick,
|
|
58
67
|
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
|
59
68
|
"aria-label": "last page",
|
|
60
|
-
className: classes.actionIconLastPage,
|
|
61
69
|
src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/last.svg`
|
|
62
70
|
}
|
|
63
71
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Sizes } from '@m4l/styles';
|
|
2
2
|
export interface PagerActionsProps {
|
|
3
3
|
count: number;
|
|
4
4
|
page: number;
|
|
5
5
|
rowsPerPage: number;
|
|
6
6
|
onPageChange: (event: React.MouseEvent<HTMLButtonElement>, newPage: number) => void;
|
|
7
|
-
|
|
7
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
8
8
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Theme } from '@mui/material';
|
|
2
|
+
import { PAGER_KEY_COMPONENT } from './constants';
|
|
3
|
+
import { OverridesStyleRules } from '@mui/material/styles/overrides';
|
|
4
|
+
import { PagerSlots } from './slots/PagerEnum';
|
|
5
|
+
import { Sizes } from '@m4l/styles';
|
|
6
|
+
export type PagerType = keyof typeof PagerSlots;
|
|
7
|
+
export interface PagerProps {
|
|
8
|
+
records: number;
|
|
9
|
+
totalRecords: number;
|
|
10
|
+
rowsPerPageOptions?: number[];
|
|
11
|
+
rowsPerPage?: number;
|
|
12
|
+
page: number;
|
|
13
|
+
onPageChange: (newPage: number) => void;
|
|
14
|
+
onRowsPerPageChange: (newRowsPerPage: number) => void;
|
|
15
|
+
labelRows?: string;
|
|
16
|
+
labelOf?: string;
|
|
17
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
18
|
+
}
|
|
19
|
+
export type selectOption<T = unknown> = {
|
|
20
|
+
id: T;
|
|
21
|
+
label: string;
|
|
22
|
+
value?: T;
|
|
23
|
+
startAdornment?: React.ReactNode;
|
|
24
|
+
};
|
|
25
|
+
export type PagerStyles = OverridesStyleRules<PagerType, typeof PAGER_KEY_COMPONENT, Theme>;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ToastContainer as ToastContainer$1 } from "react-toastify";
|
|
3
3
|
import { T as TOAST_KEY_COMPONENT, D as DEFAULT_CLOSE_TIME } from "./constants.js";
|
|
4
4
|
import { g as getPropDataTestId } from "../../test/getNameDataTestId.js";
|
|
5
5
|
import "react-toastify/dist/ReactToastify.min.css";
|
|
6
|
-
import { A as AppearanceComponentProvider } from "../../contexts/AppearanceComponentContext/AppearanceComponentContext.js";
|
|
7
6
|
import { R as RootStyled } from "./slots/toastContainerSlots.js";
|
|
8
7
|
import { T as ToastContainerSlots } from "./slots/ToastContainerEnum.js";
|
|
9
8
|
const ToastContainer = (props) => {
|
|
10
9
|
const { children, fixed = true, dataTestId, ...restProps } = props;
|
|
11
10
|
const ownerState = { fixed };
|
|
12
|
-
return /* @__PURE__ */
|
|
11
|
+
return /* @__PURE__ */ jsxs(
|
|
13
12
|
RootStyled,
|
|
14
13
|
{
|
|
15
14
|
ownerState,
|
|
@@ -29,7 +28,7 @@ const ToastContainer = (props) => {
|
|
|
29
28
|
children
|
|
30
29
|
]
|
|
31
30
|
}
|
|
32
|
-
)
|
|
31
|
+
);
|
|
33
32
|
};
|
|
34
33
|
export {
|
|
35
34
|
ToastContainer as T
|
|
@@ -3,8 +3,8 @@ import { a as RHFSELECT_COMPONENT_KEY } from "../constants.js";
|
|
|
3
3
|
import { R as RHFSelectEnum } from "./RHFSelectEnum.js";
|
|
4
4
|
import { r as rhfSelectStyles } from "../RHFSelect.styles.js";
|
|
5
5
|
import { L as Label } from "../../../Label/Label.js";
|
|
6
|
-
import { S as Select } from "../../../mui_extended/Select/Select.js";
|
|
7
6
|
import { H as HelperError } from "../../../HelperError/HelperError.js";
|
|
7
|
+
import { S as Select } from "../../../mui_extended/Select/Select.js";
|
|
8
8
|
const RootStyled = styled("div", {
|
|
9
9
|
name: RHFSELECT_COMPONENT_KEY,
|
|
10
10
|
slot: RHFSelectEnum.root
|
|
@@ -5,8 +5,8 @@ const selectStyles = {
|
|
|
5
5
|
* Estilos para el componente Select
|
|
6
6
|
* @author Bruce Escobar - automatic
|
|
7
7
|
* @createdAt 2024-10-22 10:30:26 - automatic
|
|
8
|
-
* @updatedAt 2025-01-
|
|
9
|
-
* @updatedUser
|
|
8
|
+
* @updatedAt 2025-01-17 19:00:56 - automatic
|
|
9
|
+
* @updatedUser cesar - automatic
|
|
10
10
|
*/
|
|
11
11
|
root: ({ theme, ownerState }) => ({
|
|
12
12
|
[`&.${SELECT_CLASSES.root}`]: {
|
|
@@ -67,6 +67,13 @@ const selectStyles = {
|
|
|
67
67
|
"&:focus-within": {
|
|
68
68
|
borderColor: ownerState.paletteColor?.focus
|
|
69
69
|
},
|
|
70
|
+
'&[aria-hidden="true"]': {
|
|
71
|
+
pointerEvents: "none"
|
|
72
|
+
},
|
|
73
|
+
"&[inert]": {
|
|
74
|
+
pointerEvents: "none",
|
|
75
|
+
opacity: 0.5
|
|
76
|
+
},
|
|
70
77
|
...ownerState.error && {
|
|
71
78
|
borderColor: ownerState.paletteColor?.enabled,
|
|
72
79
|
"&:hover": {
|
|
@@ -100,8 +107,8 @@ const selectStyles = {
|
|
|
100
107
|
* @returns {object} The styles for the render option container
|
|
101
108
|
* @author SebastianM - automatic
|
|
102
109
|
* @createdAt 2024-12-18 15:11:13 - automatic
|
|
103
|
-
* @updatedAt 2025-01-
|
|
104
|
-
* @updatedUser
|
|
110
|
+
* @updatedAt 2025-01-17 19:00:56 - automatic
|
|
111
|
+
* @updatedUser cesar - automatic
|
|
105
112
|
*/
|
|
106
113
|
renderValueContainer: ({ theme }) => ({
|
|
107
114
|
display: "flex",
|
|
@@ -116,8 +123,8 @@ const selectStyles = {
|
|
|
116
123
|
* Styles for the label option
|
|
117
124
|
* @author SebastianM - automatic
|
|
118
125
|
* @createdAt 2024-12-23 10:47:53 - automatic
|
|
119
|
-
* @updatedAt 2025-01-
|
|
120
|
-
* @updatedUser
|
|
126
|
+
* @updatedAt 2025-01-17 19:00:56 - automatic
|
|
127
|
+
* @updatedUser cesar - automatic
|
|
121
128
|
*/
|
|
122
129
|
labelOption: ({ theme }) => ({
|
|
123
130
|
paddingLeft: theme.vars.size.baseSpacings.sp1,
|
|
@@ -128,8 +135,8 @@ const selectStyles = {
|
|
|
128
135
|
* @returns {object} The styles for the label placeholder
|
|
129
136
|
* @author SebastianM - automatic
|
|
130
137
|
* @createdAt 2024-12-26 14:16:33 - automatic
|
|
131
|
-
* @updatedAt 2025-01-
|
|
132
|
-
* @updatedUser
|
|
138
|
+
* @updatedAt 2025-01-17 19:00:56 - automatic
|
|
139
|
+
* @updatedUser cesar - automatic
|
|
133
140
|
*/
|
|
134
141
|
labelPlaceholer: ({ theme }) => ({
|
|
135
142
|
paddingLeft: theme.vars.size.baseSpacings.sp1
|
|
@@ -158,8 +165,8 @@ const selectStyles = {
|
|
|
158
165
|
* Styles for the skeleton select component
|
|
159
166
|
* @author SebastianM - automatic
|
|
160
167
|
* @createdAt 2024-12-17 15:54:22 - automatic
|
|
161
|
-
* @updatedAt 2025-01-
|
|
162
|
-
* @updatedUser
|
|
168
|
+
* @updatedAt 2025-01-17 19:00:56 - automatic
|
|
169
|
+
* @updatedUser cesar - automatic
|
|
163
170
|
*/
|
|
164
171
|
skeletonSelect: ({ theme, ownerState }) => ({
|
|
165
172
|
width: "100%",
|
|
@@ -19,9 +19,9 @@ export * from './Skeleton';
|
|
|
19
19
|
export * from './Stack';
|
|
20
20
|
export * from './Tabs';
|
|
21
21
|
export * from './TabContent';
|
|
22
|
-
export { Pager } from '
|
|
23
|
-
export type { PagerProps } from '
|
|
24
|
-
export { getPagerComponentsDictionary } from '
|
|
22
|
+
export { Pager } from '../Pager/Pager';
|
|
23
|
+
export type { PagerProps } from '../Pager/types';
|
|
24
|
+
export { getPagerComponentsDictionary } from '../Pager/dicctionary';
|
|
25
25
|
export { Tab } from './Tab/Tab';
|
|
26
26
|
export * from './TabContext';
|
|
27
27
|
export * from './Typography/Typography';
|
package/index.js
CHANGED
|
@@ -157,8 +157,8 @@ import { B as B5 } from "./components/mui_extended/Badge/Badge.js";
|
|
|
157
157
|
import { L as L9 } from "./components/mui_extended/LinearProgress/index.js";
|
|
158
158
|
import { L as L10 } from "./components/mui_extended/LinkWithRoute/index.js";
|
|
159
159
|
import { L as L11 } from "./components/mui_extended/LoadingButton/LoadingButton.js";
|
|
160
|
-
import { P as P14 } from "./components/
|
|
161
|
-
import { g as g25 } from "./components/
|
|
160
|
+
import { P as P14 } from "./components/Pager/Pager.js";
|
|
161
|
+
import { g as g25 } from "./components/Pager/dicctionary.js";
|
|
162
162
|
import { T as T6 } from "./components/mui_extended/Tab/Tab.js";
|
|
163
163
|
import { T as T7 } from "./components/mui_extended/Tooltip/Tooltip.js";
|
|
164
164
|
import { I as I6 } from "./components/mui_extended/IconButton/IconButton.js";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const componentName = "M4LPager";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { PagerClassesType } from './types';
|
|
2
|
-
export declare const pagerClasses: PagerClassesType;
|
|
3
|
-
export declare function getPagerUtilityClass(slot: string): string;
|
|
4
|
-
/**
|
|
5
|
-
* TODO: Documentar
|
|
6
|
-
*/
|
|
7
|
-
export declare const pagerUtilityClasses: () => {
|
|
8
|
-
select: string;
|
|
9
|
-
root: string;
|
|
10
|
-
labelRowsPerPageContainer: string;
|
|
11
|
-
labelRowsPager: string;
|
|
12
|
-
selectMenuPopover: string;
|
|
13
|
-
selectMenuItem: string;
|
|
14
|
-
labelDisplayRows: string;
|
|
15
|
-
pagerActions: string;
|
|
16
|
-
customTablePaginationRoot: string;
|
|
17
|
-
actionIconFirstPage: string;
|
|
18
|
-
actionIconPrevious: string;
|
|
19
|
-
actionIconNextPage: string;
|
|
20
|
-
actionIconLastPage: string;
|
|
21
|
-
skeletonRoot: string;
|
|
22
|
-
skeletonRowsPerPage: string;
|
|
23
|
-
skeletonButtonContainer: string;
|
|
24
|
-
skeletonIconButton: string;
|
|
25
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
2
|
-
import { unstable_composeClasses } from "@mui/base";
|
|
3
|
-
import { c as componentName } from "./constants.js";
|
|
4
|
-
generateUtilityClasses(componentName, [
|
|
5
|
-
/* elements */
|
|
6
|
-
"root",
|
|
7
|
-
"labelRowsPerPageContainer",
|
|
8
|
-
"labelRowsPager",
|
|
9
|
-
"select",
|
|
10
|
-
"selectMenuItem",
|
|
11
|
-
"selectMenuPopover",
|
|
12
|
-
"labelDisplayRows",
|
|
13
|
-
"pagerActions",
|
|
14
|
-
"customTablePaginationRoot",
|
|
15
|
-
"skeletonRoot",
|
|
16
|
-
"skeletonRowsPerPage",
|
|
17
|
-
"skeletonButtonContainer",
|
|
18
|
-
"skeletonIconButton",
|
|
19
|
-
"actionIconFirstPage",
|
|
20
|
-
"actionIconPrevious",
|
|
21
|
-
"actionIconNextPage",
|
|
22
|
-
"actionIconLastPage"
|
|
23
|
-
/* states or variants of elements */
|
|
24
|
-
]);
|
|
25
|
-
function getPagerUtilityClass(slot) {
|
|
26
|
-
return generateUtilityClass(componentName, slot);
|
|
27
|
-
}
|
|
28
|
-
const pagerUtilityClasses = () => {
|
|
29
|
-
const slots = {
|
|
30
|
-
root: ["root"],
|
|
31
|
-
labelRowsPerPageContainer: ["labelRowsPerPageContainer"],
|
|
32
|
-
labelRowsPager: ["labelRowsBager"],
|
|
33
|
-
select: ["select"],
|
|
34
|
-
selectMenuPopover: ["selectMenuPopover"],
|
|
35
|
-
selectMenuItem: ["selectMenuItem"],
|
|
36
|
-
labelDisplayRows: ["labelDisplayRows"],
|
|
37
|
-
pagerActions: ["pagerActions"],
|
|
38
|
-
customTablePaginationRoot: ["customTablePaginationRoot"],
|
|
39
|
-
skeletonRoot: ["skeletonRoot"],
|
|
40
|
-
skeletonRowsPerPage: ["skeletonRowsPerPage"],
|
|
41
|
-
skeletonButtonContainer: ["skeletonButtonContainer"],
|
|
42
|
-
skeletonIconButton: ["skeletonIconButton"],
|
|
43
|
-
actionIconFirstPage: ["actionIconFirstPage"],
|
|
44
|
-
actionIconPrevious: ["actionIconPrevious"],
|
|
45
|
-
actionIconNextPage: ["actionIconNextPage"],
|
|
46
|
-
actionIconLastPage: ["actionIconLastPage"]
|
|
47
|
-
};
|
|
48
|
-
const composedClasses = unstable_composeClasses(slots, getPagerUtilityClass, {});
|
|
49
|
-
return {
|
|
50
|
-
...composedClasses
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
export {
|
|
54
|
-
pagerUtilityClasses as p
|
|
55
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { pagerUtilityClasses } from '.';
|
|
2
|
-
export interface PagerClassesType {
|
|
3
|
-
root: string;
|
|
4
|
-
labelRowsPerPageContainer: string;
|
|
5
|
-
labelRowsPager: string;
|
|
6
|
-
select: string;
|
|
7
|
-
selectMenuPopover: string;
|
|
8
|
-
selectMenuItem: string;
|
|
9
|
-
labelDisplayRows: string;
|
|
10
|
-
pagerActions: string;
|
|
11
|
-
customTablePaginationRoot: string;
|
|
12
|
-
actionIconFirstPage: string;
|
|
13
|
-
actionIconPrevious: string;
|
|
14
|
-
actionIconNextPage: string;
|
|
15
|
-
actionIconLastPage: string;
|
|
16
|
-
}
|
|
17
|
-
export type PagerClassesKey = keyof PagerClassesType;
|
|
18
|
-
export type Classes = ReturnType<typeof pagerUtilityClasses>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { P as PagerRoot } from "./styles.js";
|
|
4
|
-
import { p as pagerUtilityClasses } from "./classes/index.js";
|
|
5
|
-
import { C as CustomTablePagination } from "./subcomponents/CustomTablePagination/index.js";
|
|
6
|
-
function Pager(props) {
|
|
7
|
-
const {
|
|
8
|
-
totalRecords,
|
|
9
|
-
rowsPerPageOptions = [5, 10, 2],
|
|
10
|
-
rowsPerPage = 25,
|
|
11
|
-
page,
|
|
12
|
-
onPageChange,
|
|
13
|
-
onRowsPerPageChange,
|
|
14
|
-
labelRows = "Rows per page",
|
|
15
|
-
labelOf = "Of",
|
|
16
|
-
isXs
|
|
17
|
-
} = props;
|
|
18
|
-
const currentPage = useMemo(() => {
|
|
19
|
-
if (rowsPerPage * page > totalRecords) {
|
|
20
|
-
return Math.floor(totalRecords / rowsPerPage);
|
|
21
|
-
}
|
|
22
|
-
return page;
|
|
23
|
-
}, [page, rowsPerPage, totalRecords]);
|
|
24
|
-
const handleChangeRowsPerPage = (event) => {
|
|
25
|
-
onRowsPerPageChange(parseInt(event.target.value, 10));
|
|
26
|
-
onPageChange(0);
|
|
27
|
-
};
|
|
28
|
-
const handleChangePage = (_event, newPage) => {
|
|
29
|
-
onPageChange(newPage);
|
|
30
|
-
};
|
|
31
|
-
const classes = pagerUtilityClasses();
|
|
32
|
-
return /* @__PURE__ */ jsx(PagerRoot, { className: classes.root, children: /* @__PURE__ */ jsx(
|
|
33
|
-
CustomTablePagination,
|
|
34
|
-
{
|
|
35
|
-
rowsPerPageOptions,
|
|
36
|
-
count: totalRecords,
|
|
37
|
-
rowsPerPage,
|
|
38
|
-
classes,
|
|
39
|
-
labelRowsPerPage: labelRows,
|
|
40
|
-
page: currentPage,
|
|
41
|
-
onPageChange: handleChangePage,
|
|
42
|
-
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
43
|
-
labelDisplayedRows: !isXs ? ({ from, to, count }) => `${from}-${to} ${labelOf} ${count}` : () => ``
|
|
44
|
-
}
|
|
45
|
-
) });
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
Pager as P
|
|
49
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const PagerRoot: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme>, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useTheme, Select, InputBase, MenuItem } from "@mui/material";
|
|
3
|
-
import { P as PagerActions } from "../PagerActions/index.js";
|
|
4
|
-
import { useResponsiveContainerStore } from "@m4l/graphics";
|
|
5
|
-
import { shallow } from "zustand/shallow";
|
|
6
|
-
import { useEnvironment } from "@m4l/core";
|
|
7
|
-
import { T as Typography } from "../../../Typography/Typography.js";
|
|
8
|
-
import { I as Icon } from "../../../../Icon/Icon.js";
|
|
9
|
-
const CustomTablePagination = (props) => {
|
|
10
|
-
const {
|
|
11
|
-
count: countTotal,
|
|
12
|
-
page,
|
|
13
|
-
rowsPerPage,
|
|
14
|
-
rowsPerPageOptions = [10, 25, 50, 100],
|
|
15
|
-
labelRowsPerPage,
|
|
16
|
-
classes,
|
|
17
|
-
onRowsPerPageChange,
|
|
18
|
-
onPageChange,
|
|
19
|
-
SelectProps,
|
|
20
|
-
labelDisplayedRows = defaultLabelDisplayedRows
|
|
21
|
-
} = props;
|
|
22
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
23
|
-
const isUpSm = useResponsiveContainerStore((state) => state.isUpSm, shallow);
|
|
24
|
-
const theme = useTheme();
|
|
25
|
-
function defaultLabelDisplayedRows({
|
|
26
|
-
from,
|
|
27
|
-
to,
|
|
28
|
-
count
|
|
29
|
-
}) {
|
|
30
|
-
return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
|
|
31
|
-
}
|
|
32
|
-
const getLabelDisplayedRowsTo = () => {
|
|
33
|
-
if (countTotal === -1) {
|
|
34
|
-
return (page + 1) * rowsPerPage;
|
|
35
|
-
}
|
|
36
|
-
return rowsPerPage === -1 ? countTotal : Math.min(countTotal, (page + 1) * rowsPerPage);
|
|
37
|
-
};
|
|
38
|
-
const CustomIconComponent = (CustomIconComponentProps) => /* @__PURE__ */ jsx(
|
|
39
|
-
Icon,
|
|
40
|
-
{
|
|
41
|
-
src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/chevronDown.svg`,
|
|
42
|
-
...CustomIconComponentProps
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
46
|
-
rowsPerPageOptions?.length > 1 ? /* @__PURE__ */ jsxs("div", { className: classes.labelRowsPerPageContainer, children: [
|
|
47
|
-
isUpSm ? /* @__PURE__ */ jsx(Typography, { variant: "body", children: labelRowsPerPage }) : null,
|
|
48
|
-
/* @__PURE__ */ jsx(
|
|
49
|
-
Select,
|
|
50
|
-
{
|
|
51
|
-
variant: "standard",
|
|
52
|
-
...!SelectProps?.variant && { input: /* @__PURE__ */ jsx(InputBase, {}) },
|
|
53
|
-
value: rowsPerPage,
|
|
54
|
-
onChange: (e) => {
|
|
55
|
-
onRowsPerPageChange(e);
|
|
56
|
-
},
|
|
57
|
-
className: classes.select,
|
|
58
|
-
MenuProps: {
|
|
59
|
-
className: classes.selectMenuPopover,
|
|
60
|
-
sx: { ...theme.components?.M4LPagerMenuPopover?.styleOverrides }
|
|
61
|
-
},
|
|
62
|
-
IconComponent: CustomIconComponent,
|
|
63
|
-
...SelectProps,
|
|
64
|
-
children: rowsPerPageOptions.map((item, idx) => /* @__PURE__ */ jsx(
|
|
65
|
-
MenuItem,
|
|
66
|
-
{
|
|
67
|
-
className: classes.selectMenuItem,
|
|
68
|
-
value: item,
|
|
69
|
-
children: item
|
|
70
|
-
},
|
|
71
|
-
`${classes.selectMenuItem}-${idx}`
|
|
72
|
-
))
|
|
73
|
-
}
|
|
74
|
-
)
|
|
75
|
-
] }) : null,
|
|
76
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", className: classes.labelDisplayRows, children: labelDisplayedRows({
|
|
77
|
-
from: countTotal === 0 ? 0 : page * rowsPerPage + 1,
|
|
78
|
-
to: getLabelDisplayedRowsTo(),
|
|
79
|
-
count: countTotal === -1 ? -1 : countTotal,
|
|
80
|
-
page
|
|
81
|
-
}) }),
|
|
82
|
-
/* @__PURE__ */ jsx(
|
|
83
|
-
PagerActions,
|
|
84
|
-
{
|
|
85
|
-
count: countTotal,
|
|
86
|
-
page,
|
|
87
|
-
rowsPerPage,
|
|
88
|
-
onPageChange,
|
|
89
|
-
classes
|
|
90
|
-
}
|
|
91
|
-
)
|
|
92
|
-
] });
|
|
93
|
-
};
|
|
94
|
-
export {
|
|
95
|
-
CustomTablePagination as C
|
|
96
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface PagerProps {
|
|
2
|
-
records: number;
|
|
3
|
-
totalRecords: number;
|
|
4
|
-
rowsPerPageOptions?: number[];
|
|
5
|
-
rowsPerPage?: number;
|
|
6
|
-
page: number;
|
|
7
|
-
onPageChange: (newPage: number) => void;
|
|
8
|
-
onRowsPerPageChange: (newRowsPerPage: number) => void;
|
|
9
|
-
labelRows?: string;
|
|
10
|
-
labelOf?: string;
|
|
11
|
-
isSkeleton?: boolean;
|
|
12
|
-
isXs?: boolean;
|
|
13
|
-
}
|