@farm-investimentos/front-mfe-components 2.4.1 → 2.4.5

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.4.1",
3
+ "version": "2.4.5",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -6,6 +6,10 @@
6
6
  border-radius: 5px;
7
7
  }
8
8
 
9
+ .card-context.height-full {
10
+ height: 100%;
11
+ }
12
+
9
13
  .card-context-header {
10
14
  width: 100%;
11
15
  height: 40px;
@@ -32,6 +32,15 @@ export const WithLoading = () => ({
32
32
  `,
33
33
  });
34
34
 
35
+ export const WithLoadingLarge = () => ({
36
+ components: { CardContext },
37
+ template: `
38
+ <CardContext icon="mdi-currency-usd" title="Titulo do Card" isLoading largeLoading>
39
+ <p>Conteúdo do Card</p>
40
+ </CardContext>
41
+ `,
42
+ });
43
+
35
44
  export const WithError = () => ({
36
45
  components: { CardContext },
37
46
  template: `
@@ -44,4 +53,5 @@ export const WithError = () => ({
44
53
  Primary.storyName = 'Básico';
45
54
  Secondary.storyName = 'Título em Bold';
46
55
  WithLoading.storyName = 'Com Loading';
56
+ WithLoadingLarge.storyName = 'Com Loading Large';
47
57
  WithError.storyName = 'Com Erro';
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="card-context">
2
+ <div :class="isHeightFull">
3
3
  <div class="card-context-header" v-if="isSuccess">
4
4
  <IconBox :icon="icon" />
5
5
  <div class="card-context-content">
@@ -12,7 +12,7 @@
12
12
  <slot></slot>
13
13
  </div>
14
14
  <div class="card-context-loding-or-error" v-if="isLoading">
15
- <Loader size="small" />
15
+ <Loader :size="isLargeLoading" />
16
16
  </div>
17
17
  <div class="card-context-loding-or-error" v-if="isError">
18
18
  <AlertReload :label="errorLabel" @onClick="$emit('onLoad')" />
@@ -61,6 +61,10 @@ export default Vue.extend({
61
61
  type: Boolean,
62
62
  default: false,
63
63
  },
64
+ largeLoading: {
65
+ type: Boolean,
66
+ default: false,
67
+ },
64
68
  /**
65
69
  * Show error alert
66
70
  */
@@ -75,8 +79,11 @@ export default Vue.extend({
75
79
  type: String,
76
80
  default: 'Ocorreu um erro',
77
81
  },
82
+ full: {
83
+ type: Boolean,
84
+ default: false,
85
+ },
78
86
  },
79
-
80
87
  computed: {
81
88
  isBold() {
82
89
  if (this.bold) {
@@ -84,9 +91,21 @@ export default Vue.extend({
84
91
  }
85
92
  return 'card-context-title';
86
93
  },
94
+ isHeightFull() {
95
+ if (this.full) {
96
+ return 'card-context height-full';
97
+ }
98
+ return 'card-context';
99
+ },
87
100
  isSuccess() {
88
101
  return !this.isLoading && !this.isError;
89
102
  },
103
+ isLargeLoading() {
104
+ if (this.largeLoading) {
105
+ return 'normal';
106
+ }
107
+ return 'small';
108
+ },
90
109
  },
91
110
  });
92
111
  </script>
@@ -22,4 +22,4 @@ th.sortable {
22
22
  }
23
23
  }
24
24
  }
25
- }
25
+ }
@@ -21,7 +21,7 @@ export const Primary = () => ({
21
21
  sortable: true,
22
22
  value: 'approvedAmount',
23
23
  align: 'center',
24
- width: 160,
24
+ width: 320,
25
25
  },
26
26
  {
27
27
  text: 'Disponível',
@@ -12,6 +12,7 @@
12
12
  v-bind:style="{
13
13
  textAlign: item.align ? item.align : '',
14
14
  width: thWidth(item),
15
+ minWidth: thWidth(item),
15
16
  }"
16
17
  @click="item.sortable ? clickSort(item.value, $index) : ''"
17
18
  @mouseover="changeShow($index)"
@@ -30,6 +31,14 @@
30
31
  mdi-sort-descending
31
32
  </v-icon>
32
33
  </span>
34
+
35
+ <span v-if="isTHDataTableSelect(item)">
36
+ <v-simple-checkbox
37
+ :indeterminate="headerProps.someItems && !headerProps.everyItem"
38
+ v-model="inputVal"
39
+ @input="selectAll"
40
+ ></v-simple-checkbox>
41
+ </span>
33
42
  </th>
34
43
  </tr>
35
44
  </thead>
@@ -38,10 +47,13 @@
38
47
  <script>
39
48
  import Vue from 'vue';
40
49
  import VIcon from 'vuetify/lib/components/VIcon';
50
+ import VSimpleCheckbox from 'vuetify/lib/components/VCheckbox/VSimpleCheckbox';
51
+
41
52
  export default Vue.extend({
42
53
  name: 'farm-datatable-header',
43
54
  components: {
44
55
  VIcon,
56
+ VSimpleCheckbox,
45
57
  },
46
58
  props: {
47
59
  /**
@@ -72,6 +84,28 @@ export default Vue.extend({
72
84
  type: Number,
73
85
  default: 0,
74
86
  },
87
+ /**
88
+ * v-model for data-table-select
89
+ */
90
+ value: {
91
+ required: true,
92
+ },
93
+ /**
94
+ * Original header props
95
+ */
96
+ headerProps: {
97
+ type: Object,
98
+ },
99
+ },
100
+ computed: {
101
+ inputVal: {
102
+ get() {
103
+ return this.value;
104
+ },
105
+ set(val) {
106
+ this.$emit('input', val);
107
+ },
108
+ },
75
109
  },
76
110
  methods: {
77
111
  getTypeSort(value) {
@@ -119,6 +153,10 @@ export default Vue.extend({
119
153
  isTHDataTableSelect(item) {
120
154
  return item.value === 'data-table-select';
121
155
  },
156
+ selectAll(value) {
157
+ this.$emit('toggleSelectAll', value);
158
+ this.inputVal = value;
159
+ },
122
160
  },
123
161
  created() {
124
162
  for (let i = 0; i < this.headers.length; i += 1) {
@@ -8,7 +8,24 @@ describe('DataTableHeader component', () => {
8
8
  beforeEach(() => {
9
9
  wrapper = shallowMount(DataTableHeader, {
10
10
  propsData: {
11
- headers: [],
11
+ headers: [
12
+ {
13
+ value: 'A',
14
+ },
15
+ ],
16
+ sortClick: [
17
+ {
18
+ clicked: true,
19
+ show: true,
20
+ },
21
+ {
22
+ clicked: false,
23
+ show: false,
24
+ },
25
+ ],
26
+ selectedIndex: 0,
27
+ firstSelected: true,
28
+ value: false,
12
29
  },
13
30
  });
14
31
  component = wrapper.vm;
@@ -35,5 +52,44 @@ describe('DataTableHeader component', () => {
35
52
  expect(component.thWidth({ width: 24 })).toEqual('24px');
36
53
  expect(component.thWidth({})).toEqual('auto');
37
54
  });
55
+
56
+ it('Should remove clicked', () => {
57
+ component.removeClicked();
58
+ expect(component.sortClick[0].clicked).toBeFalsy();
59
+ expect(component.sortClick[0].show).toBeFalsy();
60
+ });
61
+
62
+ it('Should check first selected', () => {
63
+ expect(component.checkFirstSelected(999)).toBeFalsy();
64
+ expect(component.checkFirstSelected(0)).toBeTruthy();
65
+ });
66
+
67
+ it('Should emit event when clickSort', () => {
68
+ component.clickSort('A', 0);
69
+ expect(wrapper.emitted().onClickSort).toBeDefined();
70
+ });
71
+
72
+ it('Should get type sort', () => {
73
+ expect(component.getTypeSort(false)).toEqual('ASC');
74
+ expect(component.getTypeSort(true)).toEqual('DESC');
75
+ });
76
+
77
+ it('Should change show', async () => {
78
+ component.changeShow(0);
79
+ await new Promise(r => setTimeout(r, 20));
80
+ expect(component.sortClick[0].show).toBeTruthy();
81
+ });
82
+
83
+ it('Should change show', async () => {
84
+ component.changeHidden(0);
85
+ component.changeHidden(1);
86
+ await new Promise(r => setTimeout(r, 30));
87
+ expect(component.sortClick[1].show).toBeFalsy();
88
+ });
89
+
90
+ it('Should emit new value when selectAll checkbox is clicked', () => {
91
+ component.selectAll(true);
92
+ expect(wrapper.emitted().toggleSelectAll).toBeDefined();
93
+ });
38
94
  });
39
95
  });
@@ -1,97 +1,100 @@
1
1
  <template>
2
- <v-tabs color="secondary" v-model="selected">
3
- <v-tab
4
- v-for="(tab, index) in tabs"
5
- :key="index"
6
- :class="{ hideCounter: !showCounter }"
7
- @change="changeTab(tab, index)"
8
- :disabled="!allowUserChange"
9
- >
10
- <div
11
- v-if="showCounter"
12
- :class="{ 'is-selected': isSelected(index) }"
13
- class="pl-3 pr-3 pt-2 pb-2 mr-2 rounded-circle d-inline-block white--text"
14
- >
15
- <span>{{ index + 1 }}</span>
16
- </div>
17
- <span class="black--text text-capitalize">{{ tab.name }}</span>
18
- </v-tab>
19
- </v-tabs>
2
+ <v-tabs color="secondary" v-model="selected">
3
+ <v-tab
4
+ v-for="(tab, index) in tabs"
5
+ :key="index"
6
+ :class="{ hideCounter: !showCounter }"
7
+ @change="changeTab(tab, index)"
8
+ :disabled="!allowUserChange"
9
+ >
10
+ <div
11
+ v-if="showCounter"
12
+ :class="{ 'is-selected': isSelected(index) }"
13
+ class="pl-3 pr-3 pt-2 pb-2 mr-2 rounded-circle d-inline-block white--text"
14
+ >
15
+ <span>{{ index + 1 }}</span>
16
+ </div>
17
+ <span class="black--text text-capitalize">{{ tab.name }}</span>
18
+ </v-tab>
19
+ </v-tabs>
20
20
  </template>
21
21
 
22
22
  <script>
23
23
  import { VTabs, VTab } from 'vuetify/lib/components/VTabs';
24
24
  export default {
25
- data: () => ({
26
- selected: 0,
27
- }),
28
- props: {
29
- tabs: {
30
- type: Array,
31
- default: () => [
32
- {
33
- name: 'Seleção',
34
- path: 'selection',
35
- },
36
- {
37
- name: 'Revisão',
38
- path: 'review',
39
- },
40
- ],
41
- },
42
- showCounter: {
43
- type: Boolean,
44
- default: true,
45
- },
46
- initialSelect: {
47
- type: Number,
48
- default: 0,
49
- },
50
- allowUserChange: {
51
- type: Boolean,
52
- default: true,
53
- },
54
- },
55
- methods: {
56
- isSelected(index) {
57
- return index === this.selected;
58
- },
59
- changeTab(_, index) {
60
- this.$emit('update', this.tabs[index]);
61
- },
62
- next() {
63
- this.selected = this.selected + 1;
64
- this.$emit('update', this.tabs[this.selected]);
65
- },
66
- previous() {
67
- this.selected = this.selected - 1;
68
- this.$emit('update', this.tabs[this.selected]);
69
- },
70
- toIndex(index) {
71
- this.selected = index;
72
- this.$emit('update', this.tabs[index]);
73
- },
74
- updateTabRouting: (component, item, nextRoutePrefix) => {
75
- component.currentTab = item.path;
76
- const nextRoute = `${nextRoutePrefix}/${item.path}`;
77
- const currentRoute = component.$router.history.current.path;
78
- if (nextRoute !== currentRoute) component.$router.push(nextRoute);
79
- },
80
- },
81
- created() {
82
- this.selected = this.initialSelect;
83
- },
84
- components: {
85
- VTabs,
86
- VTab,
87
- },
25
+ data: () => ({
26
+ selected: 0,
27
+ }),
28
+ props: {
29
+ tabs: {
30
+ type: Array,
31
+ default: () => [
32
+ {
33
+ name: 'Seleção',
34
+ path: 'selection',
35
+ },
36
+ {
37
+ name: 'Revisão',
38
+ path: 'review',
39
+ },
40
+ ],
41
+ },
42
+ showCounter: {
43
+ type: Boolean,
44
+ default: true,
45
+ },
46
+ initialSelect: {
47
+ type: Number,
48
+ default: 0,
49
+ },
50
+ allowUserChange: {
51
+ type: Boolean,
52
+ default: true,
53
+ },
54
+ },
55
+ methods: {
56
+ isSelected(index) {
57
+ return index === this.selected;
58
+ },
59
+ changeTab(_, index) {
60
+ this.$emit('update', this.tabs[index]);
61
+ },
62
+ next() {
63
+ this.selected = this.selected + 1;
64
+ this.$emit('update', this.tabs[this.selected]);
65
+ },
66
+ previous() {
67
+ this.selected = this.selected - 1;
68
+ this.$emit('update', this.tabs[this.selected]);
69
+ },
70
+ toIndex(index) {
71
+ this.selected = index;
72
+ this.$emit('update', this.tabs[index]);
73
+ },
74
+ updateTabRouting: (component, item, nextRoutePrefix) => {
75
+ component.currentTab = item.path;
76
+ const nextRoute = `${nextRoutePrefix}/${item.path}`;
77
+ const currentRoute = component.$router.history.current.path;
78
+ if (nextRoute !== currentRoute) component.$router.push(nextRoute);
79
+ },
80
+ },
81
+ created() {
82
+ this.selected = this.initialSelect;
83
+ },
84
+ components: {
85
+ VTabs,
86
+ VTab,
87
+ },
88
88
  };
89
89
  </script>
90
90
  <style scoped lang="scss">
91
91
  div.rounded-circle {
92
- background-color: var(--v-gray-lighten3);
93
- &.is-selected {
94
- background-color: var(--v-secondary-base);
95
- }
92
+ background-color: var(--v-gray-lighten3);
93
+ &.is-selected {
94
+ background-color: var(--v-secondary-base);
95
+ }
96
96
  }
97
- </style>
97
+ .v-tab--active.v-tab--disabled {
98
+ opacity: 1;
99
+ }
100
+ </style>