@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 onClickPrev = () => {
12
- value--;
13
- window.scrollTo({ top: 0, behavior: 'smooth' });
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
- const onClickNext = () => {
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} onclick={onClickPrev}
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} onclick={onClickNext}
28
+ <Btn class="join-item rounded-l-none btn-outline" disabled={deadend} href={nextHref}
27
29
  >次の{per}件</Btn
28
30
  >
29
31
  </div>
@@ -31,6 +31,7 @@ export interface Data<T> {
31
31
  status: number;
32
32
  data?: T;
33
33
  message?: string;
34
+ meta?: string;
34
35
  }
35
36
  export interface ContentImage {
36
37
  src: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3birds/midori-ui",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",