@farm-investimentos/front-mfe-components 9.2.0 → 9.2.3
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 +243 -210
- 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 +243 -210
- 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/Chip/Chip.scss +6 -0
- package/src/components/Chip/Chip.stories.js +9 -2
- package/src/components/Chip/Chip.stories.scss +1 -1
- package/src/components/Chip/Chip.vue +11 -4
- package/src/components/DataTablePaginator/DataTablePaginator.scss +5 -1
- package/src/components/DataTablePaginator/DataTablePaginator.stories.js +2 -2
- package/src/components/DataTablePaginator/DataTablePaginator.vue +16 -6
- package/src/components/Icon/Icon.stories.js +19 -9
- package/src/components/Logger/Logger.stories.js +55 -0
- package/src/components/Logger/LoggerItem/ILoggerItem.ts +1 -0
- package/src/components/Logger/LoggerItem/LoggerItem.stories.js +40 -0
- package/src/components/Logger/LoggerItem/LoggerItem.vue +27 -2
- package/src/components/Logger/LoggerItem/__tests__/LoggerItem.spec.js +40 -0
- package/src/components/MultipleFilePicker/MultipleFilePicker.stories.js +35 -4
- package/src/components/MultipleFilePicker/MultipleFilePicker.vue +5 -14
- package/src/examples/Modal.stories.js +0 -1
- package/src/examples/Table.stories.js +2 -0
package/package.json
CHANGED
|
@@ -10,8 +10,15 @@ export default {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const Primary = () => ({
|
|
13
|
-
template: `<div>
|
|
14
|
-
<farm-chip color="info">Chip</farm-chip>
|
|
13
|
+
template: `<div class="chips-container">
|
|
14
|
+
<farm-chip color="info">Chip (100% width)</farm-chip>
|
|
15
|
+
</div>`,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const Dense = () => ({
|
|
19
|
+
template: `<div class="chips-container">
|
|
20
|
+
<farm-chip color="info" :dense="true">prop</farm-chip>
|
|
21
|
+
<farm-chip color="secondary" dense>attribute</farm-chip>
|
|
15
22
|
</div>`,
|
|
16
23
|
});
|
|
17
24
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<span :class="{ 'farm-chip': true }">
|
|
3
|
-
<farm-typography tag="span" size="sm">
|
|
4
|
-
<slot></slot>
|
|
5
|
-
</farm-typography>
|
|
2
|
+
<span :class="{ 'farm-chip': true, 'farm-chip--dense': dense }">
|
|
3
|
+
<farm-typography tag="span" size="sm"> <slot></slot> </farm-typography>
|
|
6
4
|
</span>
|
|
7
5
|
</template>
|
|
8
6
|
<script lang="ts">
|
|
@@ -11,6 +9,15 @@ import Vue from 'vue';
|
|
|
11
9
|
export default Vue.extend({
|
|
12
10
|
name: 'farm-chip',
|
|
13
11
|
inheritAttrs: true,
|
|
12
|
+
props: {
|
|
13
|
+
/**
|
|
14
|
+
* Is dense (not 100% width)?
|
|
15
|
+
*/
|
|
16
|
+
dense: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
14
21
|
});
|
|
15
22
|
</script>
|
|
16
23
|
<style lang="scss" scoped>
|
|
@@ -55,9 +55,13 @@ ul.farm-paginator {
|
|
|
55
55
|
display: flex;
|
|
56
56
|
flex-direction: row;
|
|
57
57
|
justify-content: space-between;
|
|
58
|
-
margin:
|
|
58
|
+
margin: 0;
|
|
59
59
|
|
|
60
60
|
&.hidden-perpageoptions {
|
|
61
61
|
justify-content: flex-end;
|
|
62
62
|
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.farm-paginator--gutter {
|
|
66
|
+
margin: 1rem 1.5rem 0;
|
|
63
67
|
}
|
|
@@ -25,13 +25,13 @@ export const Primary = () => ({
|
|
|
25
25
|
components: { DataTablePaginator },
|
|
26
26
|
data() {
|
|
27
27
|
return {
|
|
28
|
-
totalPages:
|
|
28
|
+
totalPages: 8
|
|
29
29
|
};
|
|
30
30
|
},
|
|
31
31
|
template: '<DataTablePaginator :totalPages="totalPages" :page="1" />',
|
|
32
32
|
mounted() {
|
|
33
33
|
setTimeout(() => {
|
|
34
|
-
this.totalPages =
|
|
34
|
+
this.totalPages = 0;
|
|
35
35
|
}, 1000);
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<section
|
|
3
|
-
class="
|
|
4
|
-
|
|
3
|
+
:class="{
|
|
4
|
+
'v-data-table-custom-footer': true,
|
|
5
|
+
'hidden-perpageoptions': hidePerPageOptions,
|
|
6
|
+
'farm-paginator--gutter': hasGutter,
|
|
7
|
+
}"
|
|
5
8
|
>
|
|
6
9
|
<div v-if="!hidePerPageOptions">
|
|
7
10
|
<v-select
|
|
@@ -13,9 +16,9 @@
|
|
|
13
16
|
></v-select>
|
|
14
17
|
</div>
|
|
15
18
|
|
|
16
|
-
<ul :class="{ 'farm-paginator': true, 'farm-paginator--disabled': disabled }">
|
|
19
|
+
<ul :class="{ 'farm-paginator': true, 'farm-paginator--disabled': disabled || totalPages == null }">
|
|
17
20
|
<li>
|
|
18
|
-
<button :disabled="currentPage === 1 || disabled" @click="previousPage">
|
|
21
|
+
<button :disabled="currentPage === 1 || disabled || totalPages == null" @click="previousPage">
|
|
19
22
|
<farm-icon color="gray" size="sm">chevron-left</farm-icon>
|
|
20
23
|
</button>
|
|
21
24
|
</li>
|
|
@@ -34,7 +37,7 @@
|
|
|
34
37
|
</li>
|
|
35
38
|
|
|
36
39
|
<li>
|
|
37
|
-
<button :disabled="currentPage === totalPages || disabled"
|
|
40
|
+
<button :disabled="currentPage === totalPages || disabled || totalPages == null || totalPages === 0" @click="nextPage">
|
|
38
41
|
<farm-icon color="gray" size="sm">chevron-right</farm-icon>
|
|
39
42
|
</button>
|
|
40
43
|
</li>
|
|
@@ -67,7 +70,10 @@ export default Vue.extend({
|
|
|
67
70
|
/**
|
|
68
71
|
* Total de páginas
|
|
69
72
|
*/
|
|
70
|
-
totalPages:
|
|
73
|
+
totalPages: {
|
|
74
|
+
type: Number,
|
|
75
|
+
default: null,
|
|
76
|
+
},
|
|
71
77
|
/**
|
|
72
78
|
* Desabilita controles
|
|
73
79
|
*/
|
|
@@ -89,6 +95,10 @@ export default Vue.extend({
|
|
|
89
95
|
type: Number,
|
|
90
96
|
default: 10,
|
|
91
97
|
},
|
|
98
|
+
hasGutter: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: true,
|
|
101
|
+
},
|
|
92
102
|
},
|
|
93
103
|
methods: {
|
|
94
104
|
range(from: number, to: number) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { withDesign } from 'storybook-addon-designs';
|
|
2
|
-
import Icon from './Icon';
|
|
3
2
|
import colors from '../../configurations/colors';
|
|
4
3
|
import sizes from '../../configurations/sizes';
|
|
5
4
|
import iconsList from './icons_list';
|
|
@@ -84,14 +83,25 @@ export const ListOfIcons = () => ({
|
|
|
84
83
|
data() {
|
|
85
84
|
return {
|
|
86
85
|
iconsList: [...iconsList],
|
|
86
|
+
filterKey: '',
|
|
87
87
|
};
|
|
88
88
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
watch: {
|
|
90
|
+
filterKey(newValue) {
|
|
91
|
+
this.iconsList = [...iconsList].filter(
|
|
92
|
+
item => item.toLowerCase().indexOf(newValue.toLowerCase()) >= 0
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
template: `<div>
|
|
97
|
+
<farm-textfield v-model="filterKey" style="margin: 0 auto; width: 240px;" />
|
|
98
|
+
<div class="icons-container__list">
|
|
99
|
+
<div v-for="icon of iconsList" :key="'icon_' + icon">
|
|
100
|
+
<farm-icon>
|
|
101
|
+
{{ icon }}
|
|
102
|
+
</farm-icon>
|
|
103
|
+
<span>{{ icon }}</span>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>`,
|
|
97
107
|
});
|
|
@@ -59,3 +59,58 @@ export const Primary = () => ({
|
|
|
59
59
|
},
|
|
60
60
|
template: `<farm-logger :items="items" />`,
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
export const Details = () => ({
|
|
64
|
+
data() {
|
|
65
|
+
return {
|
|
66
|
+
items: [
|
|
67
|
+
{
|
|
68
|
+
message: 'Recusado entre as pré elegíveis',
|
|
69
|
+
userName: 'Cleyton Rasta',
|
|
70
|
+
formattedDate: '13/06/2022 20:40',
|
|
71
|
+
status: 'error',
|
|
72
|
+
details() {
|
|
73
|
+
alert('Ver Detalhes');
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
message: 'Aprovado entre as pré elegíveis',
|
|
78
|
+
userName: 'Cleyton Rasta',
|
|
79
|
+
formattedDate: '13/06/2022 20:40',
|
|
80
|
+
status: 'success',
|
|
81
|
+
details() {
|
|
82
|
+
alert('Ver Detalhes');
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
message: 'Aprovado entre as pré elegíveis',
|
|
87
|
+
userName: 'Cleyton Rasta',
|
|
88
|
+
formattedDate: '13/06/2022 20:40',
|
|
89
|
+
status: 'success',
|
|
90
|
+
details() {
|
|
91
|
+
alert('Ver Detalhes');
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
message: 'Recusado entre as pré elegíveis',
|
|
96
|
+
userName: 'Cleyton Rasta',
|
|
97
|
+
formattedDate: '13/06/2022 20:40',
|
|
98
|
+
status: 'error',
|
|
99
|
+
details() {
|
|
100
|
+
alert('Ver Detalhes');
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
message: 'Recusado entre as pré elegíveis',
|
|
105
|
+
userName: 'Cleyton Rasta',
|
|
106
|
+
formattedDate: '13/06/2022 20:40',
|
|
107
|
+
status: 'error',
|
|
108
|
+
details() {
|
|
109
|
+
alert('Ver Detalhes');
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
template: `<farm-logger :items="items" />`,
|
|
116
|
+
});
|
|
@@ -74,3 +74,43 @@ export const CustomIcon = () => ({
|
|
|
74
74
|
},
|
|
75
75
|
template: `<farm-logger-item :item="item" />`,
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
export const Details = () => ({
|
|
79
|
+
data() {
|
|
80
|
+
return {
|
|
81
|
+
items: [
|
|
82
|
+
{
|
|
83
|
+
icon: 'book',
|
|
84
|
+
message: 'Aprovado entre as pré elegíveis',
|
|
85
|
+
userName: 'Cleyton Rasta',
|
|
86
|
+
formattedDate: '13/06/2022 20:40',
|
|
87
|
+
status: 'success',
|
|
88
|
+
details() {
|
|
89
|
+
alert('Ver Detalhes');
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
icon: 'book',
|
|
94
|
+
message: 'Reprovado entre as pré elegíveis',
|
|
95
|
+
userName: 'Cleyton Rasta',
|
|
96
|
+
formattedDate: '13/06/2022 20:40',
|
|
97
|
+
status: 'error',
|
|
98
|
+
details() {
|
|
99
|
+
alert('Ver Detalhes');
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
icon: 'book',
|
|
104
|
+
message: 'Reprovado entre as pré elegíveis',
|
|
105
|
+
userName: 'Cleyton Rasta',
|
|
106
|
+
formattedDate: '13/06/2022 20:40',
|
|
107
|
+
status: 'primary',
|
|
108
|
+
details() {
|
|
109
|
+
alert('Ver Detalhes');
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
template: `<div><farm-logger-item v-for="item of items" :key="item.status" :item="item" /></div>`,
|
|
116
|
+
});
|
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
{{ item.userName }}
|
|
20
20
|
</span>
|
|
21
21
|
</div>
|
|
22
|
+
<farm-btn
|
|
23
|
+
v-if="hasDetails"
|
|
24
|
+
:color="buttonColor"
|
|
25
|
+
plain
|
|
26
|
+
title="Ver Detalhes"
|
|
27
|
+
@click="callDetails"
|
|
28
|
+
>Ver Detalhes</farm-btn
|
|
29
|
+
>
|
|
22
30
|
</section>
|
|
23
31
|
</template>
|
|
24
32
|
<script lang="ts">
|
|
@@ -33,8 +41,13 @@ export default Vue.extend({
|
|
|
33
41
|
*/
|
|
34
42
|
item: { required: true, type: Object as PropType<ILoggerItem> },
|
|
35
43
|
},
|
|
44
|
+
methods: {
|
|
45
|
+
callDetails(): void {
|
|
46
|
+
this.item.details();
|
|
47
|
+
},
|
|
48
|
+
},
|
|
36
49
|
computed: {
|
|
37
|
-
mdiIconName() {
|
|
50
|
+
mdiIconName(): string {
|
|
38
51
|
if (this.item.icon) {
|
|
39
52
|
return `${this.item.icon}`;
|
|
40
53
|
}
|
|
@@ -43,9 +56,21 @@ export default Vue.extend({
|
|
|
43
56
|
}
|
|
44
57
|
return `${this.item.status === 'success' ? 'check' : 'close'}`;
|
|
45
58
|
},
|
|
59
|
+
buttonColor(): string {
|
|
60
|
+
if (this.item.status === 'success') {
|
|
61
|
+
return 'secondary';
|
|
62
|
+
} else if (this.item.status === 'error') {
|
|
63
|
+
return 'error';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return 'primary';
|
|
67
|
+
},
|
|
68
|
+
hasDetails(): boolean {
|
|
69
|
+
return !!this.item.details;
|
|
70
|
+
},
|
|
46
71
|
},
|
|
47
72
|
});
|
|
48
73
|
</script>
|
|
49
74
|
<style lang="scss" scoped>
|
|
50
|
-
@import './LoggerItem.scss'
|
|
75
|
+
@import './LoggerItem.scss';
|
|
51
76
|
</style>
|
|
@@ -49,5 +49,45 @@ describe('LoggerItem component', () => {
|
|
|
49
49
|
expect(component.mdiIconName).toEqual('close');
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
it('Should return success button color', async () => {
|
|
53
|
+
await wrapper.setProps({
|
|
54
|
+
item: {
|
|
55
|
+
status: 'success',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
expect(component.buttonColor).toEqual('secondary');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('Should return error button color', async () => {
|
|
62
|
+
await wrapper.setProps({
|
|
63
|
+
item: {
|
|
64
|
+
status: 'error',
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
expect(component.buttonColor).toEqual('error');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('Should return default button color', async () => {
|
|
71
|
+
await wrapper.setProps({
|
|
72
|
+
item: {
|
|
73
|
+
status: 'primary',
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
expect(component.buttonColor).toEqual('primary');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('Should not have a detail button', async () => {
|
|
80
|
+
await wrapper.setProps({
|
|
81
|
+
item: {
|
|
82
|
+
details: () => {},
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect(component.hasDetails).toBeTruthy();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('Should not have a detail button', () => {
|
|
90
|
+
expect(component.hasDetails).toBeFalsy();
|
|
91
|
+
});
|
|
52
92
|
});
|
|
53
93
|
});
|
|
@@ -3,21 +3,52 @@ import MultipleFilePicker from './MultipleFilePicker.vue';
|
|
|
3
3
|
export default {
|
|
4
4
|
title: 'Form/MultipleFilePicker',
|
|
5
5
|
component: MultipleFilePicker,
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: `Multiple File Picker<br />
|
|
10
|
+
selector: <em>farm-multiple-filepicker</em>
|
|
11
|
+
`,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
viewMode: 'docs',
|
|
15
|
+
},
|
|
6
16
|
};
|
|
7
17
|
|
|
8
18
|
export const Primary = () => ({
|
|
9
|
-
template: '<
|
|
19
|
+
template: '<farm-multiple-filepicker />',
|
|
10
20
|
});
|
|
11
21
|
|
|
12
22
|
export const MaxFileSize = () => ({
|
|
13
|
-
template: '<
|
|
23
|
+
template: '<farm-multiple-filepicker :maxFileSize="5" />',
|
|
14
24
|
});
|
|
15
25
|
|
|
16
26
|
export const MaxFilesNumber = () => ({
|
|
17
|
-
template: '<
|
|
27
|
+
template: '<farm-multiple-filepicker :maxFileSize="5" :maxFilesNumber="1" />',
|
|
18
28
|
});
|
|
19
29
|
|
|
20
30
|
export const Download = () => ({
|
|
21
31
|
template:
|
|
22
|
-
'<
|
|
32
|
+
'<farm-multiple-filepicker :maxFileSize="5" :downloadFiles="[{ id: 1, name: `Arquivo 1`, size: 10000 }, { id: 2, name: `Arquivo 2`, size: 15000 }]" />',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const InvalidFiles = () => ({
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
fileTypes:
|
|
39
|
+
'.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel',
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
onInvalidFiles(files) {
|
|
44
|
+
alert(`${files.length} invalid file(s)`);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
template: `<div>
|
|
48
|
+
<farm-multiple-filepicker
|
|
49
|
+
:maxFileSize="5"
|
|
50
|
+
:maxFilesNumber="3"
|
|
51
|
+
:acceptedFileTypes="fileTypes"
|
|
52
|
+
@onInvalidFiles="onInvalidFiles" />
|
|
53
|
+
</div>`,
|
|
23
54
|
});
|
|
@@ -94,8 +94,6 @@
|
|
|
94
94
|
</template>
|
|
95
95
|
<script lang="ts">
|
|
96
96
|
import Vue, { PropType } from 'vue';
|
|
97
|
-
import DefaultButton from '../Buttons/DefaultButton';
|
|
98
|
-
import Icon from '../Icon';
|
|
99
97
|
import { sizeOf } from '@farm-investimentos/front-mfe-libs-ts';
|
|
100
98
|
|
|
101
99
|
export type DownloadFiles = {
|
|
@@ -106,10 +104,7 @@ export type DownloadFiles = {
|
|
|
106
104
|
|
|
107
105
|
export default Vue.extend({
|
|
108
106
|
name: 'farm-multiple-filepicker',
|
|
109
|
-
|
|
110
|
-
'farm-btn': DefaultButton,
|
|
111
|
-
'farm-icon': Icon,
|
|
112
|
-
},
|
|
107
|
+
|
|
113
108
|
props: {
|
|
114
109
|
/*
|
|
115
110
|
* Accepted file types
|
|
@@ -200,15 +195,11 @@ export default Vue.extend({
|
|
|
200
195
|
this.$emit('onFileChange', newValue);
|
|
201
196
|
return;
|
|
202
197
|
}
|
|
203
|
-
const invalidTypeArray = newValue.filter(
|
|
204
|
-
|
|
198
|
+
const invalidTypeArray = newValue.filter(
|
|
199
|
+
file =>
|
|
205
200
|
this.acceptedFileTypes !== '*' &&
|
|
206
201
|
this.acceptedFileTypes.indexOf(file.type) === -1
|
|
207
|
-
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
return false;
|
|
211
|
-
});
|
|
202
|
+
);
|
|
212
203
|
|
|
213
204
|
if (invalidTypeArray.length > 0) {
|
|
214
205
|
const validTypeArray = newValue.filter(file => {
|
|
@@ -217,7 +208,7 @@ export default Vue.extend({
|
|
|
217
208
|
}
|
|
218
209
|
return true;
|
|
219
210
|
});
|
|
220
|
-
|
|
211
|
+
this.$emit('onInvalidFiles', [...invalidTypeArray]);
|
|
221
212
|
this.files = validTypeArray;
|
|
222
213
|
return;
|
|
223
214
|
}
|