@isoftdata/svelte-table 2.8.0 → 2.8.1

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 (2) hide show
  1. package/dist/Table.svelte +33 -22
  2. package/package.json +1 -1
package/dist/Table.svelte CHANGED
@@ -902,31 +902,42 @@
902
902
  </tr>
903
903
  </thead>
904
904
  <tbody class:unselectable={selectionMode === 'RANGE'}>
905
+ {#snippet tableRow(row: R & { originalIndex: number; uuid: string }, index: number)}
906
+ {#if children}{@render children({ row, index })}{:else}
907
+ <tr
908
+ class:table-primary={rowIsSelected(row, rowSelectionIdProp, selectedRowIds)}
909
+ onclick={() => rowClick(row)}
910
+ >
911
+ {#each computedColumns as column (column.property)}
912
+ <Td
913
+ align={column.align}
914
+ property={column.property}
915
+ >
916
+ {isArbitraryProperty(column.property)
917
+ ? ''
918
+ : column.formatter
919
+ ? column.formatter(getNestedProperty(row, column.property, ''))
920
+ : getNestedProperty(row, column.property, '')}
921
+ </Td>
922
+ {/each}
923
+ </tr>
924
+ {/if}
925
+ {/snippet}
905
926
  {#if body}
906
927
  {@render body?.({ rows: currentPageRows, visibleColumnsCount: visibleColumns.length })}
907
- {:else}
928
+ {:else if !currentPageRows.length}
929
+ {@render noRows?.({ visibleColumnsCount: visibleColumns.length })}
930
+ <!--
931
+ Only key the #each if the idProp is in the original row.
932
+ Otherwise, the table will re-render all rows if idProp is 'uuid' and your original row doesn't have one
933
+ -->
934
+ {:else if idProp in rows[currentPageRows[0]?.originalIndex]}
908
935
  {#each currentPageRows as row, index (row[idProp])}
909
- {#if children}{@render children({ row, index })}{:else}
910
- <tr
911
- class:table-primary={rowIsSelected(row, rowSelectionIdProp, selectedRowIds)}
912
- onclick={() => rowClick(row)}
913
- >
914
- {#each computedColumns as column (column.property)}
915
- <Td
916
- align={column.align}
917
- property={column.property}
918
- >
919
- {isArbitraryProperty(column.property)
920
- ? ''
921
- : column.formatter
922
- ? column.formatter(getNestedProperty(row, column.property, ''))
923
- : getNestedProperty(row, column.property, '')}
924
- </Td>
925
- {/each}
926
- </tr>
927
- {/if}
928
- {:else}
929
- {@render noRows?.({ visibleColumnsCount: visibleColumns.length })}
936
+ {@render tableRow(row, index)}
937
+ {/each}
938
+ {:else}
939
+ {#each currentPageRows as row, index}
940
+ {@render tableRow(row, index)}
930
941
  {/each}
931
942
  {/if}
932
943
  </tbody>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/svelte-table",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",