@farm-investimentos/front-mfe-components 3.4.4 → 3.4.7
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 +133 -56
- 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 +133 -56
- 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 +2 -1
- package/src/components/DatePicker/DatePicker.stories.js +9 -0
- package/src/components/DatePicker/DatePicker.vue +5 -0
- package/src/components/DefaultTextField/DefaultTextField.stories.js +48 -7
- package/src/components/DefaultTextField/DefaultTextField.vue +19 -2
- package/src/components/DefaultTextField/__tests__/DefaultTextField.spec.js +21 -0
- package/src/components/RangeDatePicker/RangeDatePicker.vue +20 -2
- package/src/examples/Table.stories.js +63 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm-investimentos/front-mfe-components",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.7",
|
|
4
4
|
"author": "farm investimentos",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/front-mfe-components.common.js",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"eslint": "^6.7.2",
|
|
43
43
|
"eslint-plugin-vue": "^6.2.2",
|
|
44
44
|
"storybook-addon-designs": "^6.2.1",
|
|
45
|
+
"v-mask": "^2.3.0",
|
|
45
46
|
"vue-template-compiler": "^2.6.11",
|
|
46
47
|
"webpack-cli": "^4.9.0"
|
|
47
48
|
},
|
|
@@ -35,6 +35,15 @@ export const MinMaxDates = () => ({
|
|
|
35
35
|
</div>`,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
+
export const RequiredDates = () => ({
|
|
39
|
+
components: { DatePicker },
|
|
40
|
+
|
|
41
|
+
template: `<div style='max-width: 320px'>
|
|
42
|
+
<DatePicker inputId="input-custom-id-3" :required="true" />
|
|
43
|
+
</div>`,
|
|
44
|
+
});
|
|
45
|
+
|
|
38
46
|
Primary.storyName = 'Básico';
|
|
39
47
|
InitValue.storyName = 'Data inicial';
|
|
40
48
|
MinMaxDates.storyName = 'Data mínima e máxima';
|
|
49
|
+
RequiredDates.storyName = 'Obrigatório';
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import { withDesign } from 'storybook-addon-designs';
|
|
1
2
|
import DefaultTextField from './DefaultTextField.vue';
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
title: 'API/Form/DefaultTextField',
|
|
5
6
|
component: DefaultTextField,
|
|
7
|
+
decorators: [withDesign],
|
|
8
|
+
parameters: {
|
|
9
|
+
viewMode: 'docs',
|
|
10
|
+
docs: {
|
|
11
|
+
description: {
|
|
12
|
+
component: `Default Text Field with label (inherit from Vuetify)<br />
|
|
13
|
+
selector: <em>farm-textfield-labelled</em>`,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
6
17
|
};
|
|
7
18
|
|
|
8
19
|
export const Primary = () => ({
|
|
@@ -10,7 +21,7 @@ export const Primary = () => ({
|
|
|
10
21
|
data() {
|
|
11
22
|
return {
|
|
12
23
|
model: 'primary',
|
|
13
|
-
item: { label: 'Nome do campo', key: 'key' },
|
|
24
|
+
item: { label: 'Nome do campo', key: 'key', md: 4 },
|
|
14
25
|
};
|
|
15
26
|
},
|
|
16
27
|
template: '<DefaultTextField v-model="model" :item="item" />',
|
|
@@ -21,10 +32,12 @@ export const Secondary = () => ({
|
|
|
21
32
|
data() {
|
|
22
33
|
return {
|
|
23
34
|
model: 'secondary',
|
|
24
|
-
item: { label: 'Nome do campo', key: 'key' },
|
|
35
|
+
item: { label: 'Nome do campo', key: 'key', md: 4 },
|
|
25
36
|
};
|
|
26
37
|
},
|
|
27
|
-
template:
|
|
38
|
+
template: `<v-form>
|
|
39
|
+
<DefaultTextField :item="item" v-model="model" :required="true" />
|
|
40
|
+
</v-form>`,
|
|
28
41
|
});
|
|
29
42
|
|
|
30
43
|
export const ReadOnly = () => ({
|
|
@@ -32,12 +45,40 @@ export const ReadOnly = () => ({
|
|
|
32
45
|
data() {
|
|
33
46
|
return {
|
|
34
47
|
model: 'readonly',
|
|
35
|
-
item: { label: 'Nome do campo', key: 'key' },
|
|
48
|
+
item: { label: 'Nome do campo', key: 'key', md: 4 },
|
|
36
49
|
};
|
|
37
50
|
},
|
|
38
51
|
template: '<DefaultTextField :item="item" v-model="model" :readonly="true" />',
|
|
39
52
|
});
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
export const Masked = () => ({
|
|
55
|
+
components: { DefaultTextField },
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
model: '12345',
|
|
59
|
+
item: { label: 'Máscara (##.###)', key: 'key', md: 4 },
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
template: `
|
|
63
|
+
<v-form>
|
|
64
|
+
<DefaultTextField :item="item" v-model="model" mask="##.###" />
|
|
65
|
+
</v-form>
|
|
66
|
+
`,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export const Placeholder = () => ({
|
|
70
|
+
components: { DefaultTextField },
|
|
71
|
+
data() {
|
|
72
|
+
return {
|
|
73
|
+
model: '',
|
|
74
|
+
item: { label: 'Nome do campo', key: 'key', md: 4 },
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
template: '<DefaultTextField v-model="model" :item="item" placeholder="your text" />',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
Primary.storyName = 'Basic';
|
|
81
|
+
Secondary.storyName = 'Required field';
|
|
82
|
+
ReadOnly.storyName = 'Readonly input';
|
|
83
|
+
Masked.storyName = 'Masked';
|
|
84
|
+
Placeholder.storyName = 'Placeholder'
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
outlined
|
|
11
11
|
dense
|
|
12
12
|
v-mask="`${mask ? mask : ''}`"
|
|
13
|
+
:placeholder="placeholder"
|
|
13
14
|
:id="inputId"
|
|
14
15
|
:rules="inputRules"
|
|
15
16
|
:disabled="disabled"
|
|
@@ -18,14 +19,20 @@
|
|
|
18
19
|
</v-col>
|
|
19
20
|
</template>
|
|
20
21
|
<script>
|
|
22
|
+
import Vue from 'vue';
|
|
21
23
|
import { VTextField } from 'vuetify/lib/components/VTextField';
|
|
22
24
|
import { VCol } from 'vuetify/lib/components/VGrid';
|
|
23
|
-
|
|
25
|
+
|
|
26
|
+
export default Vue.extend({
|
|
27
|
+
name: 'farm-textfield-labelled',
|
|
24
28
|
props: {
|
|
25
29
|
item: {
|
|
26
30
|
type: Object,
|
|
27
31
|
required: true,
|
|
28
32
|
},
|
|
33
|
+
/**
|
|
34
|
+
* v-model
|
|
35
|
+
*/
|
|
29
36
|
value: {
|
|
30
37
|
required: true,
|
|
31
38
|
},
|
|
@@ -61,10 +68,20 @@ export default {
|
|
|
61
68
|
type: String,
|
|
62
69
|
default: null,
|
|
63
70
|
},
|
|
71
|
+
/**
|
|
72
|
+
* Input is readonly or not
|
|
73
|
+
*/
|
|
64
74
|
readonly: {
|
|
65
75
|
type: Boolean,
|
|
66
76
|
default: false,
|
|
67
77
|
},
|
|
78
|
+
/**
|
|
79
|
+
* Placeholder is helper text for input
|
|
80
|
+
*/
|
|
81
|
+
placeholder: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: null,
|
|
84
|
+
},
|
|
68
85
|
},
|
|
69
86
|
components: {
|
|
70
87
|
VCol,
|
|
@@ -92,5 +109,5 @@ export default {
|
|
|
92
109
|
return `${this.forKey}-${this.item.key}`;
|
|
93
110
|
},
|
|
94
111
|
},
|
|
95
|
-
};
|
|
112
|
+
});
|
|
96
113
|
</script>
|
|
@@ -29,5 +29,26 @@ describe('DefaultTextField component', () => {
|
|
|
29
29
|
it('Should have inputId', () => {
|
|
30
30
|
expect(component.inputId).toEqual('form-key');
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
it('Should have default inputRules', () => {
|
|
34
|
+
expect(component.inputRules).toEqual([]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('Should have inputRules from prop', async () => {
|
|
38
|
+
expect(component.inputRules).toEqual([]);
|
|
39
|
+
await wrapper.setProps({
|
|
40
|
+
rules: [jest.fn()],
|
|
41
|
+
});
|
|
42
|
+
expect(component.inputRules.length).toEqual(1);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Should not have inputRules if disabled', async () => {
|
|
46
|
+
expect(component.inputRules).toEqual([]);
|
|
47
|
+
await wrapper.setProps({
|
|
48
|
+
rules: [jest.fn()],
|
|
49
|
+
disabled: true,
|
|
50
|
+
});
|
|
51
|
+
expect(component.inputRules.length).toEqual(0);
|
|
52
|
+
});
|
|
32
53
|
});
|
|
33
54
|
});
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
outlined
|
|
20
20
|
dense
|
|
21
21
|
:id="inputId"
|
|
22
|
+
:rules="required ? [requiredRule] : []"
|
|
22
23
|
></v-text-field>
|
|
23
24
|
</template>
|
|
24
25
|
<v-date-picker
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
</v-menu>
|
|
44
45
|
</template>
|
|
45
46
|
<script>
|
|
47
|
+
import Vue from 'vue';
|
|
46
48
|
import { VTextField } from 'vuetify/lib/components/VTextField';
|
|
47
49
|
import { VMenu } from 'vuetify/lib/components/VMenu';
|
|
48
50
|
import { VBtn } from 'vuetify/lib/components/VBtn';
|
|
@@ -51,7 +53,8 @@ import { defaultFormat as dateDefaultFormatter } from '../../helpers/date';
|
|
|
51
53
|
/**
|
|
52
54
|
* Componente de input com datepicker para range de data
|
|
53
55
|
*/
|
|
54
|
-
export default {
|
|
56
|
+
export default Vue.extend({
|
|
57
|
+
name: 'farm-input-rangedatepicker',
|
|
55
58
|
components: {
|
|
56
59
|
VTextField,
|
|
57
60
|
VMenu,
|
|
@@ -89,6 +92,13 @@ export default {
|
|
|
89
92
|
type: String,
|
|
90
93
|
default: null,
|
|
91
94
|
},
|
|
95
|
+
/**
|
|
96
|
+
* Required field (inside form)
|
|
97
|
+
*/
|
|
98
|
+
required: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: false,
|
|
101
|
+
},
|
|
92
102
|
},
|
|
93
103
|
data() {
|
|
94
104
|
const s = this.formatDateRange(this.value);
|
|
@@ -96,6 +106,9 @@ export default {
|
|
|
96
106
|
menuField: false,
|
|
97
107
|
dateField: this.value,
|
|
98
108
|
fieldRange: s,
|
|
109
|
+
requiredRule: value => {
|
|
110
|
+
return !!value || value != '' || 'Campo obrigatório';
|
|
111
|
+
},
|
|
99
112
|
};
|
|
100
113
|
},
|
|
101
114
|
watch: {
|
|
@@ -137,5 +150,10 @@ export default {
|
|
|
137
150
|
return false;
|
|
138
151
|
},
|
|
139
152
|
},
|
|
140
|
-
};
|
|
153
|
+
});
|
|
141
154
|
</script>
|
|
155
|
+
<style lang="scss" scoped>
|
|
156
|
+
.theme--light.v-input.v-input--dense.v-text-field.v-text-field--outlined.error--text:after {
|
|
157
|
+
content: '' !important;
|
|
158
|
+
}
|
|
159
|
+
</style>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withDesign } from 'storybook-addon-designs';
|
|
2
2
|
import { DataTableEmptyWrapper } from '../main';
|
|
3
|
+
import { DataTablePaginator } from '../main';
|
|
3
4
|
|
|
4
5
|
const headers = [
|
|
5
6
|
{
|
|
@@ -24,7 +25,8 @@ export default {
|
|
|
24
25
|
parameters: {
|
|
25
26
|
design: {
|
|
26
27
|
type: 'figma',
|
|
27
|
-
url:
|
|
28
|
+
url:
|
|
29
|
+
'https://www.figma.com/file/1f84J4m1IBghWhozQvdyyt/%E2%9C%8D---Design-System?node-id=1505%3A372',
|
|
28
30
|
},
|
|
29
31
|
viewMode: 'docs',
|
|
30
32
|
docs: {
|
|
@@ -86,6 +88,62 @@ export const TableSampleData = () => ({
|
|
|
86
88
|
</div>`,
|
|
87
89
|
});
|
|
88
90
|
|
|
91
|
+
export const TableSampleLocalPagination = () => ({
|
|
92
|
+
components: {
|
|
93
|
+
DataTableEmptyWrapper,
|
|
94
|
+
DataTablePaginator,
|
|
95
|
+
},
|
|
96
|
+
data() {
|
|
97
|
+
return {
|
|
98
|
+
headers,
|
|
99
|
+
items: [
|
|
100
|
+
{ id: 1, name: 'name 1' },
|
|
101
|
+
{ id: 2, name: 'name 2' },
|
|
102
|
+
{ id: 3, name: 'name 3' },
|
|
103
|
+
{ id: 4, name: 'name 4' },
|
|
104
|
+
{ id: 5, name: 'name 5' },
|
|
105
|
+
{ id: 6, name: 'name 6' },
|
|
106
|
+
{ id: 7, name: 'name 7' },
|
|
107
|
+
{ id: 8, name: 'name 8' },
|
|
108
|
+
{ id: 9, name: 'name 9' },
|
|
109
|
+
{ id: 10, name: 'name 10' },
|
|
110
|
+
{ id: 11, name: 'name 11' },
|
|
111
|
+
{ id: 12, name: 'name 12' },
|
|
112
|
+
],
|
|
113
|
+
pagination: {
|
|
114
|
+
page: 1,
|
|
115
|
+
itemsPerPage: 10,
|
|
116
|
+
pages: 2,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
methods: {
|
|
121
|
+
onChangePage(newPage) {
|
|
122
|
+
this.pagination.page = newPage;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
template: `<div>
|
|
126
|
+
<v-data-table
|
|
127
|
+
hide-default-footer
|
|
128
|
+
id="v-data-table--default"
|
|
129
|
+
:headers="headers"
|
|
130
|
+
:items="items"
|
|
131
|
+
:options.sync="pagination"
|
|
132
|
+
>
|
|
133
|
+
<template v-slot:footer>
|
|
134
|
+
<DataTablePaginator
|
|
135
|
+
class="my-6"
|
|
136
|
+
hidePerPageOptions
|
|
137
|
+
:initialLimitPerPage="pagination.itemsPerPage"
|
|
138
|
+
:page="pagination.page"
|
|
139
|
+
:totalPages="pagination.pages"
|
|
140
|
+
@onChangePage="onChangePage"
|
|
141
|
+
/>
|
|
142
|
+
</template>
|
|
143
|
+
</v-data-table>
|
|
144
|
+
</div>`,
|
|
145
|
+
});
|
|
146
|
+
|
|
89
147
|
TableNoData.story = {
|
|
90
148
|
name: 'No data',
|
|
91
149
|
};
|
|
@@ -93,3 +151,7 @@ TableNoData.story = {
|
|
|
93
151
|
TableSampleData.story = {
|
|
94
152
|
name: 'With data',
|
|
95
153
|
};
|
|
154
|
+
|
|
155
|
+
TableSampleLocalPagination.story = {
|
|
156
|
+
name: 'With data and local pagination',
|
|
157
|
+
};
|