@webitel/ui-sdk 24.12.33 → 24.12.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "24.12.33",
3
+ "version": "24.12.35",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -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
- // vue-multiselect doesn't show placeholder if value is empty object
78
- return this.isValue ? this.value : '';
87
+ if (!this.isValue) return '';
88
+
89
+ if (this.useValueFromOptionsByProp) {
90
+ const valueFromOptions = this.cachedOptionsMap[this.useValueFromOptionsByProp];
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.$emit('input', value);
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
- value: {},
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
  ],
@@ -71,6 +71,7 @@ export default {
71
71
  more: 'More',
72
72
  read: 'Read',
73
73
  create: 'Create',
74
+ draggable: 'Draggable',
74
75
  },
75
76
  // yak zhe ya zaebalsya povtoriaty odni i ti sami slova!!!!
76
77
  vocabulary: {
@@ -71,6 +71,7 @@ export default {
71
71
  more: 'Больше',
72
72
  read: 'Читать',
73
73
  create: 'Создать',
74
+ draggable: 'Перетащить',
74
75
  },
75
76
  vocabulary: {
76
77
  language: 'Язык',
@@ -72,6 +72,7 @@ export default {
72
72
  more: 'Більше',
73
73
  read: 'Читати',
74
74
  create: 'Створити',
75
+ draggable: 'Перетягнути',
75
76
  },
76
77
  vocabulary: {
77
78
  language: 'Мова',