@juspay/svelte-ui-components 2.88.0 → 2.89.0

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.
@@ -111,14 +111,19 @@
111
111
  };
112
112
 
113
113
  // ─── Row click ───────────────────────────────────────────────────────────────
114
- const handleRowClick = (rowIndex: number, rowData: JSONValue[]): void => {
115
- onRowClick?.(rowIndex, rowData);
114
+ const handleRowClick = (rowIndex: number, rowData: JSONValue[], originalIndex: number): void => {
115
+ onRowClick?.(rowIndex, rowData, originalIndex);
116
116
  };
117
117
 
118
- const handleRowKeydown = (event: KeyboardEvent, rowIndex: number, rowData: JSONValue[]): void => {
118
+ const handleRowKeydown = (
119
+ event: KeyboardEvent,
120
+ rowIndex: number,
121
+ rowData: JSONValue[],
122
+ originalIndex: number
123
+ ): void => {
119
124
  if (event.key === 'Enter' || event.key === ' ') {
120
125
  event.preventDefault();
121
- onRowClick?.(rowIndex, rowData);
126
+ onRowClick?.(rowIndex, rowData, originalIndex);
122
127
  }
123
128
  };
124
129
 
@@ -329,9 +334,10 @@
329
334
  const resolveRowId = (
330
335
  cfg: TableCheckboxSelectionConfig,
331
336
  row: JSONValue[],
332
- rowIndex: number
337
+ rowIndex: number,
338
+ originalIndex: number
333
339
  ): string => {
334
- return cfg.getRowId ? cfg.getRowId(row, rowIndex) : String(rowIndex);
340
+ return cfg.getRowId ? cfg.getRowId(row, rowIndex, originalIndex) : String(rowIndex);
335
341
  };
336
342
 
337
343
  let internalSelectedIds = new SvelteSet<string>();
@@ -374,7 +380,12 @@
374
380
  const originalIndex = indexMap.get(row) ?? -1;
375
381
  const stableIndex = originalIndex === -1 ? fallbackIndex : originalIndex;
376
382
  if (checkboxSelection && checkboxSelection.enabled !== false) {
377
- return resolveRowId(checkboxSelection, row, stableIndex);
383
+ return resolveRowId(
384
+ checkboxSelection,
385
+ row,
386
+ stableIndex,
387
+ originalIndexByRow.get(row) ?? stableIndex
388
+ );
378
389
  }
379
390
  return String(stableIndex);
380
391
  });
@@ -725,9 +736,9 @@
725
736
  class:table-row-clickable={isRowClickable}
726
737
  class:table-row-selected={rowSelected}
727
738
  data-pw={typeof getRowTestId === 'function' ? getRowTestId(row, rowIndex) : null}
728
- onclick={isRowClickable ? () => handleRowClick(rowIndex, row) : null}
739
+ onclick={isRowClickable ? () => handleRowClick(rowIndex, row, originalIndex) : null}
729
740
  onkeydown={isRowClickable
730
- ? (keyboardEvent) => handleRowKeydown(keyboardEvent, rowIndex, row)
741
+ ? (keyboardEvent) => handleRowKeydown(keyboardEvent, rowIndex, row, originalIndex)
731
742
  : null}
732
743
  tabindex={isRowClickable ? 0 : null}
733
744
  >
@@ -244,7 +244,7 @@ export type TableCheckboxSelectionConfig = {
244
244
  enabled?: boolean;
245
245
  selectionMode?: 'single' | 'multiple';
246
246
  onSelectionChange?: (selectedIds: Set<string>) => void;
247
- getRowId?: (row: JSONValue[], rowIndex: number) => string;
247
+ getRowId?: (row: JSONValue[], rowIndex: number, originalIndex: number) => string;
248
248
  disabledRowIds?: Set<string>;
249
249
  /**
250
250
  * Controlled-selection overlay. Omitted: today's uncontrolled behavior via
@@ -367,7 +367,7 @@ export type OptionalTableProperties = {
367
367
  searchConfig?: TableSearchConfig;
368
368
  };
369
369
  export type TableEventProperties = {
370
- onRowClick?: (rowIndex: number, rowData: JSONValue[]) => void;
370
+ onRowClick?: (rowIndex: number, rowData: JSONValue[], originalIndex: number) => void;
371
371
  onSort?: (columnIndex: number, direction: SortDirection) => void;
372
372
  /**
373
373
  * C2-2: Callback invoked when a cell value changes via an editable element
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "2.88.0",
3
+ "version": "2.89.0",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",