@farm-investimentos/front-mfe-components 2.4.0 → 2.4.4

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.0",
3
+ "version": "2.4.4",
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',
@@ -7,17 +7,18 @@
7
7
  v-bind:class="[
8
8
  item.sortable ? 'sortable' : '',
9
9
  sortClick[$index].clicked ? 'active' : '',
10
- item.sortable && sortClick[$index].descending === 'DESC' ? 'DESC' : 'ASC',
10
+ item.sortable ? (sortClick[$index].descending === 'DESC' ? 'DESC' : 'ASC') : '',
11
11
  ]"
12
12
  v-bind:style="{
13
- textAlign: item.align,
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)"
18
19
  @mouseout="changeHidden($index)"
19
20
  >
20
- <span class="header-text">
21
+ <span class="header-text" v-if="!isTHDataTableSelect(item)">
21
22
  {{ item.text }}
22
23
 
23
24
  <v-icon
@@ -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) {
@@ -111,8 +145,18 @@ export default Vue.extend({
111
145
  return false;
112
146
  },
113
147
  thWidth(item) {
148
+ if (this.isTHDataTableSelect(item)) {
149
+ return '64px';
150
+ }
114
151
  return item.width ? item.width + 'px' : 'auto';
115
152
  },
153
+ isTHDataTableSelect(item) {
154
+ return item.value === 'data-table-select';
155
+ },
156
+ selectAll(value) {
157
+ this.$emit('toggleSelectAll', value);
158
+ this.inputVal = value;
159
+ },
116
160
  },
117
161
  created() {
118
162
  for (let i = 0; i < this.headers.length; i += 1) {
@@ -0,0 +1,95 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import DataTableHeader from '../DataTableHeader';
3
+
4
+ describe('DataTableHeader component', () => {
5
+ let wrapper;
6
+ let component;
7
+
8
+ beforeEach(() => {
9
+ wrapper = shallowMount(DataTableHeader, {
10
+ propsData: {
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,
29
+ },
30
+ });
31
+ component = wrapper.vm;
32
+ });
33
+
34
+ test('Created hook', () => {
35
+ expect(wrapper).toBeDefined();
36
+ });
37
+
38
+ describe('mount component', () => {
39
+ it('renders correctly', () => {
40
+ expect(wrapper.element).toMatchSnapshot();
41
+ });
42
+ });
43
+
44
+ describe('Methods', () => {
45
+ it('Should check if item is data-table-select column', () => {
46
+ expect(component.isTHDataTableSelect({ value: 'data-table-select' })).toBeTruthy();
47
+ expect(component.isTHDataTableSelect({ value: 'anything else' })).toBeFalsy();
48
+ });
49
+
50
+ it('Should get th width', () => {
51
+ expect(component.thWidth({ value: 'data-table-select' })).toEqual('64px');
52
+ expect(component.thWidth({ width: 24 })).toEqual('24px');
53
+ expect(component.thWidth({})).toEqual('auto');
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
+ });
94
+ });
95
+ });
@@ -0,0 +1,20 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import DataTablePaginator from '../DataTablePaginator';
3
+
4
+ describe('DataTablePaginator component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(DataTablePaginator);
9
+ });
10
+
11
+ test('Created hook', () => {
12
+ expect(wrapper).toBeDefined();
13
+ });
14
+
15
+ describe('mount component', () => {
16
+ it('renders correctly', () => {
17
+ expect(wrapper.element).toMatchSnapshot();
18
+ });
19
+ });
20
+ });
@@ -0,0 +1,24 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import DatePicker from '../DatePicker';
3
+
4
+ describe('DatePicker component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(DatePicker, {
9
+ propsData: {
10
+ inputId: 'someid',
11
+ },
12
+ });
13
+ });
14
+
15
+ test('Created hook', () => {
16
+ expect(wrapper).toBeDefined();
17
+ });
18
+
19
+ describe('mount component', () => {
20
+ it('renders correctly', () => {
21
+ expect(wrapper.element).toMatchSnapshot();
22
+ });
23
+ });
24
+ });
@@ -0,0 +1,25 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import DefaultTextField from '../DefaultTextField';
3
+
4
+ describe('DefaultTextField component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(DefaultTextField, {
9
+ propsData: {
10
+ item: {},
11
+ value: false,
12
+ },
13
+ });
14
+ });
15
+
16
+ test('Created hook', () => {
17
+ expect(wrapper).toBeDefined();
18
+ });
19
+
20
+ describe('mount component', () => {
21
+ it('renders correctly', () => {
22
+ expect(wrapper.element).toMatchSnapshot();
23
+ });
24
+ });
25
+ });
@@ -0,0 +1,20 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import DialogFooter from '../DialogFooter';
3
+
4
+ describe('DialogFooter component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(DialogFooter);
9
+ });
10
+
11
+ test('Created hook', () => {
12
+ expect(wrapper).toBeDefined();
13
+ });
14
+
15
+ describe('mount component', () => {
16
+ it('renders correctly', () => {
17
+ expect(wrapper.element).toMatchSnapshot();
18
+ });
19
+ });
20
+ });
@@ -0,0 +1,24 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import DialogHeader from '../DialogHeader';
3
+
4
+ describe('DialogHeader component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(DialogHeader, {
9
+ propsData: {
10
+ title: ''
11
+ }
12
+ });
13
+ });
14
+
15
+ test('Created hook', () => {
16
+ expect(wrapper).toBeDefined();
17
+ });
18
+
19
+ describe('mount component', () => {
20
+ it('renders correctly', () => {
21
+ expect(wrapper.element).toMatchSnapshot();
22
+ });
23
+ });
24
+ });