vue3-extended-multiselect 1.2.3 → 1.3.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Patch notes
2
2
 
3
- Current `vue3-extended-multiselect` version: **1.2.3**
3
+ Current `vue3-extended-multiselect` version: **1.3.0**
4
4
 
5
5
  ***
6
6
 
@@ -144,5 +144,14 @@ Adding descriptive comments for some types in typings.
144
144
  * Removal of excess "transition" css-property.
145
145
 
146
146
  ### 1.2.3 (2022-12-22)
147
- * Fix bug with excess bottom offset of options list when prop "toggleAppearanceSide" set to "atop".
147
+ * Fix bug with excess bottom offset of options list when prop "toggleAppearanceSide" is set to "atop".
148
148
  * Supplementation of some css-variables.
149
+
150
+ ### 1.2.4 (2022-12-22)
151
+ * Fix bug of too wide extended multiselect with long single selected option.
152
+
153
+ ### 1.3.0 (2023-01-11)
154
+ * Adding "autoSelectSearchValue" optional prop.
155
+ * Adding unit-test for new optional prop.
156
+ * Fix bug with setting search pattern when deselecting all options.
157
+ * Fix bug with selected options display when prop "toggleOptionsBySelect" is set to false.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.2.3
1
+ # vue3-extended-multiselect v1.3.0
2
2
 
3
3
  ***
4
4
 
@@ -38,6 +38,7 @@ import { UnionOptionType } from "vue3-extended-multiselect"
38
38
  Prop name | Prop type | Prop appointment | Prop default value | Prop values
39
39
  ----------|-----------|------------------|--------------------|------------
40
40
  **autoSelect<br/>CreatedOption**|Boolean|Determines whether to select just now created option automatically.|false|&mdash;|
41
+ **autoSelect<br/>SearchValue**|Boolean|Determines whether to take search value from current selected option if "multiple" prop equals false.|false|&mdash;|
41
42
  **clearBySelect<br/>WhenMultiple**|Boolean|Determines whether to clear search field by option selection.|false|&mdash;|
42
43
  **createOnThe<br/>Go**|Boolean|Allows user to create new options from search field.|false|&mdash;|
43
44
  **default<br/>Expanded**|Boolean|Determines whether options list should be expanded by default.|false|&mdash;|
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -26,6 +26,7 @@
26
26
  import {
27
27
  computed,
28
28
  defineProps,
29
+ inject,
29
30
  ref,
30
31
  toRefs,
31
32
  } from "vue";
@@ -113,6 +114,9 @@ const props = defineProps({
113
114
  },
114
115
  });
115
116
 
