@farm-investimentos/front-mfe-components 2.4.7 → 3.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.
Files changed (26) hide show
  1. package/dist/front-mfe-components.common.js +250 -132
  2. package/dist/front-mfe-components.common.js.map +1 -1
  3. package/dist/front-mfe-components.css +1 -1
  4. package/dist/front-mfe-components.umd.js +250 -132
  5. package/dist/front-mfe-components.umd.js.map +1 -1
  6. package/dist/front-mfe-components.umd.min.js +1 -1
  7. package/dist/front-mfe-components.umd.min.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/components/Buttons/ImportButton/__tests__/ImportButton.spec.js +7 -0
  10. package/src/components/Buttons/RemoveButton/RemoveButton.vue +1 -1
  11. package/src/components/Buttons/RemoveButton/__tests__/RemoveButton.spec.js +7 -0
  12. package/src/components/Buttons/ToggleButton/__tests__/ToggleButton.spec.js +7 -0
  13. package/src/components/CardContext/CardContext.scss +1 -1
  14. package/src/components/CardContext/CardContext.vue +8 -14
  15. package/src/components/CardContext/__tests__/CardContext.spec.js +37 -0
  16. package/src/components/DataTableHeader/DataTableHeader.vue +7 -1
  17. package/src/components/RangeDatePicker/RangeDatePicker.stories.js +6 -0
  18. package/src/components/RangeDatePicker/RangeDatePicker.vue +16 -0
  19. package/src/components/RangeDatePicker/__tests__/RangeDatePicker.spec.js +37 -0
  20. package/src/components/ResetTableRowSelection/ResetTableRowSelection.stories.js +18 -0
  21. package/src/components/ResetTableRowSelection/ResetTableRowSelection.vue +40 -0
  22. package/src/components/ResetTableRowSelection/__tests__/ResetTableRowSelection.spec.js +33 -0
  23. package/src/components/ResetTableRowSelection/index.js +4 -0
  24. package/src/components/TableContextMenu/TableContextMenu.vue +14 -4
  25. package/src/components/TableContextMenu/__tests__/TableContextMenu.spec.js +45 -0
  26. package/src/main.js +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "2.4.7",
3
+ "version": "3.0.0",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -13,4 +13,11 @@ describe('ImportButton component', () => {
13
13
  test('Created hook', () => {
14
14
  expect(wrapper).toBeDefined();
15
15
  });
16
+
17
+ describe('Methods', () => {
18
+ it('Should emit event', () => {
19
+ component.onClick();
20
+ expect(wrapper.emitted().onClick).toBeDefined();
21
+ });
22
+ });
16
23
  });
