@invopop/popui 0.1.88 → 0.1.90
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/data-table/data-table-types.d.ts +8 -0
- package/dist/data-table/data-table.svelte +5 -3
- package/dist/data-table/table-setup.d.ts +1 -0
- package/dist/data-table/table-setup.js +1 -0
- package/dist/table/table-cell.svelte +2 -2
- package/dist/table/table-cell.svelte.d.ts +1 -1
- package/package.json +1 -1
|
@@ -134,6 +134,14 @@ export interface DataTableProps<TData> {
|
|
|
134
134
|
initialColumnSizing?: Record<string, number>;
|
|
135
135
|
pageSizeOptions?: number[];
|
|
136
136
|
emptyState?: Omit<EmptyStateProps, 'children' | 'check'>;
|
|
137
|
+
/**
|
|
138
|
+
* Identify rows by a stable key derived from the data instead of the default
|
|
139
|
+
* row index. Critical when consumers prepend/insert rows: with index-based
|
|
140
|
+
* IDs, Svelte's keyed `{#each}` reuses the existing top `<tr>` and mounts a
|
|
141
|
+
* fresh DOM node at the bottom for the shifted-down row, which sends row-
|
|
142
|
+
* level animations (slide-in, flash) to the wrong element.
|
|
143
|
+
*/
|
|
144
|
+
getRowId?: (row: TData, index: number) => string;
|
|
137
145
|
onRowClick?: (row: TData) => void;
|
|
138
146
|
onRowFocus?: (row: TData) => void;
|
|
139
147
|
onSelectionChange?: (selectedRows: TData[]) => void;
|
|
@@ -78,11 +78,12 @@
|
|
|
78
78
|
onColumnVisibilityChange,
|
|
79
79
|
getRowClassName,
|
|
80
80
|
getRowState,
|
|
81
|
+
getRowId,
|
|
81
82
|
children
|
|
82
83
|
}: DataTableProps<TData> = $props()
|
|
83
84
|
|
|
84
|
-
const enableSelection = !disableSelection
|
|
85
|
-
const enablePagination = !disablePagination
|
|
85
|
+
const enableSelection = $derived(!disableSelection)
|
|
86
|
+
const enablePagination = $derived(!disablePagination)
|
|
86
87
|
|
|
87
88
|
let rowSelection = $state<RowSelectionState>({})
|
|
88
89
|
let columnVisibility = $state<VisibilityState>(untrack(() => initialColumnVisibility))
|
|
@@ -177,6 +178,7 @@
|
|
|
177
178
|
const table = setupTable<TData>({
|
|
178
179
|
getData: () => data,
|
|
179
180
|
getColumns: () => columns,
|
|
181
|
+
getRowId,
|
|
180
182
|
enableSelection,
|
|
181
183
|
enablePagination,
|
|
182
184
|
manualPagination,
|
|
@@ -381,7 +383,7 @@
|
|
|
381
383
|
<Table.Root>
|
|
382
384
|
<Table.Header>
|
|
383
385
|
{#each table.getHeaderGroups() as headerGroup (`${headerGroup.id}-${tableRenderKey}`)}
|
|
384
|
-
<Table.Row class="hover
|
|
386
|
+
<Table.Row class="hover:bg-transparent!">
|
|
385
387
|
{#each headerGroup.headers as header, index (header.id)}
|
|
386
388
|
<DataTableHeaderCell
|
|
387
389
|
{header}
|
|
@@ -17,6 +17,7 @@ interface TableSetupOptions<TData> {
|
|
|
17
17
|
getRowCount?: () => number | undefined;
|
|
18
18
|
getData?: () => TData[];
|
|
19
19
|
getColumns?: () => any[];
|
|
20
|
+
getRowId?: (row: TData, index: number) => string;
|
|
20
21
|
getRowSelection: () => RowSelectionState;
|
|
21
22
|
getColumnVisibility: () => VisibilityState;
|
|
22
23
|
getSorting: () => SortingState;
|
|
@@ -124,6 +124,7 @@ export function setupTable(options) {
|
|
|
124
124
|
getCoreRowModel: getCoreRowModel(),
|
|
125
125
|
getPaginationRowModel: options.enablePagination && !options.manualPagination ? getPaginationRowModel() : undefined,
|
|
126
126
|
getSortedRowModel: !options.manualSorting ? getSortedRowModel() : undefined,
|
|
127
|
+
getRowId: options.getRowId,
|
|
127
128
|
// Manual pagination configuration
|
|
128
129
|
manualPagination: options.manualPagination,
|
|
129
130
|
// Manual sorting configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { createBubbler } from 'svelte/legacy'
|
|
3
|
-
import { cn, type WithElementRef } from '../utils
|
|
3
|
+
import { cn, type WithElementRef } from '../utils'
|
|
4
4
|
import type { HTMLTdAttributes } from 'svelte/elements'
|
|
5
5
|
|
|
6
6
|
const bubble = createBubbler()
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
bind:this={ref}
|
|
17
17
|
data-slot="table-cell"
|
|
18
18
|
class={cn(
|
|
19
|
-
'py-
|
|
19
|
+
'py-2.25 [&:has([role=menu])]:py-0 [&:has([data-uuid-copy])]:py-0 pl-3 pr-3 align-middle text-foreground font-normal text-base [&:has([role=menu])]:pl-1 [&:has([role=menu])]:bg-background [&:has([type=checkbox])]:bg-background',
|
|
20
20
|
className
|
|
21
21
|
)}
|
|
22
22
|
{...restProps}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type WithElementRef } from '../utils
|
|
1
|
+
import { type WithElementRef } from '../utils';
|
|
2
2
|
import type { HTMLTdAttributes } from 'svelte/elements';
|
|
3
3
|
declare const TableCell: import("svelte").Component<WithElementRef<HTMLTdAttributes>, {}, "ref">;
|
|
4
4
|
type TableCell = ReturnType<typeof TableCell>;
|