@m4l/components 9.4.51-beta-fix-683-datagrids-remove-localstorage.1 → 9.4.51

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 (54) hide show
  1. package/components/datagrids/components/DataGridMain/DataGridMain.d.ts.map +1 -1
  2. package/components/datagrids/components/DataGridMain/DataGridMain.js +9 -7
  3. package/components/datagrids/components/TreeDataGrid/TreeDataGrid.d.ts.map +1 -1
  4. package/components/datagrids/components/TreeDataGrid/TreeDataGrid.js +27 -25
  5. package/components/datagrids/helpers/index.d.ts +1 -0
  6. package/components/datagrids/helpers/index.d.ts.map +1 -1
  7. package/components/datagrids/helpers/persistence/getColumnsWidth/getColumnsWidth.d.ts +5 -3
  8. package/components/datagrids/helpers/persistence/getColumnsWidth/getColumnsWidth.d.ts.map +1 -1
  9. package/components/datagrids/helpers/persistence/getColumnsWidth/getColumnsWidth.js +20 -9
  10. package/components/datagrids/helpers/persistence/getViewMode/getViewMode.d.ts +25 -20
  11. package/components/datagrids/helpers/persistence/getViewMode/getViewMode.d.ts.map +1 -1
  12. package/components/datagrids/helpers/persistence/getViewMode/getViewMode.js +10 -4
  13. package/components/datagrids/helpers/persistence/loadViewConfig/index.d.ts +2 -0
  14. package/components/datagrids/helpers/persistence/loadViewConfig/index.d.ts.map +1 -0
  15. package/components/datagrids/helpers/persistence/loadViewConfig/loadViewConfig.d.ts +24 -0
  16. package/components/datagrids/helpers/persistence/loadViewConfig/loadViewConfig.d.ts.map +1 -0
  17. package/components/datagrids/helpers/persistence/loadViewConfig/loadViewConfig.js +11 -0
  18. package/components/datagrids/helpers/persistence/saveColumnsWidth/saveColumnsWidth.d.ts +9 -4
  19. package/components/datagrids/helpers/persistence/saveColumnsWidth/saveColumnsWidth.d.ts.map +1 -1
  20. package/components/datagrids/helpers/persistence/saveColumnsWidth/saveColumnsWidth.js +13 -8
  21. package/components/datagrids/helpers/persistence/saveViewConfig/saveViewConfig.d.ts +18 -13
  22. package/components/datagrids/helpers/persistence/saveViewConfig/saveViewConfig.d.ts.map +1 -1
  23. package/components/datagrids/helpers/persistence/saveViewConfig/saveViewConfig.js +11 -8
  24. package/components/datagrids/helpers/persistence/saveViewMode/saveViewMode.d.ts +17 -14
  25. package/components/datagrids/helpers/persistence/saveViewMode/saveViewMode.d.ts.map +1 -1
  26. package/components/datagrids/helpers/persistence/saveViewMode/saveViewMode.js +10 -6
  27. package/components/datagrids/helpers/shared/getInitialColumnsConfig/getInitialColumnsConfig.d.ts +19 -18
  28. package/components/datagrids/helpers/shared/getInitialColumnsConfig/getInitialColumnsConfig.d.ts.map +1 -1
  29. package/components/datagrids/helpers/shared/getInitialColumnsConfig/getInitialColumnsConfig.js +16 -11
  30. package/components/datagrids/helpers/shared/getViewSuffix/getViewSuffix.d.ts +11 -11
  31. package/components/datagrids/helpers/shared/scrollToRowElement/scrollToRowElement.d.ts +2 -1
  32. package/components/datagrids/helpers/shared/scrollToRowElement/scrollToRowElement.d.ts.map +1 -1
  33. package/components/datagrids/helpers/shared/scrollToRowElement/scrollToRowElement.js +3 -3
  34. package/components/datagrids/hooks/useChangeColumnsConfig/useChangeColumnsConfig.d.ts +4 -5
  35. package/components/datagrids/hooks/useChangeColumnsConfig/useChangeColumnsConfig.d.ts.map +1 -1
  36. package/components/datagrids/hooks/useViewMode/useViewMode.d.ts +13 -13
  37. package/components/datagrids/hooks/useViewMode/useViewMode.d.ts.map +1 -1
  38. package/components/datagrids/types.d.ts +8 -2
  39. package/components/datagrids/types.d.ts.map +1 -1
  40. package/components/datagrids/views/CardsView/CardsView.d.ts.map +1 -1
  41. package/components/datagrids/views/CardsView/CardsView.js +36 -34
  42. package/components/datagrids/views/ListView/ListView.d.ts.map +1 -1
  43. package/components/datagrids/views/ListView/ListView.js +45 -43
  44. package/components/datagrids/views/TableView/TableView.d.ts.map +1 -1
  45. package/components/datagrids/views/TableView/TableView.js +115 -109
  46. package/hooks/useDataGridPersistence/constants.d.ts +0 -1
  47. package/hooks/useDataGridPersistence/constants.d.ts.map +1 -1
  48. package/hooks/useDataGridPersistence/constants.js +4 -5
  49. package/hooks/useDataGridPersistence/helpers.d.ts +0 -4
  50. package/hooks/useDataGridPersistence/helpers.d.ts.map +1 -1
  51. package/hooks/useDataGridPersistence/helpers.js +2 -3
  52. package/hooks/useDataGridPersistence/useDataGridPersistence.d.ts.map +1 -1
  53. package/hooks/useDataGridPersistence/useDataGridPersistence.js +38 -47
  54. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"DataGridMain.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/datagrids/components/DataGridMain/DataGridMain.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EACtE,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,oDAqC9C"}
