@alaarab/ogrid-react 2.0.4 → 2.0.5

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.
@@ -51,9 +51,14 @@ export function useDataGridState(params) {
51
51
  : flatColumns;
52
52
  if (!columnOrder?.length)
53
53
  return filtered;
54
+ // Build index map for O(1) lookup instead of repeated O(n) indexOf
55
+ const orderMap = new Map();
56
+ for (let i = 0; i < columnOrder.length; i++) {
57
+ orderMap.set(columnOrder[i], i);
58
+ }
54
59
  return [...filtered].sort((a, b) => {
55
- const ia = columnOrder.indexOf(a.columnId);
56
- const ib = columnOrder.indexOf(b.columnId);
60
+ const ia = orderMap.get(a.columnId) ?? -1;
61
+ const ib = orderMap.get(b.columnId) ?? -1;
57
62
  if (ia === -1 && ib === -1)
58
63
  return 0;
59
64
  if (ia === -1)
@@ -336,7 +341,14 @@ export function useDataGridState(params) {
336
341
  canPinRight: headerMenuResult.canPinRight,
337
342
  canUnpin: headerMenuResult.canUnpin,
338
343
  },
339
- }), [pinningResult, headerMenuResult]);
344
+ }), [
345
+ pinningResult.pinnedColumns, pinningResult.pinColumn, pinningResult.unpinColumn,
346
+ pinningResult.isPinned, pinningResult.computeLeftOffsets, pinningResult.computeRightOffsets,
347
+ headerMenuResult.isOpen, headerMenuResult.openForColumn, headerMenuResult.anchorElement,
348
+ headerMenuResult.open, headerMenuResult.close, headerMenuResult.handlePinLeft,
349
+ headerMenuResult.handlePinRight, headerMenuResult.handleUnpin,
350
+ headerMenuResult.canPinLeft, headerMenuResult.canPinRight, headerMenuResult.canUnpin,
351
+ ]);
340
352
  return {
341
353
  layout: layoutState,
342
354
  rowSelection: rowSelectionState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-react",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "OGrid React – React hooks, headless components, and utilities for OGrid data grids.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -35,7 +35,7 @@
35
35
  "node": ">=18"
36
36
  },
37
37
  "dependencies": {
38
- "@alaarab/ogrid-core": "2.0.4",
38
+ "@alaarab/ogrid-core": "2.0.5",
39
39
  "@tanstack/react-virtual": "^3.11.0"
40
40
  },
41
41
  "peerDependencies": {