117
+ const setSearchValue = inject("setSearchValue");
118
+ const setSearchPattern = inject("setSearchPattern");
119
+
116
120
  const {
117
121
  disabled,
118
122
  emitterUniqueId,
@@ -133,6 +137,8 @@ const { cancel } = useCancel(
133
137
  showSearchField,
134
138
  selectedOptions,
135
139
  emitterUniqueId,
140
+ setSearchValue,
141
+ setSearchPattern,
136
142
  );
137
143
  const { iconSizeClass } = useSizes(iconSize);
138
144
 
@@ -154,6 +154,16 @@ import emitter from "../events/emitter";
154
154
  import ExtendedMultiselectMultiple from "./ExtendedMultiselectMultiple.vue";
155
155
 
156
156
  const props = defineProps({
157
+ /**
158
+ * Determines whether to take search value from current
159
+ * selected option if "multiple" prop equals false
160
+ * @property {boolean} autoSelectSearchValue
161
+ */
162
+ autoSelectSearchValue: {
163
+ type: Boolean,
164
+ required: true,
165
+ },
166
+
157
167
  /**
158
168
  * Determines which placeholder to use
159
169
  * depending on the options creation mode
@@ -413,6 +423,7 @@ const searchDebounce = ref(debounce(() => {
413
423
  const extendedInput = ref(null);
414
424
 
415
425
  const {
426
+ autoSelectSearchValue,
416
427
  createOnTheGo,
417
428
  createOptionPlaceholder,
418
429
  disabled,
@@ -484,6 +495,9 @@ const searchFieldForwarding = computed(() => {
484
495
  * @param {boolean} searchFieldForwarding - restrictor of triggered option
485
496
  */
486
497
  watch(searchFieldForwarding, (value) => {
498
+ if (value && autoSelectSearchValue.value && !multiple.value && singleLabel.value) {
499
+ searchValue.value = singleLabel.value;
500
+ }
487
501
  emitter.emit(`extended:renew-field-forwarding-${emitterUniqueId.value}`, value);
488
502
  });
489
503
 
@@ -648,6 +662,9 @@ onBeforeMount(() => {
648
662
  });
649
663
 
650
664
  emitter.on(`extended:trigger-selection-${emitterUniqueId.value}`, (triggerState) => {
665
+ if (!toggleOptionsBySelect.value) {
666
+ searchFieldFocused.value = false;
667
+ }
651
668
  optionWillBeTriggered.value = triggerState;
652
669
  });
653
670
  });
@@ -27,6 +27,7 @@
27
27
  :spellcheck="attrs.spellcheck"
28
28
  :tabindex="attrs.tabindex"
29
29
  :translate="attrs.translate"
30
+ :auto-select-search-value="autoSelectSearchValue"
30
31
  :create-on-the-go="createOnTheGo"
31
32
  :disabled="inputDisabled"
32
33
  :dropdown-active="dropdownActive"
@@ -253,7 +254,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
253
254
 
254
255
  /**
255
256
  * @author Ridiger Daniil Dmitrievich
256
- * @version 1.2.3
257
+ * @version 1.3.0
257
258
  */
258
259
 
259
260
  const props = defineProps({
@@ -268,6 +269,17 @@ const props = defineProps({
268
269
  default: false,
269
270
  },
270
271
 
272
+ /**
273
+ * Determines whether to take search value from current
274
+ * selected option if "multiple" prop equals false
275
+ * @default false
276
+ * @property {boolean} autoSelectSearchValue
277
+ */
278
+ autoSelectSearchValue: {
279
+ type: Boolean,
280
+ default: false,
281
+ },
282
+
271
283
  /**
272
284
  * Determines whether to clear search field by option selection
273
285
  * @default false
@@ -939,6 +951,8 @@ const { cancel } = useCancel(
939
951
  showSearchField,
940
952
  selectedOptions,
941
953
  emitterUniqueId,
954
+ setSearchValue,
955
+ setSearchPattern,
942
956
  );
943
957
  const { createLabel, optionTypeRestrictor } = usePreselectedOptions(
944
958
  label,
@@ -1,8 +1,13 @@
1
1
  import emitter from "../events/emitter";
2
2
 
3
- import useSearchValue from './search-value';
4
-
5
- export default function useCancel(disabled, showSearchField, selectedOptions, emitterUniqueId) {
3
+ export default function useCancel(
4
+ disabled,
5
+ showSearchField,
6
+ selectedOptions,
7
+ emitterUniqueId,
8
+ setSearchValue,
9
+ setSearchPattern,
10
+ ) {
6
11
  /**
7
12
  * Removes all selected options or single selected option
8
13
  * when "multiple" prop equals false
@@ -12,8 +17,6 @@ export default function useCancel(disabled, showSearchField, selectedOptions, em
12
17
  * @emits extended:clean-options
13
18
  */
14
19
  const cancel = () => {
15
- const { setSearchValue, setSearchPattern } = useSearchValue();
16
-
17
20
  if (disabled.value) return;
18
21
 
19
22
  emitter.emit(`extended:skip-block-blur-zeroing-${emitterUniqueId.value}`);
@@ -25,7 +28,6 @@ export default function useCancel(disabled, showSearchField, selectedOptions, em
25
28
  if (!showSearchField.value) return;
26
29
 
27
30
  emitter.emit(`extended:clean-options-${emitterUniqueId.value}`, selectedOptions.value);
28
-
29
31
  setSearchValue(null);
30
32
  setSearchPattern(null);
31
33
  };
@@ -154,6 +154,10 @@
154
154
  outline: none;
155
155
  }
156
156
 
157
+ .extended__multiselect-block > span {
158
+ word-break: break-all;
159
+ }
160
+
157
161
  .extended__multiselect-input {
158
162
  cursor: text;
159
163
  color: inherit;
@@ -46,6 +46,24 @@ describe("props", () => {
46
46
  });
47
47
 
48
48
 
49
+ it("correctly handles 'autoSelectSearchValue' prop value", async () => {
50
+ const propsData = {
51
+ autoSelectSearchValue: true,
52
+ defaultExpanded: true,
53
+ options: globalThis.OPTIONS,
54
+ };
55
+
56
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
57
+
58
+ await mockOptionSelection(wrapper);
59
+
60
+ const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput).find("input");
61
+
62
+ await fireEvent.focus(inputWrapper.element);
63
+ expect(inputWrapper.element.value).toEqual(globalThis.OPTIONS[0].label);
64
+ });
65
+
66
+
49
67
  it("correctly handles 'clearBySelectWhenMultiple' prop value", async () => {
50
68
  const propsData = {
51
69
  clearBySelectWhenMultiple: true,