1
+ {"version":3,"file":"DataGridMain.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/datagrids/components/DataGridMain/DataGridMain.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EACtE,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,oDAuC9C"}
@@ -1,7 +1,7 @@
1
- import { jsx as o } from "@emotion/react/jsx-runtime";
1
+ import { jsx as e } from "@emotion/react/jsx-runtime";
2
2
  import { BaseDataGrid as f } from "../BaseDataGrid/BaseDataGrid.js";
3
- import { RenderContent as l } from "../../views/adapters/RenderContent/RenderContent.js";
4
- function G(e) {
3
+ import { RenderContent as g } from "../../views/adapters/RenderContent/RenderContent.js";
4
+ function p(o) {
5
5
  const {
6
6
  id: n,
7
7
  withActions: r,
@@ -13,12 +13,13 @@ function G(e) {
13
13
  onRowsChange: w,
14
14
  cardsViewConfig: a,
15
15
  focusOnRowKey: h,
16
+ smoothScroll: l,
16
17
  checkedRows: m,
17
18
  onCheckedRowsChange: C,
18
19
  rowCellsBackground: R
19
- } = e;
20
- return /* @__PURE__ */ o(f, { ...e, children: /* @__PURE__ */ o(
21
- l,
20
+ } = o;
21
+ return /* @__PURE__ */ e(f, { ...o, children: /* @__PURE__ */ e(
22
+ g,
22
23
  {
23
24
  id: n,
24
25
  withActions: r,
@@ -30,6 +31,7 @@ function G(e) {
30
31
  onRowsChange: w,
31
32
  cardsViewConfig: a,
32
33
  focusOnRowKey: h,
34
+ smoothScroll: l,
33
35
  checkedRows: m,
34
36
  onCheckedRowsChange: C,
35
37
  rowCellsBackground: R
@@ -37,5 +39,5 @@ function G(e) {
37
39
  ) });
38
40
  }
39
41
  export {
40
- G as DataGrid
42
+ p as DataGrid
41
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TreeDataGrid.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/datagrids/components/TreeDataGrid/TreeDataGrid.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EAC1E,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,oDA6DlD"}
1
+ {"version":3,"file":"TreeDataGrid.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/datagrids/components/TreeDataGrid/TreeDataGrid.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EAC1E,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,oDA+DlD"}
@@ -1,48 +1,50 @@
1
1
  import { jsx as r } from "@emotion/react/jsx-runtime";
2
- import { useState as g } from "react";
3
- import { TableView as f } from "../../views/TableView/TableView.js";
4
- import { BaseDataGrid as E } from "../BaseDataGrid/BaseDataGrid.js";
5
- function B(o) {
2
+ import { useState as f } from "react";
3
+ import { TableView as E } from "../../views/TableView/TableView.js";
4
+ import { BaseDataGrid as R } from "../BaseDataGrid/BaseDataGrid.js";
5
+ function D(e) {
6
6
  const {
7
7
  id: s,
8
8
  withActions: t,
9
9
  columns: a,
10
10
  rows: p,
11
- selectedRows: u,
12
- onSelectedRowsChange: c,
11
+ selectedRows: c,
12
+ onSelectedRowsChange: u,
13
13
  rowKeyGetter: i,
14
14
  onRowsChange: G,
15
- focusOnRowKey: w,
16
- checkedRows: x,
17
- onCheckedRowsChange: h,
18
- rowGrouper: l,
19
- expandedGroupIds: e,
15
+ focusOnRowKey: l,
16
+ smoothScroll: w,
17
+ checkedRows: h,
18
+ onCheckedRowsChange: x,
19
+ rowGrouper: I,
20
+ expandedGroupIds: o,
20
21
  onExpandedGroupIdsChange: n,
21
- rowCellsBackground: I
22
- } = o, [C, m] = g(() => new Set(e ?? [])), d = e !== void 0 && n !== void 0;
23
- return /* @__PURE__ */ r(E, { ...o, children: /* @__PURE__ */ r(
24
- f,
22
+ rowCellsBackground: m
23
+ } = e, [C, g] = f(() => new Set(o ?? [])), d = o !== void 0 && n !== void 0;
24
+ return /* @__PURE__ */ r(R, { ...e, children: /* @__PURE__ */ r(
25
+ E,
25
26
  {
26
27
  id: s,
27
28
  withActions: t,
28
29
  columns: a,
29
30
  rows: p,
30
- selectedRows: u,
31
- onSelectedRowsChange: c,
31
+ selectedRows: c,
32
+ onSelectedRowsChange: u,
32
33
  rowKeyGetter: i,
33
34
  onRowsChange: G,
34
- focusOnRowKey: w,
35
- checkedRows: x,
36
- onCheckedRowsChange: h,
37
- rowCellsBackground: I,
35
+ focusOnRowKey: l,
36
+ smoothScroll: w,
37
+ checkedRows: h,
38
+ onCheckedRowsChange: x,
39
+ rowCellsBackground: m,
38
40
  treeProps: {
39
- rowGrouper: l,
40
- expandedGroupIds: d ? e : C,
41
- onExpandedGroupIdsChange: d ? n : m
41
+ rowGrouper: I,
42
+ expandedGroupIds: d ? o : C,
43
+ onExpandedGroupIdsChange: d ? n : g
42
44
  }
43
45
  }
44
46
  ) });
45
47
  }
46
48
  export {
47
- B as TreeDataGrid
49
+ D as TreeDataGrid
48
50
  };
@@ -1,6 +1,7 @@
1
1
  export { saveColumnsWidth } from './persistence/saveColumnsWidth';
2
2
  export { saveViewConfig } from './persistence/saveViewConfig';
3
3
  export { saveViewMode } from './persistence/saveViewMode';
4
+ export { loadViewConfig } from './persistence/loadViewConfig';
4
5
  export { getColumnsWidth } from './persistence/getColumnsWidth';
5
6
  export { getViewMode } from './persistence/getViewMode';
6
7
  export { castMapColumnsWidthToRecord } from './shared/castMapColumnsWidthToRecord';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/datagrids/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/datagrids/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -13,7 +13,9 @@ import { IGridConfig } from './types';
13
13
  * Configuración que viene de las cookies de red cuando el componente se monta.
14
14
  * En producción, esta es la fuente principal de datos persistidos.
15
15
  *
16
- * localStorage is not used; configuration must be provided via defaultConfig (network cookies).
16
+ * 2. **localStorage** - Fallback local
17
+ * Solo se usa cuando NO hay configuración de cookies de red.
18
+ * Útil para desarrollo o cuando no hay integración con cookies de red.
17
19
  *
18
20
  * Si no se encuentra configuración en ninguna fuente, la columna no se incluye
19
21
  * en el Map resultante y usará el ancho por defecto definido en la columna.
@@ -33,10 +35,10 @@ import { IGridConfig } from './types';
33
35
  * @returns Map donde la key es el identificador de la columna (column.key) y el value
34
36
  * es el ancho configurado (número en píxeles o string con unidad CSS)
35
37
  * @example
36
- * // No network cookie config (no fallback; defaultConfig must come from consumer)
38
+ * // Sin configuración de cookies de red (usa localStorage como fallback)
37
39
  * const columnsWidths = getColumnsWidth('my-grid', columns, null);
38
40
  * @example
39
- * // With network cookie config (typical production case)
41
+ * // Con configuración de cookies de red (caso típico en producción)
40
42
  * const columnsWidths = getColumnsWidth('my-grid', columns, {
41
43
  * columnsWidths: { name: 200, email: 300 }
42
44
  * });
@@ -1 +1 @@
1
- {"version":3,"file":"getColumnsWidth.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/getColumnsWidth/getColumnsWidth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAC/C,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,SAAS,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAC7C,aAAa,EAAE,KAAK,CAAC,WAAW,CAAC,GAChC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAuBrC"}
1
+ {"version":3,"file":"getColumnsWidth.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/getColumnsWidth/getColumnsWidth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAC/C,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,SAAS,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAC7C,aAAa,EAAE,KAAK,CAAC,WAAW,CAAC,GAChC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAsCrC"}
@@ -1,16 +1,27 @@
1
- function o(r, e, n) {
2
- const h = /* @__PURE__ */ new Map();
3
- for (let t = 0; t < e.length; t++) {
4
- let i;
5
- if (n)
1
+ function s(h, i, r) {
2
+ const a = /* @__PURE__ */ new Map();
3
+ let n;
4
+ try {
5
+ const t = window.localStorage.getItem(`${h}_columns_width`);
6
+ n = t !== null ? new Map(JSON.parse(t)) : /* @__PURE__ */ new Map();
7
+ } catch {
8
+ n = /* @__PURE__ */ new Map();
9
+ }
10
+ for (let t = 0; t < i.length; t++) {
11
+ let e;
12
+ if (r)
6
13
  try {
7
- i = n.columnsWidths[e[t].key];
14
+ e = r.columnsWidths[i[t].key];
8
15
  } catch {
9
16
  }
10
- i !== void 0 && h.set(e[t].key, i);
17
+ if (e === void 0) {
18
+ const o = n.get(i[t].key);
19
+ typeof o == "number" && (e = o);
20
+ }
21
+ e !== void 0 && a.set(i[t].key, e);
11
22
  }
12
- return h;
23
+ return a;
13
24
  }
14
25
  export {
15
- o as getColumnsWidth
26
+ s as getColumnsWidth
16
27
  };
@@ -2,36 +2,41 @@ import { Maybe } from '@m4l/core';
2
2
  import { RowKey } from '../../../types';
3
3
  import { IGridConfigExtended, ViewMode } from '../../../contexts/DataGridContext/types';
4
4
  /**
5
- * Gets the DataGrid view mode (table/cards).
5
+ * Obtiene el modo de visualización del DataGrid.
6
6
  *
7
- * ## Persistence flow
7
+ * ## Flujo de persistencia
8
8
  *
9
- * This function obtains viewMode following a precedence order:
9
+ * Esta función obtiene el viewMode siguiendo una jerarquía de precedencia:
10
10
  *
11
- * 1. **defaultConfig.viewMode** (Network cookies) - Highest priority
12
- * Configuration that comes from network cookies when the component mounts.
13
- * In production, this is the main source of persisted data.
11
+ * 1. **defaultConfig.viewMode** (Cookies de red) - Prioridad máxima
12
+ * Configuración que viene de las cookies de red cuando el componente se monta.
13
+ * En producción, esta es la fuente principal de datos persistidos.
14
14
  *
15
- * localStorage is not used.
15
+ * 2. **localStorage** - Fallback local
16
+ * Solo se usa cuando NO hay configuración de cookies de red.
17
+ * Útil para desarrollo o cuando no hay integración con cookies de red.
16
18
  *
17
- * 2. **defaultViewMode** - Developer default value
18
- * Used when there is no configuration saved in network cookies.
19
+ * 3. **defaultViewMode** - Valor por defecto del desarrollador
20
+ * Se usa si no hay configuración guardada en ningún lado.
19
21
  *
20
- * ## Relation with saveViewMode
22
+ * ## Relación con saveViewMode
21
23
  *
22
- * - When the user changes view, `saveViewMode` sends changes via the `onChangeConfig` callback
23
- * - On next load, that data comes back as `defaultConfig.viewMode`
24
- * @param id - Unique DataGrid identifier (API compatibility)
25
- * @param defaultConfig - User configuration from network cookies. Main source in production.
26
- * @param defaultViewMode - Developer default when no configuration is saved
27
- * @returns The viewMode to use, or undefined if none found
24
+ * - Cuando el usuario cambia de vista, `saveViewMode` envía los cambios
25
+ * mediante el callback `onChangeConfig`
26
+ * - En la siguiente carga, esos datos vuelven como `defaultConfig.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 defaultConfig - Configuración del usuario obtenida de cookies de red.
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
28
33
  * @example
29
- * // No network cookie config (uses defaultViewMode if provided)
34
+ * // Sin configuración de cookies de red (usa localStorage como fallback)
30
35
  * const viewMode = getViewMode('my-grid', null, 'table');
31
36
  * @example
32
- * // With network cookie config (typical production case)
37
+ * // Con configuración de cookies de red (caso típico en producción)
33
38
  * const viewMode = getViewMode('my-grid', { viewMode: 'cards' }, 'table');
34
- * @see saveViewMode - Complementary function to persist view mode
39
+ * @see saveViewMode - Función complementaria para persistir la configuración
35
40
  */
36
- export declare function getViewMode(_id: RowKey, defaultConfig: Maybe<IGridConfigExtended>, defaultViewMode?: ViewMode): ViewMode | undefined;
41
+ export declare function getViewMode(id: RowKey, defaultConfig: Maybe<IGridConfigExtended>, defaultViewMode?: ViewMode): ViewMode | undefined;
37
42
  //# sourceMappingURL=getViewMode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getViewMode.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/getViewMode/getViewMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AAExF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,EACzC,eAAe,CAAC,EAAE,QAAQ,GACzB,QAAQ,GAAG,SAAS,CAUtB"}
1
+ {"version":3,"file":"getViewMode.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/getViewMode/getViewMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AAExF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,EACV,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,EACzC,eAAe,CAAC,EAAE,QAAQ,GACzB,QAAQ,GAAG,SAAS,CA0BtB"}
@@ -1,9 +1,15 @@
1
- function n(i, e, r) {
2
- if (e?.viewMode)
3
- return e.viewMode;
1
+ function o(i, t, r) {
2
+ if (t?.viewMode)
3
+ return t.viewMode;
4
+ try {
5
+ const e = window.localStorage.getItem(`${i}_view_mode`);
6
+ if (e === "cards" || e === "table" || e === "list")
7
+ return e;
8
+ } catch {
9
+ }
4
10
  if (r)
5
11
  return r;
6
12
  }
7
13
  export {
8
- n as getViewMode
14
+ o as getViewMode
9
15
  };
@@ -0,0 +1,2 @@
1
+ export { loadViewConfig } from './loadViewConfig';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/loadViewConfig/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,24 @@
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;
24
+ //# sourceMappingURL=loadViewConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadViewConfig.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/loadViewConfig/loadViewConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAC9B,IAAI,MAAM,EACV,YAAY,MAAM,KACjB,CAAC,EAAE,GAAG,IAYR,CAAC"}
@@ -0,0 +1,11 @@
1
+ const c = (o, t) => {
2
+ try {
3
+ const n = t === "" ? `${o}_columns_config` : `${o}_columns_config${t}`, e = localStorage.getItem(n);
4
+ return e ? JSON.parse(e) : null;
5
+ } catch {
6
+ return null;
7
+ }
8
+ };
9
+ export {
10
+ c as loadViewConfig
11
+ };
@@ -12,7 +12,9 @@ import { RowKey, OnChangeConfig } from '../../../types';
12
12
  * la persista en cookies de red. En la siguiente carga, estos datos volverán
13
13
  * como `defaultConfig` en `getColumnsWidth`.
14
14
  *
15
- * localStorage is not used; if no callback is configured, nothing is saved.
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 cookies de red.
16
18
  *
17
19
  * ## Ciclo completo de persistencia
18
20
  *
@@ -27,7 +29,7 @@ import { RowKey, OnChangeConfig } from '../../../types';
27
29
  * ↓
28
30
  * getColumnsWidth() lee de defaultConfig
29
31
  * ```
30
- * @param id - Identificador único del DataGrid
32
+ * @param id - Identificador único del DataGrid. Se usa como prefijo en localStorage (fallback)
31
33
  * @param storeColumnsWidth - Map con la configuración de anchos donde:
32
34
  * - key: identificador de la columna (column.key)
33
35
  * - value: ancho en píxeles (number) o string con unidad CSS
@@ -41,8 +43,11 @@ import { RowKey, OnChangeConfig } from '../../../types';
41
43
  * // Persistir en cookies de red
42
44
  * setCookie(userConfig);
43
45
  * });
44
- * @see getColumnsWidth - Complementary function to load configuration
45
- * @see castMapColumnsWidthToRecord - Helper to convert Map to Record
46
+ * @example
47
+ * // Desarrollo: Guardar en localStorage (sin cookies de red)
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
46
51
  */
47
52
  export declare function saveColumnsWidth(id: RowKey, storeColumnsWidth: Map<string, Maybe<string | number>>, onChangeConfig?: OnChangeConfig): void;
48
53
  //# sourceMappingURL=saveColumnsWidth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveColumnsWidth.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/saveColumnsWidth/saveColumnsWidth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,EACtD,cAAc,CAAC,EAAE,cAAc,GAC9B,IAAI,CAYN"}
1
+ {"version":3,"file":"saveColumnsWidth.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/saveColumnsWidth/saveColumnsWidth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,EACtD,cAAc,CAAC,EAAE,cAAc,GAC9B,IAAI,CAkBN"}
@@ -1,13 +1,18 @@
1
1
  import { castMapColumnsWidthToRecord as i } from "../../shared/castMapColumnsWidthToRecord/castMapColumnsWidthToRecord.js";
2
- function n(r, t, o) {
3
- if (!o)
2
+ function e(s, t, o) {
3
+ if (o) {
4
+ const c = i(t);
5
+ o({
6
+ reason: "columnsWidths",
7
+ userConfig: c
8
+ });
4
9
  return;
5
- const s = i(t);
6
- o({
7
- reason: "columnsWidths",
8
- userConfig: s
9
- });
10
+ }
11
+ localStorage.setItem(
12
+ `${s}_columns_width`,
13
+ JSON.stringify([...t])
14
+ );
10
15
  }
11
16
  export {
12
- n as saveColumnsWidth
17
+ e as saveColumnsWidth
13
18
  };
@@ -1,27 +1,32 @@
1
1
  import { RowKey } from '../../../types';
2
2
  /**
3
- * Saves view configuration or notifies via callback.
3
+ * Guarda configuraciones de vista en localStorage o notifica via callback.
4
4
  *
5
- * ## Purpose
5
+ * ## Propósito
6
6
  *
7
- * Persists column configuration for a specific view.
8
- * Only external callback (network cookies) is supported. localStorage is not used.
7
+ * Persiste la configuración de columnas para una vista específica.
8
+ * Soporta dos modos: localStorage directo o callback externo (cookies de red).
9
9
  *
10
- * ## Persistence priority
10
+ * ## Prioridad de persistencia
11
11
  *
12
- * 1. If `onChangeConfig` is present, notifies the callback (to save in network cookies)
13
- * 2. If no callback, nothing is saved
12
+ * 1. Si hay `onChangeConfig`, notifica al callback (para guardar en cookies de red)
13
+ * 2. Si no hay callback, guarda directamente en localStorage
14
14
  *
15
- * ## Key format (reference; persistence is only via callback)
15
+ * ## Formato de key en localStorage
16
16
  *
17
+ * ```
17
18
  * table: `${id}_columns_config`
18
19
  * cards: `${id}_columns_config_cards`
19
- * @param id - Unique DataGrid identifier
20
- * @param viewSuffix - Suffix to identify the view ('' for table, '_cards' for cards)
21
- * @param config - Configuration array to save
22
- * @param onChangeConfig - Optional callback to notify changes. If not provided, nothing is saved.
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 onChangeConfig - Callback opcional para notificar cambios (prioridad sobre localStorage)
23
25
  * @example
24
- * // Notify via callback
26
+ * // Guardar en localStorage
27
+ * saveViewConfig('my-grid', '', config);
28
+ *
29
+ * // Notificar via callback
25
30
  * saveViewConfig('my-grid', '_cards', config, onChangeConfig);
26
31
  */
27
32
  export declare const saveViewConfig: <T>(id: RowKey, viewSuffix: string, config: T[], onChangeConfig?: (data: {
@@ -1 +1 @@
1
- {"version":3,"file":"saveViewConfig.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/saveViewConfig/saveViewConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAC9B,IAAI,MAAM,EACV,YAAY,MAAM,EAClB,QAAQ,CAAC,EAAE,EACX,iBAAiB,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,CAAC,EAAE,CAAA;CAAE,KAAK,IAAI,KACnE,IAaF,CAAC"}
1
+ {"version":3,"file":"saveViewConfig.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/saveViewConfig/saveViewConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAC9B,IAAI,MAAM,EACV,YAAY,MAAM,EAClB,QAAQ,CAAC,EAAE,EACX,iBAAiB,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,CAAC,EAAE,CAAA;CAAE,KAAK,IAAI,KACnE,IAmBF,CAAC"}
@@ -1,12 +1,15 @@
1
- const n = (c, e, r, o) => {
2
- if (!o)
1
+ const t = (s, o, c, e) => {
2
+ if (e) {
3
+ const r = o === "" ? "columnsConfig" : `columnsConfig${o.replace("_", "").charAt(0).toUpperCase()}${o.replace("_", "").slice(1)}`;
4
+ e({
5
+ reason: r,
6
+ userConfig: c
7
+ });
3
8
  return;
4
- const s = e === "" ? "columnsConfig" : `columnsConfig${e.replace("_", "").charAt(0).toUpperCase()}${e.replace("_", "").slice(1)}`;
5
- o({
6
- reason: s,
7
- userConfig: r
8
- });
9
+ }
10
+ const n = o === "" ? `${s}_columns_config` : `${s}_columns_config${o}`;
11
+ localStorage.setItem(n, JSON.stringify(c));
9
12
  };
10
13
  export {
11
- n as saveViewConfig
14
+ t as saveViewConfig
12
15
  };
@@ -1,31 +1,34 @@
1
1
  import { ViewMode } from '../../../contexts/DataGridContext/types';
2
2
  import { OnChangeConfig, RowKey } from '../../../types';
3
3
  /**
4
- * Saves the view mode (table or cards).
4
+ * Guarda el modo de visualización (table o cards).
5
5
  *
6
- * ## Purpose
6
+ * ## Propósito
7
7
  *
8
- * Persists the user's preference for the selected view mode.
9
- * Allows the last used view to be kept on reload when the consumer persists in network cookies.
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
10
  *
11
- * ## Save priority
11
+ * ## Prioridad de guardado
12
12
  *
13
- * 1. If `onChangeConfig` exists Saves to network cookies
14
- * 2. If it does not exist Nothing is saved (localStorage is not used)
13
+ * 1. Si existe `onChangeConfig` → Guarda en cookies de red
14
+ * 2. Si no existeFallback a localStorage
15
15
  *
16
- * ## Key format (reference; persistence is only via callback)
16
+ * ## Formato de key en localStorage (fallback)
17
17
  *
18
+ * ```
18
19
  * `${id}_view_mode` -> 'table' | 'cards'
19
- * @param id - Unique DataGrid identifier
20
- * @param viewMode - View mode ('table' | 'cards')
21
- * @param onChangeConfig - Optional callback to save to network cookies. If not provided, nothing is saved.
20
+ * ```
21
+ * @param id - Identificador único del DataGrid
22
+ * @param viewMode - Modo de visualización ('table' | 'cards')
23
+ * @param onChangeConfig - Callback opcional para guardar en cookies de red
22
24
  * @example
23
- * // With network cookies
25
+ * // Con cookies de red
24
26
  * saveViewMode('my-grid', 'cards', onChangeConfig);
25
- * // Calls: onChangeConfig({ reason: 'viewMode', userConfig: 'cards' })
27
+ * // Llama: onChangeConfig({ reason: 'viewMode', userConfig: 'cards' })
26
28
  *
27
- * // Without callback: nothing is persisted
29
+ * // Sin cookies de red (fallback)
28
30
  * saveViewMode('my-grid', 'cards');
31
+ * // localStorage: 'my-grid_view_mode' = 'cards'
29
32
  */
30
33
  export declare const saveViewMode: (id: RowKey, viewMode: ViewMode, onChangeConfig?: OnChangeConfig) => void;
31
34
  //# sourceMappingURL=saveViewMode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveViewMode.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/saveViewMode/saveViewMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,YAAY,GACvB,IAAI,MAAM,EACV,UAAU,QAAQ,EAClB,iBAAiB,cAAc,KAC9B,IAQF,CAAC"}
1
+ {"version":3,"file":"saveViewMode.d.ts","sourceRoot":"","sources":["../../../../../../../../../packages/components/src/components/datagrids/helpers/persistence/saveViewMode/saveViewMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,YAAY,GACvB,IAAI,MAAM,EACV,UAAU,QAAQ,EAClB,iBAAiB,cAAc,KAC9B,IAUF,CAAC"}
@@ -1,9 +1,13 @@
1
- const o = (i, r, e) => {
2
- e && e({
3
- reason: "viewMode",
4
- userConfig: r
5
- });
1
+ const t = (r, e, o) => {
2
+ if (o) {
3
+ o({
4
+ reason: "viewMode",
5
+ userConfig: e
6
+ });
7
+ return;
8
+ }
9
+ localStorage.setItem(`${r}_view_mode`, e);
6
10
  };
7
11
  export {
8
- o as saveViewMode
12
+ t as saveViewMode
9
13
  };