@webitel/ui-sdk 24.12.34 → 24.12.36
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/CHANGELOG.md +15 -0
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.js +218 -185
- package/dist/ui-sdk.umd.cjs +2 -2
- package/package.json +1 -1
- package/src/components/wt-select/mixins/multiselectMixin.js +33 -3
- package/src/components/wt-select/wt-select.vue +11 -2
package/package.json
CHANGED
|
@@ -49,9 +49,18 @@ export default {
|
|
|
49
49
|
type: Boolean,
|
|
50
50
|
default: false,
|
|
51
51
|
},
|
|
52
|
+
/**
|
|
53
|
+
* pass "value" prop as string, receive @input event with string,
|
|
54
|
+
* but pass options as objects and calculate value from options by this prop
|
|
55
|
+
*/
|
|
56
|
+
useValueFromOptionsByProp: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: '',
|
|
59
|
+
},
|
|
52
60
|
},
|
|
53
61
|
data: () => ({
|
|
54
62
|
apiOptions: [],
|
|
63
|
+
cachedOptionsMap: {}, // is needed for props.useValueFromOptionsByProp
|
|
55
64
|
isLoading: false,
|
|
56
65
|
defaultOptionLabel: 'name',
|
|
57
66
|
|
|
@@ -73,9 +82,16 @@ export default {
|
|
|
73
82
|
showIntersectionObserver() {
|
|
74
83
|
return this.isApiMode && !this.isLoading && this.apiOptions.length;
|
|
75
84
|
},
|
|
85
|
+
// vue-multiselect doesn't show placeholder if value is empty object
|
|
76
86
|
selectValue() {
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
if (!this.isValue) return '';
|
|
88
|
+
|
|
89
|
+
if (this.useValueFromOptionsByProp) {
|
|
90
|
+
const valueFromOptions = this.cachedOptionsMap[this.value];
|
|
91
|
+
if (valueFromOptions) return valueFromOptions;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return this.value;
|
|
79
95
|
},
|
|
80
96
|
|
|
81
97
|
selectOptions() {
|
|
@@ -139,7 +155,11 @@ export default {
|
|
|
139
155
|
},
|
|
140
156
|
|
|
141
157
|
input(value) {
|
|
142
|
-
this
|
|
158
|
+
const emittedValue = this.useValueFromOptionsByProp
|
|
159
|
+
? value[this.useValueFromOptionsByProp]
|
|
160
|
+
: value;
|
|
161
|
+
this.$emit('input', emittedValue); // vue 2
|
|
162
|
+
this.$emit('update:model-value', emittedValue); // vue 3
|
|
143
163
|
},
|
|
144
164
|
|
|
145
165
|
close(event) {
|
|
@@ -154,6 +174,16 @@ export default {
|
|
|
154
174
|
// load options if becomes enabled
|
|
155
175
|
if (!this.disabled) this.fetchOptions();
|
|
156
176
|
},
|
|
177
|
+
options: {
|
|
178
|
+
handler() {
|
|
179
|
+
if (this.trackBy === null) return; // then, options are primitives
|
|
180
|
+
|
|
181
|
+
for (const opt of this.options) {
|
|
182
|
+
this.cachedOptionsMap[opt[this.useValueFromOptionsByProp || this.trackBy]] = opt;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
immediate: true,
|
|
186
|
+
},
|
|
157
187
|
},
|
|
158
188
|
|
|
159
189
|
created() {
|
|
@@ -154,7 +154,15 @@ export default {
|
|
|
154
154
|
taggableMixin,
|
|
155
155
|
],
|
|
156
156
|
props: {
|
|
157
|
-
|
|
157
|
+
// vue 3
|
|
158
|
+
modelValue: {},
|
|
159
|
+
|
|
160
|
+
// vue 2 fallback
|
|
161
|
+
value: {
|
|
162
|
+
default: (props) => {
|
|
163
|
+
return props.modelValue;
|
|
164
|
+
},
|
|
165
|
+
},
|
|
158
166
|
|
|
159
167
|
multiple: {
|
|
160
168
|
type: Boolean,
|
|
@@ -184,7 +192,8 @@ export default {
|
|
|
184
192
|
emits: [
|
|
185
193
|
'reset',
|
|
186
194
|
'search-change',
|
|
187
|
-
'input',
|
|
195
|
+
'input', // vue 2
|
|
196
|
+
'update:modelValue', // vue 3
|
|
188
197
|
'closed',
|
|
189
198
|
'custom-value', // fires when allowCustomValues and new customValue is added
|
|
190
199
|
],
|