vue3-extended-multiselect 1.5.8 → 1.5.10

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.10**
4
4
 
5
5
  ***
6
6
 
@@ -223,6 +223,16 @@ 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.
234
+
235
+ ### 1.5.10 (2023-02-01)
236
+
237
+ * Fixing bug with field focus when selecting an option.
238
+ * Removal of validator from "emptyObjectsPlaceholder" prop.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.5.8
1
+ # vue3-extended-multiselect v1.5.10
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.10",
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.10",
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.10
257
258
  */
258
259
 
259
260
  const props = defineProps({
@@ -528,9 +529,6 @@ const props = defineProps({
528
529
  emptyObjectsPlaceholder: {
529
530
  type: String,
530
531
  default: "Empty Object/Array",
531
- validator(value) {
532
- return !!value;
533
- },
534
532
  },
535
533
 
536
534
  /**
@@ -885,7 +883,6 @@ const emit = defineEmits([
885
883
  ]);
886
884
 
887
885
  const dropdownActive = ref(false);
888
- const inputDisabled = ref(false);
889
886
  const externalOptionsLoader = ref(null);
890
887
  const chosenToggleAppearanceSide = ref(null);
891
888
  const rawOptions = ref([]);
@@ -1114,20 +1111,11 @@ const tabindexIfSearch = computed(() => {
1114
1111
  * @returns {string} class
1115
1112
  */
1116
1113
  const wrapperClasses = computed(() => {
1117
- return inputDisabled.value && !internalLoading.value
1114
+ return disabled.value && !internalLoading.value
1118
1115
  ? "extended__multiselect-wrapper--disabled"
1119
1116
  : "extended__multiselect-wrapper";
1120
1117
  });
1121
1118
 
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
1119
  /**
1132
1120
  * Forcibly rolls up dropdown options list by changing "dropdownActive" flag
1133
1121
  * @function
@@ -1140,17 +1128,6 @@ watch(dropdownActive, (value) => {
1140
1128
  }
1141
1129
  });
1142
1130
 
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
1131
  /**
1155
1132
  * Clears value of search field after changing selected option/options
1156
1133
  * if "resetSearchByValue" prop equals true
@@ -1242,7 +1219,7 @@ const createEventFields = (field, fieldName) => {
1242
1219
  * @param {MouseEvent} mouseEvent - MouseEvent instance
1243
1220
  */
1244
1221
  const fieldFocus = (mouseEvent) => {
1245
- if (internalLoading.value || disabled.value) return;
1222
+ if (disabled.value) return;
1246
1223
 
1247
1224
  if (!toggleOptionsBySelect.value) {
1248
1225
  const customFilteredOptions = toggleOptionsRestrictor(mouseEvent);
@@ -1518,8 +1495,8 @@ const toggleDetector = (mouseEvent, pattern, mode) => {
1518
1495
  target
1519
1496
  && (target.classList
1520
1497
  && !target.classList.contains("extended__multiselect-wrapper")
1521
- && !target.classList.contains("extended__multiselect-options_container")
1522
- || target.classList && !target.classList.length)
1498
+ || target.classList
1499
+ && !target.classList.length)
1523
1500
  && mode
1524
1501
  && !filteredHasToggle.length
1525
1502
  ) {
@@ -1527,6 +1504,11 @@ const toggleDetector = (mouseEvent, pattern, mode) => {
1527
1504
  return pattern.test(className) === true;
1528
1505
  });
1529
1506
 
1507
+ if (target.classList.contains("extended__multiselect-options_container")) {
1508
+ filteredHasToggle.push("extended__multiselect-options_container");
1509
+ return filteredHasToggle;
1510
+ }
1511
+
1530
1512
  target = target.parentNode;
1531
1513
  }
1532
1514
 
@@ -1745,9 +1727,8 @@ onMounted(() => {
1745
1727
  setPreselectedOptionsByModelValue();
1746
1728
 
1747
1729
  if (
1748
- defaultExpanded.value
1749
- && !inputDisabled.value
1750
- && !internalLoading.value
1730
+ defaultExpanded.value
1731
+ && !disabled.value
1751
1732
  && typeof options.value !== "function"
1752
1733
  ) {
1753
1734
  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