@bl33dz/fa814698dcde12f86a37ac31dd3aedf9 1.0.19 → 1.0.20

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.19",
6
+ "version": "1.0.20",
7
7
  "main": "dist/perisai-ui.umd.js",
8
8
  "module": "dist/perisai-ui.es.js",
9
9
  "scripts": {
@@ -1,21 +1,37 @@
1
1
  <template>
2
- <nav class="flex items-center justify-center gap-2" role="navigation" aria-label="Pagination">
2
+ <nav class="flex items-center justify-center gap-1" role="navigation" aria-label="Pagination">
3
3
  <button
4
- class="h-8 w-8 flex items-center justify-center rounded border border-input bg-background px-0 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50"
4
+ class="px-3 py-2 text-sm font-medium rounded-md transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:cursor-not-allowed"
5
5
  :disabled="page <= 1"
6
6
  @click="$emit('update:page', page - 1)"
7
7
  aria-label="Previous page"
8
8
  >
9
- &lt;
9
+ Previous
10
10
  </button>
11
- <span class="px-2 text-sm">{{ page }} / {{ totalPages }}</span>
11
+
12
+ <template v-for="(pageNum, index) in visiblePages" :key="pageNum">
13
+ <span v-if="pageNum === '...'" class="px-3 py-2 text-sm">...</span>
14
+ <button
15
+ v-else
16
+ class="px-3 py-2 text-sm font-medium rounded-md transition-colors"
17
+ :class="pageNum === page
18
+ ? 'border border-input bg-background'
19
+ : 'hover:bg-accent hover:text-accent-foreground'"
20
+ @click="$emit('update:page', pageNum)"
21
+ :aria-label="`Page ${pageNum}`"
22
+ :aria-current="pageNum === page ? 'page' : undefined"
23
+ >
24
+ {{ pageNum }}
25
+ </button>
26
+ </template>
27
+
12
28
  <button
13
- class="h-8 w-8 flex items-center justify-center rounded border border-input bg-background px-0 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50"
29
+ class="px-3 py-2 text-sm font-medium rounded-md transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:cursor-not-allowed"
14
30
  :disabled="page >= totalPages"
15
31
  @click="$emit('update:page', page + 1)"
16
32
  aria-label="Next page"
17
33
  >
18
- &gt;
34
+ Next
19
35
  </button>
20
36
  </nav>
21
37
  </template>
@@ -38,4 +54,45 @@ const props = defineProps({
38
54
  });
39
55
  const emit = defineEmits(['update:page']);
40
56
  const totalPages = computed(() => Math.max(1, Math.ceil(props.total / props.perPage)));
57
+
58
+ const visiblePages = computed(() => {
59
+ const pages = [];
60
+ const current = props.page;
61
+ const total = totalPages.value;
62
+
63
+ if (total <= 7) {
64
+ // Show all pages if total is 7 or less
65
+ for (let i = 1; i <= total; i++) {
66
+ pages.push(i);
67
+ }
68
+ } else {
69
+ // Always show first page
70
+ pages.push(1);
71
+
72
+ if (current <= 4) {
73
+ // Show pages 2, 3, 4, 5, then ellipsis, then last page
74
+ for (let i = 2; i <= 5; i++) {
75
+ pages.push(i);
76
+ }
77
+ pages.push('...');
78
+ pages.push(total);
79
+ } else if (current >= total - 3) {
80
+ // Show first page, ellipsis, then last 4 pages
81
+ pages.push('...');
82
+ for (let i = total - 4; i <= total; i++) {
83
+ pages.push(i);
84
+ }
85
+ } else {
86
+ // Show first page, ellipsis, current-1, current, current+1, ellipsis, last page
87
+ pages.push('...');
88
+ pages.push(current - 1);
89
+ pages.push(current);
90
+ pages.push(current + 1);
91
+ pages.push('...');
92
+ pages.push(total);
93
+ }
94
+ }
95
+
96
+ return pages;
97
+ });
41
98
  </script>