@farm-investimentos/front-mfe-components 2.4.9 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "2.4.9",
3
+ "version": "2.5.0",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -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
@@ -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
+ });
@@ -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/';