@farm-investimentos/front-mfe-components 2.1.2 → 2.2.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/front-mfe-components.common.js +218 -23
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.css +1 -1
- package/dist/front-mfe-components.umd.js +218 -23
- package/dist/front-mfe-components.umd.js.map +1 -1
- package/dist/front-mfe-components.umd.min.js +1 -1
- package/dist/front-mfe-components.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DataTableHeader/DataTableHeader.scss +22 -0
- package/src/components/DataTableHeader/DataTableHeader.stories.js +8 -0
- package/src/components/DataTableHeader/DataTableHeader.vue +117 -0
- package/src/components/DataTableHeader/index.js +3 -0
- package/src/main.js +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.header-text {
|
|
2
|
+
position: relative;
|
|
3
|
+
i {
|
|
4
|
+
position: absolute;
|
|
5
|
+
right: -20px;
|
|
6
|
+
top: -1px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.v-icon {
|
|
10
|
+
&.v-icon--asc {
|
|
11
|
+
transform: rotateX(180deg);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
th.sortable:not(.active) {
|
|
17
|
+
&:hover {
|
|
18
|
+
.v-icon {
|
|
19
|
+
opacity: 0.5 !important;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<thead>
|
|
3
|
+
<tr>
|
|
4
|
+
<th
|
|
5
|
+
v-for="(item, $index) in headers"
|
|
6
|
+
:key="item.value"
|
|
7
|
+
v-bind:class="[
|
|
8
|
+
item.sortable ? 'sortable' : '',
|
|
9
|
+
sortClick[$index].clicked ? 'active' : '',
|
|
10
|
+
item.sortable && sortClick[$index].descending === 'DESC' ? 'DESC' : 'ASC',
|
|
11
|
+
]"
|
|
12
|
+
v-bind:style="{
|
|
13
|
+
textAlign: item.align,
|
|
14
|
+
width: thWidth(item),
|
|
15
|
+
}"
|
|
16
|
+
@click="item.sortable ? clickSort(item.value, $index) : ''"
|
|
17
|
+
@mouseover="changeShow($index)"
|
|
18
|
+
@mouseout="changeHidden($index)"
|
|
19
|
+
>
|
|
20
|
+
<span class="header-text">
|
|
21
|
+
{{ item.text }}
|
|
22
|
+
|
|
23
|
+
<v-icon
|
|
24
|
+
v-if="item.sortable && sortClick[$index].show"
|
|
25
|
+
v-bind:class="[
|
|
26
|
+
sortClick[$index][item.value] ? 'v-icon--desc' : 'v-icon--asc',
|
|
27
|
+
]"
|
|
28
|
+
small
|
|
29
|
+
>
|
|
30
|
+
mdi-sort-descending
|
|
31
|
+
</v-icon>
|
|
32
|
+
</span>
|
|
33
|
+
</th>
|
|
34
|
+
</tr>
|
|
35
|
+
</thead>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
import Vue from 'vue';
|
|
40
|
+
import VIcon from 'vuetify/lib/components/VIcon';
|
|
41
|
+
export default Vue.extend({
|
|
42
|
+
name: 'farm-datatable-header',
|
|
43
|
+
components: {
|
|
44
|
+
VIcon,
|
|
45
|
+
},
|
|
46
|
+
props: {
|
|
47
|
+
headers: {
|
|
48
|
+
type: Array,
|
|
49
|
+
require: true,
|
|
50
|
+
},
|
|
51
|
+
sortClick: {
|
|
52
|
+
type: Array,
|
|
53
|
+
require: true,
|
|
54
|
+
},
|
|
55
|
+
fistSelected: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: () => false,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
61
|
+
getTypeSort(value) {
|
|
62
|
+
return value ? 'DESC' : 'ASC';
|
|
63
|
+
},
|
|
64
|
+
clickSort(value, index) {
|
|
65
|
+
this.removeClicked();
|
|
66
|
+
this.sortClick[index].clicked = true;
|
|
67
|
+
this.sortClick[index].show = true;
|
|
68
|
+
this.sortClick[index][value] = !this.sortClick[index][value];
|
|
69
|
+
this.sortClick[index].descending = this.getTypeSort(this.sortClick[index][value]);
|
|
70
|
+
this.$emit('onClickSort', this.sortClick[index]);
|
|
71
|
+
},
|
|
72
|
+
changeShow(index) {
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
this.sortClick[index].show = true;
|
|
75
|
+
}, 10);
|
|
76
|
+
},
|
|
77
|
+
changeHidden(index) {
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
if (this.sortClick[index].clicked) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.sortClick[index].show = false;
|
|
83
|
+
}, 10);
|
|
84
|
+
},
|
|
85
|
+
removeClicked() {
|
|
86
|
+
for (let i = 0; i < this.sortClick.length; i += 1) {
|
|
87
|
+
this.sortClick[i].clicked = false;
|
|
88
|
+
this.sortClick[i].show = false;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
checkFistSelected(index) {
|
|
92
|
+
if (index === 0) {
|
|
93
|
+
return this.fistSelected;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
},
|
|
97
|
+
thWidth(item) {
|
|
98
|
+
return item.width ? item.width + 'px' : 'auto';
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
created() {
|
|
102
|
+
for (let i = 0; i < this.headers.length; i += 1) {
|
|
103
|
+
this.sortClick.push({
|
|
104
|
+
[this.headers[i].value]: false,
|
|
105
|
+
descending: 'ASC',
|
|
106
|
+
field: this.headers[i].value,
|
|
107
|
+
clicked: this.checkFistSelected(i),
|
|
108
|
+
show: this.checkFistSelected(i),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<style lang="scss" scoped>
|
|
116
|
+
@import './DataTableHeader.scss';
|
|
117
|
+
</style>
|
package/src/main.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import DataTableEmptyWrapper from './components/DataTableEmptyWrapper';
|
|
2
2
|
import DataTablePaginator from './components/DataTablePaginator';
|
|
3
|
+
import DataTableHeader from './components/DataTableHeader';
|
|
3
4
|
import AlertReload from './components/AlertReload';
|
|
4
5
|
import MainFilter from './components/MainFilter';
|
|
5
6
|
import Loader from './components/Loader';
|
|
@@ -20,6 +21,7 @@ import DefaultButton from './components/Buttons/DefaultButton/DefaultButton.vue'
|
|
|
20
21
|
export {
|
|
21
22
|
DataTableEmptyWrapper,
|
|
22
23
|
DataTablePaginator,
|
|
24
|
+
DataTableHeader,
|
|
23
25
|
MainFilter,
|
|
24
26
|
Loader,
|
|
25
27
|
FilePicker,
|