@invopop/popui 0.1.91 → 0.1.93

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.
@@ -2,6 +2,7 @@
2
2
  import Button from '../button/button.svelte'
3
3
  import InputSelect from '../InputSelect.svelte'
4
4
  import InputText from '../InputText.svelte'
5
+ import Skeleton from '../skeleton/skeleton.svelte'
5
6
  import { ArrowLeft, ArrowRight, ScrollLeft, ScrollRight } from '@invopop/ui-icons'
6
7
  import { cn } from '../utils.js'
7
8
  import clsx from 'clsx'
@@ -19,9 +20,11 @@
19
20
  onPageSizeChange,
20
21
  data,
21
22
  rowCount,
23
+ pageCount,
22
24
  manualPagination,
23
25
  disabled = false,
24
- disableJumpToPage = false
26
+ disableJumpToPage = false,
27
+ countLoading = false
25
28
  }: DataTablePaginationProps<any> = $props()
26
29
 
27
30
  let currentPage = $derived(table.getState().pagination.pageIndex + 1)
@@ -34,8 +37,12 @@
34
37
  // For client-side pagination, use data length directly
35
38
  return data?.length ?? 0
36
39
  })
37
- // Calculate totalPages from reactive values instead of calling table.getPageCount()
38
- let totalPages = $derived(Math.ceil(totalItems / rowsPerPage) || 1)
40
+ // Prefer the caller-supplied pageCount when provided (manual pagination): it lets
41
+ // consumers express "Next is available" before an exact rowCount is known. Fall
42
+ // back to deriving from rowCount/data for the client-side default.
43
+ let totalPages = $derived(
44
+ manualPagination && pageCount !== undefined ? pageCount : Math.ceil(totalItems / rowsPerPage) || 1
45
+ )
39
46
 
40
47
  let pageInputValue = $derived(`${currentPage}`)
41
48
 
@@ -140,8 +147,13 @@
140
147
  disabled={disableJumpToPage}
141
148
  />
142
149
  </div>
143
- <span class="text-base text-foreground-default-secondary whitespace-nowrap">
144
- / {formatNumber(totalPages)}
150
+ <span class="text-base text-foreground-default-secondary whitespace-nowrap flex items-center gap-1.5">
151
+ /
152
+ {#if countLoading}
153
+ <Skeleton class="h-4 w-8" />
154
+ {:else}
155
+ {formatNumber(totalPages)}
156
+ {/if}
145
157
  </span>
146
158
  </div>
147
159
  <div class="flex items-center">
@@ -206,7 +218,12 @@
206
218
  </div>
207
219
  {/if}
208
220
  </div>
209
- {#if totalItems > 0}
221
+ {#if countLoading}
222
+ <span class="text-base text-foreground-default-secondary flex items-center gap-1.5">
223
+ <Skeleton class="h-4 w-10" />
224
+ {itemsLabel}
225
+ </span>
226
+ {:else if totalItems > 0}
210
227
  <span class="text-base text-foreground-default-secondary">
211
228
  {formatNumber(totalItems)}
212
229
  {itemsLabel}
@@ -91,9 +91,11 @@ export interface DataTablePaginationProps<T> {
91
91
  onPageSizeChange?: (pageSize: number) => void;
92
92
  data?: T[];
93
93
  rowCount?: number;
94
+ pageCount?: number;
94
95
  manualPagination?: boolean;
95
96
  disabled?: boolean;
96
97
  disableJumpToPage?: boolean;
98
+ countLoading?: boolean;
97
99
  }
98
100
  export interface DataTableRowProps<TData> {
99
101
  row: Row<TData>;
@@ -152,6 +154,7 @@ export interface DataTableProps<TData> {
152
154
  manualSorting?: boolean;
153
155
  pageCount?: number;
154
156
  rowCount?: number;
157
+ countLoading?: boolean;
155
158
  onPageChange?: (pageIndex: number) => void;
156
159
  onPageSizeChange?: (pageSize: number) => void;
157
160
  onSortingChange?: (columnId: string, direction: TableSortBy) => void;
@@ -68,6 +68,7 @@
68
68
  manualSorting = false,
69
69
  pageCount,
70
70
  rowCount,
71
+ countLoading = false,
71
72
  onPageChange,
72
73
  onPageSizeChange,
73
74
  onSortingChange,
@@ -433,10 +434,12 @@
433
434
  {table}
434
435
  {data}
435
436
  {rowCount}
437
+ {pageCount}
436
438
  {manualPagination}
437
439
  {onPageChange}
438
440
  {onPageSizeChange}
439
441
  {disableJumpToPage}
442
+ {countLoading}
440
443
  disabled={disableControls || loading}
441
444
  >
442
445
  {#if paginationSlot}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.1.91",
4
+ "version": "0.1.93",
5
5
  "repository": {
6
6
  "url": "https://github.com/invopop/popui"
7
7
  },