@alaarab/ogrid-vue 2.0.3 → 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.
@@ -5,7 +5,6 @@ import { getCellValue, parseValue, normalizeSelectionRange } from '@alaarab/ogri
5
5
  */
6
6
  export function useClipboard(params) {
7
7
  const { items, visibleCols, colOffset, selectionRange, activeCell, editable, onCellValueChanged, beginBatch, endBatch, } = params;
8
- const cutRangeRef = ref(null);
9
8
  const cutRange = shallowRef(null);
10
9
  const copyRange = shallowRef(null);
11
10
  const internalClipboardRef = ref(null);
@@ -49,7 +48,6 @@ export function useClipboard(params) {
49
48
  if (range == null || onCellValueChanged.value == null)
50
49
  return;
51
50
  const norm = normalizeSelectionRange(range);
52
- cutRangeRef.value = norm;
53
51
  cutRange.value = norm;
54
52
  copyRange.value = null;
55
53
  handleCopy();
@@ -107,8 +105,8 @@ export function useClipboard(params) {
107
105
  });
108
106
  }
109
107
  }
110
- if (cutRangeRef.value) {
111
- const cut = cutRangeRef.value;
108
+ if (cutRange.value) {
109
+ const cut = cutRange.value;
112
110
  for (let r = cut.startRow; r <= cut.endRow; r++) {
113
111
  for (let c = cut.startCol; c <= cut.endCol; c++) {
114
112
  if (r >= currentItems.length || c >= currentCols.length)
@@ -132,7 +130,6 @@ export function useClipboard(params) {
132
130
  });
133
131
  }
134
132
  }
135
- cutRangeRef.value = null;
136
133
  cutRange.value = null;
137
134
  }
138
135
  endBatch?.();
@@ -141,7 +138,6 @@ export function useClipboard(params) {
141
138
  const clearClipboardRanges = () => {
142
139
  copyRange.value = null;
143
140
  cutRange.value = null;
144
- cutRangeRef.value = null;
145
141
  };
146
- return { handleCopy, handleCut, handlePaste, cutRange, copyRange, clearClipboardRanges, cutRangeRef };
142
+ return { handleCopy, handleCut, handlePaste, cutRange, copyRange, clearClipboardRanges };
147
143
  }
@@ -61,9 +61,14 @@ export function useDataGridState(params) {
61
61
  const filtered = vis ? flatColumns.value.filter((c) => vis.has(c.columnId)) : flatColumns.value;
62
62
  if (!order?.length)
63
63
  return filtered;
64
+ // Build index map for O(1) lookup instead of repeated O(n) indexOf
65
+ const orderMap = new Map();
66
+ for (let i = 0; i < order.length; i++) {
67
+ orderMap.set(order[i], i);
68
+ }
64
69
  return [...filtered].sort((a, b) => {
65
- const ia = order.indexOf(a.columnId);
66
- const ib = order.indexOf(b.columnId);
70
+ const ia = orderMap.get(a.columnId) ?? -1;
71
+ const ib = orderMap.get(b.columnId) ?? -1;
67
72
  if (ia === -1 && ib === -1)
68
73
  return 0;
69
74
  if (ia === -1)
@@ -75,8 +80,10 @@ export function useDataGridState(params) {
75
80
  });
76
81
  const visibleColumnCount = computed(() => visibleCols.value.length);
77
82
  const hasCheckboxCol = computed(() => rowSelectionProp.value === 'multiple');
78
- const totalColCount = computed(() => visibleColumnCount.value + (hasCheckboxCol.value ? 1 : 0));
79
- const colOffset = computed(() => hasCheckboxCol.value ? 1 : 0).value; // stable once computed
83
+ const hasRowNumbersCol = computed(() => !!props.value.showRowNumbers);
84
+ const specialColsCount = computed(() => (hasCheckboxCol.value ? 1 : 0) + (hasRowNumbersCol.value ? 1 : 0));
85
+ const totalColCount = computed(() => visibleColumnCount.value + specialColsCount.value);
86
+ const colOffset = computed(() => specialColsCount.value).value; // stable once computed
80
87
  const rowIndexByRowId = computed(() => {
81
88
  const m = new Map();
82
89
  items.value.forEach((item, idx) => m.set(getRowId(item), idx));
@@ -236,6 +243,7 @@ export function useDataGridState(params) {
236
243
  totalColCount: totalColCount.value,
237
244
  colOffset,
238
245
  hasCheckboxCol: hasCheckboxCol.value,
246
+ hasRowNumbersCol: hasRowNumbersCol.value,
239
247
  rowIndexByRowId: rowIndexByRowId.value,
240
248
  containerWidth: containerWidth.value,
241
249
  minTableWidth: minTableWidth.value,
@@ -18,7 +18,6 @@ export interface UseClipboardResult {
18
18
  cutRange: ShallowRef<ISelectionRange | null>;
19
19
  copyRange: ShallowRef<ISelectionRange | null>;
20
20
  clearClipboardRanges: () => void;
21
- cutRangeRef: Ref<ISelectionRange | null>;
22
21
  }
23
22
  /**
24
23
  * Manages copy, cut, and paste operations for cell ranges with TSV clipboard format.
@@ -12,6 +12,7 @@ export interface DataGridLayoutState<T> {
12
12
  totalColCount: number;
13
13
  colOffset: number;
14
14
  hasCheckboxCol: boolean;
15
+ hasRowNumbersCol: boolean;
15
16
  rowIndexByRowId: Map<RowId, number>;
16
17
  containerWidth: number;
17
18
  minTableWidth: number;
@@ -131,6 +131,9 @@ export interface IOGridDataGridProps<T> {
131
131
  rowSelection?: RowSelectionMode;
132
132
  selectedRows?: Set<RowId>;
133
133
  onSelectionChange?: (event: IRowSelectionChangeEvent<T>) => void;
134
+ showRowNumbers?: boolean;
135
+ currentPage?: number;
136
+ pageSize?: number;
134
137
  statusBar?: IStatusBarProps;
135
138
  /** Unified filter model (discriminated union values). */
136
139
  filters: IFilters;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-vue",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "OGrid Vue – Vue 3 composables, headless components, and utilities for OGrid data grids.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -22,7 +22,7 @@
22
22
  "files": ["dist", "README.md", "LICENSE"],
23
23
  "engines": { "node": ">=18" },
24
24
  "dependencies": {
25
- "@alaarab/ogrid-core": "2.0.3"
25
+ "@alaarab/ogrid-core": "2.0.5"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "vue": "^3.3.0"