@lavalogic/scoria 0.38.6 → 0.38.7
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.
|
@@ -111,17 +111,27 @@
|
|
|
111
111
|
$effect(() => {
|
|
112
112
|
if (tableContext.paginationRepo?.paginationState.pageIndex == null) {
|
|
113
113
|
pageButtons = [1];
|
|
114
|
-
|
|
115
|
-
const startingPage = Math.min(
|
|
116
|
-
tableContext.lastPage - 2,
|
|
117
|
-
tableContext.paginationRepo.paginationState.pageIndex - 1
|
|
118
|
-
);
|
|
119
|
-
const pageToStartWith = Math.max(1, Math.min(startingPage, tableContext.lastPage - 4));
|
|
120
|
-
|
|
121
|
-
pageButtons = new Array<number>(Math.min(tableContext.lastPage, 5))
|
|
122
|
-
.fill(pageToStartWith)
|
|
123
|
-
.map((item, index) => item + index);
|
|
114
|
+
return;
|
|
124
115
|
}
|
|
116
|
+
const current = tableContext.paginationRepo.paginationState.pageIndex + 1;
|
|
117
|
+
const last = tableContext.lastPage;
|
|
118
|
+
// `pages` accumulates the dedup'd, sorted button set. The minimum
|
|
119
|
+
// the user always sees between the Previous and Next arrows is the
|
|
120
|
+
// current page, the next page (when one exists), and the last
|
|
121
|
+
// page. On top of that we still surface a small window around the
|
|
122
|
+
// current page for visual context.
|
|
123
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
124
|
+
const pages = new Set<number>();
|
|
125
|
+
const windowStart = Math.max(1, Math.min(current - 2, last - 4));
|
|
126
|
+
for (let i = windowStart; i < windowStart + 5 && i <= last; i++) {
|
|
127
|
+
pages.add(i);
|
|
128
|
+
}
|
|
129
|
+
pages.add(current);
|
|
130
|
+
if (current + 1 <= last) {
|
|
131
|
+
pages.add(current + 1);
|
|
132
|
+
}
|
|
133
|
+
pages.add(last);
|
|
134
|
+
pageButtons = [...pages].sort((a, b) => a - b);
|
|
125
135
|
});
|
|
126
136
|
|
|
127
137
|
let hasNoSelectedItems = $derived(tableContext.selectedItems.size == 0);
|
|
@@ -250,6 +260,11 @@
|
|
|
250
260
|
id="{tableContext.tableName}-jump-to-page"
|
|
251
261
|
value={pageValue}
|
|
252
262
|
oninput={onNumberInput}
|
|
263
|
+
onfocus={(e) => {
|
|
264
|
+
// Select the existing value so typing replaces it, instead of
|
|
265
|
+
// appending to it (typing "5" on a "4" otherwise yields "45").
|
|
266
|
+
(e.target as HTMLInputElement).select();
|
|
267
|
+
}}
|
|
253
268
|
disabled={tableContext.showSelectedOnly}
|
|
254
269
|
/>
|
|
255
270
|
</div>
|
|
@@ -68,8 +68,11 @@ export declare class BuiltInRemoteRepository<TRow extends object> extends TableD
|
|
|
68
68
|
readonly setFilterMode: (id: string, mode: FilterMode) => void;
|
|
69
69
|
readonly filterBy: (id: string, value: unknown) => void;
|
|
70
70
|
readonly resetFilters: () => void;
|
|
71
|
+
/** Jumps to the given 1-based page number, clamped at >= 1. */
|
|
71
72
|
readonly setPage: (page: number) => void;
|
|
73
|
+
/** Advances to the next page. */
|
|
72
74
|
readonly nextPage: () => void;
|
|
75
|
+
/** Returns to the previous page, clamped at >= 1. */
|
|
73
76
|
readonly prevPage: () => void;
|
|
74
77
|
readonly setPageSize: (size: number | string) => void;
|
|
75
78
|
readonly updateSorting: (next: SortingState | ((prev: SortingState) => SortingState)) => void;
|
|
@@ -121,8 +124,11 @@ export declare class CustomRemoteRepository<TRow extends object> extends TableDa
|
|
|
121
124
|
readonly setFilterMode: (id: string, mode: FilterMode) => void;
|
|
122
125
|
readonly filterBy: (id: string, value: unknown) => void;
|
|
123
126
|
readonly resetFilters: () => void;
|
|
127
|
+
/** Jumps to the given 1-based page number, clamped at >= 1. */
|
|
124
128
|
readonly setPage: (page: number) => void;
|
|
129
|
+
/** Advances to the next page. */
|
|
125
130
|
readonly nextPage: () => void;
|
|
131
|
+
/** Returns to the previous page, clamped at >= 1. */
|
|
126
132
|
readonly prevPage: () => void;
|
|
127
133
|
readonly setPageSize: (size: number | string) => void;
|
|
128
134
|
readonly updateSorting: (next: SortingState | ((prev: SortingState) => SortingState)) => void;
|
|
@@ -118,15 +118,29 @@ export class BuiltInRemoteRepository extends TableDataRepository {
|
|
|
118
118
|
this._filtering = [];
|
|
119
119
|
this.scheduleReload();
|
|
120
120
|
};
|
|
121
|
+
/** Jumps to the given 1-based page number, clamped at >= 1. */
|
|
121
122
|
setPage = (page) => {
|
|
122
|
-
this.paginationState = {
|
|
123
|
+
this.paginationState = {
|
|
124
|
+
...this.paginationState,
|
|
125
|
+
pageIndex: Math.max(0, page - 1),
|
|
126
|
+
};
|
|
123
127
|
this.scheduleReload({ immediate: true });
|
|
124
128
|
};
|
|
129
|
+
/** Advances to the next page. */
|
|
125
130
|
nextPage = () => {
|
|
126
|
-
this.
|
|
131
|
+
this.paginationState = {
|
|
132
|
+
...this.paginationState,
|
|
133
|
+
pageIndex: this.paginationState.pageIndex + 1,
|
|
134
|
+
};
|
|
135
|
+
this.scheduleReload({ immediate: true });
|
|
127
136
|
};
|
|
137
|
+
/** Returns to the previous page, clamped at >= 1. */
|
|
128
138
|
prevPage = () => {
|
|
129
|
-
this.
|
|
139
|
+
this.paginationState = {
|
|
140
|
+
...this.paginationState,
|
|
141
|
+
pageIndex: Math.max(0, this.paginationState.pageIndex - 1),
|
|
142
|
+
};
|
|
143
|
+
this.scheduleReload({ immediate: true });
|
|
130
144
|
};
|
|
131
145
|
setPageSize = (size) => {
|
|
132
146
|
const parsed = typeof size === 'number' ? size : Number.parseInt(size, 10);
|
|
@@ -379,15 +393,29 @@ export class CustomRemoteRepository extends TableDataRepository {
|
|
|
379
393
|
this._filtering = [];
|
|
380
394
|
void this.reload();
|
|
381
395
|
};
|
|
396
|
+
/** Jumps to the given 1-based page number, clamped at >= 1. */
|
|
382
397
|
setPage = (page) => {
|
|
383
|
-
this.paginationState = {
|
|
398
|
+
this.paginationState = {
|
|
399
|
+
...this.paginationState,
|
|
400
|
+
pageIndex: Math.max(0, page - 1),
|
|
401
|
+
};
|
|
384
402
|
void this.reload();
|
|
385
403
|
};
|
|
404
|
+
/** Advances to the next page. */
|
|
386
405
|
nextPage = () => {
|
|
387
|
-
this.
|
|
406
|
+
this.paginationState = {
|
|
407
|
+
...this.paginationState,
|
|
408
|
+
pageIndex: this.paginationState.pageIndex + 1,
|
|
409
|
+
};
|
|
410
|
+
void this.reload();
|
|
388
411
|
};
|
|
412
|
+
/** Returns to the previous page, clamped at >= 1. */
|
|
389
413
|
prevPage = () => {
|
|
390
|
-
this.
|
|
414
|
+
this.paginationState = {
|
|
415
|
+
...this.paginationState,
|
|
416
|
+
pageIndex: Math.max(0, this.paginationState.pageIndex - 1),
|
|
417
|
+
};
|
|
418
|
+
void this.reload();
|
|
391
419
|
};
|
|
392
420
|
setPageSize = (size) => {
|
|
393
421
|
const parsed = typeof size === 'number' ? size : Number.parseInt(size, 10);
|