@m4l/components 9.3.37-JT20251128-beta.2 → 9.3.38
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/@types/types.d.ts +16 -0
- package/components/CommonActions/components/ActionCancel/slots/ActionsCancelSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionFormCancel/slots/ActionFormCancelSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionIntro/slots/ActionsIntroSlots.d.ts +1 -1
- package/components/DataGrid/contexts/DataGridContext/index.js +268 -41
- package/components/DataGrid/contexts/DataGridContext/types.d.ts +20 -3
- package/components/DataGrid/index.d.ts +4 -5
- package/components/EditLabel/slots/EditLabelSlots.d.ts +1 -1
- package/components/LoadingError/LoadingError.js +1 -1
- package/components/ModalDialog/slots/ModalDialogSlots.d.ts +1 -1
- package/components/PropertyValue/PropertyValue.js +1 -1
- package/components/SettingsLayout/slots/SettingsLayoutSlots.d.ts +1 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js +1 -1
- package/components/areas/components/AreasAdmin/slots/AreasAdminSlots.d.ts +1 -1
- package/components/formatters/ImageFormatter/slots/ImageFormatterSlots.js +1 -1
- package/components/hook-form/RHFCheckbox/slots/RHFCheckBoxSlots.d.ts +1 -1
- package/components/hook-form/RHFColorPicker/slots/RHFColorPickerSlots.js +1 -1
- package/components/hook-form/RHFDatePicker/RHFDatePicker.d.ts +7 -0
- package/components/hook-form/RHFDatePicker/RHFDatePicker.js +85 -0
- package/components/hook-form/RHFDatePicker/RHFDatePicker.styles.d.ts +5 -0
- package/components/hook-form/RHFDatePicker/RHFDatePicker.styles.js +200 -0
- package/components/hook-form/RHFDatePicker/constants.d.ts +4 -0
- package/components/hook-form/RHFDatePicker/constants.js +4 -0
- package/components/hook-form/RHFDatePicker/icons.d.ts +6 -0
- package/components/hook-form/RHFDatePicker/index.d.ts +1 -0
- package/components/hook-form/RHFDatePicker/slots/RHFDatePickerEnum.d.ts +11 -0
- package/components/hook-form/RHFDatePicker/slots/RHFDatePickerEnum.js +15 -0
- package/components/hook-form/RHFDatePicker/slots/RHFDatePickerSlots.d.ts +50 -0
- package/components/hook-form/RHFDatePicker/slots/RHFDatePickerSlots.js +44 -0
- package/components/hook-form/RHFDatePicker/slots/index.d.ts +2 -0
- package/components/hook-form/RHFDatePicker/types.d.ts +61 -0
- package/components/hook-form/RHFDateTime/RHFDateTime.d.ts +24 -1
- package/components/hook-form/RHFDateTimePicker/RHFDateTimePicker.d.ts +11 -0
- package/components/hook-form/RHFDateTimePicker/RHFDateTimePicker.js +8 -0
- package/components/hook-form/RHFDateTimePicker/index.d.ts +1 -0
- package/components/hook-form/RHFPeriod/slots/RHFPeriodSlots.d.ts +1 -1
- package/components/hook-form/RHFSelect/slots/RHFSlots.d.ts +1 -1
- package/components/hook-form/RHFTextField/slots/RHFTextFieldSlots.d.ts +1 -1
- package/components/hook-form/RHFTextFieldPassword/slots/RHFTextFieldPasswordSlots.d.ts +1 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/slots/RHFUploadImageSlots.d.ts +1 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.d.ts +1 -1
- package/components/hook-form/index.d.ts +2 -0
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +1 -1
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +1 -1
- package/components/mui_extended/Button/slots/ButtonSlots.d.ts +1 -1
- package/components/mui_extended/DatePicker/DatePicker.d.ts +7 -0
- package/components/mui_extended/DatePicker/DatePicker.js +39 -0
- package/components/mui_extended/DatePicker/DatePicker.styles.d.ts +5 -0
- package/components/mui_extended/DatePicker/DatePicker.styles.js +193 -0
- package/components/mui_extended/DatePicker/constants.d.ts +2 -0
- package/components/mui_extended/DatePicker/constants.js +8 -0
- package/components/mui_extended/DatePicker/hooks/useDatePicker/types.d.ts +11 -0
- package/components/mui_extended/DatePicker/hooks/useDatePicker/useDatePicker.d.ts +9 -0
- package/components/mui_extended/DatePicker/hooks/useDatePicker/useDatePicker.js +200 -0
- package/components/mui_extended/DatePicker/icons.d.ts +4 -0
- package/components/mui_extended/DatePicker/icons.js +10 -0
- package/components/mui_extended/DatePicker/index.d.ts +2 -0
- package/components/mui_extended/DatePicker/slots/DatePickerEnum.d.ts +10 -0
- package/components/mui_extended/DatePicker/slots/DatePickerEnum.js +14 -0
- package/components/mui_extended/DatePicker/slots/DatePickerSlots.d.ts +44 -0
- package/components/mui_extended/DatePicker/slots/DatePickerSlots.js +46 -0
- package/components/mui_extended/DatePicker/types.d.ts +32 -0
- package/components/mui_extended/LoadingButton/slots/LoadingButtonSlots.d.ts +1 -1
- package/components/mui_extended/NavLink/constants.d.ts +1 -1
- package/components/mui_extended/Select/slots/SelectSlots.d.ts +1 -1
- package/components/mui_extended/Select/slots/SelectSlots.js +1 -1
- package/components/mui_extended/TextField/TextField.js +2 -2
- package/components/mui_extended/TextField/TextField.styles.js +1 -1
- package/components/mui_extended/TextField/slots/TextFieldSlots.d.ts +1 -1
- package/components/mui_extended/ToggleButton/slots/ToggleButtonSlots.d.ts +1 -1
- package/components/mui_extended/index.d.ts +1 -0
- package/hooks/useDataGridPersistence/constants.d.ts +0 -1
- package/hooks/useDataGridPersistence/constants.js +2 -4
- package/hooks/useDataGridPersistence/useDataGridPersistence.js +2 -5
- package/index.js +46 -40
- package/package.json +1 -1
- package/components/DataGrid/helpers/getAllViewModes/getAllViewModes.d.ts +0 -19
- package/components/DataGrid/helpers/getAllViewModes/getAllViewModes.js +0 -6
- package/components/DataGrid/helpers/getAllViewModes/index.d.ts +0 -1
- package/components/DataGrid/helpers/getColumnsWidth/getColumnsWidth.d.ts +0 -47
- package/components/DataGrid/helpers/getColumnsWidth/getColumnsWidth.js +0 -32
- package/components/DataGrid/helpers/getColumnsWidth/index.d.ts +0 -1
- package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.d.ts +0 -24
- package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.js +0 -12
- package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.test.d.ts +0 -1
- package/components/DataGrid/helpers/getIndexRowHeightVariant/index.d.ts +0 -1
- package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.d.ts +0 -48
- package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.js +0 -35
- package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.test.d.ts +0 -1
- package/components/DataGrid/helpers/getInitialColumnsConfig/index.d.ts +0 -1
- package/components/DataGrid/helpers/getViewMode/getViewMode.d.ts +0 -41
- package/components/DataGrid/helpers/getViewMode/getViewMode.js +0 -19
- package/components/DataGrid/helpers/getViewMode/getViewMode.test.d.ts +0 -1
- package/components/DataGrid/helpers/getViewMode/index.d.ts +0 -1
- package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.d.ts +0 -28
- package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.js +0 -22
- package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.test.d.ts +0 -1
- package/components/DataGrid/helpers/getViewSpecificConfig/index.d.ts +0 -1
- package/components/DataGrid/helpers/getViewSpecificConfig/index.js +0 -1
- package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.d.ts +0 -24
- package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.js +0 -9
- package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.test.d.ts +0 -1
- package/components/DataGrid/helpers/getViewSuffix/index.d.ts +0 -1
- package/components/DataGrid/helpers/getViewSuffix/index.js +0 -1
- package/components/DataGrid/helpers/index.d.ts +0 -13
- package/components/DataGrid/helpers/index.js +0 -1
- package/components/DataGrid/helpers/loadViewConfig/index.d.ts +0 -1
- package/components/DataGrid/helpers/loadViewConfig/index.js +0 -1
- package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.d.ts +0 -23
- package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.js +0 -12
- package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.test.d.ts +0 -1
- package/components/DataGrid/helpers/saveColumnsWidth/index.d.ts +0 -1
- package/components/DataGrid/helpers/saveColumnsWidth/index.js +0 -1
- package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.d.ts +0 -52
- package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.js +0 -18
- package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.test.d.ts +0 -1
- package/components/DataGrid/helpers/saveViewConfig/index.d.ts +0 -1
- package/components/DataGrid/helpers/saveViewConfig/index.js +0 -1
- package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.d.ts +0 -35
- package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.js +0 -15
- package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.test.d.ts +0 -1
- package/components/DataGrid/helpers/saveViewMode/index.d.ts +0 -1
- package/components/DataGrid/helpers/saveViewMode/index.js +0 -1
- package/components/DataGrid/helpers/saveViewMode/saveViewMode.d.ts +0 -33
- package/components/DataGrid/helpers/saveViewMode/saveViewMode.js +0 -13
- package/components/DataGrid/helpers/saveViewMode/saveViewMode.test.d.ts +0 -1
- package/components/DataGrid/hooks/index.d.ts +0 -6
- package/components/DataGrid/hooks/index.js +0 -1
- package/components/DataGrid/hooks/useChangeColumnsConfig/index.d.ts +0 -1
- package/components/DataGrid/hooks/useChangeColumnsConfig/index.js +0 -1
- package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.d.ts +0 -9
- package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.js +0 -27
- package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.test.d.ts +0 -1
- package/components/DataGrid/hooks/useChangeColumnsOrder/index.d.ts +0 -1
- package/components/DataGrid/hooks/useChangeColumnsOrder/index.js +0 -1
- package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.d.ts +0 -10
- package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.js +0 -34
- package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.test.d.ts +0 -1
- package/components/DataGrid/hooks/useColumnsWidth/index.d.ts +0 -1
- package/components/DataGrid/hooks/useColumnsWidth/index.js +0 -1
- package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.d.ts +0 -11
- package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.js +0 -29
- package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.test.d.ts +0 -1
- package/components/DataGrid/hooks/useRowHeight/index.d.ts +0 -1
- package/components/DataGrid/hooks/useRowHeight/index.js +0 -1
- package/components/DataGrid/hooks/useRowHeight/useRowHeight.d.ts +0 -28
- package/components/DataGrid/hooks/useRowHeight/useRowHeight.js +0 -51
- package/components/DataGrid/hooks/useRowHeight/useRowHeight.test.d.ts +0 -1
- package/components/DataGrid/hooks/useViewConfig/index.d.ts +0 -1
- package/components/DataGrid/hooks/useViewConfig/index.js +0 -1
- package/components/DataGrid/hooks/useViewConfig/useViewConfig.d.ts +0 -9
- package/components/DataGrid/hooks/useViewConfig/useViewConfig.js +0 -30
- package/components/DataGrid/hooks/useViewConfig/useViewConfig.test.d.ts +0 -1
- package/components/DataGrid/hooks/useViewMode/index.d.ts +0 -1
- package/components/DataGrid/hooks/useViewMode/index.js +0 -1
- package/components/DataGrid/hooks/useViewMode/useViewMode.d.ts +0 -31
- package/components/DataGrid/hooks/useViewMode/useViewMode.js +0 -44
- package/components/DataGrid/hooks/useViewMode/useViewMode.test.d.ts +0 -1
- package/components/DataGrid/types.helpers.d.ts +0 -55
- package/components/DataGrid/types.helpers.js +0 -1
- package/components/DataGrid/types.hooks.d.ts +0 -81
- /package/components/{DataGrid/helpers/getAllViewModes/getAllViewModes.test.d.ts → hook-form/RHFDatePicker/__tests__/RHFDatePicker.test.d.ts} +0 -0
- /package/components/{DataGrid/helpers/getAllViewModes → hook-form/RHFDatePicker}/index.js +0 -0
- /package/components/{DataGrid/helpers/getColumnsWidth → hook-form/RHFDatePicker/slots}/index.js +0 -0
- /package/components/{DataGrid/helpers/getIndexRowHeightVariant → hook-form/RHFDateTimePicker}/index.js +0 -0
- /package/components/{DataGrid/helpers/getColumnsWidth/getColumnsWidth.test.d.ts → mui_extended/DatePicker/__tests__/DatePicker.test.d.ts} +0 -0
- /package/components/{DataGrid/helpers/getInitialColumnsConfig → mui_extended/DatePicker}/index.js +0 -0
- /package/components/{DataGrid/helpers/getViewMode → mui_extended/LoadingButton}/index.js +0 -0
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Column } from 'react-data-grid';
|
|
2
|
-
import { RowKey } from '../../types';
|
|
3
|
-
import { BaseViewConfig } from '../../types.helpers';
|
|
4
|
-
import { IViewConfig, ViewMode } from '../../contexts/DataGridContext/types';
|
|
5
|
-
/**
|
|
6
|
-
* Obtiene la configuración inicial de columnas para cualquier vista.
|
|
7
|
-
*
|
|
8
|
-
* ## Propósito
|
|
9
|
-
*
|
|
10
|
-
* Genera la configuración inicial de columnas combinando:
|
|
11
|
-
* 1. Configuración del usuario (defaultUserConfig) si existe
|
|
12
|
-
* 2. Configuración guardada en localStorage si no hay defaultUserConfig
|
|
13
|
-
* 3. Valores por defecto de las columnas
|
|
14
|
-
*
|
|
15
|
-
* ## Prioridad de configuración
|
|
16
|
-
*
|
|
17
|
-
* 1. defaultUserConfig (del backend/API)
|
|
18
|
-
* 2. localStorage (preferencia guardada del usuario)
|
|
19
|
-
* 3. Valores por defecto de las columnas
|
|
20
|
-
* @param id - Identificador único del DataGrid
|
|
21
|
-
* @param columns - Columnas del DataGrid
|
|
22
|
-
* @param viewMode - Modo de visualización actual ('table' | 'cards')
|
|
23
|
-
* @param defaultUserConfig - Configuración por defecto del usuario (opcional)
|
|
24
|
-
* @param viewSpecificDefaults - Valores por defecto específicos de la vista
|
|
25
|
-
* @param originalViewSpecificDefaults - Valores originales específicos de la vista
|
|
26
|
-
* @returns Array de configuración de columnas ordenado por índice
|
|
27
|
-
* @example
|
|
28
|
-
* // Para vista table
|
|
29
|
-
* getInitialColumnsConfig(
|
|
30
|
-
* 'my-grid',
|
|
31
|
-
* columns,
|
|
32
|
-
* 'table',
|
|
33
|
-
* undefined,
|
|
34
|
-
* { frozen: false },
|
|
35
|
-
* { originalFrozen: false }
|
|
36
|
-
* );
|
|
37
|
-
*
|
|
38
|
-
* // Para vista cards
|
|
39
|
-
* getInitialColumnsConfig(
|
|
40
|
-
* 'my-grid',
|
|
41
|
-
* columns,
|
|
42
|
-
* 'cards',
|
|
43
|
-
* undefined,
|
|
44
|
-
* { showTitle: true },
|
|
45
|
-
* { originalShowTitle: true }
|
|
46
|
-
* );
|
|
47
|
-
*/
|
|
48
|
-
export declare const getInitialColumnsConfig: <TRow, TSummaryRow, TViewSpecific, TOriginalViewSpecific>(id: RowKey, columns: readonly Column<TRow, TSummaryRow>[], viewMode: ViewMode, defaultUserConfig?: BaseViewConfig<TViewSpecific>[], viewSpecificDefaults?: TViewSpecific, originalViewSpecificDefaults?: TOriginalViewSpecific) => IViewConfig<TViewSpecific, TOriginalViewSpecific>[];
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { l as loadViewConfig } from "../loadViewConfig/loadViewConfig.js";
|
|
2
|
-
import { g as getViewSuffix } from "../getViewSuffix/getViewSuffix.js";
|
|
3
|
-
const getInitialColumnsConfig = (id, columns, viewMode, defaultUserConfig, viewSpecificDefaults, originalViewSpecificDefaults) => {
|
|
4
|
-
let columnsConfig;
|
|
5
|
-
if (defaultUserConfig) {
|
|
6
|
-
columnsConfig = defaultUserConfig;
|
|
7
|
-
} else {
|
|
8
|
-
columnsConfig = loadViewConfig(
|
|
9
|
-
id,
|
|
10
|
-
getViewSuffix(viewMode)
|
|
11
|
-
) || [];
|
|
12
|
-
}
|
|
13
|
-
return columns.map((column, index) => {
|
|
14
|
-
const existingConfig = columnsConfig.find((c) => c.key === column.key);
|
|
15
|
-
const columnConfigIndex = existingConfig ? columnsConfig.indexOf(existingConfig) : -1;
|
|
16
|
-
const baseConfig = {
|
|
17
|
-
key: column.key,
|
|
18
|
-
name: typeof column.name === "string" ? column.name : String(column.name),
|
|
19
|
-
hidden: column.hidden === void 0 ? false : column.hidden,
|
|
20
|
-
index: columnConfigIndex > -1 ? columnConfigIndex : index,
|
|
21
|
-
visible: existingConfig?.visible !== void 0 ? existingConfig.visible : column.visible === void 0 ? true : column.visible,
|
|
22
|
-
originalIndex: index,
|
|
23
|
-
originalVisible: column.visible === void 0 ? true : column.visible
|
|
24
|
-
};
|
|
25
|
-
return {
|
|
26
|
-
...baseConfig,
|
|
27
|
-
...viewSpecificDefaults,
|
|
28
|
-
...originalViewSpecificDefaults,
|
|
29
|
-
...existingConfig || {}
|
|
30
|
-
};
|
|
31
|
-
}).sort((a, b) => a.index - b.index);
|
|
32
|
-
};
|
|
33
|
-
export {
|
|
34
|
-
getInitialColumnsConfig as g
|
|
35
|
-
};
|
package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getInitialColumnsConfig } from './getInitialColumnsConfig';
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Maybe } from '@m4l/core';
|
|
2
|
-
import { RowKey } from '../../types';
|
|
3
|
-
import { IGridConfigExtended, ViewMode } from '../../contexts/DataGridContext/types';
|
|
4
|
-
/**
|
|
5
|
-
* Obtiene el modo de visualización del DataGrid.
|
|
6
|
-
*
|
|
7
|
-
* ## Flujo de persistencia
|
|
8
|
-
*
|
|
9
|
-
* Esta función obtiene el viewMode siguiendo una jerarquía de precedencia:
|
|
10
|
-
*
|
|
11
|
-
* 1. **defaultUserColumns.viewMode** (Backend/API) - Prioridad máxima
|
|
12
|
-
* Configuración que viene del backend cuando el componente se monta.
|
|
13
|
-
* En producción, esta es la fuente principal de datos persistidos.
|
|
14
|
-
*
|
|
15
|
-
* 2. **localStorage** - Fallback local
|
|
16
|
-
* Solo se usa cuando NO hay configuración del backend.
|
|
17
|
-
* Útil para desarrollo o cuando no hay integración con backend.
|
|
18
|
-
*
|
|
19
|
-
* 3. **defaultViewMode** - Valor por defecto del desarrollador
|
|
20
|
-
* Se usa si no hay configuración guardada en ningún lado.
|
|
21
|
-
*
|
|
22
|
-
* ## Relación con saveViewMode
|
|
23
|
-
*
|
|
24
|
-
* - Cuando el usuario cambia de vista, `saveViewMode` envía los cambios al backend
|
|
25
|
-
* mediante el callback `onChangeUserColumns`
|
|
26
|
-
* - En la siguiente carga, esos datos vuelven como `defaultUserColumns.viewMode`
|
|
27
|
-
* - localStorage es solo un fallback cuando no hay callback configurado
|
|
28
|
-
* @param id - Identificador único del DataGrid. Se usa como prefijo para la key en localStorage (fallback)
|
|
29
|
-
* @param defaultUserColumns - Configuración del usuario obtenida del backend/API.
|
|
30
|
-
* Esta es la fuente principal en producción.
|
|
31
|
-
* @param defaultViewMode - Valor por defecto del desarrollador cuando no hay configuración guardada
|
|
32
|
-
* @returns El viewMode a usar, o undefined si no se encontró configuración
|
|
33
|
-
* @example
|
|
34
|
-
* // Sin configuración del backend (usa localStorage como fallback)
|
|
35
|
-
* const viewMode = getViewMode('my-grid', null, 'table');
|
|
36
|
-
* @example
|
|
37
|
-
* // Con configuración del backend (caso típico en producción)
|
|
38
|
-
* const viewMode = getViewMode('my-grid', { viewMode: 'cards' }, 'table');
|
|
39
|
-
* @see saveViewMode - Función complementaria para persistir la configuración
|
|
40
|
-
*/
|
|
41
|
-
export declare function getViewMode(id: RowKey, defaultUserColumns: Maybe<IGridConfigExtended>, defaultViewMode?: ViewMode): ViewMode | undefined;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
function getViewMode(id, defaultUserColumns, defaultViewMode) {
|
|
2
|
-
if (defaultUserColumns?.viewMode) {
|
|
3
|
-
return defaultUserColumns.viewMode;
|
|
4
|
-
}
|
|
5
|
-
try {
|
|
6
|
-
const savedViewMode = window.localStorage.getItem(`${id}_view_mode`);
|
|
7
|
-
if (savedViewMode === "cards" || savedViewMode === "table") {
|
|
8
|
-
return savedViewMode;
|
|
9
|
-
}
|
|
10
|
-
} catch (_e) {
|
|
11
|
-
}
|
|
12
|
-
if (defaultViewMode) {
|
|
13
|
-
return defaultViewMode;
|
|
14
|
-
}
|
|
15
|
-
return void 0;
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
getViewMode as g
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getViewMode } from './getViewMode';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ViewMode } from '../../contexts/DataGridContext/types';
|
|
2
|
-
import { ViewSpecificConfig } from '../../types.helpers';
|
|
3
|
-
/**
|
|
4
|
-
* Obtiene la configuración específica para cada modo de vista.
|
|
5
|
-
*
|
|
6
|
-
* ## Propósito
|
|
7
|
-
*
|
|
8
|
-
* Centraliza la lógica específica de cada ViewMode para evitar hardcoding
|
|
9
|
-
* disperso en el código. Cada vista tiene sus propias propiedades:
|
|
10
|
-
*
|
|
11
|
-
* - **table**: `frozen` (columnas fijas)
|
|
12
|
-
* - **cards**: `showTitle` (mostrar título en tarjetas)
|
|
13
|
-
*
|
|
14
|
-
* ## Estructura de retorno
|
|
15
|
-
*
|
|
16
|
-
* - `defaults`: Valores por defecto para nuevas columnas
|
|
17
|
-
* - `originalDefaults`: Valores originales para tracking
|
|
18
|
-
* - `dynamicOriginalProperty`: Función para extraer propiedades originales de items existentes
|
|
19
|
-
* @param viewMode - Modo de vista ('table' | 'cards')
|
|
20
|
-
* @returns Configuración específica del modo de vista
|
|
21
|
-
* @example
|
|
22
|
-
* const tableConfig = getViewSpecificConfig('table');
|
|
23
|
-
* // { defaults: { frozen: false }, originalDefaults: { originalFrozen: false }, ... }
|
|
24
|
-
* @example
|
|
25
|
-
* const cardsConfig = getViewSpecificConfig('cards');
|
|
26
|
-
* // { defaults: { showTitle: true }, originalDefaults: { originalShowTitle: true }, ... }
|
|
27
|
-
*/
|
|
28
|
-
export declare const getViewSpecificConfig: (viewMode: ViewMode) => ViewSpecificConfig;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const getViewSpecificConfig = (viewMode) => {
|
|
2
|
-
const configs = {
|
|
3
|
-
table: {
|
|
4
|
-
defaults: { frozen: false },
|
|
5
|
-
originalDefaults: { originalFrozen: false },
|
|
6
|
-
dynamicOriginalProperty: (item) => ({
|
|
7
|
-
originalFrozen: item?.frozen ?? false
|
|
8
|
-
})
|
|
9
|
-
},
|
|
10
|
-
cards: {
|
|
11
|
-
defaults: { showTitle: true },
|
|
12
|
-
originalDefaults: { originalShowTitle: true },
|
|
13
|
-
dynamicOriginalProperty: (item) => ({
|
|
14
|
-
originalShowTitle: item?.showTitle ?? true
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
return configs[viewMode] || configs.table;
|
|
19
|
-
};
|
|
20
|
-
export {
|
|
21
|
-
getViewSpecificConfig as g
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getViewSpecificConfig } from './getViewSpecificConfig';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ViewMode } from '../../contexts/DataGridContext/types';
|
|
2
|
-
/**
|
|
3
|
-
* Genera el sufijo de localStorage basado en el viewMode.
|
|
4
|
-
*
|
|
5
|
-
* ## Propósito
|
|
6
|
-
*
|
|
7
|
-
* Mantiene retrocompatibilidad con las keys de localStorage existentes:
|
|
8
|
-
* - Vista `table`: sin sufijo (retrocompatibilidad)
|
|
9
|
-
* - Vista `cards`: con sufijo `_cards`
|
|
10
|
-
* - Futuras vistas: con sufijo `_${viewMode}`
|
|
11
|
-
*
|
|
12
|
-
* ## Uso en localStorage
|
|
13
|
-
*
|
|
14
|
-
* ```
|
|
15
|
-
* table: `${id}_columns_config`
|
|
16
|
-
* cards: `${id}_columns_config_cards`
|
|
17
|
-
* ```
|
|
18
|
-
* @param viewMode - Modo de vista ('table' | 'cards')
|
|
19
|
-
* @returns Sufijo para la key de localStorage ('' para table, '_cards' para cards)
|
|
20
|
-
* @example
|
|
21
|
-
* getViewSuffix('table'); // ''
|
|
22
|
-
* getViewSuffix('cards'); // '_cards'
|
|
23
|
-
*/
|
|
24
|
-
export declare const getViewSuffix: (viewMode: ViewMode) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getViewSuffix } from './getViewSuffix';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from './saveColumnsWidth';
|
|
2
|
-
export * from './castMapColumnsWidthToRecord';
|
|
3
|
-
export * from './getColumnsWidth';
|
|
4
|
-
export * from './getColumnKey';
|
|
5
|
-
export * from './getAllViewModes';
|
|
6
|
-
export * from './getViewSpecificConfig';
|
|
7
|
-
export * from './getViewSuffix';
|
|
8
|
-
export * from './saveViewMode';
|
|
9
|
-
export * from './getViewMode';
|
|
10
|
-
export * from './loadViewConfig';
|
|
11
|
-
export * from './saveViewConfig';
|
|
12
|
-
export * from './getIndexRowHeightVariant';
|
|
13
|
-
export * from './getInitialColumnsConfig';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { loadViewConfig } from './loadViewConfig';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { RowKey } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Carga configuraciones de vista desde localStorage.
|
|
4
|
-
*
|
|
5
|
-
* ## Propósito
|
|
6
|
-
*
|
|
7
|
-
* Recupera la configuración de columnas guardada previamente para una vista específica.
|
|
8
|
-
* Trabaja en conjunto con `saveViewConfig` y `getViewSuffix` para persistencia.
|
|
9
|
-
*
|
|
10
|
-
* ## Formato de key en localStorage
|
|
11
|
-
*
|
|
12
|
-
* ```
|
|
13
|
-
* table: `${id}_columns_config`
|
|
14
|
-
* cards: `${id}_columns_config_cards`
|
|
15
|
-
* ```
|
|
16
|
-
* @param id - Identificador único del DataGrid
|
|
17
|
-
* @param viewSuffix - Sufijo para identificar la vista ('' para table, '_cards' para cards)
|
|
18
|
-
* @returns Array de configuración o null si no existe/error
|
|
19
|
-
* @example
|
|
20
|
-
* loadViewConfig('my-grid', ''); // Lee 'my-grid_columns_config'
|
|
21
|
-
* loadViewConfig('my-grid', '_cards'); // Lee 'my-grid_columns_config_cards'
|
|
22
|
-
*/
|
|
23
|
-
export declare const loadViewConfig: <T>(id: RowKey, viewSuffix: string) => T[] | null;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const loadViewConfig = (id, viewSuffix) => {
|
|
2
|
-
try {
|
|
3
|
-
const storageKey = viewSuffix === "" ? `${id}_columns_config` : `${id}_columns_config${viewSuffix}`;
|
|
4
|
-
const stored = localStorage.getItem(storageKey);
|
|
5
|
-
return stored ? JSON.parse(stored) : null;
|
|
6
|
-
} catch (_e) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
loadViewConfig as l
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { saveColumnsWidth } from './saveColumnsWidth';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Maybe } from '@m4l/core';
|
|
2
|
-
import { RowKey, OnChangeUserColumns } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
* Persiste la configuración de anchos de las columnas del DataGrid.
|
|
5
|
-
*
|
|
6
|
-
* ## Flujo de persistencia
|
|
7
|
-
*
|
|
8
|
-
* Esta función guarda los anchos de columnas siguiendo esta lógica:
|
|
9
|
-
*
|
|
10
|
-
* 1. **onChangeUserColumns** (Backend/API) - Método principal en producción
|
|
11
|
-
* Si está disponible, envía la configuración al callback para que el consumidor
|
|
12
|
-
* la persista en el backend. En la siguiente carga, estos datos volverán
|
|
13
|
-
* como `defaultUserColumns` en `getColumnsWidth`.
|
|
14
|
-
*
|
|
15
|
-
* 2. **localStorage** - Fallback local
|
|
16
|
-
* Solo se usa cuando NO hay callback configurado.
|
|
17
|
-
* Útil para desarrollo o cuando no hay integración con backend.
|
|
18
|
-
*
|
|
19
|
-
* ## Ciclo completo de persistencia
|
|
20
|
-
*
|
|
21
|
-
* ```
|
|
22
|
-
* Usuario redimensiona columna
|
|
23
|
-
* ↓
|
|
24
|
-
* saveColumnsWidth() envía al backend via onChangeUserColumns
|
|
25
|
-
* ↓
|
|
26
|
-
* Backend persiste en BD/cookies
|
|
27
|
-
* ↓
|
|
28
|
-
* Próxima carga: datos vienen en defaultUserColumns
|
|
29
|
-
* ↓
|
|
30
|
-
* getColumnsWidth() lee de defaultUserColumns
|
|
31
|
-
* ```
|
|
32
|
-
* @param id - Identificador único del DataGrid. Se usa como prefijo en localStorage (fallback)
|
|
33
|
-
* @param storeColumnsWidth - Map con la configuración de anchos donde:
|
|
34
|
-
* - key: identificador de la columna (column.key)
|
|
35
|
-
* - value: ancho en píxeles (number) o string con unidad CSS
|
|
36
|
-
* @param onChangeUserColumns - Callback para enviar la configuración al backend.
|
|
37
|
-
* Recibe un objeto con:
|
|
38
|
-
* - reason: 'columnsWidths' (identificador del tipo de cambio)
|
|
39
|
-
* - userConfig: Record con los anchos de columnas
|
|
40
|
-
* @example
|
|
41
|
-
* // Producción: Guardar mediante callback al backend
|
|
42
|
-
* saveColumnsWidth('my-grid', columnsWidthsMap, ({ reason, userConfig }) => {
|
|
43
|
-
* // El backend persiste en BD o cookies
|
|
44
|
-
* api.saveUserPreferences(userConfig);
|
|
45
|
-
* });
|
|
46
|
-
* @example
|
|
47
|
-
* // Desarrollo: Guardar en localStorage (sin backend)
|
|
48
|
-
* saveColumnsWidth('my-grid', columnsWidthsMap);
|
|
49
|
-
* @see getColumnsWidth - Función complementaria para obtener la configuración
|
|
50
|
-
* @see castMapColumnsWidthToRecord - Helper usado para convertir el Map a Record
|
|
51
|
-
*/
|
|
52
|
-
export declare function saveColumnsWidth(id: RowKey, storeColumnsWidth: Map<string, Maybe<string | number>>, onChangeUserColumns?: OnChangeUserColumns): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { c as castMapColumnsWidthToRecord } from "../castMapColumnsWidthToRecord.js";
|
|
2
|
-
function saveColumnsWidth(id, storeColumnsWidth, onChangeUserColumns) {
|
|
3
|
-
if (onChangeUserColumns) {
|
|
4
|
-
const columnsWidthObject = castMapColumnsWidthToRecord(storeColumnsWidth);
|
|
5
|
-
onChangeUserColumns({
|
|
6
|
-
reason: "columnsWidths",
|
|
7
|
-
userConfig: columnsWidthObject
|
|
8
|
-
});
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
localStorage.setItem(
|
|
12
|
-
`${id}_columns_width`,
|
|
13
|
-
JSON.stringify([...storeColumnsWidth])
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
saveColumnsWidth as s
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { saveViewConfig } from './saveViewConfig';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { RowKey } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Guarda configuraciones de vista en localStorage o notifica via callback.
|
|
4
|
-
*
|
|
5
|
-
* ## Propósito
|
|
6
|
-
*
|
|
7
|
-
* Persiste la configuración de columnas para una vista específica.
|
|
8
|
-
* Soporta dos modos: localStorage directo o callback externo (API/backend).
|
|
9
|
-
*
|
|
10
|
-
* ## Prioridad de persistencia
|
|
11
|
-
*
|
|
12
|
-
* 1. Si hay `onChangeCallback`, notifica al callback (para guardar en backend)
|
|
13
|
-
* 2. Si no hay callback, guarda directamente en localStorage
|
|
14
|
-
*
|
|
15
|
-
* ## Formato de key en localStorage
|
|
16
|
-
*
|
|
17
|
-
* ```
|
|
18
|
-
* table: `${id}_columns_config`
|
|
19
|
-
* cards: `${id}_columns_config_cards`
|
|
20
|
-
* ```
|
|
21
|
-
* @param id - Identificador único del DataGrid
|
|
22
|
-
* @param viewSuffix - Sufijo para identificar la vista ('' para table, '_cards' para cards)
|
|
23
|
-
* @param config - Array de configuración a guardar
|
|
24
|
-
* @param onChangeCallback - Callback opcional para notificar cambios (prioridad sobre localStorage)
|
|
25
|
-
* @example
|
|
26
|
-
* // Guardar en localStorage
|
|
27
|
-
* saveViewConfig('my-grid', '', config);
|
|
28
|
-
*
|
|
29
|
-
* // Notificar via callback
|
|
30
|
-
* saveViewConfig('my-grid', '_cards', config, handleChange);
|
|
31
|
-
*/
|
|
32
|
-
export declare const saveViewConfig: <T>(id: RowKey, viewSuffix: string, config: T[], onChangeCallback?: (data: {
|
|
33
|
-
reason: string;
|
|
34
|
-
userConfig: T[];
|
|
35
|
-
}) => void) => void;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const saveViewConfig = (id, viewSuffix, config, onChangeCallback) => {
|
|
2
|
-
if (onChangeCallback) {
|
|
3
|
-
const reason = viewSuffix === "" ? "columnsConfig" : `columnsConfig${viewSuffix.replace("_", "")}`;
|
|
4
|
-
onChangeCallback({
|
|
5
|
-
reason,
|
|
6
|
-
userConfig: config
|
|
7
|
-
});
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const storageKey = viewSuffix === "" ? `${id}_columns_config` : `${id}_columns_config${viewSuffix}`;
|
|
11
|
-
localStorage.setItem(storageKey, JSON.stringify(config));
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
saveViewConfig as s
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { saveViewMode } from './saveViewMode';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ViewMode } from '../../contexts/DataGridContext/types';
|
|
2
|
-
import { OnChangeUserColumns, RowKey } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
* Guarda el modo de visualización (table o cards).
|
|
5
|
-
*
|
|
6
|
-
* ## Propósito
|
|
7
|
-
*
|
|
8
|
-
* Persiste la preferencia del usuario sobre el modo de vista seleccionado.
|
|
9
|
-
* Permite que al recargar la página se mantenga la última vista utilizada.
|
|
10
|
-
*
|
|
11
|
-
* ## Prioridad de guardado
|
|
12
|
-
*
|
|
13
|
-
* 1. Si existe `onChangeUserColumns` → Guarda en backend (cookies de red)
|
|
14
|
-
* 2. Si no existe → Fallback a localStorage
|
|
15
|
-
*
|
|
16
|
-
* ## Formato de key en localStorage (fallback)
|
|
17
|
-
*
|
|
18
|
-
* ```
|
|
19
|
-
* `${id}_view_mode` -> 'table' | 'cards'
|
|
20
|
-
* ```
|
|
21
|
-
* @param id - Identificador único del DataGrid
|
|
22
|
-
* @param viewMode - Modo de visualización ('table' | 'cards')
|
|
23
|
-
* @param onChangeUserColumns - Callback opcional para guardar en backend
|
|
24
|
-
* @example
|
|
25
|
-
* // Con backend
|
|
26
|
-
* saveViewMode('my-grid', 'cards', onChangeUserColumns);
|
|
27
|
-
* // Llama: onChangeUserColumns({ reason: 'viewMode', userConfig: 'cards' })
|
|
28
|
-
*
|
|
29
|
-
* // Sin backend (fallback)
|
|
30
|
-
* saveViewMode('my-grid', 'cards');
|
|
31
|
-
* // localStorage: 'my-grid_view_mode' = 'cards'
|
|
32
|
-
*/
|
|
33
|
-
export declare const saveViewMode: (id: RowKey, viewMode: ViewMode, onChangeUserColumns?: OnChangeUserColumns) => void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const saveViewMode = (id, viewMode, onChangeUserColumns) => {
|
|
2
|
-
if (onChangeUserColumns) {
|
|
3
|
-
onChangeUserColumns({
|
|
4
|
-
reason: "viewMode",
|
|
5
|
-
userConfig: viewMode
|
|
6
|
-
});
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
localStorage.setItem(`${id}_view_mode`, viewMode);
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
saveViewMode as s
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useChangeColumnsConfig } from './useChangeColumnsConfig';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useChangeColumnsOrder } from './useChangeColumnsOrder';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|