@3birds/midori-ui 0.0.51 → 0.0.52
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { page as pageState } from '$app/state';
|
|
2
3
|
import { Btn } from '@3birds/midori-ui';
|
|
3
4
|
|
|
4
5
|
let {
|
|
@@ -8,22 +9,23 @@
|
|
|
8
9
|
class: className
|
|
9
10
|
}: { value: number; per: number; deadend: boolean; class?: string } = $props();
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const generatePaginationHref = (value: number): string => {
|
|
13
|
+
const searchParams: URLSearchParams = new URLSearchParams(pageState.url.searchParams);
|
|
14
|
+
|
|
15
|
+
searchParams.set('page', value.toString());
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
value++;
|
|
18
|
-
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
17
|
+
return `${pageState.url.pathname}?${searchParams.toString()}`;
|
|
19
18
|
};
|
|
19
|
+
|
|
20
|
+
const prevHref = $derived(value === 1 ? '' : generatePaginationHref(value - 1));
|
|
21
|
+
const nextHref = $derived(deadend ? '' : generatePaginationHref(value + 1));
|
|
20
22
|
</script>
|
|
21
23
|
|
|
22
24
|
<div class="join col-span-8 col-start-3 grid grid-cols-2 {className}">
|
|
23
|
-
<Btn class="join-item rounded-r-none btn-outline" disabled={value === 1}
|
|
25
|
+
<Btn class="join-item rounded-r-none btn-outline" href={prevHref} disabled={value === 1}
|
|
24
26
|
>前の{per}件</Btn
|
|
25
27
|
>
|
|
26
|
-
<Btn class="join-item rounded-l-none btn-outline" disabled={deadend}
|
|
28
|
+
<Btn class="join-item rounded-l-none btn-outline" disabled={deadend} href={nextHref}
|
|
27
29
|
>次の{per}件</Btn
|
|
28
30
|
>
|
|
29
31
|
</div>
|
package/dist/types/index.d.ts
CHANGED