@@ -23,7 +23,7 @@ export default Vue.extend({
23
23
  */
24
24
  label: {
25
25
  type: String,
26
- default: 'Importar',
26
+ default: 'Remover',
27
27
  },
28
28
  /**
29
29
  * Desabilita o botão
@@ -13,4 +13,11 @@ describe('RemoveButton component', () => {
13
13
  test('Created hook', () => {
14
14
  expect(wrapper).toBeDefined();
15
15
  });
16
+
17
+ describe('Methods', () => {
18
+ it('Should emit event', () => {
19
+ component.onClick();
20
+ expect(wrapper.emitted().onClick).toBeDefined();
21
+ });
22
+ });
16
23
  });
@@ -11,4 +11,11 @@ describe('ToggleButton component', () => {
11
11
  test('Created hook', () => {
12
12
  expect(wrapper).toBeDefined();
13
13
  });
14
+
15
+ describe('Methods', () => {
16
+ it('Should handle click', () => {
17
+ wrapper.vm.onClick();
18
+ expect(wrapper.vm.open).toBeTruthy();
19
+ });
20
+ });
14
21
  });
@@ -42,7 +42,7 @@
42
42
  padding-top: 1rem;
43
43
  }
44
44
 
45
- .card-context-loding-or-error {
45
+ .card-context-loading-or-error {
46
46
  width: 100%;
47
47
  display: flex;
48
48
  align-items: center;
@@ -11,10 +11,10 @@
11
11
  <div class="card-context-body" v-if="isSuccess">
12
12
  <slot></slot>
13
13
  </div>
14
- <div class="card-context-loding-or-error" v-if="isLoading">
14
+ <div class="card-context-loading-or-error" v-if="isLoading">
15
15
  <Loader :size="isLargeLoading" />
16
16
  </div>
17
- <div class="card-context-loding-or-error" v-if="isError">
17
+ <div class="card-context-loading-or-error" v-if="isError">
18
18
  <AlertReload :label="errorLabel" @onClick="$emit('onLoad')" />
19
19
  </div>
20
20
  </div>
@@ -79,6 +79,9 @@ export default Vue.extend({
79
79
  type: String,
80
80
  default: 'Ocorreu um erro',
81
81
  },
82
+ /**
83
+ * Is full
84
+ */
82
85
  full: {
83
86
  type: Boolean,
84
87
  default: false,
@@ -86,25 +89,16 @@ export default Vue.extend({
86
89
  },
87
90
  computed: {
88
91
  isBold() {
89
- if (this.bold) {
90
- return 'card-context-title bold';
91
- }
92
- return 'card-context-title';
92
+ return this.bold ? 'card-context-title bold' : 'card-context-title';
93
93
  },
94
94
  isHeightFull() {
95
- if (this.full) {
96
- return 'card-context height-full';
97
- }
98
- return 'card-context';
95
+ return this.full ? 'card-context height-full' : 'card-context';
99
96
  },
100
97
  isSuccess() {
101
98
  return !this.isLoading && !this.isError;
102
99
  },
103
100
  isLargeLoading() {
104
- if (this.largeLoading) {
105
- return 'normal';
106
- }
107
- return 'small';
101
+ return this.largeLoading ? 'normal' : 'small';
108
102
  },
109
103
  },
110
104
  });
@@ -3,9 +3,11 @@ import CardContext from '../CardContext';
3
3
 
4
4
  describe('CardContext component', () => {
5
5
  let wrapper;
6
+ let component;
6
7
 
7
8
  beforeEach(() => {
8
9
  wrapper = shallowMount(CardContext);
10
+ component = wrapper.vm;
9
11
  });
10
12
 
11
13
  test('Created hook', () => {
@@ -17,4 +19,39 @@ describe('CardContext component', () => {
17
19
  expect(wrapper.element).toMatchSnapshot();
18
20
  });
19
21
  });
22
+
23
+ describe('Computed properties', () => {
24
+ it('Should compute isBold for false', () => {
25
+ expect(component.isBold).toEqual('card-context-title');
26
+ });
27
+
28
+ it('Should compute isBold for true', async () => {
29
+ await wrapper.setProps({
30
+ bold: true,
31
+ });
32
+ expect(component.isBold).toEqual('card-context-title bold');
33
+ });
34
+
35
+ it('Should compute isHeightFull for false', () => {
36
+ expect(component.isHeightFull).toEqual('card-context');
37
+ });
38
+
39
+ it('Should compute isHeightFull for true', async () => {
40
+ await wrapper.setProps({
41
+ full: true,
42
+ });
43
+ expect(component.isHeightFull).toEqual('card-context height-full');
44
+ });
45
+
46
+ it('Should compute isLargeLoading for false', () => {
47
+ expect(component.isLargeLoading).toEqual('small');
48
+ });
49
+
50
+ it('Should compute isLargeLoading for true', async () => {
51
+ await wrapper.setProps({
52
+ largeLoading: true,
53
+ });
54
+ expect(component.isLargeLoading).toEqual('normal');
55
+ });
56
+ });
20
57
  });
@@ -32,7 +32,7 @@
32
32
  </v-icon>
33
33
  </span>
34
34
 
35
- <span v-if="isTHDataTableSelect(item)">
35
+ <span v-if="isTHDataTableSelect(item) && showCheckbox">
36
36
  <v-simple-checkbox
37
37
  :indeterminate="headerProps.someItems && !headerProps.everyItem"
38
38
  v-model="inputVal"
@@ -96,6 +96,12 @@ export default Vue.extend({
96
96
  headerProps: {
97
97
  type: Object,
98
98
  },
99
+ /**
100
+ * Hide/show checkbox
101
+ */
102
+ showCheckbox: {
103
+ default: true,
104
+ },
99
105
  },
100
106
  computed: {
101
107
  inputVal: {
@@ -15,5 +15,11 @@ export const Secondary = () => ({
15
15
  template: `<RangeDatePicker inputId="input-custom-id" :value="['2021-08-01', '2021-08-05']" />`,
16
16
  });
17
17
 
18
+ export const MinMax = () => ({
19
+ components: { RangeDatePicker },
20
+ template: `<RangeDatePicker inputId="input-custom-id" min="2022-01-17" max="2022-02-15" />`,
21
+ });
22
+
18
23
  Primary.storyName = 'Básico';
19
24
  Secondary.storyName = 'Data inicial';
25
+ MinMax.storyName = 'Data Mínima e Máxima';
@@ -27,6 +27,8 @@
27
27
  no-title
28
28
  scrollable
29
29
  range
30
+ :max="max"
31
+ :min="min"
30
32
  color="secondary"
31
33
  locale="pt-br"
32
34
  >
@@ -73,6 +75,20 @@ export default {
73
75
  return [];
74
76
  },
75
77
  },
78
+ /**
79
+ * Variável usada para definir a data máxima (yyyy-mm-dd)
80
+ */
81
+ max: {
82
+ type: String,
83
+ default: null,
84
+ },
85
+ /**
86
+ * Variável usada para definir a data minima (yyyy-mm-dd)
87
+ */
88
+ min: {
89
+ type: String,
90
+ default: null,
91
+ },
76
92
  },
77
93
  data() {
78
94
  const s = this.formatDateRange(this.value);
@@ -0,0 +1,37 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import RangeDatePicker from '../RangeDatePicker';
3
+
4
+ describe('RangeDatePicker component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(RangeDatePicker, {
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
+
25
+ describe('computed values', () => {
26
+ it('min max correctly', async () => {
27
+ await wrapper.setProps({
28
+ inputId: 'someid',
29
+ min: '2022-01-17',
30
+ max: '2022-01-31',
31
+ });
32
+ expect(wrapper.vm.inputId).toBe('someid');
33
+ expect(wrapper.vm.min).toBe('2022-01-17');
34
+ expect(wrapper.vm.max).toBe('2022-01-31');
35
+ });
36
+ });
37
+ });
@@ -0,0 +1,18 @@
1
+ import ResetTableRowSelection from './ResetTableRowSelection';
2
+
3
+ export default {
4
+ title: 'Example/ResetTableRowSelection',
5
+ component: ResetTableRowSelection,
6
+ };
7
+
8
+ export const Primary = () => ({
9
+ components: { ResetTableRowSelection },
10
+ data() {
11
+ return {
12
+ items: [1, 2, 3],
13
+ };
14
+ },
15
+ template: `<ResetTableRowSelection v-model="items" />`,
16
+ });
17
+
18
+ Primary.storyName = 'Básico';
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <div class="ml-6 mr-3 d-flex align-center">
3
+ Total de linhas selecionadas: {{ length }}
4
+ <v-btn color="error" @click="reset" small dense class="ml-3" v-if="length > 0">
5
+ <v-icon small> mdi-trash-can </v-icon>
6
+ Desmarcar
7
+ </v-btn>
8
+ </div>
9
+ </template>
10
+ <script>
11
+ import Vue from 'vue';
12
+ import VBtn from 'vuetify/lib/components/VBtn';
13
+ import VIcon from 'vuetify/lib/components/VIcon';
14
+ export default Vue.extend({
15
+ // name: 'farm-tablerowselection',
16
+ components: {
17
+ VBtn,
18
+ VIcon,
19
+ },
20
+ props: {
21
+ /**
22
+ * Current items length selected
23
+ */
24
+ length: {
25
+ default: 0,
26
+ type: Number,
27
+ },
28
+ },
29
+ methods: {
30
+ reset() {
31
+ this.$emit('onReset');
32
+ },
33
+ },
34
+ });
35
+ </script>
36
+ <style lang="scss" scoped>
37
+ div {
38
+ height: 2rem;
39
+ }
40
+ </style>
@@ -0,0 +1,33 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import ResetTableRowSelection from '../ResetTableRowSelection';
3
+
4
+ describe('ResetTableRowSelection component', () => {
5
+ let wrapper;
6
+ let component;
7
+
8
+ beforeEach(() => {
9
+ wrapper = shallowMount(ResetTableRowSelection, {
10
+ propsData: {
11
+ length: 2,
12
+ },
13
+ });
14
+ component = wrapper.vm;
15
+ });
16
+
17
+ test('Created hook', () => {
18
+ expect(wrapper).toBeDefined();
19
+ });
20
+
21
+ describe('mount component', () => {
22
+ it('renders correctly', () => {
23
+ expect(wrapper.element).toMatchSnapshot();
24
+ });
25
+ });
26
+
27
+ describe('methods', () => {
28
+ it('Should reset', () => {
29
+ component.reset();
30
+ expect(wrapper.emitted().onReset).toBeDefined();
31
+ });
32
+ });
33
+ });
@@ -0,0 +1,4 @@
1
+ import ResetTableRowSelection from './ResetTableRowSelection';
2
+
3
+ export { ResetTableRowSelection };
4
+ export default ResetTableRowSelection;
@@ -2,7 +2,7 @@
2
2
  <v-menu>
3
3
  <template v-slot:activator="{ on, attrs }">
4
4
  <v-btn icon v-bind="attrs" v-on="on" title="Abrir opções">
5
- <v-icon class="ml-3">mdi-dots-horizontal</v-icon>
5
+ <v-icon>mdi-dots-horizontal</v-icon>
6
6
  </v-btn>
7
7
  </template>
8
8
 
@@ -11,7 +11,7 @@
11
11
  v-for="item in items"
12
12
  :key="item.label"
13
13
  :title="item.label"
14
- @click="$emit(item.handler)"
14
+ @click="onClick(item.handler)"
15
15
  >
16
16
  <v-list-item-content>
17
17
  <v-list-item-title>
@@ -29,13 +29,16 @@
29
29
  </v-menu>
30
30
  </template>
31
31
  <script>
32
+ import Vue from 'vue';
32
33
  import { VMenu } from 'vuetify/lib/components/VMenu';
33
34
  import { VBtn } from 'vuetify/lib/components/VBtn';
34
35
  import { VIcon } from 'vuetify/lib/components/VIcon';
35
36
  import { VList } from 'vuetify/lib/components/VList';
36
37
  import VListItem from 'vuetify/lib/components/VList/VListItem';
37
38
  import { VListItemContent, VListItemTitle } from 'vuetify/lib';
38
- export default {
39
+
40
+ export default Vue.extend({
41
+ name: 'farm-context-menu',
39
42
  components: {
40
43
  VBtn,
41
44
  VIcon,
@@ -51,5 +54,12 @@ export default {
51
54
  required: true,
52
55
  },
53
56
  },
54
- };
57
+ methods: {
58
+ onClick(handler) {
59
+ if (handler !== undefined) {
60
+ this.$emit(handler);
61
+ }
62
+ },
63
+ },
64
+ });
55
65
  </script>
@@ -0,0 +1,45 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import TableContextMenu from '../TableContextMenu';
3
+ const items = [{ label: 'Remover', icon: { color: 'error', type: 'delete' }, handler: 'test' }];
4
+
5
+ describe('TableContextMenu component', () => {
6
+ let wrapper;
7
+
8
+ beforeEach(() => {
9
+ wrapper = shallowMount(TableContextMenu, {
10
+ propsData: {
11
+ items,
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
+
26
+ describe('computed values', () => {
27
+ it('should items to be created correctly', async () => {
28
+ expect(wrapper.vm.items).toBeInstanceOf(Array);
29
+ expect(wrapper.vm.items).toEqual(items);
30
+ });
31
+ });
32
+
33
+ describe('emitted', () => {
34
+ it('should emit event', async () => {
35
+ wrapper.vm.onClick('test');
36
+ await wrapper.vm.$nextTick();
37
+ expect(wrapper.emitted().test).toBeTruthy();
38
+ });
39
+ it('should not emit click event without value', async () => {
40
+ wrapper.vm.onClick();
41
+ await wrapper.vm.$nextTick();
42
+ expect(wrapper.emitted()).toEqual({});
43
+ });
44
+ });
45
+ });
package/src/main.js CHANGED
@@ -53,3 +53,4 @@ export * from './components/Buttons/ToggleButton/';
53
53
  export * from './components/Buttons/RemoveButton/';
54
54
  export * from './components/Logos/ProductLogo/';
55
55
  export * from './components/Logos/OriginatorLogo/';
56
+ export * from './components/ResetTableRowSelection/';