edvoyui-component-library-test-flight 0.0.207 → 0.0.208

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.
@@ -28,6 +28,7 @@ export { default as EUITableCheckbox } from './table/EUITableCheckbox';
28
28
  export { default as UCheckbox } from './table/UCheckbox';
29
29
  export { default as EUIPagination } from './table/EUIPagination';
30
30
  export { default as EUIStudentPagination } from './table/EUIStudentPagination';
31
+ export { default as EUIDashboardPagination } from './table/EUIDashboardPagination';
31
32
  export { default as EUIMultiDropdown } from './dropdown/EUIMultiDropdown';
32
33
  export { default as EUIDashboardTable } from './table/EUIDashboardTable';
33
34
  export { default as UTable } from './table/UTable';
@@ -0,0 +1,60 @@
1
+ declare const _default: import('../../../node_modules/vue').DefineComponent<import('../../../node_modules/vue').ExtractPropTypes<{
2
+ totalCount: {
3
+ type: NumberConstructor;
4
+ default: number;
5
+ required: true;
6
+ };
7
+ pageLimit: {
8
+ type: NumberConstructor;
9
+ default: number;
10
+ required: true;
11
+ };
12
+ activePage: {
13
+ type: NumberConstructor;
14
+ default: number;
15
+ };
16
+ divider: {
17
+ type: StringConstructor;
18
+ default: string;
19
+ };
20
+ max: {
21
+ type: NumberConstructor;
22
+ default: number;
23
+ validator: (value: number) => boolean;
24
+ };
25
+ }>, {}, {}, {}, {}, import('../../../node_modules/vue').ComponentOptionsMixin, import('../../../node_modules/vue').ComponentOptionsMixin, {
26
+ changePage: (...args: any[]) => void;
27
+ }, string, import('../../../node_modules/vue').PublicProps, Readonly<import('../../../node_modules/vue').ExtractPropTypes<{
28
+ totalCount: {
29
+ type: NumberConstructor;
30
+ default: number;
31
+ required: true;
32
+ };
33
+ pageLimit: {
34
+ type: NumberConstructor;
35
+ default: number;
36
+ required: true;
37
+ };
38
+ activePage: {
39
+ type: NumberConstructor;
40
+ default: number;
41
+ };
42
+ divider: {
43
+ type: StringConstructor;
44
+ default: string;
45
+ };
46
+ max: {
47
+ type: NumberConstructor;
48
+ default: number;
49
+ validator: (value: number) => boolean;
50
+ };
51
+ }>> & Readonly<{
52
+ onChangePage?: ((...args: any[]) => any) | undefined;
53
+ }>, {
54
+ max: number;
55
+ pageLimit: number;
56
+ totalCount: number;
57
+ activePage: number;
58
+ divider: string;
59
+ }, {}, {}, {}, string, import('../../../node_modules/vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
60
+ export default _default;
@@ -0,0 +1,134 @@
1
+ <template>
2
+ <div class="inline-flex flex-row items-center overflow-hidden gap-x-1">
3
+ <button
4
+ :class="[
5
+ 'rounded capitalize box-border border-none focus:outline-none inline-flex flex-row gap-0 items-center transition duration-150 ease-in-out bg-white text-gray-500 cursor-pointer p-px justify-center size-6 ring-1 ring-gray-200 ring-inset',
6
+ currentPage === 1 &&
7
+ 'disabled:opacity-50 disabled:select-none disabled:pointer-events-none disabled:cursor-default',
8
+ ]"
9
+ :disabled="currentPage === 1"
10
+ @click="prev()"
11
+ >
12
+ <ChevronDownStroke class="text-current transform rotate-90 size-5" />
13
+ </button>
14
+
15
+ <button
16
+ v-for="i in displayedPages"
17
+ :key="`button-${i}`"
18
+ :class="[
19
+ 'rounded capitalize box-border border-none focus:outline-none inline-flex flex-row gap-0 items-center transition-transform duration-100 ease-in-out cursor-pointer text-xs font-medium p-1 justify-center min-w-6 h-6',
20
+ i === '…'
21
+ ? 'select-none pointer-events-none cursor-default'
22
+ : currentPage === i
23
+ ? 'text-purple-700 bg-purple-50 ring-1 ring-inset ring-purple-500'
24
+ : 'bg-white text-gray-500 ring-1 ring-inset ring-gray-200',
25
+ ]"
26
+ @click="typeof i === 'number' && changePage(i - 1)"
27
+ >
28
+ {{ i }}
29
+ </button>
30
+
31
+ <button
32
+ :class="[
33
+ 'rounded capitalize box-border border-none focus:outline-none inline-flex flex-row gap-0 items-center transition duration-150 ease-in-out bg-white text-gray-500 cursor-pointer p-px justify-center size-6 ring-1 ring-gray-200 ring-inset',
34
+ totalPages === currentPage &&
35
+ 'disabled:opacity-50 disabled:pointer-events-none disabled:cursor-default disabled:select-none',
36
+ ]"
37
+ :disabled="totalPages === currentPage"
38
+ @click="next()"
39
+ >
40
+ <ChevronDownStroke class="text-current transform -rotate-90 size-5" />
41
+ </button>
42
+ </div>
43
+ </template>
44
+
45
+ <script setup lang="ts">
46
+ import { computed } from "vue";
47
+ import ChevronDownStroke from "../../assets/svg/ChevronDownStroke.vue";
48
+
49
+ const props = defineProps({
50
+ totalCount: { type: Number, default: 0, required: true },
51
+ pageLimit: { type: Number, default: 0, required: true },
52
+ activePage: { type: Number, default: 0 },
53
+ divider: { type: String, default: "…" },
54
+ max: {
55
+ type: Number,
56
+ default: 7,
57
+ validator: (value: number) => value >= 5 && value < Number.MAX_VALUE,
58
+ },
59
+ });
60
+
61
+ const emit = defineEmits(["changePage"]);
62
+
63
+ const currentPage = computed(() => props.activePage + 1);
64
+
65
+ const totalPages = computed(() =>
66
+ props.pageLimit > 0 ? Math.ceil(props.totalCount / props.pageLimit) : 1,
67
+ );
68
+
69
+ const prev = () => {
70
+ if (props.activePage > 0) changePage(props.activePage - 1);
71
+ };
72
+
73
+ const next = () => {
74
+ if (props.activePage < totalPages.value - 1) changePage(props.activePage + 1);
75
+ };
76
+
77
+ const changePage = (page: number) => emit("changePage", page);
78
+
79
+ const displayedPages = computed(() => {
80
+ const total = totalPages.value;
81
+ const current = currentPage.value;
82
+ const maxDisplayedPages = Math.max(props.max, 5);
83
+
84
+ const r = Math.floor((Math.min(maxDisplayedPages, total) - 5) / 2);
85
+ const r1 = current - r;
86
+ const r2 = current + r;
87
+
88
+ const beforeWrapped = r1 - 1 > 1;
89
+ const afterWrapped = r2 + 1 < total;
90
+
91
+ const items: Array<number | string> = [];
92
+
93
+ if (total <= maxDisplayedPages) {
94
+ return Array.from({ length: total }, (_, i) => i + 1);
95
+ }
96
+
97
+ items.push(1);
98
+
99
+ if (beforeWrapped) items.push(props.divider);
100
+
101
+ if (!afterWrapped) {
102
+ const addedItems = current + r + 2 - total;
103
+ for (let i = current - r - addedItems; i <= current - r - 1; i++)
104
+ items.push(i);
105
+ }
106
+
107
+ for (let i = Math.max(2, r1); i <= Math.min(total, r2); i++) items.push(i);
108
+
109
+ if (!beforeWrapped) {
110
+ const addedItems = 1 - (current - r - 2);
111
+ for (let i = current + r + 1; i <= current + r + addedItems; i++)
112
+ items.push(i);
113
+ }
114
+
115
+ if (afterWrapped) items.push(props.divider);
116
+
117
+ if (r2 < total) items.push(total);
118
+
119
+ // Replace divider by number on start edge case [1, '…', 3, ...]
120
+ if (items.length >= 3 && items[1] === props.divider && items[2] === 3)
121
+ items[1] = 2;
122
+
123
+ // Replace divider by number on end edge case [..., 48, '…', 50]
124
+ if (
125
+ items.length >= 3 &&
126
+ items[items.length - 2] === props.divider &&
127
+ items[items.length - 1] === items.length
128
+ )
129
+ items[items.length - 2] = items.length - 1;
130
+
131
+ return items;
132
+ });
133
+ </script>
134
+ <style scoped></style>