@farm-investimentos/front-mfe-components 3.2.0 → 3.2.1
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 +48 -39
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.umd.js +48 -39
- 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/DefaultTextField/DefaultTextField.stories.js +30 -6
- package/src/components/DefaultTextField/DefaultTextField.vue +11 -3
- package/src/components/DefaultTextField/__tests__/DefaultTextField.spec.js +9 -1
package/package.json
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
import DefaultTextField from './DefaultTextField.vue';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
title: 'Example/Form/DefaultTextField',
|
|
5
|
+
component: DefaultTextField,
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export const Primary = () => ({
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
components: { DefaultTextField },
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
model: 'primary',
|
|
13
|
+
item: { label: 'Nome do campo', key: 'key' },
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
template: '<DefaultTextField v-model="model" :item="item" />',
|
|
11
17
|
});
|
|
12
18
|
|
|
13
19
|
export const Secondary = () => ({
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
components: { DefaultTextField },
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
model: 'secondary',
|
|
24
|
+
item: { label: 'Nome do campo', key: 'key' },
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
template: '<DefaultTextField :item="item" v-model="model" required="true" />',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const ReadOnly = () => ({
|
|
31
|
+
components: { DefaultTextField },
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
model: 'readonly',
|
|
35
|
+
item: { label: 'Nome do campo', key: 'key' },
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
template: '<DefaultTextField :item="item" v-model="model" :readonly="true" />',
|
|
16
39
|
});
|
|
17
40
|
|
|
18
41
|
Primary.storyName = 'Básico';
|
|
19
42
|
Secondary.storyName = 'Label de obrigatório';
|
|
43
|
+
ReadOnly.storyName = 'Input readonly';
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-col cols="12" sm="12" :md="item.md ? item.md : 2" class="v-col-fieldset-default pl-0">
|
|
3
|
-
<label :for="
|
|
3
|
+
<label :for="inputId">
|
|
4
4
|
{{ item.label }}
|
|
5
5
|
<span class="required" v-if="required && !disabled">*</span>
|
|
6
6
|
</label>
|
|
7
7
|
<v-text-field
|
|
8
|
-
:id="`${forKey}-${item.key}`"
|
|
9
8
|
color="secondary"
|
|
10
9
|
v-model="inputVal"
|
|
11
10
|
outlined
|
|
12
11
|
dense
|
|
13
12
|
v-mask="`${mask ? mask : ''}`"
|
|
13
|
+
:id="inputId"
|
|
14
14
|
:rules="inputRules"
|
|
15
15
|
:disabled="disabled"
|
|
16
|
+
:readonly="readonly"
|
|
16
17
|
></v-text-field>
|
|
17
18
|
</v-col>
|
|
18
19
|
</template>
|
|
@@ -38,16 +39,20 @@ export default {
|
|
|
38
39
|
forKey: {
|
|
39
40
|
type: String,
|
|
40
41
|
required: false,
|
|
42
|
+
default: 'form',
|
|
41
43
|
},
|
|
42
44
|
required: {
|
|
43
45
|
type: Boolean,
|
|
44
46
|
default: false,
|
|
45
|
-
required: false,
|
|
46
47
|
},
|
|
47
48
|
mask: {
|
|
48
49
|
type: String,
|
|
49
50
|
default: null,
|
|
50
51
|
},
|
|
52
|
+
readonly: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false,
|
|
55
|
+
},
|
|
51
56
|
},
|
|
52
57
|
components: {
|
|
53
58
|
VCol,
|
|
@@ -71,6 +76,9 @@ export default {
|
|
|
71
76
|
}
|
|
72
77
|
return [];
|
|
73
78
|
},
|
|
79
|
+
inputId() {
|
|
80
|
+
return `${this.forKey}-${this.item.key}`;
|
|
81
|
+
},
|
|
74
82
|
},
|
|
75
83
|
};
|
|
76
84
|
</script>
|
|
@@ -3,14 +3,16 @@ import DefaultTextField from '../DefaultTextField';
|
|
|
3
3
|
|
|
4
4
|
describe('DefaultTextField component', () => {
|
|
5
5
|
let wrapper;
|
|
6
|
+
let component;
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
8
9
|
wrapper = shallowMount(DefaultTextField, {
|
|
9
10
|
propsData: {
|
|
10
|
-
item: {},
|
|
11
|
+
item: { key: 'key' },
|
|
11
12
|
value: false,
|
|
12
13
|
},
|
|
13
14
|
});
|
|
15
|
+
component = wrapper.vm;
|
|
14
16
|
});
|
|
15
17
|
|
|
16
18
|
test('Created hook', () => {
|
|
@@ -22,4 +24,10 @@ describe('DefaultTextField component', () => {
|
|
|
22
24
|
expect(wrapper.element).toMatchSnapshot();
|
|
23
25
|
});
|
|
24
26
|
});
|
|
27
|
+
|
|
28
|
+
describe('Computed properties', () => {
|
|
29
|
+
it('Should have inputId', () => {
|
|
30
|
+
expect(component.inputId).toEqual('form-key');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
25
33
|
});
|