@webitel/ui-sdk 24.2.43 → 24.2.45

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.43",
3
+ "version": "24.2.45",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -2,8 +2,13 @@
2
2
  <aside
3
3
  class="wt-badge"
4
4
  :class="{ 'wt-badge--outside': outside }"
5
- :style="{ background: iconBadge ? `url(${showIconBadge})` : `var(--${colorVariable})` }"
6
- />
5
+ :style="{ background: `var(--${colorVariable})` }"
6
+ >
7
+ <img
8
+ :src="iconBadgePic"
9
+ :alt="iconBadge"
10
+ >
11
+ </aside>
7
12
  </template>
8
13
 
9
14
  <script>
@@ -29,7 +34,7 @@ export default {
29
34
  },
30
35
  },
31
36
  computed: {
32
- showIconBadge() {
37
+ iconBadgePic() {
33
38
  switch (this.iconBadge) {
34
39
  case AbstractUserStatus.DND:
35
40
  return BadgeDnd;
@@ -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,6 +196,30 @@ 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
@@ -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
  },