@farm-investimentos/front-mfe-components 11.9.0 → 11.10.0
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 +283 -147
- 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 +283 -147
- 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.scss +4 -0
- package/src/components/Checkbox/Checkbox.stories.js +12 -9
- package/src/components/Checkbox/Checkbox.vue +30 -6
- package/src/components/Form/Form.stories.js +14 -16
- package/src/components/Logos/OriginatorLogo/OriginatorLogo.vue +1 -1
- package/src/components/Logos/ProductLogo/ProductLogo.vue +1 -1
- package/src/components/Radio/Radio.vue +1 -1
- package/src/components/ValueCaption/ValueCaption.scss +19 -0
- package/src/components/ValueCaption/ValueCaption.stories.js +33 -0
- package/src/components/ValueCaption/ValueCaption.vue +60 -0
- package/src/components/ValueCaption/__tests__/ValueCaption.spec.js +14 -0
- package/src/components/ValueCaption/index.ts +4 -0
- package/src/main.ts +1 -0
package/package.json
CHANGED
|
@@ -23,22 +23,24 @@ export default {
|
|
|
23
23
|
export const Primary = () => ({
|
|
24
24
|
data() {
|
|
25
25
|
return {
|
|
26
|
-
isChecked:
|
|
26
|
+
isChecked: null,
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
29
|
template: `<div>
|
|
30
|
-
<farm-checkbox v-model="isChecked" />
|
|
30
|
+
<farm-checkbox v-model="isChecked" value="1" />
|
|
31
|
+
isChecked (value): {{ isChecked }}
|
|
31
32
|
</div>`,
|
|
32
33
|
});
|
|
33
34
|
|
|
34
|
-
export const
|
|
35
|
+
export const DefaultCheck = () => ({
|
|
35
36
|
data() {
|
|
36
37
|
return {
|
|
37
38
|
isChecked: true,
|
|
38
39
|
};
|
|
39
40
|
},
|
|
40
41
|
template: `<div>
|
|
41
|
-
<farm-checkbox v-model="isChecked" />
|
|
42
|
+
<farm-checkbox v-model="isChecked" :value="true" />
|
|
43
|
+
isChecked (value): {{ isChecked }}
|
|
42
44
|
</div>`,
|
|
43
45
|
});
|
|
44
46
|
|
|
@@ -49,7 +51,7 @@ export const WithLabel = () => ({
|
|
|
49
51
|
};
|
|
50
52
|
},
|
|
51
53
|
template: `<div>
|
|
52
|
-
<farm-checkbox v-model="isChecked" label="custom label" />
|
|
54
|
+
<farm-checkbox v-model="isChecked" value="1" label="custom label" />
|
|
53
55
|
</div>`,
|
|
54
56
|
});
|
|
55
57
|
|
|
@@ -61,8 +63,8 @@ export const Disabled = () => ({
|
|
|
61
63
|
};
|
|
62
64
|
},
|
|
63
65
|
template: `<div>
|
|
64
|
-
<farm-checkbox v-model="isChecked" :disabled="true" /><br />
|
|
65
|
-
<farm-checkbox v-model="notIsChecked" :disabled="true" />
|
|
66
|
+
<farm-checkbox v-model="isChecked" :value="true" :disabled="true" /><br />
|
|
67
|
+
<farm-checkbox v-model="notIsChecked" value="" :disabled="true" />
|
|
66
68
|
</div>`,
|
|
67
69
|
});
|
|
68
70
|
|
|
@@ -84,6 +86,7 @@ export const Colors = () => ({
|
|
|
84
86
|
>
|
|
85
87
|
<farm-checkbox
|
|
86
88
|
v-model="isChecked"
|
|
89
|
+
:value="true"
|
|
87
90
|
:color="color"
|
|
88
91
|
:variation="variation"
|
|
89
92
|
:label="variation || 'Base'"
|
|
@@ -102,7 +105,7 @@ export const Sizes = () => ({
|
|
|
102
105
|
},
|
|
103
106
|
template: `<div style="display: flex; flex-direction: column; flex-wrap: wrap;">
|
|
104
107
|
<div v-for="size of sizes">
|
|
105
|
-
<farm-checkbox v-model="isChecked" :size="size" :label="size" /><br />
|
|
108
|
+
<farm-checkbox v-model="isChecked" :size="size" :value="true" :label="size" /><br />
|
|
106
109
|
</div>
|
|
107
110
|
</div>`,
|
|
108
111
|
});
|
|
@@ -115,6 +118,6 @@ export const Indeterminate = () => ({
|
|
|
115
118
|
};
|
|
116
119
|
},
|
|
117
120
|
template: `<div>
|
|
118
|
-
<farm-checkbox :indeterminate="true" v-model="isChecked" />
|
|
121
|
+
<farm-checkbox :indeterminate="true" v-model="isChecked" :value="true" />
|
|
119
122
|
</div>`,
|
|
120
123
|
});
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
<span
|
|
4
4
|
:class="{
|
|
5
5
|
'farm-checkbox': true,
|
|
6
|
-
'farm-checkbox--checked':
|
|
6
|
+
'farm-checkbox--checked': isChecked,
|
|
7
7
|
'farm-checkbox--disabled': disabled,
|
|
8
8
|
'farm-checkbox--indeterminate': indeterminate,
|
|
9
9
|
'farm-checkbox--lighten': variation === 'lighten',
|
|
10
10
|
'farm-checkbox--darken': variation === 'darken',
|
|
11
|
+
'farm-checkbox--error': showError,
|
|
11
12
|
}"
|
|
12
13
|
:size="$props.size"
|
|
13
14
|
@click="toggleValue"
|
|
@@ -30,11 +31,18 @@ import deepEqual from '../../composition/deepEqual';
|
|
|
30
31
|
|
|
31
32
|
export default Vue.extend({
|
|
32
33
|
name: 'farm-checkbox',
|
|
34
|
+
model: {
|
|
35
|
+
prop: 'modelValue',
|
|
36
|
+
},
|
|
33
37
|
props: {
|
|
34
38
|
/**
|
|
35
39
|
* v-model binding
|
|
36
40
|
*/
|
|
37
|
-
|
|
41
|
+
modelValue: {},
|
|
42
|
+
/**
|
|
43
|
+
* Value to be set to v-model
|
|
44
|
+
*/
|
|
45
|
+
value: { type: [String, Number, Boolean], default: undefined },
|
|
38
46
|
/**
|
|
39
47
|
* Label
|
|
40
48
|
*/
|
|
@@ -85,28 +93,40 @@ export default Vue.extend({
|
|
|
85
93
|
indeterminate: { type: Boolean, default: false },
|
|
86
94
|
},
|
|
87
95
|
setup(props, { emit }) {
|
|
88
|
-
const innerValue = ref(props.
|
|
96
|
+
const innerValue = ref(props.modelValue);
|
|
89
97
|
const { label, disabled, rules } = toRefs(props);
|
|
90
98
|
const { errorBucket, valid, validatable } = validateFormStateBuilder();
|
|
91
|
-
|
|
99
|
+
const isTouched = ref(false);
|
|
92
100
|
let fieldValidator = validateFormFieldBuilder(rules.value);
|
|
93
101
|
|
|
94
102
|
const toggleValue = () => {
|
|
95
103
|
if (disabled.value) {
|
|
96
104
|
return false;
|
|
97
105
|
}
|
|
98
|
-
|
|
106
|
+
isTouched.value = true;
|
|
107
|
+
if (isChecked.value) {
|
|
108
|
+
innerValue.value = null;
|
|
109
|
+
} else {
|
|
110
|
+
innerValue.value = props.value;
|
|
111
|
+
}
|
|
99
112
|
emit('input', innerValue.value);
|
|
100
113
|
validate(innerValue.value);
|
|
101
114
|
};
|
|
102
115
|
|
|
116
|
+
const isChecked = computed(() => {
|
|
117
|
+
return innerValue.value == props.value;
|
|
118
|
+
});
|
|
119
|
+
|
|
103
120
|
const hasError = computed(() => {
|
|
104
121
|
return errorBucket.value.length > 0;
|
|
105
122
|
});
|
|
106
123
|
|
|
124
|
+
const showError = computed(() => hasError.value && isTouched.value);
|
|
125
|
+
|
|
107
126
|
watch(
|
|
108
127
|
() => props.value,
|
|
109
128
|
() => {
|
|
129
|
+
isTouched.value = true;
|
|
110
130
|
innerValue.value = props.value;
|
|
111
131
|
validate(innerValue.value);
|
|
112
132
|
}
|
|
@@ -126,7 +146,9 @@ export default Vue.extend({
|
|
|
126
146
|
if (disabled.value) {
|
|
127
147
|
return false;
|
|
128
148
|
}
|
|
129
|
-
|
|
149
|
+
isTouched.value = true;
|
|
150
|
+
innerValue.value = null;
|
|
151
|
+
validate(innerValue.value);
|
|
130
152
|
emit('input', innerValue.value);
|
|
131
153
|
};
|
|
132
154
|
|
|
@@ -144,9 +166,11 @@ export default Vue.extend({
|
|
|
144
166
|
valid,
|
|
145
167
|
validatable,
|
|
146
168
|
hasError,
|
|
169
|
+
isChecked,
|
|
147
170
|
toggleValue,
|
|
148
171
|
reset,
|
|
149
172
|
validate,
|
|
173
|
+
showError,
|
|
150
174
|
};
|
|
151
175
|
},
|
|
152
176
|
});
|
|
@@ -26,14 +26,13 @@ const styles = {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
/*
|
|
30
29
|
export const Primary = () => ({
|
|
31
30
|
data() {
|
|
32
31
|
return {
|
|
33
32
|
form: {
|
|
34
33
|
document: 'Document',
|
|
35
34
|
name: 'Name',
|
|
36
|
-
checkbox:
|
|
35
|
+
checkbox: '2',
|
|
37
36
|
birthDate: new Date('1980/09/20').toISOString(),
|
|
38
37
|
selectId: 1,
|
|
39
38
|
rangeDate: [],
|
|
@@ -55,16 +54,16 @@ export const Primary = () => ({
|
|
|
55
54
|
<farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
|
|
56
55
|
<div>
|
|
57
56
|
<farm-label :required="true">Documento</farm-label>
|
|
58
|
-
<farm-textfield v-model="form.document" :rules="[rules.required]" />
|
|
57
|
+
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
59
58
|
</div>
|
|
60
59
|
<farm-label :required="true">Nome</farm-label>
|
|
61
|
-
<farm-textfield v-model="form.name" :rules="[rules.required]" />
|
|
60
|
+
<farm-textfield-v2 v-model="form.name" :rules="[rules.required]" />
|
|
62
61
|
|
|
63
62
|
<farm-label :required="true">True/false</farm-label>
|
|
64
|
-
<farm-checkbox v-model="form.checkbox" :rules="[rules.checked]" />
|
|
63
|
+
<farm-checkbox v-model="form.checkbox" value="1" :rules="[rules.checked]" />
|
|
65
64
|
|
|
66
65
|
<farm-label :required="true">Select</farm-label>
|
|
67
|
-
<
|
|
66
|
+
<farm-select :rules="[rules.required]" :items="items" v-model="form.selectId"/>
|
|
68
67
|
|
|
69
68
|
<farm-label :required="true">Birthdate:</farm-label>
|
|
70
69
|
<farm-input-datepicker
|
|
@@ -120,7 +119,7 @@ export const Secondary = () => ({
|
|
|
120
119
|
<section>
|
|
121
120
|
<div>
|
|
122
121
|
<farm-label :required="true">Documento</farm-label>
|
|
123
|
-
<farm-textfield v-model="form.document" :rules="[rules.required]" />
|
|
122
|
+
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
124
123
|
</div>
|
|
125
124
|
</section>
|
|
126
125
|
<section>
|
|
@@ -131,11 +130,11 @@ export const Secondary = () => ({
|
|
|
131
130
|
</section>
|
|
132
131
|
|
|
133
132
|
<farm-label>Not required</farm-label>
|
|
134
|
-
<farm-checkbox v-model="form.checkbox" />
|
|
133
|
+
<farm-checkbox value="1" v-model="form.checkbox" />
|
|
135
134
|
|
|
136
135
|
<div class="footer" :style="[styles.footer]">
|
|
137
|
-
<farm-btn
|
|
138
|
-
<farm-btn
|
|
136
|
+
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
137
|
+
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
139
138
|
</div>
|
|
140
139
|
</farm-form>
|
|
141
140
|
`,
|
|
@@ -162,22 +161,22 @@ export const InitInvalid = () => ({
|
|
|
162
161
|
<section>
|
|
163
162
|
<div>
|
|
164
163
|
<farm-label :required="true">Documento</farm-label>
|
|
165
|
-
<farm-textfield v-model="form.document" :rules="[rules.required]" />
|
|
164
|
+
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
166
165
|
</div>
|
|
167
166
|
</section>
|
|
168
167
|
<section>
|
|
169
168
|
<div>
|
|
170
169
|
<farm-label :required="true">Nome</farm-label>
|
|
171
|
-
<farm-textfield v-model="form.name" :rules="[rules.required]" />
|
|
170
|
+
<farm-textfield-v2 v-model="form.name" :rules="[rules.required]" />
|
|
172
171
|
</div>
|
|
173
172
|
</section>
|
|
174
173
|
|
|
175
174
|
<farm-label :required="true">True/false</farm-label>
|
|
176
|
-
<farm-checkbox v-model="form.checkbox" :rules="[rules.checked]" />
|
|
175
|
+
<farm-checkbox v-model="form.checkbox" value="1" :rules="[rules.checked]" />
|
|
177
176
|
|
|
178
177
|
<div class="footer" :style="[styles.footer]">
|
|
179
|
-
<farm-btn
|
|
180
|
-
<farm-btn
|
|
178
|
+
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
179
|
+
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
181
180
|
</div>
|
|
182
181
|
</farm-form>
|
|
183
182
|
`,
|
|
@@ -311,7 +310,6 @@ export const MigrateSelectV2 = () => ({
|
|
|
311
310
|
</farm-form>
|
|
312
311
|
`,
|
|
313
312
|
});
|
|
314
|
-
*/
|
|
315
313
|
|
|
316
314
|
export const ValidateRadioGroup = () => ({
|
|
317
315
|
data() {
|
|
@@ -26,7 +26,7 @@ export default Vue.extend({
|
|
|
26
26
|
imgSrc() {
|
|
27
27
|
const href = window.location.href;
|
|
28
28
|
return `${
|
|
29
|
-
href.indexOf('localhost') || href.indexOf('front-farm-storybook')
|
|
29
|
+
href.indexOf('localhost') >= 0 || href.indexOf('front-farm-storybook') >= 0
|
|
30
30
|
? 'https://dev.plataforma.portalfarm.com.br'
|
|
31
31
|
: ''
|
|
32
32
|
}/public/logos/originadores/${this.id}/${this.variation}.svg`;
|
|
@@ -26,7 +26,7 @@ export default Vue.extend({
|
|
|
26
26
|
imgSrc() {
|
|
27
27
|
const href = window.location.href;
|
|
28
28
|
return `${
|
|
29
|
-
href.indexOf('localhost') || href.indexOf('front-farm-storybook')
|
|
29
|
+
href.indexOf('localhost') >= 0 || href.indexOf('front-farm-storybook') >= 0
|
|
30
30
|
? 'https://dev.plataforma.portalfarm.com.br'
|
|
31
31
|
: ''
|
|
32
32
|
}/public/logos/products/${this.id}/${this.variation}.svg`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.farm-valuecaption {
|
|
2
|
+
display: flex;
|
|
3
|
+
|
|
4
|
+
.farm-icon-box {
|
|
5
|
+
margin-right: 8px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
div.farm-valuecaption__content {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
|
|
13
|
+
p {
|
|
14
|
+
margin-bottom: 0;
|
|
15
|
+
word-break: break-word;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { withDesign } from 'storybook-addon-designs';
|
|
2
|
+
import ValueCaption from '.';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Display/ValueCaption',
|
|
6
|
+
component: ValueCaption,
|
|
7
|
+
decorators: [withDesign],
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: `Value Caption<br />
|
|
12
|
+
selector: <em>farm-valuecaption</em>
|
|
13
|
+
`,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
viewMode: 'docs',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Primary = () => ({
|
|
21
|
+
template: `
|
|
22
|
+
<farm-valuecaption
|
|
23
|
+
icon="account-box-outline"
|
|
24
|
+
>
|
|
25
|
+
<template v-slot:title>
|
|
26
|
+
Upper Line Text
|
|
27
|
+
</template>
|
|
28
|
+
<template v-slot:subtitle>
|
|
29
|
+
R$ 1.000.000,00
|
|
30
|
+
</template>
|
|
31
|
+
</farm-valuecaption>
|
|
32
|
+
`,
|
|
33
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="farm-valuecaption">
|
|
3
|
+
<farm-icon-box v-if="icon" :icon="icon" :color="iconBoxColor" size="md" />
|
|
4
|
+
<div class="farm-valuecaption__content">
|
|
5
|
+
<farm-caption variation="regular" color="gray" v-if="hasTitle">
|
|
6
|
+
<slot name="title"></slot>
|
|
7
|
+
</farm-caption>
|
|
8
|
+
|
|
9
|
+
<farm-bodytext bodytext type="1" variation="bold" v-if="hasSubtitle">
|
|
10
|
+
<slot name="subtitle"></slot>
|
|
11
|
+
</farm-bodytext>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import Vue, { computed, PropType } from 'vue';
|
|
18
|
+
export default Vue.extend({
|
|
19
|
+
name: 'farm-valuecaption',
|
|
20
|
+
props: {
|
|
21
|
+
/**
|
|
22
|
+
* Icon (from Material Icons)
|
|
23
|
+
* Example: chart-bar
|
|
24
|
+
*/
|
|
25
|
+
icon: {
|
|
26
|
+
type: String,
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* IconBox Color
|
|
30
|
+
*/
|
|
31
|
+
iconBoxColor: {
|
|
32
|
+
type: String as PropType<
|
|
33
|
+
| 'primary'
|
|
34
|
+
| 'secondary'
|
|
35
|
+
| 'neutral'
|
|
36
|
+
| 'info'
|
|
37
|
+
| 'success'
|
|
38
|
+
| 'error'
|
|
39
|
+
| 'warning'
|
|
40
|
+
| 'success'
|
|
41
|
+
| 'extra-1'
|
|
42
|
+
| 'extra-2'
|
|
43
|
+
| 'gray'
|
|
44
|
+
>,
|
|
45
|
+
default: 'primary',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
setup(_, { slots }) {
|
|
50
|
+
const hasTitle = computed(() => slots.title);
|
|
51
|
+
const hasSubtitle = computed(() => slots.subtitle);
|
|
52
|
+
|
|
53
|
+
return { hasSubtitle, hasTitle };
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<style lang="scss" scoped>
|
|
59
|
+
@import './ValueCaption';
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import ValueCaption from '../ValueCaption.vue';
|
|
3
|
+
|
|
4
|
+
describe('ValueCaption component', () => {
|
|
5
|
+
let wrapper;
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
wrapper = shallowMount(ValueCaption);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('Created hook', () => {
|
|
12
|
+
expect(wrapper).toBeDefined();
|
|
13
|
+
});
|
|
14
|
+
});
|
package/src/main.ts
CHANGED
|
@@ -91,6 +91,7 @@ export * from './components/TextField';
|
|
|
91
91
|
export * from './components/TextFieldV2';
|
|
92
92
|
export * from './components/Tooltip';
|
|
93
93
|
export * from './components/Typography';
|
|
94
|
+
export * from './components/ValueCaption';
|
|
94
95
|
|
|
95
96
|
export * from './components/layout/Box';
|
|
96
97
|
export * from './components/layout/Col';
|