@farm-investimentos/front-mfe-components 11.10.2 → 11.10.4
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 +137 -115
- 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 +137 -115
- 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/Form/Form.stories.js +0 -4
- package/src/components/Form/Form.vue +1 -1
- package/src/components/Select/Select.stories.js +13 -0
- package/src/components/Select/Select.vue +33 -8
- package/src/components/Select/__tests__/Select.spec.js +1 -2
package/package.json
CHANGED
|
@@ -181,3 +181,16 @@ export const OutsideChangeVmodel = () => ({
|
|
|
181
181
|
</farm-btn>
|
|
182
182
|
</div>`,
|
|
183
183
|
});
|
|
184
|
+
|
|
185
|
+
export const NoItems = () => ({
|
|
186
|
+
data() {
|
|
187
|
+
return {
|
|
188
|
+
v: null,
|
|
189
|
+
items: [],
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
template: `<div style="width: 120px">
|
|
193
|
+
<farm-select v-model="v" :items="items" />
|
|
194
|
+
v-model: {{ v }}
|
|
195
|
+
</div>`,
|
|
196
|
+
});
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
>
|
|
25
25
|
<farm-caption bold tag="span">{{ item[itemText] }}</farm-caption>
|
|
26
26
|
</farm-listitem>
|
|
27
|
+
<farm-listitem v-if="!items || items.length === 0">
|
|
28
|
+
{{ noDataText }}
|
|
29
|
+
</farm-listitem>
|
|
27
30
|
</farm-list>
|
|
28
31
|
<template v-slot:activator="{}">
|
|
29
32
|
<div class="farm-textfield--input farm-textfield--input--iconed">
|
|
@@ -41,7 +44,6 @@
|
|
|
41
44
|
</div>
|
|
42
45
|
</template>
|
|
43
46
|
</farm-contextmenu>
|
|
44
|
-
|
|
45
47
|
<farm-caption v-if="showErrorText" color="error" variation="regular">
|
|
46
48
|
{{ errorBucket[0] }}
|
|
47
49
|
</farm-caption>
|
|
@@ -114,9 +116,16 @@ export default Vue.extend({
|
|
|
114
116
|
type: String,
|
|
115
117
|
default: 'value',
|
|
116
118
|
},
|
|
119
|
+
/**
|
|
120
|
+
* No data text
|
|
121
|
+
*/
|
|
122
|
+
noDataText: {
|
|
123
|
+
type: String,
|
|
124
|
+
default: 'Não há dados',
|
|
125
|
+
},
|
|
117
126
|
},
|
|
118
127
|
setup(props, { emit }) {
|
|
119
|
-
const { rules, items, itemText, itemValue } = toRefs(props);
|
|
128
|
+
const { rules, items, itemText, itemValue, disabled } = toRefs(props);
|
|
120
129
|
const innerValue = ref(props.value);
|
|
121
130
|
const isTouched = ref(false);
|
|
122
131
|
const isBlured = ref(false);
|
|
@@ -126,6 +135,7 @@ export default Vue.extend({
|
|
|
126
135
|
const { errorBucket, valid, validatable } = validateFormStateBuilder();
|
|
127
136
|
|
|
128
137
|
let fieldValidator = validateFormFieldBuilder(rules.value);
|
|
138
|
+
let validate = validateFormMethodBuilder(errorBucket, valid, fieldValidator);
|
|
129
139
|
|
|
130
140
|
const hasError = computed(() => {
|
|
131
141
|
return errorBucket.value.length > 0;
|
|
@@ -135,8 +145,20 @@ export default Vue.extend({
|
|
|
135
145
|
|
|
136
146
|
watch(
|
|
137
147
|
() => props.value,
|
|
148
|
+
newValue => {
|
|
149
|
+
innerValue.value = newValue;
|
|
150
|
+
errorBucket.value = [];
|
|
151
|
+
validate(newValue);
|
|
152
|
+
updateSelectedTextValue();
|
|
153
|
+
emit('input', newValue);
|
|
154
|
+
emit('change', newValue);
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
watch(
|
|
159
|
+
() => props.items,
|
|
138
160
|
() => {
|
|
139
|
-
|
|
161
|
+
errorBucket.value = [];
|
|
140
162
|
validate(innerValue.value);
|
|
141
163
|
updateSelectedTextValue();
|
|
142
164
|
}
|
|
@@ -157,21 +179,20 @@ export default Vue.extend({
|
|
|
157
179
|
(newVal, oldVal) => {
|
|
158
180
|
if (deepEqual(newVal, oldVal)) return;
|
|
159
181
|
fieldValidator = validateFormFieldBuilder(rules.value);
|
|
160
|
-
validate = validateFormMethodBuilder(errorBucket, valid, fieldValidator);
|
|
161
182
|
validate(innerValue.value);
|
|
162
183
|
}
|
|
163
184
|
);
|
|
164
185
|
|
|
165
186
|
onBeforeMount(() => {
|
|
166
187
|
validate(innerValue.value);
|
|
167
|
-
|
|
168
188
|
updateSelectedTextValue();
|
|
169
189
|
});
|
|
170
190
|
|
|
171
|
-
let validate = validateFormMethodBuilder(errorBucket, valid, fieldValidator);
|
|
172
|
-
|
|
173
191
|
const reset = () => {
|
|
174
|
-
|
|
192
|
+
if (disabled.value) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
innerValue.value = null;
|
|
175
196
|
selectedText.value = '';
|
|
176
197
|
isTouched.value = true;
|
|
177
198
|
emit('input', innerValue.value);
|
|
@@ -198,6 +219,10 @@ export default Vue.extend({
|
|
|
198
219
|
};
|
|
199
220
|
|
|
200
221
|
const updateSelectedTextValue = () => {
|
|
222
|
+
if (!items.value || items.value.length === 0) {
|
|
223
|
+
selectedText.value = '';
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
201
226
|
const selectedItem = items.value.find(
|
|
202
227
|
item => item[itemValue.value] === innerValue.value
|
|
203
228
|
);
|
|
@@ -24,7 +24,7 @@ describe('Select component', () => {
|
|
|
24
24
|
it('reset', () => {
|
|
25
25
|
component.reset();
|
|
26
26
|
expect(component.isTouched).toBeTruthy();
|
|
27
|
-
expect(component.innerValue).toEqual(
|
|
27
|
+
expect(component.innerValue).toEqual(null);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it('onBlur', () => {
|
|
@@ -41,6 +41,5 @@ describe('Select component', () => {
|
|
|
41
41
|
component.updateSelectedTextValue();
|
|
42
42
|
expect(component.selectedText).toBeDefined();
|
|
43
43
|
});
|
|
44
|
-
|
|
45
44
|
});
|
|
46
45
|
});
|