@m4l/components 9.3.36 → 9.3.37-JT20251128-beta.2

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.
Files changed (131) hide show
  1. package/@types/export.d.ts +3 -0
  2. package/@types/types.d.ts +33 -6
  3. package/components/DataGrid/DataGrid.js +2 -0
  4. package/components/DataGrid/Datagrid.styles.js +11 -2
  5. package/components/DataGrid/contexts/DataGridContext/index.js +43 -268
  6. package/components/DataGrid/contexts/DataGridContext/types.d.ts +5 -22
  7. package/components/DataGrid/helpers/getAllViewModes/getAllViewModes.d.ts +19 -0
  8. package/components/DataGrid/helpers/getAllViewModes/getAllViewModes.js +6 -0
  9. package/components/DataGrid/helpers/getAllViewModes/getAllViewModes.test.d.ts +1 -0
  10. package/components/DataGrid/helpers/getAllViewModes/index.d.ts +1 -0
  11. package/components/DataGrid/helpers/getAllViewModes/index.js +1 -0
  12. package/components/DataGrid/helpers/getColumnsWidth/getColumnsWidth.d.ts +47 -0
  13. package/components/DataGrid/helpers/getColumnsWidth/getColumnsWidth.js +32 -0
  14. package/components/DataGrid/helpers/getColumnsWidth/getColumnsWidth.test.d.ts +1 -0
  15. package/components/DataGrid/helpers/getColumnsWidth/index.d.ts +1 -0
  16. package/components/DataGrid/helpers/getColumnsWidth/index.js +1 -0
  17. package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.d.ts +24 -0
  18. package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.js +12 -0
  19. package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.test.d.ts +1 -0
  20. package/components/DataGrid/helpers/getIndexRowHeightVariant/index.d.ts +1 -0
  21. package/components/DataGrid/helpers/getIndexRowHeightVariant/index.js +1 -0
  22. package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.d.ts +48 -0
  23. package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.js +35 -0
  24. package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.test.d.ts +1 -0
  25. package/components/DataGrid/helpers/getInitialColumnsConfig/index.d.ts +1 -0
  26. package/components/DataGrid/helpers/getInitialColumnsConfig/index.js +1 -0
  27. package/components/DataGrid/helpers/getViewMode/getViewMode.d.ts +41 -0
  28. package/components/DataGrid/helpers/getViewMode/getViewMode.js +19 -0
  29. package/components/DataGrid/helpers/getViewMode/getViewMode.test.d.ts +1 -0
  30. package/components/DataGrid/helpers/getViewMode/index.d.ts +1 -0
  31. package/components/DataGrid/helpers/getViewMode/index.js +1 -0
  32. package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.d.ts +28 -0
  33. package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.js +22 -0
  34. package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.test.d.ts +1 -0
  35. package/components/DataGrid/helpers/getViewSpecificConfig/index.d.ts +1 -0
  36. package/components/DataGrid/helpers/getViewSpecificConfig/index.js +1 -0
  37. package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.d.ts +24 -0
  38. package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.js +9 -0
  39. package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.test.d.ts +1 -0
  40. package/components/DataGrid/helpers/getViewSuffix/index.d.ts +1 -0
  41. package/components/DataGrid/helpers/getViewSuffix/index.js +1 -0
  42. package/components/DataGrid/helpers/index.d.ts +13 -0
  43. package/components/DataGrid/helpers/index.js +1 -0
  44. package/components/DataGrid/helpers/loadViewConfig/index.d.ts +1 -0
  45. package/components/DataGrid/helpers/loadViewConfig/index.js +1 -0
  46. package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.d.ts +23 -0
  47. package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.js +12 -0
  48. package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.test.d.ts +1 -0
  49. package/components/DataGrid/helpers/saveColumnsWidth/index.d.ts +1 -0
  50. package/components/DataGrid/helpers/saveColumnsWidth/index.js +1 -0
  51. package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.d.ts +52 -0
  52. package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.js +18 -0
  53. package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.test.d.ts +1 -0
  54. package/components/DataGrid/helpers/saveViewConfig/index.d.ts +1 -0
  55. package/components/DataGrid/helpers/saveViewConfig/index.js +1 -0
  56. package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.d.ts +35 -0
  57. package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.js +15 -0
  58. package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.test.d.ts +1 -0
  59. package/components/DataGrid/helpers/saveViewMode/index.d.ts +1 -0
  60. package/components/DataGrid/helpers/saveViewMode/index.js +1 -0
  61. package/components/DataGrid/helpers/saveViewMode/saveViewMode.d.ts +33 -0
  62. package/components/DataGrid/helpers/saveViewMode/saveViewMode.js +13 -0
  63. package/components/DataGrid/helpers/saveViewMode/saveViewMode.test.d.ts +1 -0
  64. package/components/DataGrid/hooks/index.d.ts +6 -0
  65. package/components/DataGrid/hooks/index.js +1 -0
  66. package/components/DataGrid/hooks/useChangeColumnsConfig/index.d.ts +1 -0
  67. package/components/DataGrid/hooks/useChangeColumnsConfig/index.js +1 -0
  68. package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.d.ts +9 -0
  69. package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.js +27 -0
  70. package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.test.d.ts +1 -0
  71. package/components/DataGrid/hooks/useChangeColumnsOrder/index.d.ts +1 -0
  72. package/components/DataGrid/hooks/useChangeColumnsOrder/index.js +1 -0
  73. package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.d.ts +10 -0
  74. package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.js +34 -0
  75. package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.test.d.ts +1 -0
  76. package/components/DataGrid/hooks/useColumnsWidth/index.d.ts +1 -0
  77. package/components/DataGrid/hooks/useColumnsWidth/index.js +1 -0
  78. package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.d.ts +11 -0
  79. package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.js +29 -0
  80. package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.test.d.ts +1 -0
  81. package/components/DataGrid/hooks/useRowHeight/index.d.ts +1 -0
  82. package/components/DataGrid/hooks/useRowHeight/index.js +1 -0
  83. package/components/DataGrid/hooks/useRowHeight/useRowHeight.d.ts +28 -0
  84. package/components/DataGrid/hooks/useRowHeight/useRowHeight.js +51 -0
  85. package/components/DataGrid/hooks/useRowHeight/useRowHeight.test.d.ts +1 -0
  86. package/components/DataGrid/hooks/useViewConfig/index.d.ts +1 -0
  87. package/components/DataGrid/hooks/useViewConfig/index.js +1 -0
  88. package/components/DataGrid/hooks/useViewConfig/useViewConfig.d.ts +9 -0
  89. package/components/DataGrid/hooks/useViewConfig/useViewConfig.js +30 -0
  90. package/components/DataGrid/hooks/useViewConfig/useViewConfig.test.d.ts +1 -0
  91. package/components/DataGrid/hooks/useViewMode/index.d.ts +1 -0
  92. package/components/DataGrid/hooks/useViewMode/index.js +1 -0
  93. package/components/DataGrid/hooks/useViewMode/useViewMode.d.ts +31 -0
  94. package/components/DataGrid/hooks/useViewMode/useViewMode.js +44 -0
  95. package/components/DataGrid/hooks/useViewMode/useViewMode.test.d.ts +1 -0
  96. package/components/DataGrid/index.d.ts +5 -4
  97. package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.js +15 -7
  98. package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.js +4 -1
  99. package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +6 -2
  100. package/components/DataGrid/subcomponents/Table/subcomponents/RadioButtonFormatter.d.ts +6 -0
  101. package/components/DataGrid/subcomponents/Table/subcomponents/RadioButtonFormatter.js +12 -0
  102. package/components/DataGrid/subcomponents/Table/subcomponents/RadioSelectColumn.d.ts +64 -0
  103. package/components/DataGrid/subcomponents/Table/subcomponents/RadioSelectColumn.js +46 -0
  104. package/components/DataGrid/tests/table/subcomponents/RadioButtonFormatter.test.d.ts +1 -0
  105. package/components/DataGrid/tests/table/subcomponents/RadioSelectColumn.test.d.ts +1 -0
  106. package/components/DataGrid/types.d.ts +7 -0
  107. package/components/DataGrid/types.helpers.d.ts +55 -0
  108. package/components/DataGrid/types.helpers.js +1 -0
  109. package/components/DataGrid/types.hooks.d.ts +81 -0
  110. package/components/mui_extended/RadioButton/RadioButton.d.ts +24 -0
  111. package/components/mui_extended/RadioButton/RadioButton.js +110 -0
  112. package/components/mui_extended/RadioButton/RadioButton.styles.d.ts +2 -0
  113. package/components/mui_extended/RadioButton/RadioButton.styles.js +126 -0
  114. package/components/mui_extended/RadioButton/constants.d.ts +1 -0
  115. package/components/mui_extended/RadioButton/constants.js +4 -0
  116. package/components/mui_extended/RadioButton/icons.d.ts +4 -0
  117. package/components/mui_extended/RadioButton/icons.js +7 -0
  118. package/components/mui_extended/RadioButton/index.d.ts +1 -0
  119. package/components/mui_extended/RadioButton/index.js +1 -0
  120. package/components/mui_extended/RadioButton/slots/RadioButtonEnum.d.ts +8 -0
  121. package/components/mui_extended/RadioButton/slots/RadioButtonEnum.js +12 -0
  122. package/components/mui_extended/RadioButton/slots/RadioButtonSlots.d.ts +20 -0
  123. package/components/mui_extended/RadioButton/slots/RadioButtonSlots.js +39 -0
  124. package/components/mui_extended/RadioButton/tests/RadioButton.test.d.ts +1 -0
  125. package/components/mui_extended/RadioButton/types.d.ts +50 -0
  126. package/components/mui_extended/index.d.ts +1 -0
  127. package/hooks/useDataGridPersistence/constants.d.ts +1 -0
  128. package/hooks/useDataGridPersistence/constants.js +4 -2
  129. package/hooks/useDataGridPersistence/useDataGridPersistence.js +5 -2
  130. package/index.js +44 -42
  131. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ export { useChangeColumnsConfig } from './useChangeColumnsConfig';
