@farm-investimentos/front-mfe-components 12.2.2 → 12.2.3
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 +174 -176
- 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 +174 -176
- 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/Buttons/DefaultButton/DefaultButton.scss +17 -4
- package/src/components/Checkbox/Checkbox.vue +29 -43
- package/src/components/Checkbox/__tests__/modelValueWatcher.spec.js +43 -0
- package/src/components/Checkbox/modelValueWatcher.ts +12 -0
- package/src/components/ContextMenu/ContextMenu.vue +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
@import '../../../configurations/variables';
|
|
2
2
|
@import '../../../configurations/mixins';
|
|
3
3
|
@import '../../../configurations/theme-colors';
|
|
4
|
+
$butonSizes: (
|
|
5
|
+
"xs": 12px,
|
|
6
|
+
"sm": 16px,
|
|
7
|
+
"md": 24px,
|
|
8
|
+
"lg": 48px,
|
|
9
|
+
"xl": 56px,
|
|
10
|
+
'default': 36px,
|
|
11
|
+
);
|
|
4
12
|
|
|
5
13
|
.farm-btn {
|
|
6
14
|
font-size: 14px;
|
|
@@ -29,9 +37,11 @@
|
|
|
29
37
|
width: 100%;
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
@each $size,
|
|
40
|
+
@each $size,
|
|
41
|
+
$value in $sizes {
|
|
33
42
|
&#{'.farm-btn[size=' + $size + ']'} {
|
|
34
43
|
font-size: $value;
|
|
44
|
+
height: map-get($butonSizes, $size);
|
|
35
45
|
}
|
|
36
46
|
}
|
|
37
47
|
|
|
@@ -95,6 +105,7 @@
|
|
|
95
105
|
|
|
96
106
|
&.farm-btn--plain {
|
|
97
107
|
background-color: transparent !important;
|
|
108
|
+
|
|
98
109
|
&:hover {
|
|
99
110
|
.farm-btn__content {
|
|
100
111
|
opacity: 0.68;
|
|
@@ -125,7 +136,8 @@
|
|
|
125
136
|
color: gray;
|
|
126
137
|
}
|
|
127
138
|
|
|
128
|
-
@each $size,
|
|
139
|
+
@each $size,
|
|
140
|
+
$value in $sizes {
|
|
129
141
|
&#{'.farm-btn[size=' + $size + ']'} {
|
|
130
142
|
font-size: $value;
|
|
131
143
|
}
|
|
@@ -165,12 +177,13 @@
|
|
|
165
177
|
i.mdi {
|
|
166
178
|
color: white;
|
|
167
179
|
}
|
|
180
|
+
|
|
168
181
|
.farm-btn__content i.mdi {
|
|
169
182
|
color: black;
|
|
170
183
|
}
|
|
171
184
|
}
|
|
172
185
|
}
|
|
173
|
-
|
|
186
|
+
|
|
174
187
|
}
|
|
175
188
|
|
|
176
189
|
.farm-btn--extra,
|
|
@@ -250,4 +263,4 @@
|
|
|
250
263
|
width: 100%;
|
|
251
264
|
margin: 0;
|
|
252
265
|
}
|
|
253
|
-
}
|
|
266
|
+
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="farm-checkbox__container" :color="$props.color">
|
|
3
|
-
<span
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
<span
|
|
4
|
+
:class="{
|
|
5
|
+
'farm-checkbox': true,
|
|
6
|
+
'farm-checkbox--checked': isChecked,
|
|
7
|
+
'farm-checkbox--disabled': disabled,
|
|
8
|
+
'farm-checkbox--indeterminate': indeterminate,
|
|
9
|
+
'farm-checkbox--lighten': variation === 'lighten',
|
|
10
|
+
'farm-checkbox--darken': variation === 'darken',
|
|
11
|
+
'farm-checkbox--error': showError,
|
|
12
|
+
}"
|
|
13
|
+
:size="$props.size"
|
|
14
|
+
@click="toggleValue"
|
|
15
|
+
>
|
|
12
16
|
<farm-icon :size="$props.size" v-if="innerValue && !indeterminate">check</farm-icon>
|
|
13
17
|
<farm-icon :size="$props.size" v-if="indeterminate">minus</farm-icon>
|
|
14
18
|
</span>
|
|
@@ -24,6 +28,7 @@ import validateFormStateBuilder from '../../composition/validateFormStateBuilder
|
|
|
24
28
|
import validateFormFieldBuilder from '../../composition/validateFormFieldBuilder';
|
|
25
29
|
import validateFormMethodBuilder from '../../composition/validateFormMethodBuilder';
|
|
26
30
|
import deepEqual from '../../composition/deepEqual';
|
|
31
|
+
import modelValueWatcher from './modelValueWatcher';
|
|
27
32
|
|
|
28
33
|
export default Vue.extend({
|
|
29
34
|
name: 'farm-checkbox',
|
|
@@ -100,46 +105,15 @@ export default Vue.extend({
|
|
|
100
105
|
return false;
|
|
101
106
|
}
|
|
102
107
|
isTouched.value = true;
|
|
103
|
-
|
|
104
|
-
innerValue.value = null;
|
|
105
|
-
} else {
|
|
106
|
-
innerValue.value = props.value;
|
|
107
|
-
}
|
|
108
|
+
innerValue.value = isChecked.value ? null : props.value;
|
|
108
109
|
emit('input', innerValue.value);
|
|
109
110
|
validate(innerValue.value);
|
|
110
111
|
};
|
|
111
112
|
|
|
112
|
-
const isChecked = computed(() =>
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const hasError = computed(() => {
|
|
117
|
-
return errorBucket.value.length > 0;
|
|
118
|
-
});
|
|
119
|
-
|
|
113
|
+
const isChecked = computed(() => innerValue.value == props.value);
|
|
114
|
+
const hasError = computed(() => errorBucket.value.length > 0);
|
|
120
115
|
const showError = computed(() => hasError.value && isTouched.value);
|
|
121
116
|
|
|
122
|
-
|
|
123
|
-
watch(
|
|
124
|
-
() => props.modelValue,
|
|
125
|
-
(newValue) => {
|
|
126
|
-
isTouched.value = true;
|
|
127
|
-
innerValue.value = newValue;
|
|
128
|
-
validate(innerValue.value);
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
watch(
|
|
134
|
-
() => props.rules,
|
|
135
|
-
(newVal, oldVal) => {
|
|
136
|
-
if (deepEqual(newVal, oldVal)) return;
|
|
137
|
-
fieldValidator = validateFormFieldBuilder(rules.value);
|
|
138
|
-
validate = validateFormMethodBuilder(errorBucket, valid, fieldValidator);
|
|
139
|
-
validate(innerValue.value);
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
|
|
143
117
|
const reset = () => {
|
|
144
118
|
if (disabled.value) {
|
|
145
119
|
return false;
|
|
@@ -160,6 +134,18 @@ export default Vue.extend({
|
|
|
160
134
|
isTouched.value = false;
|
|
161
135
|
};
|
|
162
136
|
|
|
137
|
+
modelValueWatcher(props, isTouched, innerValue, validate);
|
|
138
|
+
|
|
139
|
+
watch(
|
|
140
|
+
() => props.rules,
|
|
141
|
+
(newVal, oldVal) => {
|
|
142
|
+
if (deepEqual(newVal, oldVal)) return;
|
|
143
|
+
fieldValidator = validateFormFieldBuilder(rules.value);
|
|
144
|
+
validate = validateFormMethodBuilder(errorBucket, valid, fieldValidator);
|
|
145
|
+
validate(innerValue.value);
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
|
|
163
149
|
return {
|
|
164
150
|
innerValue,
|
|
165
151
|
label,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ref, reactive } from 'vue';
|
|
2
|
+
import modelValueWatcher from '../modelValueWatcher.ts';
|
|
3
|
+
|
|
4
|
+
describe('modelValueWatcher', () => {
|
|
5
|
+
let props;
|
|
6
|
+
let isTouched;
|
|
7
|
+
let innerValue;
|
|
8
|
+
let validate;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
props = reactive({
|
|
12
|
+
modelValue: 'initial value',
|
|
13
|
+
});
|
|
14
|
+
isTouched = ref(false);
|
|
15
|
+
innerValue = ref('');
|
|
16
|
+
validate = jest.fn();
|
|
17
|
+
modelValueWatcher(props, isTouched, innerValue, validate);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should set isTouched.value to true when props.modelValue changes', done => {
|
|
21
|
+
props.modelValue = 'new value';
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
expect(isTouched.value).toBe(true);
|
|
24
|
+
done();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should update innerValue.value with new props.modelValue', done => {
|
|
29
|
+
props.modelValue = 'new value';
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
expect(innerValue.value).toBe('new value');
|
|
32
|
+
done();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should call validate function with new innerValue.value', done => {
|
|
37
|
+
props.modelValue = 'new value';
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
expect(validate).toHaveBeenCalledWith('new value');
|
|
40
|
+
done();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Ref, watch } from 'vue';
|
|
2
|
+
|
|
3
|
+
export default function (props, isTouched: Ref, innerValue: Ref, validate: Function) {
|
|
4
|
+
watch(
|
|
5
|
+
() => props.modelValue,
|
|
6
|
+
newValue => {
|
|
7
|
+
isTouched.value = true;
|
|
8
|
+
innerValue.value = newValue;
|
|
9
|
+
validate(innerValue.value);
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -70,9 +70,10 @@ export default Vue.extend({
|
|
|
70
70
|
|
|
71
71
|
let hasBeenBoostrapped = false;
|
|
72
72
|
|
|
73
|
-
const outClick =
|
|
73
|
+
const outClick = event => {
|
|
74
|
+
const path = event.path || (event.composedPath && event.composedPath());
|
|
74
75
|
const isInside =
|
|
75
|
-
|
|
76
|
+
path.some((e: HTMLElement) => {
|
|
76
77
|
if (e.classList) {
|
|
77
78
|
return e.classList.contains('farm-contextmenu__popup--visible');
|
|
78
79
|
}
|