@bl33dz/fa814698dcde12f86a37ac31dd3aedf9 1.0.18 → 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/dist/perisai-ui.es.js +1539 -1497
- package/dist/perisai-ui.umd.js +1 -1
- package/package.json +1 -1
- package/src/ui/SelectGroup.vue +6 -0
- package/src/ui/SelectValue.vue +10 -1
- package/src/ui/pagination.vue +63 -6
- package/src/ui/select.vue +21 -10
package/package.json
CHANGED
package/src/ui/SelectGroup.vue
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { SelectGroup as RekaSelectGroup } from "reka-ui"
|
|
3
|
+
import { cn } from "./utils"
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
class: String
|
|
7
|
+
})
|
|
3
8
|
</script>
|
|
4
9
|
|
|
5
10
|
<template>
|
|
6
11
|
<RekaSelectGroup
|
|
7
12
|
data-slot="select-group"
|
|
13
|
+
:class="cn(props.class)"
|
|
8
14
|
v-bind="$attrs"
|
|
9
15
|
>
|
|
10
16
|
<slot />
|
package/src/ui/SelectValue.vue
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { SelectValue } from '@/shadcn/select';
|
|
3
|
+
import { cn } from './utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
class: String,
|
|
7
|
+
});
|
|
3
8
|
</script>
|
|
4
9
|
|
|
5
10
|
<template>
|
|
6
|
-
<SelectValue
|
|
11
|
+
<SelectValue
|
|
12
|
+
data-slot="select-value"
|
|
13
|
+
:class="cn(props.class)"
|
|
14
|
+
v-bind="$attrs"
|
|
15
|
+
>
|
|
7
16
|
<slot />
|
|
8
17
|
</SelectValue>
|
|
9
18
|
</template>
|
package/src/ui/pagination.vue
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<nav class="flex items-center justify-center gap-
|
|
2
|
+
<nav class="flex items-center justify-center gap-1" role="navigation" aria-label="Pagination">
|
|
3
3
|
<button
|
|
4
|
-
class="
|
|
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
|
-
|
|
9
|
+
Previous
|
|
10
10
|
</button>
|
|
11
|
-
|
|
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="
|
|
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
|
-
|
|
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>
|
package/src/ui/select.vue
CHANGED
|
@@ -18,19 +18,24 @@
|
|
|
18
18
|
v-else
|
|
19
19
|
v-model="internalValue"
|
|
20
20
|
:disabled="disabled"
|
|
21
|
+
:class="mergedClass"
|
|
21
22
|
>
|
|
22
23
|
<SelectTrigger class="w-full">
|
|
23
|
-
<
|
|
24
|
+
<slot name="trigger">
|
|
25
|
+
<SelectValue :placeholder="placeholder" />
|
|
26
|
+
</slot>
|
|
24
27
|
</SelectTrigger>
|
|
25
28
|
|
|
26
|
-
<SelectContent>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
<SelectContent :class="contentClass">
|
|
30
|
+
<slot name="content">
|
|
31
|
+
<SelectItem
|
|
32
|
+
v-for="opt in options"
|
|
33
|
+
:key="String(opt.value)"
|
|
34
|
+
:value="String(opt.value)"
|
|
35
|
+
>
|
|
36
|
+
{{ opt.label }}
|
|
37
|
+
</SelectItem>
|
|
38
|
+
</slot>
|
|
34
39
|
</SelectContent>
|
|
35
40
|
</ShadcnSelect>
|
|
36
41
|
</template>
|
|
@@ -43,6 +48,8 @@ import {
|
|
|
43
48
|
SelectContent,
|
|
44
49
|
SelectItem,
|
|
45
50
|
} from '@/shadcn/select'
|
|
51
|
+
import { cn } from './utils'
|
|
52
|
+
import SelectMultiple from './select-multiple.vue'
|
|
46
53
|
|
|
47
54
|
const props = defineProps({
|
|
48
55
|
modelValue: [String, Array],
|
|
@@ -51,6 +58,10 @@ const props = defineProps({
|
|
|
51
58
|
placeholder: String,
|
|
52
59
|
disabled: Boolean,
|
|
53
60
|
customClass: String,
|
|
61
|
+
contentClass: String,
|
|
62
|
+
title: String,
|
|
63
|
+
maxDisplay: { type: Number, default: 3 },
|
|
64
|
+
size: { type: String, default: 'default' },
|
|
54
65
|
})
|
|
55
66
|
|
|
56
67
|
const emit = defineEmits(['update:modelValue'])
|
|
@@ -61,5 +72,5 @@ const internalValue = computed({
|
|
|
61
72
|
})
|
|
62
73
|
|
|
63
74
|
const attrs = useAttrs()
|
|
64
|
-
const mergedClass = computed(() => props.customClass
|
|
75
|
+
const mergedClass = computed(() => cn(props.customClass, attrs.class as string))
|
|
65
76
|
</script>
|