@@ -0,0 +1,9 @@
1
+ import { UseChangeColumnsConfigParams, UseChangeColumnsConfigReturn } from '../../types.hooks';
2
+ /**
3
+ * Hook para manejar el cambio de configuración de columnas.
4
+ *
5
+ * Guarda la configuración en localStorage y actualiza el estado.
6
+ * @param params - Parámetros del hook
7
+ * @returns Función para cambiar la configuración de columnas
8
+ */
9
+ export declare const useChangeColumnsConfig: ({ id, onChangeUserColumns, updateConfigColumns, }: UseChangeColumnsConfigParams) => UseChangeColumnsConfigReturn;
@@ -0,0 +1,27 @@
1
+ import { useCallback } from "react";
2
+ import { s as saveViewConfig } from "../../helpers/saveViewConfig/saveViewConfig.js";
3
+ import { g as getViewSuffix } from "../../helpers/getViewSuffix/getViewSuffix.js";
4
+ const useChangeColumnsConfig = ({
5
+ id,
6
+ onChangeUserColumns,
7
+ updateConfigColumns
8
+ }) => {
9
+ const onChangeColumnsConfig = useCallback(
10
+ (viewModeParam, newConfig) => {
11
+ saveViewConfig(
12
+ id,
13
+ getViewSuffix(viewModeParam),
14
+ newConfig,
15
+ onChangeUserColumns
16
+ );
17
+ updateConfigColumns(viewModeParam, newConfig);
18
+ },
19
+ [id, onChangeUserColumns, updateConfigColumns]
20
+ );
21
+ return {
22
+ onChangeColumnsConfig
23
+ };
24
+ };
25
+ export {
26
+ useChangeColumnsConfig as u
27
+ };
@@ -0,0 +1 @@
1
+ export { useChangeColumnsOrder } from './useChangeColumnsOrder';
@@ -0,0 +1,10 @@
1
+ import { UseChangeColumnsOrderParams, UseChangeColumnsOrderReturn } from '../../types.hooks';
2
+ /**
3
+ * Hook para manejar el cambio de orden de columnas.
4
+ *
5
+ * Reordena las columnas y llama a onChangeColumnsConfig para persistir.
6
+ * @param getConfigColumns Función para obtener la configuración de columnas
7
+ * @param onChangeColumnsConfig Función para cambiar la configuración de columnas
8
+ * @returns Función para cambiar el orden de columnas
9
+ */
10
+ export declare const useChangeColumnsOrder: ({ getConfigColumns, onChangeColumnsConfig, }: UseChangeColumnsOrderParams) => UseChangeColumnsOrderReturn;
@@ -0,0 +1,34 @@
1
+ import { useCallback } from "react";
2
+ const useChangeColumnsOrder = ({
3
+ getConfigColumns,
4
+ onChangeColumnsConfig
5
+ }) => {
6
+ const onChangeColumnsOrder = useCallback(
7
+ (viewModeParam, sourceKey, targetKey) => {
8
+ if (sourceKey === targetKey) {
9
+ return;
10
+ }
11
+ const currentConfig = getConfigColumns(viewModeParam);
12
+ const sourceColumnIndex = currentConfig.findIndex(
13
+ (c) => c.key === sourceKey
14
+ );
15
+ const targetColumnIndex = currentConfig.findIndex(
16
+ (c) => c.key === targetKey
17
+ );
18
+ const reorderedConfig = [...currentConfig];
19
+ reorderedConfig.splice(
20
+ targetColumnIndex,
21
+ 0,
22
+ reorderedConfig.splice(sourceColumnIndex, 1)[0]
23
+ );
24
+ onChangeColumnsConfig(viewModeParam, reorderedConfig);
25
+ },
26
+ [getConfigColumns, onChangeColumnsConfig]
27
+ );
28
+ return {
29
+ onChangeColumnsOrder
30
+ };
31
+ };
32
+ export {
33
+ useChangeColumnsOrder as u
34
+ };
@@ -0,0 +1 @@
1
+ export { useColumnsWidth } from './useColumnsWidth';
@@ -0,0 +1,11 @@
1
+ import { UseColumnsWidthParams, UseColumnsWidthReturn } from '../../types.hooks';
2
+ /**
3
+ * Hook para manejar el estado del ancho de las columnas del DataGrid.
4
+ *
5
+ * Maneja:
6
+ * - Estado del ancho de cada columna
7
+ * - Guardado con debounce de 500ms al cambiar el ancho
8
+ * @param params - Parámetros del hook
9
+ * @returns Estado y función para cambiar el ancho de columnas
10
+ */
11
+ export declare const useColumnsWidth: ({ id, onChangeUserColumns, }: UseColumnsWidthParams) => UseColumnsWidthReturn;
@@ -0,0 +1,29 @@
1
+ import { useState, useRef, useCallback } from "react";
2
+ import { s as saveColumnsWidth } from "../../helpers/saveColumnsWidth/saveColumnsWidth.js";
3
+ const useColumnsWidth = ({
4
+ id,
5
+ onChangeUserColumns
6
+ }) => {
7
+ const [columnsWidths, setColumnsWidths] = useState(/* @__PURE__ */ new Map());
8
+ const timerRef = useRef(null);
9
+ const onChangeColumnWidth = useCallback(
10
+ (columnKey, width) => {
11
+ columnsWidths.set(columnKey, Math.round(width));
12
+ if (timerRef.current) {
13
+ clearTimeout(timerRef.current);
14
+ }
15
+ timerRef.current = setTimeout(() => {
16
+ saveColumnsWidth(id, columnsWidths, onChangeUserColumns);
17
+ }, 500);
18
+ },
19
+ [id, columnsWidths, onChangeUserColumns]
20
+ );
21
+ return {
22
+ columnsWidths,
23
+ setColumnsWidths,
24
+ onChangeColumnWidth
25
+ };
26
+ };
27
+ export {
28
+ useColumnsWidth as u
29
+ };
@@ -0,0 +1 @@
1
+ export { useRowHeight } from './useRowHeight';
@@ -0,0 +1,28 @@
1
+ import { UseRowHeightParams, UseRowHeightReturn } from '../../types.hooks';
2
+ /**
3
+ * Hook para manejar el estado de la altura de las filas del DataGrid.
4
+ *
5
+ * Soporta dos modos:
6
+ * - **Modo fijo**: rowHeights y rowHeaderHeights son números fijos
7
+ * - **Modo variable**: rowHeights y rowHeaderHeights son arrays de 3 elementos [compact, standard, confortable]
8
+ * @param params - Parámetros del hook
9
+ * @returns Estado actual y función para cambiar el variant
10
+ * @throws Error si rowHeights y rowHeaderHeights no son del mismo tipo
11
+ * @throws Error si los arrays no tienen exactamente 3 elementos
12
+ * @throws Error si se intenta cambiar el variant en modo fijo
13
+ * @example
14
+ * // Modo variable (permite cambiar variant)
15
+ * const { currentRowHeightVariant, setRowHeightVariant } = useRowHeight({
16
+ * rowHeights: [32, 40, 48],
17
+ * rowHeaderHeights: [36, 44, 52],
18
+ * initialRowHeightVariant: 'standard',
19
+ * });
20
+ *
21
+ * // Modo fijo (altura constante)
22
+ * const { currentRowHeightVariant } = useRowHeight({
23
+ * rowHeights: 40,
24
+ * rowHeaderHeights: 44,
25
+ * initialRowHeightVariant: 'standard',
26
+ * });
27
+ */
28
+ export declare const useRowHeight: ({ rowHeights, rowHeaderHeights, initialRowHeightVariant, }: UseRowHeightParams) => UseRowHeightReturn;
@@ -0,0 +1,51 @@
1
+ import { useState, useCallback } from "react";
2
+ import { g as getIndexRowHeightVariant } from "../../helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.js";
3
+ const useRowHeight = ({
4
+ rowHeights,
5
+ rowHeaderHeights,
6
+ initialRowHeightVariant
7
+ }) => {
8
+ const [currentRowHeightVariant, setCurrentRowHeightVariant] = useState(() => {
9
+ if (typeof rowHeights !== typeof rowHeaderHeights) {
10
+ throw new Error("Must be same type rowheights and rowHeaderTypes");
11
+ }
12
+ if (typeof rowHeights === "number" && typeof rowHeaderHeights === "number") {
13
+ return {
14
+ rowHVariant: "compact",
15
+ rowHeight: rowHeights,
16
+ rowHeaderHeight: rowHeaderHeights
17
+ };
18
+ }
19
+ if (typeof rowHeights !== "number" && rowHeights.length !== 3) {
20
+ throw new Error("Must be 3 heights");
21
+ }
22
+ if (typeof rowHeaderHeights !== "number" && rowHeaderHeights.length !== 3) {
23
+ throw new Error("Must be 3 HeaderHeights");
24
+ }
25
+ return {
26
+ rowHVariant: initialRowHeightVariant,
27
+ rowHeight: typeof rowHeights !== "number" ? rowHeights[getIndexRowHeightVariant(initialRowHeightVariant)] : rowHeights,
28
+ rowHeaderHeight: typeof rowHeaderHeights !== "number" ? rowHeaderHeights[getIndexRowHeightVariant(initialRowHeightVariant)] : rowHeaderHeights
29
+ };
30
+ });
31
+ const setRowHeightVariant = useCallback(
32
+ (newVariant) => {
33
+ if (typeof rowHeights === "number" || typeof rowHeaderHeights === "number") {
34
+ throw new Error("Only use setCurrentRowHeight with vector rowHeights");
35
+ }
36
+ setCurrentRowHeightVariant({
37
+ rowHVariant: newVariant,
38
+ rowHeight: rowHeights[getIndexRowHeightVariant(newVariant)],
39
+ rowHeaderHeight: rowHeaderHeights[getIndexRowHeightVariant(newVariant)]
40
+ });
41
+ },
42
+ [rowHeights, rowHeaderHeights]
43
+ );
44
+ return {
45
+ currentRowHeightVariant,
46
+ setRowHeightVariant
47
+ };
48
+ };
49
+ export {
50
+ useRowHeight as u
51
+ };
@@ -0,0 +1 @@
1
+ export { useViewConfig } from './useViewConfig';
@@ -0,0 +1,9 @@
1
+ import { UseViewConfigReturn } from '../../types.hooks';
2
+ /**
3
+ * Hook para manejar el estado de la configuración de columnas por vista.
4
+ *
5
+ * Maneja un estado genérico unificado para las configuraciones de TODAS las vistas
6
+ * (table, cards, etc).
7
+ * @returns Estado y funciones para manejar la configuración de vistas
8
+ */
9
+ export declare const useViewConfig: () => UseViewConfigReturn;
@@ -0,0 +1,30 @@
1
+ import { useState, useCallback } from "react";
2
+ const useViewConfig = () => {
3
+ const [viewConfig, setViewConfig] = useState(() => ({
4
+ table: [],
5
+ cards: []
6
+ }));
7
+ const getConfigColumns = useCallback(
8
+ (viewModeParam) => {
9
+ return viewConfig[viewModeParam];
10
+ },
11
+ [viewConfig]
12
+ );
13
+ const updateConfigColumns = useCallback(
14
+ (viewModeParam, config) => {
15
+ setViewConfig((prev) => ({
16
+ ...prev,
17
+ [viewModeParam]: config
18
+ }));
19
+ },
20
+ []
21
+ );
22
+ return {
23
+ viewConfig,
24
+ getConfigColumns,
25
+ updateConfigColumns
26
+ };
27
+ };
28
+ export {
29
+ useViewConfig as u
30
+ };
@@ -0,0 +1 @@
1
+ export { useViewMode } from './useViewMode';
@@ -0,0 +1,31 @@
1
+ import { UseViewModeParams, UseViewModeReturn } from '../../types.hooks';
2
+ /**
3
+ * Hook para manejar el estado del modo de visualización (table/cards).
4
+ *
5
+ * ## Inicialización del viewMode
6
+ *
7
+ * El viewMode se inicializa siguiendo esta jerarquía de precedencia:
8
+ * 1. viewMode prop (modo controlado)
9
+ * 2. localStorage (configuración guardada localmente)
10
+ * 3. defaultViewMode (valor por defecto del desarrollador)
11
+ * 4. Fallback según dispositivo (mobile: 'cards', desktop: 'table')
12
+ *
13
+ * ## Persistencia del viewMode
14
+ *
15
+ * - Si `onChangeUserColumns` está definido → Guarda en backend (cookies de red)
16
+ * - Si no está definido → Fallback a localStorage
17
+ *
18
+ * ## Modo controlado vs no controlado
19
+ *
20
+ * - **Controlado**: Cuando se pasa `viewMode` prop, el padre controla el estado
21
+ * - **No controlado**: El hook maneja internamente el estado y persiste
22
+ * @param id - Identificador único del DataGrid
23
+ * @param viewMode - ViewMode controlado por el padre (opcional)
24
+ * @param defaultViewMode - ViewMode por defecto cuando no hay valor guardado
25
+ * @param onViewModeChange - Callback cuando cambia el viewMode (opcional)
26
+ * @param onChangeUserColumns - Callback para guardar en backend (opcional)
27
+ * @returns viewModeState - Estado actual del viewMode
28
+ * @returns setViewModeState - Función para establecer el viewMode
29
+ * @returns handleViewModeChange - Función para cambiar el viewMode y persistirlo
30
+ */
31
+ export declare const useViewMode: ({ id, viewMode, defaultViewMode, onViewModeChange, onChangeUserColumns, }: UseViewModeParams) => UseViewModeReturn;
@@ -0,0 +1,44 @@
1
+ import { useState, useCallback, useEffect } from "react";
2
+ import { useIsMobile } from "@m4l/graphics";
3
+ import { g as getViewMode } from "../../helpers/getViewMode/getViewMode.js";
4
+ import { s as saveViewMode } from "../../helpers/saveViewMode/saveViewMode.js";
5
+ const useViewMode = ({
6
+ id,
7
+ viewMode,
8
+ defaultViewMode,
9
+ onViewModeChange,
10
+ onChangeUserColumns
11
+ }) => {
12
+ const isMobile = useIsMobile();
13
+ const [viewModeState, setViewModeState] = useState(() => {
14
+ if (viewMode) {
15
+ return viewMode;
16
+ }
17
+ const savedViewMode = getViewMode(id, null, defaultViewMode);
18
+ if (savedViewMode) {
19
+ return savedViewMode;
20
+ }
21
+ return isMobile ? "cards" : "table";
22
+ });
23
+ const handleViewModeChange = useCallback(
24
+ (newViewMode) => {
25
+ setViewModeState(newViewMode);
26
+ saveViewMode(id, newViewMode, onChangeUserColumns);
27
+ onViewModeChange?.(newViewMode);
28
+ },
29
+ [id, onViewModeChange, onChangeUserColumns]
30
+ );
31
+ useEffect(() => {
32
+ if (viewMode !== void 0) {
33
+ setViewModeState(viewMode);
34
+ }
35
+ }, [viewMode]);
36
+ return {
37
+ viewModeState,
38
+ setViewModeState,
39
+ handleViewModeChange
40
+ };
41
+ };
42
+ export {
43
+ useViewMode as u
44
+ };
@@ -1,9 +1,10 @@
1
1
  export { DataGrid } from './DataGrid';
