@gridkitjs/core 0.0.0-dev-20261112201151 → 0.0.0-dev-20261118111459

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.
@@ -259,10 +259,16 @@ function partitionByValue(rows, column, direction) {
259
259
  });
260
260
  return groups;
261
261
  }
262
+ function withGroupPosition(rows, depth) {
263
+ return rows.map((row, index) => ({
264
+ ...row,
265
+ groupPosition: { level: depth, position: index + 1, setSize: rows.length }
266
+ }));
267
+ }
262
268
  function buildLevel(rows, levels, parentPath, expansion, byId, out) {
263
269
  const level = levels[0];
264
270
  if (level === void 0) {
265
- out.push(...rows);
271
+ out.push(...withGroupPosition(rows, parentPath.length));
266
272
  return;
267
273
  }
268
274
  const column = byId.get(level.columnId);
@@ -272,7 +278,7 @@ function buildLevel(rows, levels, parentPath, expansion, byId, out) {
272
278
  }
273
279
  const rest = levels.slice(1);
274
280
  const groups = partitionByValue(rows, column, level.direction ?? "asc");
275
- for (const group of groups) {
281
+ for (const [index, group] of groups.entries()) {
276
282
  const path = [...parentPath, group.value];
277
283
  const groupId = groupRowId(path);
278
284
  const expanded = isGroupExpanded(expansion, groupId);
@@ -285,6 +291,8 @@ function buildLevel(rows, levels, parentPath, expansion, byId, out) {
285
291
  path,
286
292
  expanded,
287
293
  count: group.rows.length,
294
+ position: index + 1,
295
+ setSize: groups.length,
288
296
  // Both set by `groupRows` once it has the whole flattened array.
289
297
  rowIndex: -1,
290
298
  datasetIndex: -1,
@@ -937,9 +945,10 @@ function beginColumnResize(column, startWidth, startPosition, defaults) {
937
945
  constraints: resolveColumnConstraints(column, defaults)
938
946
  };
939
947
  }
940
- function applyColumnResize(session, position) {
948
+ function applyColumnResize(session, position, direction = "ltr") {
949
+ const moved = position - session.startPosition;
941
950
  return clampColumnWidth(
942
- session.startWidth + (position - session.startPosition),
951
+ session.startWidth + (direction === "rtl" ? -moved : moved),
943
952
  session.constraints
944
953
  );
945
954
  }
@@ -3196,6 +3205,19 @@ function contextMenuEntries(contextMenu, context) {
3196
3205
  }
3197
3206
  }
3198
3207
 
3208
+ // src/util/direction.ts
3209
+ function inlineStep(key, direction = "ltr") {
3210
+ const forward = direction === "rtl" ? "ArrowLeft" : "ArrowRight";
3211
+ const backward = direction === "rtl" ? "ArrowRight" : "ArrowLeft";
3212
+ if (key === forward) {
3213
+ return 1;
3214
+ }
3215
+ if (key === backward) {
3216
+ return -1;
3217
+ }
3218
+ return null;
3219
+ }
3220
+
3199
3221
  // src/util/navigation.ts
3200
3222
  function headerFocus(columnIndex) {
3201
3223
  return { area: "header", columnIndex };
@@ -3243,7 +3265,7 @@ function skipSkippableRows(target, direction, rowCount, isSkippableRow, fallback
3243
3265
  }
3244
3266
  return bodyFocus(rowIndex, target.columnIndex);
3245
3267
  }
3246
- function nextFocusForKey(key, modifiers, focus, rowCount, columnCount2, pageSize, isSkippableRow = noRowsSkippable) {
3268
+ function nextFocusForKey(key, modifiers, focus, rowCount, columnCount2, pageSize, isSkippableRow = noRowsSkippable, direction = "ltr") {
3247
3269
  if (modifiers.altKey) {
3248
3270
  return null;
3249
3271
  }
@@ -3257,13 +3279,11 @@ function nextFocusForKey(key, modifiers, focus, rowCount, columnCount2, pageSize
3257
3279
  focus
3258
3280
  );
3259
3281
  }
3282
+ const step = inlineStep(key, direction);
3283
+ if (step !== null) {
3284
+ return modifiers.ctrlKey ? null : { ...focus, columnIndex: columnIndex + step };
3285
+ }
3260
3286
  switch (key) {
3261
- case "ArrowLeft":
3262
- if (modifiers.ctrlKey) return null;
3263
- return { ...focus, columnIndex: columnIndex - 1 };
3264
- case "ArrowRight":
3265
- if (modifiers.ctrlKey) return null;
3266
- return { ...focus, columnIndex: columnIndex + 1 };
3267
3287
  case "ArrowUp":
3268
3288
  return moveRows(-1);
3269
3289
  case "ArrowDown":
@@ -3413,9 +3433,10 @@ export {
3413
3433
  defaultContextMenu,
3414
3434
  hasContextMenu,
3415
3435
  contextMenuEntries,
3436
+ inlineStep,
3416
3437
  headerFocus,
3417
3438
  bodyFocus,
3418
3439
  clampFocus,
3419
3440
  nextFocusForKey
3420
3441
  };
3421
- //# sourceMappingURL=chunk-QGKPKQIO.js.map
3442
+ //# sourceMappingURL=chunk-PUD53NFG.js.map