@farm-investimentos/front-mfe-components 2.1.0 → 2.2.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -37,7 +37,7 @@ export default Vue.extend({
37
37
  computed: {
38
38
  iconPath() {
39
39
  if (!this.customIcon) {
40
- return 'mdi-trash-can';
40
+ return 'mdi-trash-can-outline';
41
41
  }
42
42
  return `mdi-${this.customIcon}`;
43
43
  },
@@ -19,7 +19,7 @@ describe('DangerButton component', () => {
19
19
  wrapper.setProps({
20
20
  icon: true,
21
21
  });
22
- expect(component.iconPath).toEqual('mdi-trash-can');
22
+ expect(component.iconPath).toEqual('mdi-trash-can-outline');
23
23
  });
24
24
 
25
25
  it('Should return custom icon', async () => {
@@ -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,41 @@
1
+ import DataTableHeader from './DataTableHeader.vue';
2
+
3
+ export default {
4
+ title: 'Example/Table/DataTableHeader',
5
+ component: DataTableHeader,
6
+ };
7
+
8
+ export const Primary = () => ({
9
+ components: { DataTableHeader },
10
+ data() {
11
+ return {
12
+ headers: [
13
+ {
14
+ text: 'Grupo',
15
+ sortable: true,
16
+ value: 'name',
17
+ align: 'left',
18
+ },
19
+ {
20
+ text: 'Aprovado',
21
+ sortable: true,
22
+ value: 'approvedAmount',
23
+ align: 'center',
24
+ width: 160,
25
+ },
26
+ {
27
+ text: 'Disponível',
28
+ sortable: false,
29
+ value: 'availableAmount',
30
+ align: 'center',
31
+ width: 160,
32
+ },
33
+ ],
34
+ sortClick: [],
35
+ firstSelected: false,
36
+ };
37
+ },
38
+ template: `<DataTableHeader :headers="headers" :sortClick="sortClick" :firstSelected="firstSelected" />`,
39
+ });
40
+
41
+ Primary.storyName = 'Básico';
@@ -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
+ firstSelected: {
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>
@@ -0,0 +1,3 @@
1
+ import DataTableHeader from './DataTableHeader';
2
+
3
+ export default DataTableHeader;
@@ -29,4 +29,4 @@ export const CustomPerPage = () => ({
29
29
  Primary.storyName = 'Básico';
30
30
  Secondary.storyName = 'Sem limite por páginas';
31
31
  Disabled.storyName = 'Desabilitado';
32
- CustomPerPage.storyName = 'Lista de registrois por página customizada';
32
+ CustomPerPage.storyName = 'Lista de registros por página customizada';
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,
@@ -38,6 +40,7 @@ export {
38
40
  };
39
41
 
40
42
  export * from './components/Buttons/DefaultButton/';
43
+ export * from './components/Buttons/DangerButton/';
41
44
  export * from './components/Buttons/ConfirmButton';
42
45
  export * from './components/Buttons/ExportButton/';
43
46
  export * from './components/Buttons/ImportButton/';