@isoftdata/svelte-table 2.8.0 → 2.8.2
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.
- package/dist/Table.svelte +33 -22
- package/dist/bracket-paths.d.ts +4 -16
- package/package.json +2 -2
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
|
-
{
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
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/dist/bracket-paths.d.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NonRecursiveType, StaticPartOfArray, VariablePartOfArray, ToString } from 'type-fest/source/internal';
|
|
3
|
-
import type { PathsOptions } from 'type-fest/source/paths';
|
|
1
|
+
import type { PathsOptions, Paths } from 'type-fest';
|
|
4
2
|
/**
|
|
5
3
|
Generate a union of all possible paths to properties in the given object, denoting the object structure with brackets.
|
|
6
4
|
|
|
7
5
|
This is the `Paths` utility type from the `type-fest` package, but with brackets.
|
|
8
6
|
*/
|
|
9
|
-
export type BracketPaths<Row, Options extends PathsOptions = {}> =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
type DoEndBracket<Key extends string | number, DoBracket extends boolean | undefined> = DoBracket extends true ? `${Key}]` : Key;
|
|
14
|
-
type InternalPaths<T, Options extends InternalPathOptions = {}> = (Options['maxRecursionDepth'] extends number ? Options['maxRecursionDepth'] : 10) extends infer MaxDepth extends number ? Required<T> extends infer T ? T extends EmptyObject | readonly [] ? never : {
|
|
15
|
-
[Key in keyof T]: Key extends string | number ? DoEndBracket<Key, Options['doEndBracket']> | DoEndBracket<ToString<Key>, Options['doEndBracket']> | (GreaterThan<MaxDepth, 0> extends true ? IsNever<BracketPaths<T[Key], {
|
|
16
|
-
maxRecursionDepth: Subtract<MaxDepth, 1>;
|
|
17
|
-
}>> extends false ? `${DoEndBracket<Key, Options['doEndBracket']>}[${BracketPaths<T[Key], {
|
|
18
|
-
maxRecursionDepth: Subtract<MaxDepth, 1>;
|
|
19
|
-
doEndBracket: true;
|
|
20
|
-
}>}` : never : never) : never;
|
|
21
|
-
}[keyof T & (T extends UnknownArray ? number : unknown)] : never : never;
|
|
7
|
+
export type BracketPaths<Row, Options extends PathsOptions = {}> = DotToBracket<Paths<Row, Options>>;
|
|
8
|
+
export type DotToBracket<S extends string | unknown> = S extends `${infer Head}.${infer Tail}` ? `${Head}${_DotToBracketTail<Tail>}` : S;
|
|
9
|
+
type _DotToBracketTail<S extends string> = S extends `${infer Part}.${infer Rest}` ? `[${Part}]${_DotToBracketTail<Rest>}` : `[${S}]`;
|
|
22
10
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoftdata/svelte-table",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"svelte": "^5.22.1",
|
|
41
41
|
"svelte-check": "^4.1.4",
|
|
42
42
|
"tslib": "^2.8.1",
|
|
43
|
-
"type-fest": "^4.
|
|
43
|
+
"type-fest": "^4.41.0",
|
|
44
44
|
"typescript": "^5.8.2",
|
|
45
45
|
"vite": "^6.2.0"
|
|
46
46
|
},
|