@farm-investimentos/front-mfe-components 11.10.1 → 11.10.2
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 +113 -109
- 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 +113 -109
- 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/Select/Select.stories.js +28 -3
- package/src/components/Select/Select.vue +14 -10
- package/src/components/Select/__tests__/Select.spec.js +6 -0
package/package.json
CHANGED
|
@@ -27,9 +27,9 @@ export const Primary = () => ({
|
|
|
27
27
|
return {
|
|
28
28
|
v: null,
|
|
29
29
|
items: [
|
|
30
|
-
{ value: 1, text: '
|
|
31
|
-
{ value: 2, text: '
|
|
32
|
-
{ value: 3, text: '
|
|
30
|
+
{ value: 1, text: 'value 1' },
|
|
31
|
+
{ value: 2, text: 'value 2' },
|
|
32
|
+
{ value: 3, text: 'value 3' },
|
|
33
33
|
],
|
|
34
34
|
};
|
|
35
35
|
},
|
|
@@ -156,3 +156,28 @@ export const CustomKeys = () => ({
|
|
|
156
156
|
v-model: {{ v }}
|
|
157
157
|
</div>`,
|
|
158
158
|
});
|
|
159
|
+
|
|
160
|
+
export const OutsideChangeVmodel = () => ({
|
|
161
|
+
data() {
|
|
162
|
+
return {
|
|
163
|
+
v: null,
|
|
164
|
+
items: [
|
|
165
|
+
{ value: 1, text: 'value 1' },
|
|
166
|
+
{ value: 2, text: 'value 2' },
|
|
167
|
+
{ value: 3, text: 'value 3' },
|
|
168
|
+
],
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
methods: {
|
|
172
|
+
onClick() {
|
|
173
|
+
this.v = 2;
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
template: `<div style="width: 120px">
|
|
177
|
+
<farm-select v-model="v" :items="items" />
|
|
178
|
+
v-model: {{ v }}
|
|
179
|
+
<farm-btn @click="onClick">
|
|
180
|
+
change value
|
|
181
|
+
</farm-btn>
|
|
182
|
+
</div>`,
|
|
183
|
+
});
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
<farm-contextmenu bottom v-model="isVisible">
|
|
15
15
|
<farm-list v-if="!readonly">
|
|
16
16
|
<farm-listitem
|
|
17
|
-
v-for="item in items"
|
|
17
|
+
v-for="(item, index) in items"
|
|
18
18
|
clickable
|
|
19
19
|
hoverColorVariation="lighten"
|
|
20
20
|
hover-color="primary"
|
|
21
|
-
:key="'contextmenu_item_' +
|
|
21
|
+
:key="'contextmenu_item_' + index"
|
|
22
22
|
:class="{ 'farm-listitem--selected': item[itemValue] === innerValue }"
|
|
23
23
|
@click="selectItem(item)"
|
|
24
24
|
>
|
|
@@ -85,8 +85,6 @@ export default Vue.extend({
|
|
|
85
85
|
type: Boolean,
|
|
86
86
|
default: false,
|
|
87
87
|
},
|
|
88
|
-
|
|
89
|
-
errorMessage: String,
|
|
90
88
|
/**
|
|
91
89
|
* Array of rules used for validation
|
|
92
90
|
*/
|
|
@@ -140,6 +138,7 @@ export default Vue.extend({
|
|
|
140
138
|
() => {
|
|
141
139
|
innerValue.value = props.value;
|
|
142
140
|
validate(innerValue.value);
|
|
141
|
+
updateSelectedTextValue();
|
|
143
142
|
}
|
|
144
143
|
);
|
|
145
144
|
|
|
@@ -166,12 +165,7 @@ export default Vue.extend({
|
|
|
166
165
|
onBeforeMount(() => {
|
|
167
166
|
validate(innerValue.value);
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
item => item[itemValue.value] === innerValue.value
|
|
171
|
-
);
|
|
172
|
-
if (selectedItem) {
|
|
173
|
-
selectedText.value = selectedItem[itemText.value];
|
|
174
|
-
}
|
|
168
|
+
updateSelectedTextValue();
|
|
175
169
|
});
|
|
176
170
|
|
|
177
171
|
let validate = validateFormMethodBuilder(errorBucket, valid, fieldValidator);
|
|
@@ -203,6 +197,15 @@ export default Vue.extend({
|
|
|
203
197
|
emit('click');
|
|
204
198
|
};
|
|
205
199
|
|
|
200
|
+
const updateSelectedTextValue = () => {
|
|
201
|
+
const selectedItem = items.value.find(
|
|
202
|
+
item => item[itemValue.value] === innerValue.value
|
|
203
|
+
);
|
|
204
|
+
if (selectedItem) {
|
|
205
|
+
selectedText.value = selectedItem[itemText.value];
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
206
209
|
return {
|
|
207
210
|
items,
|
|
208
211
|
innerValue,
|
|
@@ -221,6 +224,7 @@ export default Vue.extend({
|
|
|
221
224
|
onKeyUp,
|
|
222
225
|
onBlur,
|
|
223
226
|
clickInput,
|
|
227
|
+
updateSelectedTextValue,
|
|
224
228
|
};
|
|
225
229
|
},
|
|
226
230
|
});
|
|
@@ -36,5 +36,11 @@ describe('Select component', () => {
|
|
|
36
36
|
component.clickInput();
|
|
37
37
|
expect(component.isTouched).toBeTruthy();
|
|
38
38
|
});
|
|
39
|
+
|
|
40
|
+
it('updateSelectedTextValue', () => {
|
|
41
|
+
component.updateSelectedTextValue();
|
|
42
|
+
expect(component.selectedText).toBeDefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
39
45
|
});
|
|
40
46
|
});
|