vue3-extended-multiselect 1.5.8 → 1.5.9

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.5.8**
3
+ Current `vue3-extended-multiselect` version: **1.5.9**
4
4
 
5
5
  ***
6
6
 
@@ -223,6 +223,11 @@ Adding descriptive comments for some types in typings.
223
223
 
224
224
  * Removal of internal loading state because of using "lodash.debounce".
225
225
 
226
- ### 1.5.8 (2023-01-01)
226
+ ### 1.5.8 (2023-02-01)
227
227
 
228
- * Adding CONTRIBUTING.md file.
228
+ * Adding CONTRIBUTING.md file.
229
+
230
+ ### 1.5.9 (2023-02-01)
231
+
232
+ * "loading" prop no longer disables search field.
233
+ * Changing value of css-variable "--min-block-height" from 25px to 26px.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.5.8
1
+ # vue3-extended-multiselect v1.5.9
2
2
 
3
3
  ***
4
4
 
package/jest.config.js CHANGED
@@ -5,7 +5,7 @@ module.exports = {
5
5
  },
6
6
  expand: true,
7
7
  displayName: {
8
- name: "vue3-extended-multiselect 1.5.8",
8
+ name: "vue3-extended-multiselect 1.5.9",
9
9
  color: "bgGreen",
10
10
  },
11
11
  extraGlobals: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "1.5.8",
3
+ "version": "1.5.9",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -10,7 +10,10 @@
10
10
  :index="index"
11
11
  :deselect-block="deselectBlock"
12
12
  >
13
- <div :class="classes">
13
+ <div
14
+ :class="classes"
15
+ :style="styles"
16
+ >
14
17
  <span>{{ optionCreateLabel(option) }}</span>
15
18
  <div
16
19
  class="extended__multiselect-block_cancel-wrapper"
@@ -272,6 +275,16 @@ const overLimitOptionsCount = computed(() => {
272
275
  return selectedOptions.value.length - multipleBlocksLimit.value;
273
276
  });
274
277
 
278
+ /**
279
+ * Defines styles for "padding-right" css-property
280
+ * of every option block
281
+ * @function
282
+ * @returns {Object|null} styles
283
+ */
284
+ const styles = computed(() => {
285
+ return loading.value ? { paddingRight: "7px" } : null;
286
+ });
287
+
275
288
  /**
276
289
  * If limit of selected options was achieved restricts further
277
290
  * extension of options container if "multiple" prop equals true
@@ -149,6 +149,16 @@ const props = defineProps({
149
149
  required: true,
150
150
  },
151
151
 
152
+ /**
153
+ * Determines "loading" state of component
154
+ * that disables option selection
155
+ * @property {boolean} loading
156
+ */
157
+ loading: {
158
+ type: Boolean,
159
+ required: true,
160
+ },
161
+
152
162
  /**
153
163
  * Determines whether to use functionality of
154
164
  * multiple select
@@ -435,6 +445,7 @@ const {
435
445
  emitter,
436
446
  emptyObjectsPlaceholder,
437
447
  highlightOptions,
448
+ loading,
438
449
  label,
439
450
  searchByField,
440
451
  maxOptionsCount,
@@ -702,6 +713,8 @@ const compareWithSelected = (calculatedOptionLabel) => {
702
713
  * @emits extended:create-option
703
714
  */
