mgv-backoffice 1.0.0
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/components/BaseAlert.vue.d.ts +26 -0
- package/dist/components/BaseBadge.vue.d.ts +27 -0
- package/dist/components/BaseButton.vue.d.ts +119 -0
- package/dist/components/BaseLine.vue.d.ts +17 -0
- package/dist/components/BaseLogo.vue.d.ts +17 -0
- package/dist/components/BaseModal.vue.d.ts +49 -0
- package/dist/components/BaseRow.vue.d.ts +31 -0
- package/dist/components/BaseSpinner.vue.d.ts +2 -0
- package/dist/components/BaseToast.vue.d.ts +45 -0
- package/dist/components/ColoredSquares.vue.d.ts +27 -0
- package/dist/components/EuroAmount.vue.d.ts +35 -0
- package/dist/components/Pagination.vue.d.ts +29 -0
- package/dist/components/TrendArrow.vue.d.ts +20 -0
- package/dist/enums/AlertEnum.d.ts +6 -0
- package/dist/enums/BaseBadgeEnum.d.ts +4 -0
- package/dist/enums/BaseButtonEnum.d.ts +9 -0
- package/dist/enums/BaseButtonSizeEnum.d.ts +7 -0
- package/dist/enums/BaseLogoEnum.d.ts +5 -0
- package/dist/enums/BaseModalEnum.d.ts +4 -0
- package/dist/enums/BaseToastEnum.d.ts +5 -0
- package/dist/enums/ColorsEnums.d.ts +9 -0
- package/dist/enums/LineEnum.d.ts +5 -0
- package/dist/enums/PositioningEnum.d.ts +6 -0
- package/dist/index.d.ts +24 -0
- package/dist/style.css +1 -0
- package/dist/ui-lib.js +920 -0
- package/dist/ui-lib.umd.cjs +1 -0
- package/dist/utils/util.d.ts +5 -0
- package/package.json +31 -0
- package/src/components/BaseAlert.vue +32 -0
- package/src/components/BaseBadge.vue +24 -0
- package/src/components/BaseButton.vue +132 -0
- package/src/components/BaseLine.vue +17 -0
- package/src/components/BaseLogo.vue +27 -0
- package/src/components/BaseModal.vue +75 -0
- package/src/components/BaseRow.vue +19 -0
- package/src/components/BaseSpinner.vue +9 -0
- package/src/components/BaseToast.vue +101 -0
- package/src/components/ColoredSquares.vue +51 -0
- package/src/components/EuroAmount.vue +40 -0
- package/src/components/Pagination.vue +136 -0
- package/src/components/TrendArrow.vue +33 -0
- package/src/enums/AlertEnum.ts +6 -0
- package/src/enums/BaseBadgeEnum.ts +4 -0
- package/src/enums/BaseButtonEnum.ts +9 -0
- package/src/enums/BaseButtonSizeEnum.ts +7 -0
- package/src/enums/BaseLogoEnum.ts +5 -0
- package/src/enums/BaseModalEnum.ts +4 -0
- package/src/enums/BaseToastEnum.ts +5 -0
- package/src/enums/ColorsEnums.ts +9 -0
- package/src/enums/LineEnum.ts +3 -0
- package/src/enums/PositioningEnum.ts +3 -0
- package/src/index.ts +29 -0
- package/src/utils/util.ts +53 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<ul>
|
|
4
|
+
<li v-for="cell in cells" :key="cell">
|
|
5
|
+
<a v-if="cell!==0" @click="changePage(cell)" :class="{ active: cell === currentPage }">{{ cell }}</a>
|
|
6
|
+
<span v-if="cell===0" style="cursor: not-allowed;">...</span>
|
|
7
|
+
</li>
|
|
8
|
+
</ul>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { ref, watch } from "vue";
|
|
14
|
+
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
totalItems: {
|
|
17
|
+
type: Number,
|
|
18
|
+
required: true,
|
|
19
|
+
default: 10
|
|
20
|
+
},
|
|
21
|
+
itemsPerPage: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: 20
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const currentPage = ref(1);
|
|
28
|
+
const totalPages = ref(0);
|
|
29
|
+
const cells = ref([] as number[]);
|
|
30
|
+
const emit = defineEmits(['page-changed']);
|
|
31
|
+
|
|
32
|
+
function changePage(pageNumber: number) {
|
|
33
|
+
if (pageNumber !== currentPage.value && pageNumber >= 1 && pageNumber <= totalPages.value) {
|
|
34
|
+
currentPage.value = pageNumber;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (totalPages.value > 5) {
|
|
38
|
+
cells.value = [];
|
|
39
|
+
|
|
40
|
+
let isAwayFromStartPoint = (pageNumber - 3) > 0;
|
|
41
|
+
if (isAwayFromStartPoint) {
|
|
42
|
+
cells.value.push(1);
|
|
43
|
+
cells.value.push(0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for (let i = 2; i >= 1; i--) {
|
|
47
|
+
let previousCell = pageNumber - i;
|
|
48
|
+
if (previousCell > 0) {
|
|
49
|
+
cells.value.push(previousCell);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
cells.value.push(currentPage.value);
|
|
54
|
+
|
|
55
|
+
let nextPages = totalPages.value - pageNumber;
|
|
56
|
+
let hasNextPages = nextPages > 2;
|
|
57
|
+
let nextPagesSize = 2;
|
|
58
|
+
|
|
59
|
+
if (hasNextPages) {
|
|
60
|
+
for (let i = 1; i <= nextPagesSize; i++) {
|
|
61
|
+
cells.value.push(pageNumber + i);
|
|
62
|
+
}
|
|
63
|
+
cells.value.push(0);
|
|
64
|
+
cells.value.push(totalPages.value);
|
|
65
|
+
} else {
|
|
66
|
+
for (let i = 1; i <= nextPages; i++) {
|
|
67
|
+
cells.value.push(pageNumber + i);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
emit('page-changed', pageNumber);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
watch(() => props.totalItems, () => {
|
|
76
|
+
totalPages.value = Math.ceil(props.totalItems / props.itemsPerPage);
|
|
77
|
+
|
|
78
|
+
cells.value = [];
|
|
79
|
+
if (totalPages.value > 5) {
|
|
80
|
+
for (let i = 1; i < 5; i++) {
|
|
81
|
+
cells.value.push(i);
|
|
82
|
+
}
|
|
83
|
+
cells.value.push(0);
|
|
84
|
+
cells.value.push(totalPages.value);
|
|
85
|
+
} else {
|
|
86
|
+
for (let i = 1; i <= totalPages.value; i++) {
|
|
87
|
+
cells.value.push(i);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<style lang="scss" scoped>
|
|
94
|
+
span {
|
|
95
|
+
border: 1px solid #d1d5db;
|
|
96
|
+
border-radius: 10px;
|
|
97
|
+
padding: 0.75rem;
|
|
98
|
+
text-decoration: none;
|
|
99
|
+
color: black;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
ul {
|
|
103
|
+
display: flex;
|
|
104
|
+
list-style: none;
|
|
105
|
+
padding: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
li {
|
|
109
|
+
margin-right: 3px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
a {
|
|
113
|
+
border: 1px solid #d1d5db;
|
|
114
|
+
border-radius: 10px;
|
|
115
|
+
padding: 0.75rem;
|
|
116
|
+
text-decoration: none;
|
|
117
|
+
color: black;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
a:hover {
|
|
121
|
+
background-color: rgb(195 197 201);
|
|
122
|
+
color: #000000;
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
a.active:hover {
|
|
127
|
+
background-color: rgb(195 197 201);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
a.active {
|
|
131
|
+
font-weight: 700;
|
|
132
|
+
border-radius: 10px;
|
|
133
|
+
background-color: #e5e7eb;
|
|
134
|
+
color: #000000;
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="number">
|
|
3
|
+
<span v-if="isNegative" class="flex items-center space-x-2">
|
|
4
|
+
<BaseBadge :color="ColorsEnums.RED">{{ number }}{{ props.icon }}</BaseBadge>
|
|
5
|
+
<ArrowDownIcon class="h-5 w-5 text-red-500" />
|
|
6
|
+
</span>
|
|
7
|
+
|
|
8
|
+
<span v-else class="flex items-center space-x-2">
|
|
9
|
+
<BaseBadge :color="ColorsEnums.GREEN">{{ number }}{{ props.icon }}</BaseBadge>
|
|
10
|
+
<ArrowUpIcon class="h-5 w-5 text-green-500" />
|
|
11
|
+
</span>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { computed } from 'vue'
|
|
17
|
+
import BaseBadge from './BaseBadge.vue'
|
|
18
|
+
import { ColorsEnums } from '../enums/ColorsEnums'
|
|
19
|
+
import { ArrowDownIcon, ArrowUpIcon } from '@heroicons/vue/24/outline'
|
|
20
|
+
|
|
21
|
+
const props = defineProps({
|
|
22
|
+
number: {
|
|
23
|
+
type: Number,
|
|
24
|
+
required: false
|
|
25
|
+
},
|
|
26
|
+
icon: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: false
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const isNegative = computed(() => props.number !== null && props.number !== undefined && props.number < 0)
|
|
33
|
+
</script>
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Components
|
|
2
|
+
export { default as BaseAlert } from './components/BaseAlert.vue'
|
|
3
|
+
export { default as BaseBadge } from './components/BaseBadge.vue'
|
|
4
|
+
export { default as BaseButton } from './components/BaseButton.vue'
|
|
5
|
+
export { default as BaseLine } from './components/BaseLine.vue'
|
|
6
|
+
export { default as BaseLogo } from './components/BaseLogo.vue'
|
|
7
|
+
export { default as BaseModal } from './components/BaseModal.vue'
|
|
8
|
+
export { default as BaseRow } from './components/BaseRow.vue'
|
|
9
|
+
export { default as BaseSpinner } from './components/BaseSpinner.vue'
|
|
10
|
+
export { default as BaseToast } from './components/BaseToast.vue'
|
|
11
|
+
export { default as ColoredSquares } from './components/ColoredSquares.vue'
|
|
12
|
+
export { default as EuroAmount } from './components/EuroAmount.vue'
|
|
13
|
+
export { default as Pagination } from './components/Pagination.vue'
|
|
14
|
+
export { default as TrendArrow } from './components/TrendArrow.vue'
|
|
15
|
+
|
|
16
|
+
// Enums
|
|
17
|
+
export { AlertEnum } from './enums/AlertEnum'
|
|
18
|
+
export { BaseBadgeEnum } from './enums/BaseBadgeEnum'
|
|
19
|
+
export { BaseButtonEnum } from './enums/BaseButtonEnum'
|
|
20
|
+
export { BaseButtonSizeEnum } from './enums/BaseButtonSizeEnum'
|
|
21
|
+
export { BaseLoginEnum } from './enums/BaseLogoEnum'
|
|
22
|
+
export { BaseModalEnum } from './enums/BaseModalEnum'
|
|
23
|
+
export { BaseToastEnum } from './enums/BaseToastEnum'
|
|
24
|
+
export { ColorsEnums } from './enums/ColorsEnums'
|
|
25
|
+
export { LineEnum } from './enums/LineEnum'
|
|
26
|
+
export { PositioningEnum } from './enums/PositioningEnum'
|
|
27
|
+
|
|
28
|
+
// Utils
|
|
29
|
+
export { getBaseColor, getBaseColorOf } from './utils/util'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AlertEnum } from "../enums/AlertEnum";
|
|
2
|
+
import { ColorsEnums } from "../enums/ColorsEnums";
|
|
3
|
+
|
|
4
|
+
function getBaseColor(c: AlertEnum): string {
|
|
5
|
+
let color = "red";
|
|
6
|
+
switch (c) {
|
|
7
|
+
case (AlertEnum.ERROR):
|
|
8
|
+
color = "red"
|
|
9
|
+
break;
|
|
10
|
+
case (AlertEnum.SUCCESS):
|
|
11
|
+
color = "green"
|
|
12
|
+
break;
|
|
13
|
+
case (AlertEnum.INFROM):
|
|
14
|
+
color = "gray"
|
|
15
|
+
break;
|
|
16
|
+
case (AlertEnum.WARNING):
|
|
17
|
+
color = "yellow"
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
return color;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getBaseColorOf(c: ColorsEnums): string {
|
|
24
|
+
let color = 'red';
|
|
25
|
+
switch (c) {
|
|
26
|
+
case ColorsEnums.GREEN: {
|
|
27
|
+
color = 'green';
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case ColorsEnums.RED: {
|
|
31
|
+
color = 'red';
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case ColorsEnums.BLUE: {
|
|
35
|
+
color = 'blue';
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case ColorsEnums.YELLOW: {
|
|
39
|
+
color = 'yellow';
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case ColorsEnums.NONE: {
|
|
43
|
+
color = '';
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return color;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
getBaseColor,
|
|
52
|
+
getBaseColorOf
|
|
53
|
+
};
|