@farm-investimentos/front-mfe-components 11.10.4 → 11.10.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/dist/front-mfe-components.common.js +544 -527
- 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 +544 -527
- 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/Checkbox/Checkbox.vue +6 -0
- package/src/components/Checkbox/__tests__/Checkbox.spec.js +10 -0
- package/src/components/DialogFooter/DialogFooter.vue +0 -6
- package/src/components/Form/Form.stories.js +52 -0
- package/src/components/Form/Form.vue +1 -0
- package/src/components/Logos/ProductLogo/ProductLogo.stories.js +8 -1
- package/src/components/ModalPromptUser/ModalPromptUser.stories.js +24 -0
- package/src/components/ModalPromptUser/ModalPromptUser.vue +30 -10
- package/src/components/Select/Select.vue +6 -1
- package/src/components/Select/__tests__/Select.spec.js +6 -0
- package/src/components/TextFieldV2/TextFieldV2.vue +6 -0
- package/src/components/TextFieldV2/__tests__/TextFieldV2.spec.js +7 -0
package/package.json
CHANGED
|
@@ -158,6 +158,10 @@ export default Vue.extend({
|
|
|
158
158
|
|
|
159
159
|
let validate = validateFormMethodBuilder(errorBucket, valid, fieldValidator);
|
|
160
160
|
|
|
161
|
+
const makePristine = () => {
|
|
162
|
+
isTouched.value = false;
|
|
163
|
+
};
|
|
164
|
+
|
|
161
165
|
return {
|
|
162
166
|
innerValue,
|
|
163
167
|
label,
|
|
@@ -171,6 +175,8 @@ export default Vue.extend({
|
|
|
171
175
|
reset,
|
|
172
176
|
validate,
|
|
173
177
|
showError,
|
|
178
|
+
makePristine,
|
|
179
|
+
isTouched,
|
|
174
180
|
};
|
|
175
181
|
},
|
|
176
182
|
});
|
|
@@ -3,6 +3,7 @@ import Checkbox from '../Checkbox';
|
|
|
3
3
|
|
|
4
4
|
describe('Checkbox component', () => {
|
|
5
5
|
let wrapper;
|
|
6
|
+
let component;
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
8
9
|
wrapper = shallowMount(Checkbox, {
|
|
@@ -10,6 +11,7 @@ describe('Checkbox component', () => {
|
|
|
10
11
|
value: false,
|
|
11
12
|
},
|
|
12
13
|
});
|
|
14
|
+
component = wrapper.vm;
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
test('Created hook', () => {
|
|
@@ -21,4 +23,12 @@ describe('Checkbox component', () => {
|
|
|
21
23
|
expect(wrapper.element).toMatchSnapshot();
|
|
22
24
|
});
|
|
23
25
|
});
|
|
26
|
+
|
|
27
|
+
describe('methods', () => {
|
|
28
|
+
it('makePristine', () => {
|
|
29
|
+
component.isTouched = true;
|
|
30
|
+
component.makePristine();
|
|
31
|
+
expect(component.isTouched).toBeFalsy();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
24
34
|
});
|
|
@@ -30,8 +30,6 @@
|
|
|
30
30
|
|
|
31
31
|
<script lang="ts">
|
|
32
32
|
import Vue, { PropType } from 'vue';
|
|
33
|
-
import DefaultButton from '../Buttons/DefaultButton';
|
|
34
|
-
import Icon from '../Icon';
|
|
35
33
|
import IExtraButton from './IExtraButton';
|
|
36
34
|
|
|
37
35
|
/**
|
|
@@ -39,10 +37,6 @@ import IExtraButton from './IExtraButton';
|
|
|
39
37
|
*/
|
|
40
38
|
export default Vue.extend({
|
|
41
39
|
name: 'farm-dialog-footer',
|
|
42
|
-
components: {
|
|
43
|
-
'farm-btn': DefaultButton,
|
|
44
|
-
'farm-icon': Icon,
|
|
45
|
-
},
|
|
46
40
|
props: {
|
|
47
41
|
/**
|
|
48
42
|
* Label do botão de confirmação
|
|
@@ -333,3 +333,55 @@ export const ValidateRadioGroup = () => ({
|
|
|
333
333
|
</farm-form>
|
|
334
334
|
`,
|
|
335
335
|
});
|
|
336
|
+
|
|
337
|
+
export const RestartValidation = () => ({
|
|
338
|
+
data() {
|
|
339
|
+
return {
|
|
340
|
+
form: {
|
|
341
|
+
document: null,
|
|
342
|
+
name: null,
|
|
343
|
+
checkbox: null,
|
|
344
|
+
birthDate: '',
|
|
345
|
+
selectId: null,
|
|
346
|
+
rangeDate: [],
|
|
347
|
+
},
|
|
348
|
+
validForm: true,
|
|
349
|
+
rules: {
|
|
350
|
+
required: value => !!value || 'Campo obrigatório',
|
|
351
|
+
checked: value => !!value || 'Deve estar marcado',
|
|
352
|
+
},
|
|
353
|
+
items: [
|
|
354
|
+
{ value: null, text: '' },
|
|
355
|
+
{ value: 1, text: 'label 1' },
|
|
356
|
+
{ value: 2, text: 'label 2' },
|
|
357
|
+
],
|
|
358
|
+
styles,
|
|
359
|
+
};
|
|
360
|
+
},
|
|
361
|
+
template: `
|
|
362
|
+
<farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
|
|
363
|
+
{{ validForm }}
|
|
364
|
+
|
|
365
|
+
<farm-label :required="true">Nome</farm-label>
|
|
366
|
+
<farm-textfield-v2 v-model="form.name" :rules="[rules.required]" />
|
|
367
|
+
|
|
368
|
+
<div>
|
|
369
|
+
<farm-label :required="true">Documento</farm-label>
|
|
370
|
+
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
<farm-label :required="true">True/false</farm-label>
|
|
375
|
+
<farm-checkbox v-model="form.checkbox" value="1" :rules="[rules.checked]" />
|
|
376
|
+
|
|
377
|
+
<farm-label :required="true">Select</farm-label>
|
|
378
|
+
<farm-select :rules="[rules.required]" :items="items" v-model="form.selectId"/>
|
|
379
|
+
|
|
380
|
+
<div class="footer" :style="[styles.footer]">
|
|
381
|
+
<farm-btn outlined @click="$refs.form.restartValidation()" class="mr-3">Restart Validation</farm-btn>
|
|
382
|
+
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
383
|
+
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
384
|
+
</div>
|
|
385
|
+
</farm-form>
|
|
386
|
+
`,
|
|
387
|
+
});
|
|
@@ -6,7 +6,14 @@ export default {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export const Primary = () => ({
|
|
9
|
-
|
|
9
|
+
data() {
|
|
10
|
+
return {
|
|
11
|
+
ids: [34, 31208, 31228, 31238, 80000, 90000, 110000, 116000, 118000, 119000],
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
template: `<div>
|
|
15
|
+
<farm-imglogo-product v-for="id in ids" :key="'logo_'+ id" alt="primary" :id="id" />
|
|
16
|
+
</div>`,
|
|
10
17
|
});
|
|
11
18
|
|
|
12
19
|
Primary.storyName = 'Básico';
|
|
@@ -35,6 +35,7 @@ export const Primary = () => ({
|
|
|
35
35
|
</farm-btn>
|
|
36
36
|
</div>`,
|
|
37
37
|
});
|
|
38
|
+
|
|
38
39
|
export const Error = () => ({
|
|
39
40
|
data() {
|
|
40
41
|
return {
|
|
@@ -48,3 +49,26 @@ export const Error = () => ({
|
|
|
48
49
|
</farm-btn>
|
|
49
50
|
</div>`,
|
|
50
51
|
});
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export const ButtonLabels = () => ({
|
|
55
|
+
data() {
|
|
56
|
+
return {
|
|
57
|
+
showPrompt: false,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
template: `<div>
|
|
61
|
+
<farm-prompt-user
|
|
62
|
+
match="CONFIRMAR"
|
|
63
|
+
title="Título"
|
|
64
|
+
subtitle="Digite CONFIRMAR para habilitar"
|
|
65
|
+
confirmLabel="SIM"
|
|
66
|
+
closeLabel="NÃO"
|
|
67
|
+
v-model="showPrompt"
|
|
68
|
+
/>
|
|
69
|
+
click:
|
|
70
|
+
<farm-btn @click="showPrompt = true;">
|
|
71
|
+
reabrir
|
|
72
|
+
</farm-btn>
|
|
73
|
+
</div>`,
|
|
74
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<farm-modal v-model="inputVal" size="sm" :offsetTop="48" :offsetBottom="68">
|
|
3
3
|
<template v-slot:header>
|
|
4
|
-
<
|
|
4
|
+
<farm-dialog-header :title="title" @onClose="close" />
|
|
5
5
|
</template>
|
|
6
6
|
<template v-slot:content>
|
|
7
7
|
<section class="modal-content">
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<template v-slot:footer>
|
|
18
|
-
<
|
|
18
|
+
<farm-dialog-footer
|
|
19
19
|
:confirmColor="confirmColor"
|
|
20
20
|
:confirmLabel="confirmLabel"
|
|
21
|
+
:closeLabel="closeLabel"
|
|
21
22
|
:isConfirmDisabled="!canConfirm"
|
|
22
23
|
@onConfirm="confirm"
|
|
23
24
|
@onClose="close"
|
|
@@ -26,47 +27,66 @@
|
|
|
26
27
|
</farm-modal>
|
|
27
28
|
</template>
|
|
28
29
|
<script lang="ts">
|
|
29
|
-
import Vue from 'vue';
|
|
30
|
+
import Vue, { PropType } from 'vue';
|
|
30
31
|
|
|
31
32
|
export default Vue.extend({
|
|
32
33
|
name: 'farm-prompt-user',
|
|
33
34
|
props: {
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
+
* Open/close modal
|
|
36
37
|
*/
|
|
37
38
|
value: {
|
|
38
39
|
required: true,
|
|
39
40
|
},
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* Modal title
|
|
42
43
|
*/
|
|
43
44
|
title: {
|
|
44
45
|
required: true,
|
|
45
46
|
type: String,
|
|
46
47
|
},
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
* Modal subtitle
|
|
49
50
|
*/
|
|
50
51
|
subtitle: {
|
|
51
52
|
required: true,
|
|
52
53
|
type: String,
|
|
53
54
|
},
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
+
* Confirm button color
|
|
56
57
|
*/
|
|
57
58
|
confirmColor: {
|
|
58
|
-
type: String
|
|
59
|
+
type: String as PropType<
|
|
60
|
+
| 'primary'
|
|
61
|
+
| 'secondary'
|
|
62
|
+
| 'neutral'
|
|
63
|
+
| 'info'
|
|
64
|
+
| 'success'
|
|
65
|
+
| 'error'
|
|
66
|
+
| 'warning'
|
|
67
|
+
| 'success'
|
|
68
|
+
| 'extra-1'
|
|
69
|
+
| 'extra-2'
|
|
70
|
+
| 'gray'
|
|
71
|
+
>,
|
|
59
72
|
default: 'primary',
|
|
60
73
|
},
|
|
61
74
|
/**
|
|
62
|
-
*
|
|
75
|
+
* Confirm button label
|
|
63
76
|
*/
|
|
64
77
|
confirmLabel: {
|
|
65
78
|
type: String,
|
|
66
79
|
default: 'Confirmar',
|
|
67
80
|
},
|
|
68
81
|
/**
|
|
69
|
-
*
|
|
82
|
+
* Close button label
|
|
83
|
+
*/
|
|
84
|
+
closeLabel: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: 'Fechar',
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* String to be matched (and enable confirm button)
|
|
70
90
|
*/
|
|
71
91
|
match: {
|
|
72
92
|
required: true,
|
|
@@ -218,8 +218,12 @@ export default Vue.extend({
|
|
|
218
218
|
emit('click');
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
+
const makePristine = () => {
|
|
222
|
+
isTouched.value = false;
|
|
223
|
+
};
|
|
224
|
+
|
|
221
225
|
const updateSelectedTextValue = () => {
|
|
222
|
-
if (!items.value || items.value.length === 0) {
|
|
226
|
+
if (!items.value || items.value.length === 0 || !innerValue.value) {
|
|
223
227
|
selectedText.value = '';
|
|
224
228
|
return;
|
|
225
229
|
}
|
|
@@ -250,6 +254,7 @@ export default Vue.extend({
|
|
|
250
254
|
onBlur,
|
|
251
255
|
clickInput,
|
|
252
256
|
updateSelectedTextValue,
|
|
257
|
+
makePristine,
|
|
253
258
|
};
|
|
254
259
|
},
|
|
255
260
|
});
|
|
@@ -41,5 +41,11 @@ describe('Select component', () => {
|
|
|
41
41
|
component.updateSelectedTextValue();
|
|
42
42
|
expect(component.selectedText).toBeDefined();
|
|
43
43
|
});
|
|
44
|
+
|
|
45
|
+
it('makePristine', () => {
|
|
46
|
+
component.isTouched = true;
|
|
47
|
+
component.makePristine();
|
|
48
|
+
expect(component.isTouched).toBeFalsy();
|
|
49
|
+
});
|
|
44
50
|
});
|
|
45
51
|
});
|
|
@@ -176,6 +176,11 @@ export default Vue.extend({
|
|
|
176
176
|
emit('input', innerValue.value);
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
const makePristine = () => {
|
|
180
|
+
isTouched.value = false;
|
|
181
|
+
isBlured.value = false;
|
|
182
|
+
};
|
|
183
|
+
|
|
179
184
|
return {
|
|
180
185
|
innerValue,
|
|
181
186
|
errorBucket,
|
|
@@ -189,6 +194,7 @@ export default Vue.extend({
|
|
|
189
194
|
onKeyUp,
|
|
190
195
|
onBlur,
|
|
191
196
|
reset,
|
|
197
|
+
makePristine,
|
|
192
198
|
};
|
|
193
199
|
},
|
|
194
200
|
});
|
|
@@ -37,5 +37,12 @@ describe('TextFieldV2 component', () => {
|
|
|
37
37
|
expect(component.isBlured).toBeTruthy();
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
it('makePristine', () => {
|
|
41
|
+
component.isTouched = true;
|
|
42
|
+
component.isBlured = true;
|
|
43
|
+
component.makePristine();
|
|
44
|
+
expect(component.isTouched).toBeFalsy();
|
|
45
|
+
expect(component.isBlured).toBeFalsy();
|
|
46
|
+
});
|
|
40
47
|
});
|
|
41
48
|
});
|