2
2
  export * from './formatters';
3
- export type { Column, RenderEditCellProps, RenderCellProps } from 'react-data-grid';
4
- export type { RowKey, ChangeUserColumn, RowActionsGetter, RowKeyGetter } from './types';
3
+ export type { Column, RenderEditCellProps, RenderCellProps, } from 'react-data-grid';
4
+ export type { RowKey, ChangeUserColumn, RowActionsGetter, RowKeyGetter, } from './types';
5
5
  export { getDataGridComponentsDictionary } from './dictionary';
6
6
  export { TextEditor, NumberEditor } from './subcomponents/editors/TextEditor';
7
7
  export { getDataGridRowsFromSet } from './utils/getDataGridRowsFromSet';
8
- export type { IGridConfig, IGridConfigExtended, BaseConfigColumn } from './contexts/DataGridContext/types';
9
- export { DATAGRID_SEMANTIC_WIDTHS, DATAGRID_ROW_HEADER_HEIGHTS, DATAGRID_ROW_HEIGHTS } from './constants';
8
+ export type { IGridConfigExtended, BaseConfigColumn, } from './contexts/DataGridContext/types';
9
+ export { DATAGRID_SEMANTIC_WIDTHS, DATAGRID_ROW_HEADER_HEIGHTS, DATAGRID_ROW_HEIGHTS, } from './constants';
10
+ export * from './types.helpers';
@@ -15,7 +15,7 @@ function CardHeader({
15
15
  checkedRows,
16
16
  onCheckedRowsChange
17
17
  }) {
18
- const { rowKeyGetter, rowActionsGetter, size } = useDataGrid();
18
+ const { rowKeyGetter, rowActionsGetter, size, checkedRowsMultiple } = useDataGrid();
19
19
  const { host_static_assets, environment_assets } = useEnvironment();
20
20
  const rowKey = useMemo(() => rowKeyGetter(row), [rowKeyGetter, row]);
21
21
  const onChange = useCallback(
@@ -23,15 +23,23 @@ function CardHeader({
23
23
  if (!onCheckedRowsChange || !checkedRows) {
24
24
  return;
25
25
  }
26
- const newCheckedRows = new Set(checkedRows);
27
- if (checked) {
28
- newCheckedRows.add(rowKey);
26
+ if (checkedRowsMultiple === false) {
27
+ if (checked) {
28
+ onCheckedRowsChange(/* @__PURE__ */ new Set([rowKey]));
29
+ } else {
30
+ onCheckedRowsChange(/* @__PURE__ */ new Set());
31
+ }
29
32
  } else {
30
- newCheckedRows.delete(rowKey);
33
+ const newCheckedRows = new Set(checkedRows);
34
+ if (checked) {
35
+ newCheckedRows.add(rowKey);
36
+ } else {
37
+ newCheckedRows.delete(rowKey);
38
+ }
39
+ onCheckedRowsChange(newCheckedRows);
31
40
  }
32
- onCheckedRowsChange(newCheckedRows);
33
41
  },
34
- [checkedRows, onCheckedRowsChange, rowKey]
42
+ [checkedRows, onCheckedRowsChange, rowKey, checkedRowsMultiple]
35
43
  );
36
44
  const anchorOrigin = useMemo(
37
45
  () => ({
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useContext } from "react";
3
3
  import { SelectCellFormatter } from "react-data-grid";
4
4
  import { C as CheckboxFormatter } from "../Table/subcomponents/CheckboxFormatter.js";
5
+ import { R as RadioButtonFormatter } from "../Table/subcomponents/RadioButtonFormatter.js";
5
6
  import { a as DataGridContext } from "../../contexts/DataGridContext/index.js";
6
7
  import { l as CheckboxCellWrapperStyled } from "../../slots/DataGridSlot.js";
7
8
  const CheckboxCellAdapter = forwardRef(function CheckboxCellAdapter2(props, ref) {
@@ -14,12 +15,14 @@ const CheckboxCellAdapter = forwardRef(function CheckboxCellAdapter2(props, ref)
14
15
  } = props;
15
16
  const context = useContext(DataGridContext);
16
17
  const viewMode = context?.viewMode ?? "cards";
18
+ const checkedRowsMultiple = context?.checkedRowsMultiple;
17
19
  if (viewMode !== "table") {
18
20
  const handleClick = (e) => {
19
21
  e.stopPropagation();
20
22
  };
23
+ const FormatterComponent = checkedRowsMultiple === false ? RadioButtonFormatter : CheckboxFormatter;
21
24
  return /* @__PURE__ */ jsx(CheckboxCellWrapperStyled, { onClick: handleClick, children: /* @__PURE__ */ jsx(
22
- CheckboxFormatter,
25
+ FormatterComponent,
23
26
  {
24
27
  ref,
25
28
  checked: value,
@@ -2,6 +2,7 @@ import { useState, useEffect, useMemo } from "react";
2
2
  import { g as getDragHeaderRenderer } from "./getDragHeaderRenderer.js";
3
3
  import { A as ActionsColumn } from "../subcomponents/ActionsColumn.js";
4
4
  import { f as filterColumnClassName, S as SelectColumn } from "../subcomponents/SelectColumn.js";
5
+ import { R as RadioSelectColumn } from "../subcomponents/RadioSelectColumn.js";
5
6
  import { useModuleSkeleton, getPropertyByString } from "@m4l/core";
6
7
  import { u as useFilters } from "../../../hooks/useFilters.js";
7
8
  import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
@@ -38,7 +39,7 @@ function getComparator(columns, sortColumn) {
38
39
  }
39
40
  }
40
41
  const getColumIndex = (key, columnsConfig) => columnsConfig.findIndex((columnConfig) => columnConfig.key === key);
41
- const getInOrderColumns = (columns, hasCheckedRows, columnsConfig, columnsWidths, rowActionsGetter) => {
42
+ const getInOrderColumns = (columns, hasCheckedRows, checkedRowsMultiple, columnsConfig, columnsWidths, rowActionsGetter) => {
42
43
  let filteredSortedColumns = columns.filter((column) => {
43
44
  const columnConfigIndex = getColumIndex(column.key, columnsConfig);
44
45
  const visible = columnConfigIndex > -1 ? columnsConfig[columnConfigIndex].visible : true;
@@ -64,7 +65,8 @@ const getInOrderColumns = (columns, hasCheckedRows, columnsConfig, columnsWidths
64
65
  filteredSortedColumns = [ActionsColumn, ...filteredSortedColumns];
65
66
  }
66
67
  if (hasCheckedRows) {
67
- filteredSortedColumns = [SelectColumn, ...filteredSortedColumns];
68
+ const selectionColumn = checkedRowsMultiple === false ? RadioSelectColumn : SelectColumn;
69
+ filteredSortedColumns = [selectionColumn, ...filteredSortedColumns];
68
70
  }
69
71
  return filteredSortedColumns;
70
72
  };
@@ -89,6 +91,7 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
89
91
  rowActionsGetter,
90
92
  checkedRows,
91
93
  onCheckedRowsChange,
94
+ checkedRowsMultiple,
92
95
  sortColumns,
93
96
  setSortColumns
94
97
  } = useDataGrid();
@@ -109,6 +112,7 @@ const useSortColumnsRows = (sourceColumns, sourceRows, popoverHandlers) => {
109
112
  sourceColumns,
110
113
  !!checkedRows && !!onCheckedRowsChange,
111
114
  //Si están seteados se habilita el múltipe
115
+ checkedRowsMultiple,
112
116
  columnsConfig,
113
117
  columnsWidths,
114
118
  rowActionsGetter
@@ -0,0 +1,6 @@
1
+ import { RenderCheckboxProps } from 'react-data-grid';
2
+ /**
3
+ * Componente visual del RadioButton que se renderiza dentro de cada celda del DataGrid.
4
+ * ¿Para que sirve? Es un wrapper alrededor del componente Radio del MUI que adapta las props de react-data-grid
5
+ */
6
+ export declare const RadioButtonFormatter: import('react').ForwardRefExoticComponent<RenderCheckboxProps & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,12 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { R as RadioButton } from "../../../../mui_extended/RadioButton/RadioButton.js";
4
+ const RadioButtonFormatter = forwardRef(function RadioFormatter({ onChange, checked, ...props }, _ref) {
5
+ function handleChange(e) {
6
+ onChange(e.target.checked, e.nativeEvent.shiftKey);
7
+ }
8
+ return /* @__PURE__ */ jsx(RadioButton, { checked, onChange: handleChange, ...props });
9
+ });
10
+ export {
11
+ RadioButtonFormatter as R
12
+ };
@@ -0,0 +1,64 @@
1
+ import { Column, RenderCellProps, RenderGroupCellProps, RenderHeaderCellProps } from 'react-data-grid';
2
+ export declare const filterColumnClassName = "filter-cell";
3
+ export declare const filterHeight = 35;
4
+ /**
5
+ * Formateador para la celda de selección con radio button en filas agrupadas.
6
+ *
7
+ * **Nota:** Para radio buttons (selección única), no tiene sentido seleccionar grupos completos,
8
+ * por lo que este formateador retorna `null` y no renderiza ningún control.
9
+ * @param _props - Propiedades para renderizar la celda de grupo (no utilizadas).
10
+ * @returns `null` - No se renderiza ningún control de selección en grupos.
11
+ * @example
12
+ * // En un DataGrid con grupos, las filas de grupo no tendrán radio button
13
+ * // Solo las filas individuales tendrán radio buttons
14
+ */
15
+ export declare function RadioSelectGroupFormatter(_props: RenderGroupCellProps<unknown>): null;
16
+ /**
17
+ * Formateador para la celda de selección con radio button en filas individuales.
18
+ *
19
+ * Este componente maneja la lógica de **selección única**: cuando el usuario hace click
20
+ * en un radio button, se REEMPLAZA completamente la selección anterior con solo la fila actual.
21
+ *
22
+ * **Comportamiento:**
23
+ * - Si `checked` es `true`: El Set de `checkedRows` se reemplaza con `[rowKey actual]`
24
+ * - Si `checked` es `false`: El Set de `checkedRows` se vacía (deselección)
25
+ * @param props - Propiedades para renderizar la celda, incluyendo la fila actual.
26
+ * @returns Un componente `SelectCellFormatter` configurado como radio button.
27
+ * @example
28
+ * // Cuando el usuario hace click en el radio de la fila con ID=5:
29
+ * // checkedRows antes: Set([3])
30
+ * // checkedRows después: Set([5]) ← Reemplaza, no agrega
31
+ */
32
+ export declare function RadioSelectFormatter(props: RenderCellProps<any, any>): import("react/jsx-runtime").JSX.Element;
33
+ /**
34
+ * Renderizador para la celda de cabecera (header) de la columna de selección con radio buttons.
35
+ *
36
+ * **Nota:** A diferencia de los checkboxes, los radio buttons NO tienen funcionalidad de
37
+ * "Seleccionar Todo", ya que solo se puede seleccionar una fila a la vez. Por lo tanto,
38
+ * este renderizador retorna `null` y no muestra ningún control en el header.
39
+ * @param _props - Propiedades para renderizar la celda de cabecera (no utilizadas).
40
+ * @returns `null` - No se renderiza ningún control en la cabecera.
41
+ * @example
42
+ * // La cabecera de la columna estará vacía (sin checkbox "Select All")
43
+ */
44
+ export declare function RadioSelectColumnHeaderRenderer(_props: RenderHeaderCellProps<any, any>): null;
45
+ /**
46
+ * Definición de la columna de selección con radio buttons para el DataGrid.
47
+ *
48
+ * Esta columna permite **selección única** de filas mediante radio buttons.
49
+ *
50
+ * **Características:**
51
+ * - **Ancho fijo:** 32px (igual que la columna de checkboxes)
52
+ * - **No redimensionable:** `resizable: false`
53
+ * - **No draggable:** `isDraggable: false`
54
+ * - **No sortable:** `sortable: false`
55
+ * - **Congelada:** `frozen: true` (siempre visible al hacer scroll horizontal)
56
+ * - **Header vacío:** No tiene control "Select All"
57
+ * - **Selección única:** Solo una fila puede estar seleccionada a la vez
58
+ * @example
59
+ * // En useSortColumnsRows.tsx:
60
+ * const selectionColumn = checkedRowsMultiple === false
61
+ * ? RadioSelectColumn // ← Selección única con radio buttons
62
+ * : SelectColumn; // ← Selección múltiple con checkboxes
63
+ */
64
+ export declare const RadioSelectColumn: Column<any, any>;
@@ -0,0 +1,46 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { u as useDataGrid } from "../../../hooks/useDataGrid.js";
3
+ import { d as DATAGRID_SELECT_COLUMN_KEY } from "../../../constants.js";
4
+ import { R as RadioButtonFormatter } from "./RadioButtonFormatter.js";
5
+ function RadioSelectGroupFormatter(_props) {
6
+ return null;
7
+ }
8
+ function RadioSelectFormatter(props) {
9
+ const { checkedRows, onCheckedRowsChange, rowKeyGetter } = useDataGrid();
10
+ const onChange = (checked, _isShiftClick) => {
11
+ if (checked) {
12
+ onCheckedRowsChange && onCheckedRowsChange(/* @__PURE__ */ new Set([rowKeyGetter(props.row)]));
13
+ } else {
14
+ onCheckedRowsChange && onCheckedRowsChange(/* @__PURE__ */ new Set());
15
+ }
16
+ };
17
+ return /* @__PURE__ */ jsx(
18
+ RadioButtonFormatter,
19
+ {
20
+ checked: checkedRows?.has(rowKeyGetter(props.row)) || false,
21
+ tabIndex: props.tabIndex,
22
+ onChange,
23
+ "aria-label": "Select"
24
+ }
25
+ );
26
+ }
27
+ function RadioSelectColumnHeaderRenderer(_props) {
28
+ return null;
29
+ }
30
+ const RadioSelectColumn = {
31
+ key: DATAGRID_SELECT_COLUMN_KEY,
32
+ name: "",
33
+ width: 32,
34
+ minWidth: 32,
35
+ isDraggable: false,
36
+ resizable: false,
37
+ sortable: false,
38
+ frozen: true,
39
+ type: "boolean",
40
+ renderHeaderCell: RadioSelectColumnHeaderRenderer,
41
+ renderCell: RadioSelectFormatter,
42
+ renderGroupCell: RadioSelectGroupFormatter
43
+ };
44
+ export {
45
+ RadioSelectColumn as R
46
+ };