@webitel/ui-sdk 24.2.42 → 24.2.44

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.2.42",
3
+ "version": "24.2.44",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -105,11 +105,11 @@
105
105
  }
106
106
 
107
107
  .multiselect--active :deep {
108
- .multiselect__select .wt-icon__icon {
108
+ .multiselect__select.multiselect__arrow .wt-icon__icon {
109
109
  fill: var(--icon-active-color);
110
110
  }
111
111
 
112
- .multiselect__custom-value-arrow {
112
+ .multiselect__select.multiselect__custom-value {
113
113
  transform: none;
114
114
  }
115
115
  }
@@ -34,7 +34,7 @@
34
34
  :loading="false"
35
35
  :model-value="selectValue"
36
36
  :multiple="multiple"
37
- :options="selectOptions"
37
+ :options="optionsWithCustomValues"
38
38
  :placeholder="placeholder || label"
39
39
  :track-by="trackBy"
40
40
  class="wt-select__select"
@@ -88,8 +88,8 @@
88
88
  <wt-icon-btn
89
89
  v-if="allowCustomValues && searchParams.search"
90
90
  :disabled="disabled"
91
- class="multiselect__select multiselect__custom-value-arrow"
92
- icon="call-merge-filled"
91
+ class="multiselect__select multiselect__custom-value"
92
+ icon="select-custom-value-enter"
93
93
  @mousedown.prevent
94
94
  @click="handleCustomValue(toggle)"
95
95
  />
@@ -98,7 +98,7 @@
98
98
  <wt-icon-btn
99
99
  v-else
100
100
  :disabled="disabled"
101
- class="multiselect__select"
101
+ class="multiselect__select multiselect__arrow"
102
102
  icon="arrow-down"
103
103
  @mousedown.prevent
104
104
  @click="toggle"
@@ -165,7 +165,10 @@ export default {
165
165
  type: Boolean,
166
166
  default: true,
167
167
  },
168
- // for taggableMixin functionality
168
+ /*
169
+ for taggableMixin functionality
170
+ for more info, see WTEL-3181
171
+ */
169
172
  allowCustomValues: {
170
173
  type: Boolean,
171
174
  default: false,
@@ -193,12 +196,52 @@ export default {
193
196
  taggable() { return this.allowCustomValues; },
194
197
  // for taggableMixin
195
198
  manualTagging() { return this.handleCustomValuesAdditionManually; },
199
+ optionsWithCustomValues() {
200
+ if (!this.allowCustomValues) return this.selectOptions;
201
+
202
+ /**
203
+ custom values could be restored after refresh, so that they could be not included in options prop,
204
+ so that we should add them to options manually (but filter duplicates, which are already in options)
205
+
206
+ i assume it's bad decision and it's better to include custom values to options prop,
207
+ but current filters logic restores value at filter component, but options value are pre-defined at store state
208
+ */
209
+
210
+ const customValuesToOptions = Array.isArray(this.value) ? this.value : [this.value];
211
+ const optionsWithoutValues = this.selectOptions.filter((opt) => {
212
+ const optKey = this.trackBy ? opt[this.trackBy] : opt;
213
+ return !customValuesToOptions.some((customValue) => {
214
+ const customValueKey = this.trackBy ? customValue[this.trackBy] : customValue;
215
+ return customValueKey === optKey;
216
+ });
217
+ });
218
+ return [
219
+ ...customValuesToOptions,
220
+ ...optionsWithoutValues,
221
+ ];
222
+ },
196
223
  },
197
224
  methods: {
198
225
  // for taggableMixin functionality
199
- handleCustomValue(toggle) {
200
- toggle();
226
+ async handleCustomValue(toggle) {
227
+ /**
228
+ * tag emits input event, but there is a drawback
229
+ * there are causes, when input handler is async, but close event, emitted by toggle(),
230
+ * is performing some operations with input value.
231
+ * filter selects (abstract-enum(api)-filter.vue) for instance
232
+ *
233
+ * for now, i've tested this cause and it works well even without waiting for $nextTick()
234
+ * however, this is a potential problem, so, i've left this comment here
235
+ */
201
236
  this.tag(this.searchParams.search);
237
+ // await this.$nextTick();
238
+
239
+ /**
240
+ * call toggle strictly after tag() method because tag() emits input,
241
+ * because there could be code, which performs operation with input only after select close
242
+ * so that, it's crucial to emit input before close
243
+ */
244
+ toggle();
202
245
  },
203
246
  // for taggableMixin functionality
204
247
  emitTagEvent(searchQuery, id) {
@@ -4,6 +4,7 @@
4
4
  :value="value"
5
5
  :options="localizedOptions"
6
6
  :label="label"
7
+ :allow-custom-values="allowCustomValues"
7
8
  :track-by="filterSchema.storedProp"
8
9
  :multiple="filterSchema.multiple"
9
10
  @input="setValue({ filter: filterQuery, value: $event })"
@@ -2,6 +2,13 @@ import baseFilterMixin from './baseFilterMixin/baseFilterMixin';
2
2
 
3
3
  export default {
4
4
  mixins: [baseFilterMixin],
5
+ props: {
6
+ // for more detail, see allowCustomValues wt-select component prop
7
+ allowCustomValues: {
8
+ type: Boolean,
9
+ default: false,
10
+ },
11
+ },
5
12
  computed: {
6
13
  options() {
7
14
  return this.filterSchema?.options;
@@ -38,12 +45,34 @@ export default {
38
45
  restoreValue(value) {
39
46
  let newValue;
40
47
  if (Array.isArray(value)) {
48
+ /*
49
+ restore not just value, but value with all client-side properties like locale
50
+ */
41
51
  newValue = this.localizedOptions
42
52
  .filter((option) => value
43
53
  .some((value) => value === option[this.storedProp]));
54
+
55
+ /*
56
+ but if allowCustomValues is true, we should also restore custom values,
57
+ which isn't present in localizedOptions
58
+ */
59
+ if (this.allowCustomValues) {
60
+ newValue = newValue.concat(
61
+ value
62
+ .filter((val) => !this.localizedOptions
63
+ .some((option) => val === option[this.storedProp]))
64
+ .map((val) => ({ [this.storedProp]: val, name: val })),
65
+ );
66
+ }
44
67
  } else {
68
+ /*
69
+ see comments above
70
+ */
45
71
  newValue = this.localizedOptions
46
72
  .find((option) => value === option[this.storedProp]);
73
+ if (this.allowCustomValues) {
74
+ newValue = newValue || { [this.storedProp]: value, name: value };
75
+ }
47
76
  }
48
77
  this.setValue({ filter: this.filterQuery, value: newValue });
49
78
  },