@farm-investimentos/front-mfe-components 2.4.6 → 2.5.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 +236 -98
- 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 +236 -98
- 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/Buttons/RemoveButton/RemoveButton.vue +1 -1
- package/src/components/DataTableHeader/DataTableHeader.vue +11 -3
- package/src/components/RangeDatePicker/RangeDatePicker.stories.js +6 -0
- package/src/components/RangeDatePicker/RangeDatePicker.vue +16 -0
- package/src/components/RangeDatePicker/__tests__/RangeDatePicker.spec.js +37 -0
- package/src/components/ResetTableRowSelection/ResetTableRowSelection.stories.js +18 -0
- package/src/components/ResetTableRowSelection/ResetTableRowSelection.vue +51 -0
- package/src/components/ResetTableRowSelection/__tests__/ResetTableRowSelection.spec.js +34 -0
- package/src/components/ResetTableRowSelection/index.js +4 -0
- package/src/components/TableContextMenu/TableContextMenu.vue +14 -4
- package/src/components/TableContextMenu/__tests__/TableContextMenu.spec.js +45 -0
- package/src/main.js +1 -0
package/package.json
CHANGED
|
@@ -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"
|
|
@@ -87,18 +87,26 @@ export default Vue.extend({
|
|
|
87
87
|
/**
|
|
88
88
|
* v-model for data-table-select
|
|
89
89
|
*/
|
|
90
|
-
value: {
|
|
90
|
+
value: {
|
|
91
|
+
default: false,
|
|
92
|
+
},
|
|
91
93
|
/**
|
|
92
94
|
* Original header props
|
|
93
95
|
*/
|
|
94
96
|
headerProps: {
|
|
95
97
|
type: Object,
|
|
96
98
|
},
|
|
99
|
+
/**
|
|
100
|
+
* Hide/show checkbox
|
|
101
|
+
*/
|
|
102
|
+
showCheckbox: {
|
|
103
|
+
default: true,
|
|
104
|
+
},
|
|
97
105
|
},
|
|
98
106
|
computed: {
|
|
99
107
|
inputVal: {
|
|
100
108
|
get() {
|
|
101
|
-
return this.value
|
|
109
|
+
return this.value;
|
|
102
110
|
},
|
|
103
111
|
set(val) {
|
|
104
112
|
this.$emit('input', val);
|
|
@@ -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,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ml-6 mr-3 d-flex align-center">
|
|
3
|
+
Total de linhas selecionadas: {{ inputVal.length }}
|
|
4
|
+
<v-btn color="error" @click="reset" small dense class="ml-3" v-if="inputVal.length > 0">
|
|
5
|
+
<v-icon small> mdi-trash-can </v-icon>
|
|
6
|
+
Limpar
|
|
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
|
+
* Variável usada como v-model
|
|
23
|
+
* contém a lista selecionada
|
|
24
|
+
*/
|
|
25
|
+
value: {
|
|
26
|
+
required: true,
|
|
27
|
+
type: Array,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
computed: {
|
|
31
|
+
inputVal: {
|
|
32
|
+
get() {
|
|
33
|
+
return this.value;
|
|
34
|
+
},
|
|
35
|
+
set(val) {
|
|
36
|
+
this.$emit('input', val);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
methods: {
|
|
41
|
+
reset() {
|
|
42
|
+
this.inputVal = [];
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
<style lang="scss" scoped>
|
|
48
|
+
div {
|
|
49
|
+
height: 2rem;
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import ResetTableRowSelection from '../ResetTableRowSelection';
|
|
3
|
+
const items = [1, 2, 3];
|
|
4
|
+
|
|
5
|
+
describe('ResetTableRowSelection component', () => {
|
|
6
|
+
let wrapper;
|
|
7
|
+
let component;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
wrapper = shallowMount(ResetTableRowSelection, {
|
|
11
|
+
propsData: {
|
|
12
|
+
value: items,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
component = wrapper.vm;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('Created hook', () => {
|
|
19
|
+
expect(wrapper).toBeDefined();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('mount component', () => {
|
|
23
|
+
it('renders correctly', () => {
|
|
24
|
+
expect(wrapper.element).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('methods', () => {
|
|
29
|
+
it('Should reset', () => {
|
|
30
|
+
component.reset();
|
|
31
|
+
expect(wrapper.emitted().input).toBeDefined();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -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
|
|
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="
|
|
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
|
-
|
|
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