@invopop/popui 0.1.40 → 0.1.41
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.
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
data,
|
|
21
21
|
rowCount,
|
|
22
22
|
manualPagination,
|
|
23
|
-
disabled = false
|
|
23
|
+
disabled = false,
|
|
24
|
+
disableJumpToPage = false
|
|
24
25
|
}: DataTablePaginationProps<any> = $props()
|
|
25
26
|
|
|
26
27
|
let currentPage = $derived(table.getState().pagination.pageIndex + 1)
|
|
@@ -78,28 +79,32 @@
|
|
|
78
79
|
className
|
|
79
80
|
)}
|
|
80
81
|
>
|
|
81
|
-
<div
|
|
82
|
-
'
|
|
83
|
-
|
|
82
|
+
<div
|
|
83
|
+
class={clsx('flex items-center gap-3', {
|
|
84
|
+
'pointer-events-none opacity-30': disabled
|
|
85
|
+
})}
|
|
86
|
+
>
|
|
84
87
|
<div class="flex items-center gap-2">
|
|
85
88
|
<div class="flex items-center gap-1.5">
|
|
86
89
|
<div class="flex items-center">
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
{#if !disableJumpToPage}
|
|
91
|
+
<Button
|
|
92
|
+
variant="ghost"
|
|
93
|
+
size="md"
|
|
94
|
+
icon={ScrollLeft}
|
|
95
|
+
onclick={() => {
|
|
96
|
+
if (manualPagination) {
|
|
97
|
+
table.setPagination({ pageIndex: 0, pageSize: rowsPerPage })
|
|
98
|
+
} else {
|
|
99
|
+
table.setPageIndex(0)
|
|
100
|
+
}
|
|
101
|
+
onPageChange?.(1)
|
|
102
|
+
}}
|
|
103
|
+
disabled={currentPage === 1}
|
|
104
|
+
class={cn(currentPage === 1 && 'pointer-events-none opacity-30')}
|
|
105
|
+
aria-label="First page"
|
|
106
|
+
/>
|
|
107
|
+
{/if}
|
|
103
108
|
<Button
|
|
104
109
|
variant="ghost"
|
|
105
110
|
size="md"
|
|
@@ -132,6 +137,7 @@
|
|
|
132
137
|
size="sm"
|
|
133
138
|
oninput={handlePageInput}
|
|
134
139
|
onblur={handlePageBlur}
|
|
140
|
+
disabled={disableJumpToPage}
|
|
135
141
|
/>
|
|
136
142
|
</div>
|
|
137
143
|
<span class="text-base text-foreground-default-secondary whitespace-nowrap">
|
|
@@ -158,22 +164,24 @@
|
|
|
158
164
|
class={cn(currentPage === totalPages && 'pointer-events-none opacity-30')}
|
|
159
165
|
aria-label="Next page"
|
|
160
166
|
/>
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
167
|
+
{#if !disableJumpToPage}
|
|
168
|
+
<Button
|
|
169
|
+
variant="ghost"
|
|
170
|
+
size="md"
|
|
171
|
+
icon={ScrollRight}
|
|
172
|
+
onclick={() => {
|
|
173
|
+
if (manualPagination) {
|
|
174
|
+
table.setPagination({ pageIndex: totalPages - 1, pageSize: rowsPerPage })
|
|
175
|
+
} else {
|
|
176
|
+
table.setPageIndex(totalPages - 1)
|
|
177
|
+
}
|
|
178
|
+
onPageChange?.(totalPages)
|
|
179
|
+
}}
|
|
180
|
+
disabled={currentPage === totalPages}
|
|
181
|
+
class={cn(currentPage === totalPages && 'pointer-events-none opacity-30')}
|
|
182
|
+
aria-label="Last page"
|
|
183
|
+
/>
|
|
184
|
+
{/if}
|
|
177
185
|
</div>
|
|
178
186
|
</div>
|
|
179
187
|
{#if showRowsPerPage}
|
|
@@ -190,7 +198,6 @@
|
|
|
190
198
|
table.setPageSize(size)
|
|
191
199
|
table.setPageIndex(0)
|
|
192
200
|
onPageSizeChange?.(size)
|
|
193
|
-
onPageChange?.(1)
|
|
194
201
|
}}
|
|
195
202
|
placeholder="Rows per page"
|
|
196
203
|
disablePlaceholder={true}
|
|
@@ -93,6 +93,7 @@ export interface DataTablePaginationProps<T> {
|
|
|
93
93
|
rowCount?: number;
|
|
94
94
|
manualPagination?: boolean;
|
|
95
95
|
disabled?: boolean;
|
|
96
|
+
disableJumpToPage?: boolean;
|
|
96
97
|
}
|
|
97
98
|
export interface DataTableRowProps<TData> {
|
|
98
99
|
row: Row<TData>;
|
|
@@ -117,6 +118,7 @@ export interface DataTableProps<TData> {
|
|
|
117
118
|
disablePagination?: boolean;
|
|
118
119
|
disableKeyboardNavigation?: boolean;
|
|
119
120
|
disableControls?: boolean;
|
|
121
|
+
disableJumpToPage?: boolean;
|
|
120
122
|
rowActions?: TableAction[];
|
|
121
123
|
getRowActions?: (row: TData) => TableAction[];
|
|
122
124
|
onRowAction?: (action: AnyProp, row: TData) => void;
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
disablePagination = false,
|
|
48
48
|
disableKeyboardNavigation = false,
|
|
49
49
|
disableControls = false,
|
|
50
|
+
disableJumpToPage = false,
|
|
50
51
|
rowActions = [],
|
|
51
52
|
getRowActions,
|
|
52
53
|
onRowAction,
|
|
@@ -196,7 +197,14 @@
|
|
|
196
197
|
tableRenderKey++
|
|
197
198
|
},
|
|
198
199
|
setSorting: (value) => (sorting = value),
|
|
199
|
-
setPagination: (value) =>
|
|
200
|
+
setPagination: (value) => {
|
|
201
|
+
const pageChanged = pagination.pageIndex !== value.pageIndex
|
|
202
|
+
pagination = value
|
|
203
|
+
// Clear selection when page changes
|
|
204
|
+
if (pageChanged && Object.keys(rowSelection).length > 0) {
|
|
205
|
+
rowSelection = {}
|
|
206
|
+
}
|
|
207
|
+
},
|
|
200
208
|
setColumnSizing: (value) => {
|
|
201
209
|
columnSizing = value
|
|
202
210
|
if (onColumnResize && Object.keys(value).length > 0) {
|
|
@@ -417,6 +425,7 @@
|
|
|
417
425
|
{manualPagination}
|
|
418
426
|
{onPageChange}
|
|
419
427
|
{onPageSizeChange}
|
|
428
|
+
{disableJumpToPage}
|
|
420
429
|
disabled={disableControls || loading}
|
|
421
430
|
>
|
|
422
431
|
{#if paginationSlot}
|