@farm-investimentos/front-mfe-components 3.4.3 → 3.4.6
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/README.md +2 -0
- package/dist/front-mfe-components.common.js +311 -243
- 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 +311 -243
- 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 +11 -14
- package/src/components/Buttons/ConfirmButton/ConfirmButton.stories.js +10 -0
- package/src/components/Buttons/DangerButton/DangerButton.stories.js +10 -0
- package/src/components/Buttons/DefaultButton/DefaultButton.stories.js +10 -0
- package/src/components/DataTablePaginator/DataTablePaginator.stories.js +17 -2
- package/src/components/DataTablePaginator/DataTablePaginator.vue +5 -3
- package/src/components/DatePicker/DatePicker.stories.js +13 -3
- package/src/components/DatePicker/DatePicker.vue +4 -2
- package/src/components/DatePicker/__tests__/DatePicker.spec.js +13 -0
- package/src/components/DefaultTextField/DefaultTextField.stories.js +48 -7
- package/src/components/DefaultTextField/DefaultTextField.vue +31 -2
- package/src/components/DefaultTextField/__tests__/DefaultTextField.spec.js +21 -0
- package/src/components/FilePicker/FilePicker.scss +5 -4
- package/src/components/FilePicker/FilePicker.stories.js +10 -4
- package/src/components/FilePicker/FilePicker.vue +95 -67
- package/src/components/FilePicker/__tests__/FilePicker.spec.js +17 -0
- package/src/components/PromptUserToConfirm/PromptUserToConfirm.stories.js +21 -1
- package/src/examples/Table.stories.js +27 -16
- package/src/examples/inputs/Password.stories.js +42 -0
- package/src/scss/Sticky-table.scss +69 -0
- package/src/scss/Table.scss +2 -0
- package/src/scss/main.scss +4 -0
- package/src/stories/Introduction.stories.mdx +1 -1
|
@@ -1,78 +1,106 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
<section ref="container" id="droparea-container">
|
|
3
|
+
<input
|
|
4
|
+
type="file"
|
|
5
|
+
name="file"
|
|
6
|
+
@change="fileChange($event.target.files)"
|
|
7
|
+
:accept="acceptedFileTypes"
|
|
8
|
+
/>
|
|
9
|
+
<div v-if="!selectedFile" class="selectfile-container">
|
|
10
|
+
<v-icon color="secondary">mdi-cloud-upload</v-icon>
|
|
11
|
+
<p>Clique para selecionar ou arraste o arquivo aqui</p>
|
|
12
|
+
</div>
|
|
13
|
+
<div v-if="selectedFile || maxSizeReach" class="reset-container">
|
|
14
|
+
<div v-if="selectedFile">
|
|
15
|
+
<v-icon>mdi-file</v-icon> Arquivo selecionado: {{ selectedFile.name }} ({{
|
|
16
|
+
Math.floor(selectedFile.size / 1024)
|
|
17
|
+
}}kB)
|
|
18
|
+
</div>
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
<p v-if="maxSizeReach" v-html="maxSizeReachMsg"></p>
|
|
21
|
+
|
|
22
|
+
<v-btn depressed outlined color="secondary" class="v-btn-responsive" @click="reset"
|
|
23
|
+
>Escolher outro</v-btn
|
|
24
|
+
>
|
|
25
|
+
</div>
|
|
26
|
+
</section>
|
|
25
27
|
</template>
|
|
26
28
|
<script>
|
|
27
29
|
import { VBtn } from 'vuetify/lib/components/VBtn';
|
|
28
30
|
import { VIcon } from 'vuetify/lib/components/VIcon';
|
|
29
31
|
export default {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
32
|
+
props: {
|
|
33
|
+
/*
|
|
34
|
+
* Accepted file types
|
|
35
|
+
*/
|
|
36
|
+
acceptedFileTypes: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: '*',
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Max file size (in MB)
|
|
42
|
+
*/
|
|
43
|
+
maxFileSize: {
|
|
44
|
+
default: null,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
data() {
|
|
48
|
+
return {
|
|
49
|
+
selectedFile: null,
|
|
50
|
+
dropArea: null,
|
|
51
|
+
maxSizeReach: false,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
computed: {
|
|
55
|
+
maxSizeReachMsg() {
|
|
56
|
+
return `Arquivo ultrapassou o tamanho máximo de ${this.maxFileSize}MB`;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
mounted() {
|
|
60
|
+
this.dropArea = this.$refs.container;
|
|
61
|
+
this.addListeners();
|
|
62
|
+
},
|
|
63
|
+
methods: {
|
|
64
|
+
reset() {
|
|
65
|
+
this.$refs.container.querySelector('input').value = '';
|
|
66
|
+
this.$emit('onReset');
|
|
67
|
+
this.maxSizeReach = false;
|
|
68
|
+
this.selectedFile = null;
|
|
69
|
+
},
|
|
70
|
+
fileChange(fileList) {
|
|
71
|
+
this.maxSizeReach = false;
|
|
72
|
+
if (!fileList.length || fileList.length > 1) return;
|
|
73
|
+
|
|
74
|
+
if (this.maxFileSize) {
|
|
75
|
+
const sizeInMB = fileList[0].size / (1024 * 1024);
|
|
76
|
+
|
|
77
|
+
if (sizeInMB > this.maxFileSize) {
|
|
78
|
+
this.maxSizeReach = true;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this.selectedFile = fileList[0];
|
|
83
|
+
this.$emit('onFileChange', this.selectedFile);
|
|
84
|
+
},
|
|
85
|
+
handlerFunctionHighlight() {
|
|
86
|
+
this.dropArea.classList.add('highlight');
|
|
87
|
+
},
|
|
88
|
+
handlerFunctionUnhighlight() {
|
|
89
|
+
this.dropArea.classList.remove('highlight');
|
|
90
|
+
},
|
|
91
|
+
addListeners() {
|
|
92
|
+
this.dropArea.addEventListener('dragenter', this.handlerFunctionHighlight, false);
|
|
93
|
+
this.dropArea.addEventListener('dragleave', this.handlerFunctionUnhighlight, false);
|
|
94
|
+
this.dropArea.addEventListener('dragover', this.handlerFunctionHighlight, false);
|
|
95
|
+
this.dropArea.addEventListener('drop', this.handlerFunctionUnhighlight, false);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
components: {
|
|
99
|
+
VBtn,
|
|
100
|
+
VIcon,
|
|
101
|
+
},
|
|
74
102
|
};
|
|
75
103
|
</script>
|
|
76
104
|
<style scoped lang="scss">
|
|
77
105
|
@import './FilePicker.scss';
|
|
78
|
-
</style>
|
|
106
|
+
</style>
|
|
@@ -23,6 +23,14 @@ describe('FilePicker component', () => {
|
|
|
23
23
|
wrapper.vm.fileChange([]);
|
|
24
24
|
expect(wrapper.emitted().onFileChange).toBeUndefined();
|
|
25
25
|
});
|
|
26
|
+
|
|
27
|
+
it('Should handle max file size', async () => {
|
|
28
|
+
await wrapper.setProps({
|
|
29
|
+
maxFileSize: 5,
|
|
30
|
+
});
|
|
31
|
+
wrapper.vm.fileChange([{ size: 6 * 1024 * 1024 }]);
|
|
32
|
+
expect(wrapper.vm.maxSizeReach).toBeTruthy();
|
|
33
|
+
});
|
|
26
34
|
});
|
|
27
35
|
|
|
28
36
|
describe('handlerFunctionHighlight', () => {
|
|
@@ -49,4 +57,13 @@ describe('FilePicker component', () => {
|
|
|
49
57
|
});
|
|
50
58
|
});
|
|
51
59
|
});
|
|
60
|
+
|
|
61
|
+
describe('Computed properties', () => {
|
|
62
|
+
it('Should return maxSizeReachMsg', () => {
|
|
63
|
+
wrapper.setProps({
|
|
64
|
+
maxFileSize: 5,
|
|
65
|
+
});
|
|
66
|
+
expect(wrapper.vm.maxSizeReachMsg).toContain('Arquivo ultrapassou o tamanho máximo');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
52
69
|
});
|
|
@@ -7,7 +7,14 @@ export default {
|
|
|
7
7
|
|
|
8
8
|
export const Primary = () => ({
|
|
9
9
|
components: { PromptUserToConfirm },
|
|
10
|
-
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
model: {},
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
template: `<div style="max-width: 320px"><PromptUserToConfirm v-model="model"/>
|
|
16
|
+
match: {{ model }}
|
|
17
|
+
</div>`,
|
|
11
18
|
});
|
|
12
19
|
|
|
13
20
|
export const CustomTitle = () => ({
|
|
@@ -15,5 +22,18 @@ export const CustomTitle = () => ({
|
|
|
15
22
|
template: '<div style="max-width: 320px"><PromptUserToConfirm title="Custom" /></div>',
|
|
16
23
|
});
|
|
17
24
|
|
|
25
|
+
export const CustomMatchInput = () => ({
|
|
26
|
+
components: { PromptUserToConfirm },
|
|
27
|
+
data() {
|
|
28
|
+
return {
|
|
29
|
+
model: {},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
template: `<div style="max-width: 320px"><PromptUserToConfirm title="Custom match input: CONFIRMAR" match="CONFIRMAR" v-model="model" />
|
|
33
|
+
match: {{ model }}
|
|
34
|
+
</div>`,
|
|
35
|
+
});
|
|
36
|
+
|
|
18
37
|
Primary.storyName = 'Básico';
|
|
19
38
|
CustomTitle.storyName = 'Título customizado';
|
|
39
|
+
CustomMatchInput.storyName = 'Match input customizado';
|
|
@@ -9,11 +9,30 @@ const headers = [
|
|
|
9
9
|
width: 80,
|
|
10
10
|
align: 'left',
|
|
11
11
|
},
|
|
12
|
+
{
|
|
13
|
+
text: 'Name',
|
|
14
|
+
sortable: false,
|
|
15
|
+
value: 'id',
|
|
16
|
+
width: 160,
|
|
17
|
+
align: 'left',
|
|
18
|
+
},
|
|
12
19
|
];
|
|
13
20
|
|
|
14
21
|
export default {
|
|
15
22
|
title: 'Examples/Table',
|
|
16
23
|
decorators: [withDesign],
|
|
24
|
+
parameters: {
|
|
25
|
+
design: {
|
|
26
|
+
type: 'figma',
|
|
27
|
+
url: 'https://www.figma.com/file/1f84J4m1IBghWhozQvdyyt/%E2%9C%8D---Design-System?node-id=1505%3A372',
|
|
28
|
+
},
|
|
29
|
+
viewMode: 'docs',
|
|
30
|
+
docs: {
|
|
31
|
+
description: {
|
|
32
|
+
component: `Data Table (inherit from Vuetify)`,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
17
36
|
};
|
|
18
37
|
|
|
19
38
|
export const TableNoData = () => ({
|
|
@@ -26,8 +45,10 @@ export const TableNoData = () => ({
|
|
|
26
45
|
};
|
|
27
46
|
},
|
|
28
47
|
template: `<div>
|
|
48
|
+
|
|
29
49
|
<v-data-table
|
|
30
50
|
hide-default-footer
|
|
51
|
+
id="v-data-table--default"
|
|
31
52
|
:headers="headers"
|
|
32
53
|
>
|
|
33
54
|
<template slot="no-data">
|
|
@@ -46,12 +67,17 @@ export const TableSampleData = () => ({
|
|
|
46
67
|
data() {
|
|
47
68
|
return {
|
|
48
69
|
headers,
|
|
49
|
-
items: [
|
|
70
|
+
items: [
|
|
71
|
+
{ id: 1, name: 'name 1' },
|
|
72
|
+
{ id: 2, name: 'name 2' },
|
|
73
|
+
{ id: 3, name: 'name 3' },
|
|
74
|
+
],
|
|
50
75
|
};
|
|
51
76
|
},
|
|
52
77
|
template: `<div>
|
|
53
78
|
<v-data-table
|
|
54
79
|
hide-default-footer
|
|
80
|
+
id="v-data-table--default"
|
|
55
81
|
:headers="headers"
|
|
56
82
|
:items="items"
|
|
57
83
|
>
|
|
@@ -62,23 +88,8 @@ export const TableSampleData = () => ({
|
|
|
62
88
|
|
|
63
89
|
TableNoData.story = {
|
|
64
90
|
name: 'No data',
|
|
65
|
-
parameters: {
|
|
66
|
-
design: {
|
|
67
|
-
type: 'figma',
|
|
68
|
-
url:
|
|
69
|
-
'https://www.figma.com/file/rkkAsX4IP0tzv1udIDXlqe/%E2%9C%8D---Onboarding---PJ?node-id=2867%3A10594',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
91
|
};
|
|
73
92
|
|
|
74
93
|
TableSampleData.story = {
|
|
75
94
|
name: 'With data',
|
|
76
|
-
parameters: {
|
|
77
|
-
design: {
|
|
78
|
-
type: 'figma',
|
|
79
|
-
url:
|
|
80
|
-
'https://www.figma.com/file/rkkAsX4IP0tzv1udIDXlqe/%E2%9C%8D---Onboarding---PJ?node-id=2867%3A10594',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
95
|
};
|
|
84
|
-
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
title: 'Examples/Inputs/Password',
|
|
3
|
+
component: Password,
|
|
4
|
+
parameters: {
|
|
5
|
+
docs: {
|
|
6
|
+
description: {
|
|
7
|
+
component: `How to toggle password visivility.<br />
|
|
8
|
+
- Password visibility: hidden -> eye on icon (the click/tap will show the password)
|
|
9
|
+
- Password visibility: show -> eye off icon (the click/tap will hide the password)`,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const Password = () => ({
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
password: '',
|
|
19
|
+
showHidden: false,
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
template: `
|
|
23
|
+
<v-col cols="12" sm="12" md="4" class="v-col-fieldset-default pl-0">
|
|
24
|
+
<label>
|
|
25
|
+
Toggle visibility from password field
|
|
26
|
+
</label>
|
|
27
|
+
<v-text-field
|
|
28
|
+
color="secondary"
|
|
29
|
+
dense
|
|
30
|
+
outlined
|
|
31
|
+
v-model="password"
|
|
32
|
+
:append-icon="showHidden ? 'mdi-eye-off' : 'mdi-eye'"
|
|
33
|
+
:type="showHidden ? 'text' : 'password'"
|
|
34
|
+
@click:append="showHidden = !showHidden"
|
|
35
|
+
/>
|
|
36
|
+
</v-col>
|
|
37
|
+
`,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
Password.story = {
|
|
41
|
+
name: 'Básico',
|
|
42
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
$defaultLefts: 0, 4rem, 4rem;
|
|
2
|
+
@mixin stickytable($selector, $columns: 1, $lefts: $defaultLefts) {
|
|
3
|
+
#{$selector} {
|
|
4
|
+
tbody {
|
|
5
|
+
font-size: 0.75rem;
|
|
6
|
+
}
|
|
7
|
+
tbody tr:nth-of-type(odd) td {
|
|
8
|
+
background-color: #f0f0f0;
|
|
9
|
+
}
|
|
10
|
+
tr td {
|
|
11
|
+
background-color: white;
|
|
12
|
+
}
|
|
13
|
+
tr th {
|
|
14
|
+
color: var(--v-primary-base);
|
|
15
|
+
text-transform: uppercase;
|
|
16
|
+
font-weight: bold;
|
|
17
|
+
}
|
|
18
|
+
tr:not(:last-child) td,
|
|
19
|
+
tr th {
|
|
20
|
+
border-bottom: none;
|
|
21
|
+
}
|
|
22
|
+
.v-data-table__wrapper {
|
|
23
|
+
border-top: 1px solid var(--v-gray-lighten2);
|
|
24
|
+
border-bottom: 1px solid var(--v-gray-lighten2);
|
|
25
|
+
}
|
|
26
|
+
tr td:first-child,
|
|
27
|
+
th:first-child {
|
|
28
|
+
&:after {
|
|
29
|
+
content: '';
|
|
30
|
+
position: absolute;
|
|
31
|
+
left: 0;
|
|
32
|
+
bottom: -2px;
|
|
33
|
+
width: 100%;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@if $columns > 0 {
|
|
38
|
+
@for $i from 1 through $columns {
|
|
39
|
+
tr td:nth-child(#{$i}),
|
|
40
|
+
th:nth-child(#{$i}) {
|
|
41
|
+
position: sticky;
|
|
42
|
+
z-index: 4;
|
|
43
|
+
background-color: white;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@for $i from 1 through $columns {
|
|
48
|
+
tr td:nth-child(#{$i}),
|
|
49
|
+
th:nth-child(#{$i}) {
|
|
50
|
+
left: nth($lefts, $i);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.v-chip {
|
|
56
|
+
font-size: 0.75rem;
|
|
57
|
+
padding: 0 1.5rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.v-pagination {
|
|
61
|
+
li button:not([disabled]):not(.v-pagination__item--active):hover {
|
|
62
|
+
opacity: 0.6;
|
|
63
|
+
}
|
|
64
|
+
li button.v-pagination__item--active:hover {
|
|
65
|
+
cursor: default;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|