@farm-investimentos/front-mfe-components 11.4.7 → 11.5.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 +339 -271
- 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 +339 -271
- 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 +3 -2
- package/src/components/CopyToClipboard/CopyToClipboard.stories.js +7 -0
- package/src/components/CopyToClipboard/CopyToClipboard.vue +11 -3
- package/src/components/Switcher/Switcher.scss +16 -12
- package/src/components/Switcher/Switcher.stories.js +24 -2
- package/src/components/Switcher/Switcher.vue +5 -3
- package/src/components/TextFieldV2/TextFieldV2.scss +5 -0
- package/src/components/TextFieldV2/TextFieldV2.stories.js +139 -7
- package/src/components/TextFieldV2/TextFieldV2.vue +34 -9
- package/src/components/TextFieldV2/__tests__/TextFieldV2.spec.js +21 -0
- package/src/components/Typography/BodyText/BodyText.vue +1 -1
- package/src/components/Typography/Caption/Caption.vue +1 -1
- package/src/components/Typography/Heading/Heading.vue +1 -1
- package/src/components/Typography/Subtitle/Subtitle.stories.js +4 -4
- package/src/components/Typography/Subtitle/Subtitle.vue +1 -1
- package/src/components/Typography/Typography.vue +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm-investimentos/front-mfe-components",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.1",
|
|
4
4
|
"author": "farm investimentos",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/front-mfe-components.common.js",
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"sass": "~1.32.0",
|
|
50
50
|
"sass-loader": "^10.0.0",
|
|
51
51
|
"storybook-addon-designs": "^6.2.1",
|
|
52
|
+
"text-mask-addons": "^3.8.0",
|
|
52
53
|
"typescript": "~4.1.5",
|
|
53
|
-
"v-mask": "
|
|
54
|
+
"v-mask": "2.3.0",
|
|
54
55
|
"vue-template-compiler": "2.7.10"
|
|
55
56
|
},
|
|
56
57
|
"browserslist": [
|
|
@@ -23,3 +23,10 @@ export const Primary = () => ({
|
|
|
23
23
|
<farm-copytoclipboard toCopy="To be copied" />
|
|
24
24
|
</div>`,
|
|
25
25
|
});
|
|
26
|
+
|
|
27
|
+
export const NoIcon = () => ({
|
|
28
|
+
components: { 'farm-copytoclipboard': CopyToClipboard },
|
|
29
|
+
template: `<div style="max-width: 480px; padding-top: 80px; padding-left: 80px;">
|
|
30
|
+
<farm-copytoclipboard toCopy="To be copied" :isIcon="false" />
|
|
31
|
+
</div>`,
|
|
32
|
+
});
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
<farm-tooltip v-model="show">
|
|
3
3
|
{{ feedbackMessage }}
|
|
4
4
|
<template v-slot:activator="{}">
|
|
5
|
-
<farm-btn icon :disabled="disabled" @click="onClick">
|
|
5
|
+
<farm-btn v-if="isIcon" title="Copiar" icon :disabled="disabled" @click="onClick">
|
|
6
6
|
<farm-icon size="xs">content-copy</farm-icon>
|
|
7
7
|
</farm-btn>
|
|
8
|
+
<farm-btn v-else outlined title="Copiar" :disabled="disabled" @click="onClick">
|
|
9
|
+
<farm-icon>content-copy</farm-icon>
|
|
10
|
+
Copiar
|
|
11
|
+
</farm-btn>
|
|
8
12
|
</template>
|
|
9
13
|
</farm-tooltip>
|
|
10
14
|
</template>
|
|
@@ -20,12 +24,16 @@ export default Vue.extend({
|
|
|
20
24
|
* Content to be copied to clipboard
|
|
21
25
|
*/
|
|
22
26
|
toCopy: { type: String, required: true },
|
|
27
|
+
/**
|
|
28
|
+
* Is button with icon?
|
|
29
|
+
*/
|
|
30
|
+
isIcon: { type: Boolean, default: true },
|
|
23
31
|
},
|
|
24
32
|
setup(props) {
|
|
25
33
|
const show = ref(false);
|
|
26
34
|
const feedbackMessage = ref('');
|
|
27
35
|
const disabled = ref(false);
|
|
28
|
-
const { toCopy } = toRefs(props);
|
|
36
|
+
const { toCopy, isIcon } = toRefs(props);
|
|
29
37
|
|
|
30
38
|
const onClick = async () => {
|
|
31
39
|
disabled.value = true;
|
|
@@ -45,6 +53,7 @@ export default Vue.extend({
|
|
|
45
53
|
|
|
46
54
|
return {
|
|
47
55
|
show,
|
|
56
|
+
isIcon,
|
|
48
57
|
feedbackMessage,
|
|
49
58
|
disabled,
|
|
50
59
|
onClick,
|
|
@@ -52,4 +61,3 @@ export default Vue.extend({
|
|
|
52
61
|
},
|
|
53
62
|
});
|
|
54
63
|
</script>
|
|
55
|
-
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
.farm-switch--selected {
|
|
2
|
-
background-color: var(--
|
|
2
|
+
background-color: var(--farm-primary-base);
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
.farm-switch--idle {
|
|
6
|
-
background-color: var(--
|
|
6
|
+
background-color: var(--farm-neutral-base);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.farm-switch--disabled-on {
|
|
10
|
+
background-color: var(--farm-primary-lighten);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.farm-switch--disabled-off {
|
|
14
|
+
background-color: var(--farm-neutral-lighten);
|
|
7
15
|
}
|
|
8
16
|
|
|
9
17
|
.farm-switch {
|
|
10
18
|
display: inline-block;
|
|
11
19
|
position: relative;
|
|
12
20
|
cursor: pointer;
|
|
13
|
-
width:
|
|
14
|
-
height:
|
|
21
|
+
width: 24px;
|
|
22
|
+
height: 16px;
|
|
15
23
|
border-radius: 9999px;
|
|
16
24
|
|
|
17
25
|
&:focus {
|
|
@@ -22,10 +30,6 @@
|
|
|
22
30
|
display: block;
|
|
23
31
|
}
|
|
24
32
|
|
|
25
|
-
&--disabled {
|
|
26
|
-
opacity: 0.6;
|
|
27
|
-
cursor: default;
|
|
28
|
-
}
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
.farm-switch__background {
|
|
@@ -40,10 +44,10 @@
|
|
|
40
44
|
|
|
41
45
|
.farm-switch__indicator {
|
|
42
46
|
position: absolute;
|
|
43
|
-
height:
|
|
44
|
-
width:
|
|
45
|
-
left: -
|
|
46
|
-
top: -
|
|
47
|
+
height: 16px;
|
|
48
|
+
width: 16px;
|
|
49
|
+
left: -4px;
|
|
50
|
+
top: -2px;
|
|
47
51
|
background-color: #ffffff;
|
|
48
52
|
border-radius: 9999px;
|
|
49
53
|
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.16);
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
export const Primary = () => ({
|
|
9
9
|
data() {
|
|
10
10
|
return {
|
|
11
|
-
selectedValue:
|
|
11
|
+
selectedValue: true,
|
|
12
12
|
};
|
|
13
13
|
},
|
|
14
14
|
template: `<div>
|
|
@@ -16,7 +16,29 @@ export const Primary = () => ({
|
|
|
16
16
|
</div>`,
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const OnDisabled = () => ({
|
|
20
|
+
data() {
|
|
21
|
+
return {
|
|
22
|
+
selectedValue: true,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
template: `<div>
|
|
26
|
+
<farm-switcher v-model="selectedValue" block :disabled="true" />
|
|
27
|
+
</div>`,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const Off = () => ({
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
selectedValue: false,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
template: `<div>
|
|
37
|
+
<farm-switcher v-model="selectedValue" block :disabled="false" />
|
|
38
|
+
</div>`,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const OffDisabled = () => ({
|
|
20
42
|
data() {
|
|
21
43
|
return {
|
|
22
44
|
selectedValue: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:class="{ 'farm-switch': true
|
|
3
|
+
:class="{ 'farm-switch': true }"
|
|
4
4
|
role="checkbox"
|
|
5
5
|
@click="toggle"
|
|
6
6
|
@keydown.space.prevent="toggle"
|
|
@@ -35,8 +35,10 @@ export default Vue.extend({
|
|
|
35
35
|
computed: {
|
|
36
36
|
backgroundStyles() {
|
|
37
37
|
return {
|
|
38
|
-
'farm-switch--selected': this.value,
|
|
39
|
-
'farm-switch--idle': !this.value,
|
|
38
|
+
'farm-switch--selected': this.value && !this.isDisabled,
|
|
39
|
+
'farm-switch--idle': !this.value && !this.isDisabled,
|
|
40
|
+
'farm-switch--disabled-on': this.value && this.isDisabled,
|
|
41
|
+
'farm-switch--disabled-off': !this.value && this.isDisabled,
|
|
40
42
|
};
|
|
41
43
|
},
|
|
42
44
|
indicatorStyles() {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { withDesign } from 'storybook-addon-designs';
|
|
2
2
|
import TextFieldV2 from './TextFieldV2.vue';
|
|
3
3
|
|
|
4
|
+
import createNumberMask from 'text-mask-addons/dist/createNumberMask';
|
|
5
|
+
const currencyMask = createNumberMask({
|
|
6
|
+
prefix: 'R$',
|
|
7
|
+
allowDecimal: true,
|
|
8
|
+
includeThousandsSeparator: true,
|
|
9
|
+
thousandsSeparatorSymbol: '.',
|
|
10
|
+
decimalSymbol: ',',
|
|
11
|
+
allowNegative: false,
|
|
12
|
+
});
|
|
13
|
+
|
|
4
14
|
export default {
|
|
5
15
|
title: 'Form/TextFieldV2',
|
|
6
16
|
component: TextFieldV2,
|
|
@@ -34,18 +44,60 @@ export const Primary = () => ({
|
|
|
34
44
|
</div>`,
|
|
35
45
|
});
|
|
36
46
|
|
|
47
|
+
export const Disabled = () => ({
|
|
48
|
+
data() {
|
|
49
|
+
return {
|
|
50
|
+
v: 'input text',
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
template: `<div style="width: 480px">
|
|
54
|
+
<farm-textfield-v2 v-model="v" disabled />
|
|
55
|
+
</div>`,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const Readonly = () => ({
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
v: 'input text',
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
template: `<div style="width: 480px">
|
|
65
|
+
<farm-textfield-v2 v-model="v" readonly />
|
|
66
|
+
</div>`,
|
|
67
|
+
});
|
|
68
|
+
|
|
37
69
|
export const Validate = () => ({
|
|
38
70
|
data() {
|
|
39
71
|
return {
|
|
40
|
-
|
|
72
|
+
v1: 'input 1',
|
|
73
|
+
v2: '',
|
|
74
|
+
v3: '',
|
|
75
|
+
v4: '',
|
|
41
76
|
rules: {
|
|
42
|
-
required: value => !!value || '
|
|
77
|
+
required: value => !!value || 'Required field',
|
|
78
|
+
email: v =>
|
|
79
|
+
!v ||
|
|
80
|
+
/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) ||
|
|
81
|
+
'Must be an e-mail',
|
|
43
82
|
},
|
|
44
83
|
};
|
|
45
84
|
},
|
|
46
85
|
template: `<div style="width: 480px">
|
|
47
86
|
<farm-label required>Required field</farm-label>
|
|
48
|
-
<farm-textfield-v2 v-model="
|
|
87
|
+
<farm-textfield-v2 v-model="v1" :rules="[rules.required]" />
|
|
88
|
+
|
|
89
|
+
<farm-label>E-mail</farm-label>
|
|
90
|
+
<farm-textfield-v2 v-model="v2" :rules="[rules.email]" />
|
|
91
|
+
|
|
92
|
+
<farm-label required>Required and e-mail</farm-label>
|
|
93
|
+
<farm-textfield-v2 v-model="v3" :rules="[rules.required, rules.email]" />
|
|
94
|
+
|
|
95
|
+
<farm-label required>Required field with hint</farm-label>
|
|
96
|
+
<farm-textfield-v2 v-model="v4" :rules="[rules.required]" hint="hint text" />
|
|
97
|
+
|
|
98
|
+
<farm-label required>Required field with icon</farm-label>
|
|
99
|
+
<farm-textfield-v2 v-model="v1" :rules="[rules.required]" icon="eye" />
|
|
100
|
+
|
|
49
101
|
</div>`,
|
|
50
102
|
});
|
|
51
103
|
|
|
@@ -61,8 +113,8 @@ export const Icon = () => ({
|
|
|
61
113
|
},
|
|
62
114
|
},
|
|
63
115
|
template: `<div style="width: 480px">
|
|
64
|
-
<farm-textfield-v2 v-model="v" icon="eye" onClickIcon="
|
|
65
|
-
<farm-textfield-v2 v-model="v" icon="eye" icon-position="left" onClickIcon="
|
|
116
|
+
<farm-textfield-v2 v-model="v" icon="eye" @onClickIcon="show" />
|
|
117
|
+
<farm-textfield-v2 v-model="v" icon="eye" icon-position="left" @onClickIcon="show" />
|
|
66
118
|
</div>`,
|
|
67
119
|
});
|
|
68
120
|
|
|
@@ -72,8 +124,8 @@ export const HintText = () => ({
|
|
|
72
124
|
v: 'input text',
|
|
73
125
|
};
|
|
74
126
|
},
|
|
75
|
-
template: `<div style="width: 480px">
|
|
76
|
-
<farm-textfield-v2 v-model="v"
|
|
127
|
+
template: `<div style="width: 480px; display: flex;">
|
|
128
|
+
<farm-textfield-v2 v-model="v" hint="Hint text" />
|
|
77
129
|
</div>`,
|
|
78
130
|
});
|
|
79
131
|
|
|
@@ -97,3 +149,83 @@ export const UpdateValue = () => ({
|
|
|
97
149
|
<br />v-model: {{ v }}
|
|
98
150
|
</div>`,
|
|
99
151
|
});
|
|
152
|
+
|
|
153
|
+
export const Types = () => ({
|
|
154
|
+
data() {
|
|
155
|
+
return {
|
|
156
|
+
types: ['text', 'password', 'email', 'date', 'search', 'color', 'tel', 'url'],
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
template: `<div style="width: 480px">
|
|
160
|
+
<div v-for="type in types" :key="'input_type_' + type">
|
|
161
|
+
<farm-label>Type: {{ type }}</farm-label>
|
|
162
|
+
<farm-textfield-v2 :type="type" />
|
|
163
|
+
</div>
|
|
164
|
+
</div>`,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export const Reset = () => ({
|
|
168
|
+
data() {
|
|
169
|
+
return {
|
|
170
|
+
v: 'input text',
|
|
171
|
+
rules: {
|
|
172
|
+
required: value => !!value || 'Required field',
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
methods: {
|
|
177
|
+
reset() {
|
|
178
|
+
this.$refs.input.reset();
|
|
179
|
+
this.$refs.inputValidatable.reset();
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
template: `<div style="width: 480px">
|
|
183
|
+
|
|
184
|
+
<farm-label>Not Required</farm-label>
|
|
185
|
+
<farm-textfield-v2 v-model="v" ref="input" />
|
|
186
|
+
|
|
187
|
+
<farm-label required>Required</farm-label>
|
|
188
|
+
<farm-textfield-v2 v-model="v" ref="inputValidatable" :rules="[rules.required]" />
|
|
189
|
+
|
|
190
|
+
<farm-btn @click="reset">reset</farm-btn>
|
|
191
|
+
|
|
192
|
+
</div>`,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
export const Mask = () => ({
|
|
196
|
+
data() {
|
|
197
|
+
return {
|
|
198
|
+
v: '',
|
|
199
|
+
v2: '',
|
|
200
|
+
mask: '###.###.###/##',
|
|
201
|
+
currencyMask,
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
template: `<div style="width: 480px">
|
|
205
|
+
<farm-label>CPF Mask ({{ mask }})</farm-label>
|
|
206
|
+
<farm-textfield-v2 v-model="v" :v-mask="mask" />
|
|
207
|
+
v-model: {{ v }}
|
|
208
|
+
|
|
209
|
+
<farm-label>Number Mask (R$ ##.###.###,##)</farm-label>
|
|
210
|
+
<farm-textfield-v2 v-model="v2" :v-mask="currencyMask" />
|
|
211
|
+
v-model: {{ v2 }}
|
|
212
|
+
|
|
213
|
+
</div>`,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export const ToggleVisibility = () => ({
|
|
217
|
+
data() {
|
|
218
|
+
return {
|
|
219
|
+
v: 'hidden password',
|
|
220
|
+
visible: false,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
methods: {
|
|
224
|
+
toggle() {
|
|
225
|
+
this.visible = !this.visible;
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
template: `<div style="width: 480px">
|
|
229
|
+
<farm-textfield-v2 v-model="v" :type="visible ? 'text' : 'password'" :icon="visible ? 'eye-off' : 'eye'" @onClickIcon="toggle" />
|
|
230
|
+
</div>`,
|
|
231
|
+
});
|
|
@@ -10,28 +10,28 @@
|
|
|
10
10
|
}"
|
|
11
11
|
>
|
|
12
12
|
<div class="farm-textfield--input">
|
|
13
|
-
<button v-if="icon && iconPosition === 'left'" @click="$emit('onClickIcon')">
|
|
13
|
+
<button type="button" v-if="icon && iconPosition === 'left'" @click="$emit('onClickIcon')">
|
|
14
14
|
<farm-icon color="gray" size="20px">{{ icon }}</farm-icon>
|
|
15
15
|
</button>
|
|
16
|
-
|
|
17
16
|
<input
|
|
18
17
|
v-bind="$attrs"
|
|
19
18
|
v-model="innerValue"
|
|
19
|
+
v-mask="$props.vMask"
|
|
20
20
|
:disabled="disabled"
|
|
21
|
+
:readonly="readonly"
|
|
21
22
|
@keyup="onKeyUp"
|
|
22
23
|
@blur="onBlur"
|
|
23
24
|
/>
|
|
24
|
-
|
|
25
|
-
<button v-if="icon && iconPosition === 'right'" @click="$emit('onClickIcon')">
|
|
25
|
+
<button type="button" v-if="icon && iconPosition === 'right'" @click="$emit('onClickIcon')">
|
|
26
26
|
<farm-icon color="gray" size="20px">{{ icon }}</farm-icon>
|
|
27
27
|
</button>
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
|
-
<farm-caption v-if="
|
|
30
|
+
<farm-caption v-if="showErrorText" color="error" variation="regular">
|
|
31
31
|
{{ errorBucket[0] }}
|
|
32
32
|
</farm-caption>
|
|
33
|
-
<farm-caption v-if="
|
|
34
|
-
{{
|
|
33
|
+
<farm-caption v-if="hint && !showErrorText" color="gray" variation="regular">
|
|
34
|
+
{{ hint }}
|
|
35
35
|
</farm-caption>
|
|
36
36
|
</div>
|
|
37
37
|
</template>
|
|
@@ -65,17 +65,24 @@ export default Vue.extend({
|
|
|
65
65
|
/**
|
|
66
66
|
* Show hint text
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
hint: {
|
|
69
69
|
type: String,
|
|
70
70
|
default: null,
|
|
71
71
|
},
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Disabled the input
|
|
74
74
|
*/
|
|
75
75
|
disabled: {
|
|
76
76
|
type: Boolean,
|
|
77
77
|
default: false,
|
|
78
78
|
},
|
|
79
|
+
/**
|
|
80
|
+
* Puts input in readonly state
|
|
81
|
+
*/
|
|
82
|
+
readonly: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false,
|
|
85
|
+
},
|
|
79
86
|
|
|
80
87
|
errorMessage: String,
|
|
81
88
|
/**
|
|
@@ -85,6 +92,13 @@ export default Vue.extend({
|
|
|
85
92
|
type: Array as PropType<Array<Function>>,
|
|
86
93
|
default: () => [],
|
|
87
94
|
},
|
|
95
|
+
/**
|
|
96
|
+
* Mask
|
|
97
|
+
*/
|
|
98
|
+
vMask: {
|
|
99
|
+
default: '',
|
|
100
|
+
type: [String, Function],
|
|
101
|
+
},
|
|
88
102
|
},
|
|
89
103
|
setup(props, { emit }) {
|
|
90
104
|
const { rules } = toRefs(props);
|
|
@@ -100,6 +114,8 @@ export default Vue.extend({
|
|
|
100
114
|
return errorBucket.value.length > 0;
|
|
101
115
|
});
|
|
102
116
|
|
|
117
|
+
const showErrorText = computed(() => hasError.value && isTouched.value);
|
|
118
|
+
|
|
103
119
|
watch(
|
|
104
120
|
() => props.value,
|
|
105
121
|
() => {
|
|
@@ -112,6 +128,7 @@ export default Vue.extend({
|
|
|
112
128
|
() => innerValue.value,
|
|
113
129
|
() => {
|
|
114
130
|
emit('input', innerValue.value);
|
|
131
|
+
emit('change', innerValue.value);
|
|
115
132
|
}
|
|
116
133
|
);
|
|
117
134
|
|
|
@@ -139,6 +156,12 @@ export default Vue.extend({
|
|
|
139
156
|
isBlured.value = true;
|
|
140
157
|
};
|
|
141
158
|
|
|
159
|
+
const reset = () => {
|
|
160
|
+
innerValue.value = '';
|
|
161
|
+
isTouched.value = true;
|
|
162
|
+
emit('input', innerValue.value);
|
|
163
|
+
};
|
|
164
|
+
|
|
142
165
|
return {
|
|
143
166
|
innerValue,
|
|
144
167
|
errorBucket,
|
|
@@ -147,9 +170,11 @@ export default Vue.extend({
|
|
|
147
170
|
hasError,
|
|
148
171
|
isTouched,
|
|
149
172
|
isBlured,
|
|
173
|
+
showErrorText,
|
|
150
174
|
validate,
|
|
151
175
|
onKeyUp,
|
|
152
176
|
onBlur,
|
|
177
|
+
reset,
|
|
153
178
|
};
|
|
154
179
|
},
|
|
155
180
|
});
|
|
@@ -3,9 +3,11 @@ import TextFieldV2 from '../TextFieldV2';
|
|
|
3
3
|
|
|
4
4
|
describe('TextFieldV2 component', () => {
|
|
5
5
|
let wrapper;
|
|
6
|
+
let component;
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
8
9
|
wrapper = shallowMount(TextFieldV2);
|
|
10
|
+
component = wrapper.vm;
|
|
9
11
|
});
|
|
10
12
|
|
|
11
13
|
test('Created hook', () => {
|
|
@@ -17,4 +19,23 @@ describe('TextFieldV2 component', () => {
|
|
|
17
19
|
expect(wrapper.element).toMatchSnapshot();
|
|
18
20
|
});
|
|
19
21
|
});
|
|
22
|
+
|
|
23
|
+
describe('methods', () => {
|
|
24
|
+
it('reset', () => {
|
|
25
|
+
component.reset();
|
|
26
|
+
expect(component.isTouched).toBeTruthy();
|
|
27
|
+
expect(component.innerValue).toEqual('');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('onKeyUp', () => {
|
|
31
|
+
component.onKeyUp();
|
|
32
|
+
expect(component.isTouched).toBeTruthy();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('onBlur', () => {
|
|
36
|
+
component.onBlur();
|
|
37
|
+
expect(component.isBlured).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
});
|
|
20
41
|
});
|
|
@@ -21,7 +21,7 @@ export default Vue.extend({
|
|
|
21
21
|
/**
|
|
22
22
|
* Type of the heading
|
|
23
23
|
*/
|
|
24
|
-
type: { type: Number as PropType<1 | 2 | 3 | 4 | 5 | 6>, default: 1 },
|
|
24
|
+
type: { type: [String, Number] as PropType<1 | 2 | 3 | 4 | 5 | 6>, default: 1 },
|
|
25
25
|
},
|
|
26
26
|
setup(props) {
|
|
27
27
|
const { type } = toRefs(props);
|
|
@@ -24,15 +24,15 @@ export const Primary = () => ({
|
|
|
24
24
|
};
|
|
25
25
|
},
|
|
26
26
|
template: `<div>
|
|
27
|
-
<
|
|
27
|
+
<div v-for="type in types" :key="type">
|
|
28
28
|
<farm-subtitle
|
|
29
29
|
v-for="variation in variations"
|
|
30
|
-
:key="variation"
|
|
30
|
+
:key="'primary_' + variation + type"
|
|
31
31
|
:type="type"
|
|
32
32
|
:variation="variation">
|
|
33
33
|
Subtitle {{ type }} {{ variation }}
|
|
34
34
|
</farm-subtitle>
|
|
35
|
-
</
|
|
35
|
+
</div>
|
|
36
36
|
</div>`,
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -47,7 +47,7 @@ export const CustomTag = () => ({
|
|
|
47
47
|
<farm-subtitle
|
|
48
48
|
v-for="t in tags"
|
|
49
49
|
:tag="t"
|
|
50
|
-
:key="t"
|
|
50
|
+
:key="'customtag_' + t"
|
|
51
51
|
:type="1"
|
|
52
52
|
variation="regular"
|
|
53
53
|
>
|