vue3-extended-multiselect 1.9.0 → 1.9.2

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.9.0**
3
+ Current `vue3-extended-multiselect` version: **1.9.2**
4
4
 
5
5
  ***
6
6
 
@@ -336,4 +336,13 @@ Adding descriptive comments for some types in typings.
336
336
  * Adding "dropdownDisabled" optional prop.
337
337
  * Adding unit-test for new optional prop.
338
338
  * Adding some new css-variabled.
339
- * Removal of excess type from types.
339
+ * Removal of excess type from types.
340
+
341
+ ### 1.9.1 (2023-03-20)
342
+
343
+ * Fixing bug with "pattern-changed" event with a call to the internal loader method.
344
+
345
+ ### 1.9.2 (2023-03-22)
346
+
347
+ * Fixing bug with always fixed "height" css-property of option block.
348
+ * Setting default value of "anyOptionWrapperBlockHeight" optional prop to "auto".
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.9.0
1
+ # vue3-extended-multiselect v1.9.2
2
2
 
3
3
  ***
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -266,15 +266,6 @@ const props = defineProps({
266
266
  required: true,
267
267
  },
268
268
 
269
- /**
270
- * Defines "height" css-property of every option element
271
- * @property {number} anyOptionWrapperBlockHeight
272
- */
273
- anyOptionWrapperBlockHeight: {
274
- type: Number,
275
- required: true,
276
- },
277
-
278
269
  /**
279
270
  * Determines maximal limit of selected options
280
271
  * @property {number|null} maxOptionsCount
@@ -418,6 +409,15 @@ const props = defineProps({
418
409
  default: null,
419
410
  },
420
411
 
412
+ /**
413
+ * Defines "height" css-property of every option element
414
+ * @property {number} anyOptionWrapperBlockHeight
415
+ */
416
+ anyOptionWrapperBlockHeight: {
417
+ type: [Number, String],
418
+ required: true,
419
+ },
420
+
421
421
  /**
422
422
  * Option which should be selected by default
423
423
  * if "multiple" prop equals false
@@ -645,14 +645,15 @@ const minOptionsWereNotSelected = computed(() => {
645
645
  });
646
646
 
647
647
  /**
648
- * Defines styles for "padding" and "height" css-property
648
+ * Defines styles for "padding" and "height" css-property
649
649
  * of every option element
650
650
  * @function
651
651
  * @returns {Object} styles
652
652
  */
653
653
  const optionHeightByProps = computed(() => {
654
+ const heightNumeric = typeof anyOptionWrapperBlockHeight.value === "number";
654
655
  let height = {
655
- height: `${anyOptionWrapperBlockHeight.value}px`,
656
+ height: heightNumeric ? `${anyOptionWrapperBlockHeight.value}px` : `${anyOptionWrapperBlockHeight.value}`,
656
657
  };
657
658
 
658
659
  if (optionsPadding.value.length) {
@@ -46,7 +46,6 @@
46
46
  :theme-type="themeType"
47
47
  :increase-display-by="increaseDisplayBy"
48
48
  :multipleBlocksLimit="multipleBlocksLimit"
49
- :restricted-options-length="restrictedOptionsLength"
50
49
  :toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
51
50
  :selected-options="selectedOptions"
52
51
  :emitter="emitter"
@@ -262,7 +261,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
262
261
 
263
262
  /**
264
263
  * @author Ridiger Daniil Dmitrievich, 2022
265
- * @version 1.9.0
264
+ * @version 1.9.2
266
265
  */
267
266
 
268
267
  const props = defineProps({
@@ -680,16 +679,6 @@ const props = defineProps({
680
679
  },
681
680
  },
682
681
 
683
- /**
684
- * Defines "height" css-property for each option in options list
685
- * @default 30
686
- * @property {number} anyOptionWrapperBlockHeight
687
- */
688
- anyOptionWrapperBlockHeight: {
689
- type: Number,
690
- default: 30,
691
- },
692
-
693
682
  /**
694
683
  * Defines gap which increases limit of displayed elements with selected options
695
684
  * @default 5
@@ -879,6 +868,17 @@ const props = defineProps({
879
868
  default: (number) => `and ${number} more items`,
880
869
  },
881
870
 
871
+
872
+ /**
873
+ * Defines "height" css-property for each option in options list
874
+ * @default 30
875
+ * @property {number} anyOptionWrapperBlockHeight
876
+ */
877
+ anyOptionWrapperBlockHeight: {
878
+ type: [Number, String],
879
+ default: "auto",
880
+ },
881
+
882
882
  /**
883
883
  * "id" attribute of search field
884
884
  * @default null
@@ -1122,16 +1122,6 @@ const restrictedOptions = computed(() => {
1122
1122
  : rawOptions.value;
1123
1123
  });
1124
1124
 
1125
- /**
1126
- * Determines length of options list after filtering by
1127
- * maximal admissible options amount
1128
- * @function
1129
- * @returns {number} length
1130
- */
1131
- const restrictedOptionsLength = computed(() => {
1132
- return restrictedOptions.value.length;
1133
- });
1134
-
1135
1125
  /**
1136
1126
  * Defines "aria-roledescription" attribute of extended multiselect wrapper
1137
1127
  * @function
@@ -1713,6 +1703,7 @@ const updateModelValue = () => {
1713
1703
  * @listens extended:clean-options
1714
1704
  * @listens extended:create-option
1715
1705
  * @listens extended:increase-display
1706
+ * @listens extended:loader-pattern-changed
1716
1707
  * @listens extended:search-pattern-changed
1717
1708
  */
1718
1709
  onBeforeMount(() => {
@@ -1825,6 +1816,20 @@ onBeforeMount(() => {
1825
1816
  emit("increase", eventData);
1826
1817
  });
1827
1818
 
1819
+ emitter.value.on("extended:loader-pattern-changed", (pattern) => {
1820
+ const eventData = simpleEvents.value
1821
+ ? pattern
1822
+ : createEventFields(pattern, "pattern");
1823
+
1824
+ /**
1825
+ * @event pattern-changed
1826
+ * @type {Object}
1827
+ * @property {string} inputId - id of search field set by "id" prop
1828
+ * @property {pattern} - pattern of internal search for available options
1829
+ */
1830
+ emit("pattern-changed", eventData);
1831
+ });
1832
+
1828
1833
  emitter.value.on("extended:search-pattern-changed", (pattern) => {
1829
1834
  const eventData = simpleEvents.value
1830
1835
  ? pattern
@@ -1873,8 +1878,8 @@ onMounted(() => {
1873
1878
  dropdownActive.value = true;
1874
1879
  });
1875
1880
 
1876
- emitter.value.on("extended:loader-pattern-changed", (pattern) => {
1877
- loadOptionsByExternalLoader(pattern, false);
1881
+ emitter.value.on("extended:loader-pattern-changed", async (pattern) => {
1882
+ await loadOptionsByExternalLoader(pattern, false);
1878
1883
  });
1879
1884
 
1880
1885
  clickOutside.value.init(extendedMultiselectWrapper.value, () => {
@@ -5,7 +5,8 @@ import {
5
5
  SEARCH_PATTERN,
6
6
  } from "../utils/mount";
7
7
  import {
8
- mockOptionSelection,
8
+ mockOptionSelection,
9
+ mockOptionsLoader,
9
10
  createNewOptionsWrapper,
10
11
  } from "../utils/utils";
11
12
 
@@ -29,6 +30,16 @@ describe("events", () => {
29
30
  );
30
31
 
31
32
  expect(wrapper.emitted()['pattern-changed'][0][0]).toEqual(globalThis.SEARCH_VALUE);
33
+
34
+ propsData.options = mockOptionsLoader;
35
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, true, propsData);
36
+
37
+ wrapper.vm.emitter.emit(
38
+ "extended:loader-pattern-changed",
39
+ globalThis.SEARCH_VALUE_WITH_RESULTS,
40
+ );
41
+
42
+ expect(wrapper.emitted()['pattern-changed'][0][0]).toEqual(globalThis.SEARCH_VALUE_WITH_RESULTS);
32
43
  });
33
44
 
34
45
 
@@ -10,6 +10,10 @@ export const mockOptionSelection = async (wrapper) => {
10
10
  await fireEvent.click(optionElement.element);
11
11
  }
12
12
 
13
+ export const mockOptionsLoader = async () => {
14
+ return await Promise.resolve(globalThis.OPTIONS);
15
+ }
16
+
13
17
  export const expandOptionsList = async (wrapper) => {
14
18
  const toggle = wrapper.find("#extended__multiselect-toggle");
15
19
  await fireEvent.click(toggle.element);
@@ -18,4 +22,4 @@ export const expandOptionsList = async (wrapper) => {
18
22
  export const createNewOptionsWrapper = (wrapper) => {
19
23
  const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
20
24
  return optionsWrapper.find("div > div:first-child");
21
- }
25
+ }