704
715
  const createNewOption = () => {
716
+ if (loading.value) return;
717
+
705
718
  let newOption;
706
719
 
707
720
  switch(createOptionType.value) {
@@ -983,10 +996,12 @@ const optionHighlightClasses = (option) => {
983
996
  * @param {MouseEvent|KeyboardEvent} clickEvent - MouseEvent or KeyboardEvent instance
984
997
  */
985
998
  const selectOption = (option, clickEvent) => {
999
+
986
1000
  emitter.value.emit("extended:trigger-selection", false);
987
1001
 
988
1002
  if (!clickEvent) return;
989
1003
  if (keyBlocker(clickEvent)) return;
1004
+ if (loading.value) return;
990
1005
  if (maxOptionsWereSelected.value) return;
991
1006
  if (option[disableByField.value] || defineDisabledOption(option)) return;
992
1007
  if (
@@ -29,7 +29,7 @@
29
29
  :translate="attrs.translate"
30
30
  :auto-select-search-value="autoSelectSearchValue"
31
31
  :create-on-the-go="createOnTheGo"
32
- :disabled="inputDisabled"
32
+ :disabled="disabled"
33
33
  :dropdown-active="dropdownActive"
34
34
  :loading="internalLoading"
35
35
  :multiple="multiple"
@@ -96,7 +96,7 @@
96
96
  <extended-multiselect-toggle
97
97
  ref="extendedMultiselectToggle"
98
98
  :tabindex="attrs.tabindex"
99
- :disabled="inputDisabled"
99
+ :disabled="disabled"
100
100
  :dropdown-active="dropdownActive"
101
101
  :loading="internalLoading"
102
102
  :icon-filter="iconFilter"
@@ -112,7 +112,7 @@
112
112
  <extended-multiselect-cancel
113
113
  v-if="showClearIcon"
114
114
  :tabindex="attrs.tabindex"
115
- :disabled="inputDisabled"
115
+ :disabled="disabled"
116
116
  :show-search-field="showSearchField"
117
117
  :loading="internalLoading"
118
118
  :icon-filter="iconFilter"
@@ -133,6 +133,7 @@
133
133
  :create-on-the-go="createOnTheGo"
134
134
  :disabled-primitive-options-converted="disabledPrimitiveOptionsConverted"
135
135
  :highlight-options="highlightOptions"
136
+ :loading="internalLoading"
136
137
  :multiple="multiple"
137
138
  :selected-options-shown="selectedOptionsShown"
138
139
  :show-insert-warnings="showInsertWarnings"
@@ -253,7 +254,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
253
254
 
254
255
  /**
255
256
  * @author Ridiger Daniil Dmitrievich, 2022
256
- * @version 1.5.8
257
+ * @version 1.5.9
257
258
  */
258
259
 
259
260
  const props = defineProps({
@@ -885,7 +886,6 @@ const emit = defineEmits([
885
886
  ]);
886
887
 
887
888
  const dropdownActive = ref(false);
888
- const inputDisabled = ref(false);
889
889
  const externalOptionsLoader = ref(null);
890
890
  const chosenToggleAppearanceSide = ref(null);
891
891
  const rawOptions = ref([]);
@@ -1114,20 +1114,11 @@ const tabindexIfSearch = computed(() => {
1114
1114
  * @returns {string} class
1115
1115
  */
1116
1116
  const wrapperClasses = computed(() => {
1117
- return inputDisabled.value && !internalLoading.value
1117
+ return disabled.value && !internalLoading.value
1118
1118
  ? "extended__multiselect-wrapper--disabled"
1119
1119
  : "extended__multiselect-wrapper";
1120
1120
  });
1121
1121
 
1122
- /**
1123
- * Disables search field if "disabled" prop equals true
1124
- * @function
1125
- * @param {boolean} value - "disabled" prop
1126
- */
1127
- watch(disabled, (value) => {
1128
- inputDisabled.value = value;
1129
- }, { immediate: true });
1130
-
1131
1122
  /**
1132
1123
  * Forcibly rolls up dropdown options list by changing "dropdownActive" flag
1133
1124
  * @function
@@ -1140,17 +1131,6 @@ watch(dropdownActive, (value) => {
1140
1131
  }
1141
1132
  });
1142
1133
 
1143
- /**
1144
- * Disables search field if "loading" prop equals true
1145
- * @function
1146
- * @param {boolean} value - "loading" prop
1147
- */
1148
- watch(internalLoading, (value) => {
1149
- if (disabled.value) return;
1150
-
1151
- inputDisabled.value = value;
1152
- }, { immediate: true });
1153
-
1154
1134
  /**
1155
1135
  * Clears value of search field after changing selected option/options
1156
1136
  * if "resetSearchByValue" prop equals true
@@ -1242,7 +1222,7 @@ const createEventFields = (field, fieldName) => {
1242
1222
  * @param {MouseEvent} mouseEvent - MouseEvent instance
1243
1223
  */
1244
1224
  const fieldFocus = (mouseEvent) => {
1245
- if (internalLoading.value || disabled.value) return;
1225
+ if (disabled.value) return;
1246
1226
 
1247
1227
  if (!toggleOptionsBySelect.value) {
1248
1228
  const customFilteredOptions = toggleOptionsRestrictor(mouseEvent);
@@ -1745,9 +1725,8 @@ onMounted(() => {
1745
1725
  setPreselectedOptionsByModelValue();
1746
1726
 
1747
1727
  if (
1748
- defaultExpanded.value
1749
- && !inputDisabled.value
1750
- && !internalLoading.value
1728
+ defaultExpanded.value
1729
+ && !disabled.value
1751
1730
  && typeof options.value !== "function"
1752
1731
  ) {
1753
1732
  dropdownActive.value = true;
@@ -347,6 +347,7 @@
347
347
  border-radius: var(--block-border-radius);
348
348
  padding: var(--block-padding);
349
349
  gap: var(--block-gap);
350
+ min-height: var(--min-block-height);
350
351
  }
351
352
 
352
353
  .extended__multiselect-options_option:hover,
@@ -32,7 +32,7 @@
32
32
  --icon-size-small: 12px;
33
33
  --increaser-padding: 3px 7px;
34
34
  --max-size: 100%;
35
- --min-block-height: 25px;
35
+ --min-block-height: 26px;
36
36
  --options-padding: 6px 0;
37
37
  --outer-gap: 10px;
38
38
  --root-padding: 6px 10px;
@@ -164,7 +164,9 @@ describe("props", () => {
164
164
 
165
165
  it("correctly handles 'loading' prop value", async () => {
166
166
  const propsData = {
167
+ defaultExpanded: true,
167
168
  loading: true,
169
+ options: globalThis.OPTIONS,
168
170
  };
169
171
 
170
172
  wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
@@ -173,6 +175,13 @@ describe("props", () => {
173
175
 
174
176
  expect(loaderWrapper.exists()).toBeTruthy();
175
177
  expect(loaderWrapper.isVisible()).toBeTruthy();
178
+
179
+ await mockOptionSelection(wrapper);
180
+
181
+ const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
182
+ const selectedOptionWrapper = inputWrapper.find(".extended__multiselect-block");
183
+
184
+ expect(selectedOptionWrapper.text()).toHaveLength(0);
176
185
  });
177
186
 
178
187