@svadmin/ui 0.40.2 → 0.40.3
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.
|
@@ -429,6 +429,11 @@
|
|
|
429
429
|
});
|
|
430
430
|
|
|
431
431
|
const selectedCount = $derived(Object.keys(tableRowSelection.current).length);
|
|
432
|
+
|
|
433
|
+
function isColumnVisible(columnId: string): boolean {
|
|
434
|
+
return tableColumnVisibility.current[columnId] !== false;
|
|
435
|
+
}
|
|
436
|
+
|
|
432
437
|
const tableView = $derived.by(() => {
|
|
433
438
|
void tableSorting.current;
|
|
434
439
|
void tableColumnVisibility.current;
|
|
@@ -696,8 +701,9 @@
|
|
|
696
701
|
<Table.Root>
|
|
697
702
|
<Table.Header>
|
|
698
703
|
{#each tableView.headerGroups as headerGroup, _i (_i)}
|
|
704
|
+
{@const visibleHeaders = headerGroup.headers.filter((header: Header<TableFeatures, BaseRecord, unknown>) => isColumnVisible(header.column.id))}
|
|
699
705
|
<DraggableHeader
|
|
700
|
-
columns={
|
|
706
|
+
columns={visibleHeaders.map((header) => ({ id: header.column.id, header }))}
|
|
701
707
|
resourceName={resourceName}
|
|
702
708
|
onReorder={(newOrder) => columnOrderAtom.set(newOrder.map((column) => column.id))}
|
|
703
709
|
>
|
|
@@ -744,11 +750,12 @@
|
|
|
744
750
|
{#each tableView.rows as row, _i (_i)}
|
|
745
751
|
{@const record = row.original}
|
|
746
752
|
{@const id = record[primaryKey] as string | number}
|
|
753
|
+
{@const visibleCells = row_getVisibleCells(row).filter((cell) => isColumnVisible(cell.column.id))}
|
|
747
754
|
<ContextMenu.Root>
|
|
748
755
|
<ContextMenu.Trigger>
|
|
749
756
|
{#snippet child({ props })}
|
|
750
757
|
<Table.Row {...props} class="transition-all duration-300 border-b border-border/10 {row_getIsSelected(row) ? 'bg-primary/5' : 'hover:bg-muted/20'}">
|
|
751
|
-
{#each
|
|
758
|
+
{#each visibleCells as cell, _i (_i)}
|
|
752
759
|
<Table.Cell>
|
|
753
760
|
{#if cell.column.id === '_select'}
|
|
754
761
|
<Checkbox
|
|
@@ -840,7 +847,7 @@
|
|
|
840
847
|
</ContextMenu.Root>
|
|
841
848
|
{#if expandedRowRender && rowIsExpanded(row.id)}
|
|
842
849
|
<Table.Row class="bg-muted/10 border-b border-border/10 transition-all">
|
|
843
|
-
<Table.Cell colspan={
|
|
850
|
+
<Table.Cell colspan={visibleCells.length}>
|
|
844
851
|
{@render expandedRowRender({ record })}
|
|
845
852
|
</Table.Cell>
|
|
846
853
|
</Table.Row>
|
|
@@ -913,7 +920,7 @@
|
|
|
913
920
|
</div>
|
|
914
921
|
<!-- Card fields -->
|
|
915
922
|
<div class="space-y-2">
|
|
916
|
-
{#each visibleFields.slice(0, 6) as field, _i (_i)}
|
|
923
|
+
{#each visibleFields.filter((field) => isColumnVisible(field.key)).slice(0, 6) as field, _i (_i)}
|
|
917
924
|
{@const value = record[field.key]}
|
|
918
925
|
<div class="flex items-start justify-between gap-4">
|
|
919
926
|
<span class="text-xs font-medium text-muted-foreground shrink-0">{field.label}</span>
|
|
@@ -959,11 +966,11 @@
|
|
|
959
966
|
|
|
960
967
|
<!-- Pagination (shadcn) -->
|
|
961
968
|
{#if totalPages > 0}
|
|
962
|
-
<div class="flex flex-col sm:flex-row items-center justify-between gap-2 text-sm text-muted-foreground">
|
|
963
|
-
<div class="flex items-center gap-
|
|
964
|
-
<span>{i18n.t('common.total', { total: query.data?.total ?? 0 })}</span>
|
|
969
|
+
<div class="flex flex-col sm:flex-row items-center justify-between gap-3 px-1 py-2 text-sm text-muted-foreground">
|
|
970
|
+
<div class="flex shrink-0 items-center gap-3 leading-8">
|
|
971
|
+
<span class="shrink-0 whitespace-nowrap">{i18n.t('common.total', { total: query.data?.total ?? 0 })}</span>
|
|
965
972
|
<select
|
|
966
|
-
class="h-8 w-[70px] px-1 py-1 flex items-center justify-between rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
|
973
|
+
class="h-8 w-[70px] shrink-0 px-1 py-1 flex items-center justify-between rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
|
967
974
|
value={String(pagination.pageSize ?? 10)}
|
|
968
975
|
onchange={(e) => {
|
|
969
976
|
const size = Number((e.target as HTMLSelectElement).value);
|