@farm-investimentos/front-mfe-components 12.0.0 → 12.0.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 +196 -188
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.css +2 -2
- package/dist/front-mfe-components.umd.js +196 -188
- 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.stories.js +29 -3
- package/src/components/Checkbox/Checkbox.vue +14 -16
- package/src/components/IconBox/IconBox.scss +4 -0
- package/src/components/IconBox/IconBox.vue +6 -12
- package/src/components/MultipleFilePicker/MultipleFilePicker.stories.js +4 -1
- package/src/components/MultipleFilePicker/MultipleFilePicker.vue +6 -4
- package/src/components/MultipleFilePicker/__tests__/MultipleFilePicker.spec.js +12 -0
- package/src/components/Radio/Radio.scss +64 -58
- package/src/components/Radio/Radio.stories.js +16 -0
- package/src/components/Radio/Radio.vue +19 -0
package/package.json
CHANGED
|
@@ -42,15 +42,15 @@ export const Value = () => ({
|
|
|
42
42
|
},
|
|
43
43
|
template: `<div>
|
|
44
44
|
<div class="d-flex">
|
|
45
|
-
<farm-checkbox v-model="option1" value="
|
|
45
|
+
<farm-checkbox v-model="option1" value="option1" class="mr-2" />
|
|
46
46
|
option1 : {{option1}}
|
|
47
47
|
</div>
|
|
48
48
|
<div class="d-flex align-center">
|
|
49
|
-
<farm-checkbox v-model="option2" value="
|
|
49
|
+
<farm-checkbox v-model="option2" value="option2" class="mr-2 my-2" />
|
|
50
50
|
option2 : {{option2}}
|
|
51
51
|
</div>
|
|
52
52
|
<div class="d-flex">
|
|
53
|
-
<farm-checkbox v-model="option3" value="
|
|
53
|
+
<farm-checkbox v-model="option3" value="option3" class="mr-2" />
|
|
54
54
|
option3 : {{option3}}
|
|
55
55
|
</div>
|
|
56
56
|
</div>`,
|
|
@@ -145,3 +145,29 @@ export const Indeterminate = () => ({
|
|
|
145
145
|
<farm-checkbox :indeterminate="true" v-model="isChecked" :value="true" />
|
|
146
146
|
</div>`,
|
|
147
147
|
});
|
|
148
|
+
|
|
149
|
+
export const ResetByValue = () => ({
|
|
150
|
+
data() {
|
|
151
|
+
return {
|
|
152
|
+
isChecked: true,
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
template: `<div>
|
|
156
|
+
<farm-checkbox v-model="isChecked" :value="true" />
|
|
157
|
+
isChecked (value): {{ isChecked }}
|
|
158
|
+
<farm-btn @click="isChecked = null;">reset</farm-btn>
|
|
159
|
+
</div>`,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
export const ResetByMethod = () => ({
|
|
163
|
+
data() {
|
|
164
|
+
return {
|
|
165
|
+
isChecked: true,
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
template: `<div>
|
|
169
|
+
<farm-checkbox v-model="isChecked" :value="true" ref="checkbox" />
|
|
170
|
+
isChecked (value): {{ isChecked }}
|
|
171
|
+
<farm-btn @click="$refs.checkbox.reset()">reset</farm-btn>
|
|
172
|
+
</div>`,
|
|
173
|
+
});
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="farm-checkbox__container" :color="$props.color">
|
|
3
|
-
<span
|
|
4
|
-
:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}"
|
|
13
|
-
:size="$props.size"
|
|
14
|
-
@click="toggleValue"
|
|
15
|
-
>
|
|
3
|
+
<span :class="{
|
|
4
|
+
'farm-checkbox': true,
|
|
5
|
+
'farm-checkbox--checked': isChecked,
|
|
6
|
+
'farm-checkbox--disabled': disabled,
|
|
7
|
+
'farm-checkbox--indeterminate': indeterminate,
|
|
8
|
+
'farm-checkbox--lighten': variation === 'lighten',
|
|
9
|
+
'farm-checkbox--darken': variation === 'darken',
|
|
10
|
+
'farm-checkbox--error': showError,
|
|
11
|
+
}" :size="$props.size" @click="toggleValue">
|
|
16
12
|
<farm-icon :size="$props.size" v-if="innerValue && !indeterminate">check</farm-icon>
|
|
17
13
|
<farm-icon :size="$props.size" v-if="indeterminate">minus</farm-icon>
|
|
18
14
|
</span>
|
|
@@ -123,14 +119,16 @@ export default Vue.extend({
|
|
|
123
119
|
|
|
124
120
|
const showError = computed(() => hasError.value && isTouched.value);
|
|
125
121
|
|
|
122
|
+
|
|
126
123
|
watch(
|
|
127
|
-
() => props.
|
|
128
|
-
() => {
|
|
124
|
+
() => props.modelValue,
|
|
125
|
+
(newValue) => {
|
|
129
126
|
isTouched.value = true;
|
|
130
|
-
innerValue.value =
|
|
127
|
+
innerValue.value = newValue;
|
|
131
128
|
validate(innerValue.value);
|
|
132
129
|
}
|
|
133
130
|
);
|
|
131
|
+
|
|
134
132
|
|
|
135
133
|
watch(
|
|
136
134
|
() => props.rules,
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}"
|
|
8
|
-
:size="size"
|
|
9
|
-
>
|
|
2
|
+
<div :class="{
|
|
3
|
+
'farm-icon-box': true,
|
|
4
|
+
[cssColorClass]: true,
|
|
5
|
+
'farm-icon-box--inverted': inverted,
|
|
6
|
+
}" :size="size">
|
|
10
7
|
<farm-icon :color="inverted ? 'white' : color" :size="size">{{ iconParsed }}</farm-icon>
|
|
11
8
|
</div>
|
|
12
9
|
</template>
|
|
@@ -57,10 +54,7 @@ export default Vue.extend({
|
|
|
57
54
|
},
|
|
58
55
|
computed: {
|
|
59
56
|
iconParsed() {
|
|
60
|
-
|
|
61
|
-
return this.icon.split('mdi-')[1];
|
|
62
|
-
}
|
|
63
|
-
return this.icon;
|
|
57
|
+
return this.icon.indexOf('mdi-') === 0 ? this.icon.split('mdi-')[1] : this.icon;
|
|
64
58
|
},
|
|
65
59
|
cssColorClass() {
|
|
66
60
|
return `farm-icon-box--${this.color}`;
|
|
@@ -24,7 +24,10 @@ export const MaxFileSize = () => ({
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
export const MaxFilesNumber = () => ({
|
|
27
|
-
template:
|
|
27
|
+
template: `<div>
|
|
28
|
+
<farm-multiple-filepicker :maxFileSize="5" :maxFilesNumber="2" />
|
|
29
|
+
max files allowed: 2
|
|
30
|
+
</div>`,
|
|
28
31
|
});
|
|
29
32
|
|
|
30
33
|
export const Download = () => ({
|
|
@@ -79,16 +79,15 @@
|
|
|
79
79
|
</div>
|
|
80
80
|
</li>
|
|
81
81
|
</ul>
|
|
82
|
-
|
|
83
82
|
<farm-btn
|
|
84
|
-
v-if="hasFiles"
|
|
83
|
+
v-if="canAddMoreFiles && hasFiles"
|
|
85
84
|
outlined
|
|
86
|
-
title="Escolher
|
|
85
|
+
title="Escolher Arquivo"
|
|
87
86
|
class="farm-btn--responsive"
|
|
88
87
|
:disabled="disabledButton"
|
|
89
88
|
@click="addMoreFiles"
|
|
90
89
|
>
|
|
91
|
-
Escolher
|
|
90
|
+
Escolher Arquivo
|
|
92
91
|
</farm-btn>
|
|
93
92
|
</section>
|
|
94
93
|
</template>
|
|
@@ -145,6 +144,9 @@ export default Vue.extend({
|
|
|
145
144
|
hasFiles(): boolean {
|
|
146
145
|
return this.files.length > 0 || this.downloadFiles.length > 0;
|
|
147
146
|
},
|
|
147
|
+
canAddMoreFiles(): boolean {
|
|
148
|
+
return this.filesLength < this.maxFilesNumber;
|
|
149
|
+
},
|
|
148
150
|
filesLength(): number {
|
|
149
151
|
return this.files.length + this.downloadFiles.length;
|
|
150
152
|
},
|
|
@@ -143,6 +143,18 @@ describe('MultipleFilePicker component', () => {
|
|
|
143
143
|
expect(component.disabledButton).toBeTruthy();
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
|
+
|
|
147
|
+
describe('canAddMoreFiles', () => {
|
|
148
|
+
it('should return files and downloadFiles length', async () => {
|
|
149
|
+
await wrapper.setProps({
|
|
150
|
+
maxFilesNumber: 2,
|
|
151
|
+
downloadFiles: [new File([], 'test')],
|
|
152
|
+
});
|
|
153
|
+
component.files = [new File([], 'test2')];
|
|
154
|
+
|
|
155
|
+
expect(component.canAddMoreFiles).toBeFalsy();
|
|
156
|
+
});
|
|
157
|
+
});
|
|
146
158
|
});
|
|
147
159
|
|
|
148
160
|
describe('Watch', () => {
|
|
@@ -1,63 +1,69 @@
|
|
|
1
1
|
@import '../../configurations/variables';
|
|
2
|
+
@import '../../configurations/theme-colors';
|
|
2
3
|
|
|
3
|
-
input[type=
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
box-shadow: 0px 0px 0px 8px rgba(0, 0, 0, 0.1);
|
|
40
|
-
background-color: rgba(0, 0, 0, 0.1);
|
|
41
|
-
border-radius: 50%;
|
|
42
|
-
opacity: 1;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&:active {
|
|
46
|
-
animation: pulse 0.2s 1 ease-out;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
4
|
+
input[type='radio'] {
|
|
5
|
+
-webkit-appearance: none;
|
|
6
|
+
appearance: none;
|
|
7
|
+
background-color: #ffffff;
|
|
8
|
+
margin: 0;
|
|
9
|
+
font: inherit;
|
|
10
|
+
color: rgba(0, 0, 0, 0.6);
|
|
11
|
+
border: 1.5px solid rgba(0, 0, 0, 0.6);
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
display: grid;
|
|
14
|
+
place-content: center;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
|
|
17
|
+
&::before {
|
|
18
|
+
content: '';
|
|
19
|
+
border-radius: 50%;
|
|
20
|
+
transform: scale(0);
|
|
21
|
+
transition: 120ms transform ease-in-out;
|
|
22
|
+
background-color: CanvasText;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.farm-radio--checked::before {
|
|
26
|
+
transform: scale(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:focus {
|
|
30
|
+
outline: none;
|
|
31
|
+
outline-offset: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
box-shadow: 0px 0px 0px 8px rgba(0, 0, 0, 0.1);
|
|
36
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
37
|
+
border-radius: 50%;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
49
40
|
|
|
41
|
+
&:active {
|
|
42
|
+
animation: pulse 0.2s 1 ease-out;
|
|
43
|
+
}
|
|
50
44
|
|
|
51
|
-
@each $
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
@each $color in $theme-colors-list {
|
|
46
|
+
&#{'[color=' + $color + ']'} {
|
|
47
|
+
&.farm-radio--checked::before {
|
|
48
|
+
box-shadow: inset 16px 16px themeColor($color, 'base');
|
|
49
|
+
}
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
&.farm-radio--checked {
|
|
52
|
+
border-color: themeColor($color, 'base');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@each $size, $value in $sizes {
|
|
59
|
+
#{'input[type="radio"][size=' + $size + ']'} {
|
|
60
|
+
width: $value;
|
|
61
|
+
height: $value;
|
|
62
|
+
|
|
63
|
+
&::before {
|
|
64
|
+
content: '';
|
|
65
|
+
width: $value / 2;
|
|
66
|
+
height: $value / 2;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { withDesign } from 'storybook-addon-designs';
|
|
2
2
|
import Radio from './Radio.vue';
|
|
3
3
|
import sizes from '../../configurations/sizes';
|
|
4
|
+
import baseThemeColors from '../../configurations/_theme-colors-base.scss';
|
|
5
|
+
const colors = Object.keys(baseThemeColors);
|
|
4
6
|
|
|
5
7
|
export default {
|
|
6
8
|
title: 'Form/Radio',
|
|
@@ -96,3 +98,17 @@ export const Sizes = () => ({
|
|
|
96
98
|
</div>
|
|
97
99
|
</div>`,
|
|
98
100
|
});
|
|
101
|
+
|
|
102
|
+
export const Colors = () => ({
|
|
103
|
+
data() {
|
|
104
|
+
return {
|
|
105
|
+
colors,
|
|
106
|
+
v: 1,
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
template: `<div style="width: 480px">
|
|
110
|
+
<div v-for="color in colors" :key="color" class="d-flex flex-row align-center mb-3">
|
|
111
|
+
<farm-radio v-model="v" :value="1" :color="color" /> {{ color }}
|
|
112
|
+
</div>
|
|
113
|
+
</div>`,
|
|
114
|
+
});
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
'farm-radio--checked': isChecked,
|
|
6
6
|
}"
|
|
7
7
|
type="radio"
|
|
8
|
+
:color="color"
|
|
8
9
|
:size="$props.size"
|
|
9
10
|
:checked="isChecked"
|
|
10
11
|
:value="value"
|
|
@@ -35,6 +36,24 @@ export default Vue.extend({
|
|
|
35
36
|
type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
|
|
36
37
|
default: 'md',
|
|
37
38
|
},
|
|
39
|
+
/**
|
|
40
|
+
* Color
|
|
41
|
+
*/
|
|
42
|
+
color: {
|
|
43
|
+
type: String as PropType<
|
|
44
|
+
| 'primary'
|
|
45
|
+
| 'secondary'
|
|
46
|
+
| 'neutral'
|
|
47
|
+
| 'info'
|
|
48
|
+
| 'success'
|
|
49
|
+
| 'error'
|
|
50
|
+
| 'warning'
|
|
51
|
+
| 'success'
|
|
52
|
+
| 'extra-1'
|
|
53
|
+
| 'extra-2'
|
|
54
|
+
>,
|
|
55
|
+
default: 'primary',
|
|
56
|
+
},
|
|
38
57
|
},
|
|
39
58
|
computed: {
|
|
40
59
|
isChecked() {
|