vue3-extended-multiselect 2.2.3 → 2.3.1
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/README.md
CHANGED
|
@@ -345,12 +345,12 @@ const _hoisted_2$e = /*#__PURE__*/vue.createElementVNode("g", null, [
|
|
|
345
345
|
/*#__PURE__*/vue.createElementVNode("path", { d: "M96.1,103.6c-10.4,8.4-23.5,12.4-36.8,11.1c-10.5-1-20.3-5.1-28.2-11.8H44v-8H18v26h8v-11.9c9.1,7.7,20.4,12.5,32.6,13.6 c1.9,0.2,3.7,0.3,5.5,0.3c13.5,0,26.5-4.6,37-13.2c19.1-15.4,26.6-40.5,19.1-63.9l-7.6,2.4C119,68.6,112.6,90.3,96.1,103.6z" }),
|
|
346
346
|
/*#__PURE__*/vue.createElementVNode("path", { d: "M103,19.7c-21.2-18.7-53.5-20-76.1-1.6C7.9,33.5,0.4,58.4,7.7,81.7l7.6-2.4C9,59.2,15.5,37.6,31.9,24.4 C51.6,8.4,79.7,9.6,98,26H85v8h26V8h-8V19.7z" })
|
|
347
347
|
], -1 /* HOISTED */);
|
|
348
|
-
const _hoisted_3$
|
|
348
|
+
const _hoisted_3$8 = [
|
|
349
349
|
_hoisted_2$e
|
|
350
350
|
];
|
|
351
351
|
|
|
352
352
|
function render$8(_ctx, _cache) {
|
|
353
|
-
return (vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$f, [..._hoisted_3$
|
|
353
|
+
return (vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$f, [..._hoisted_3$8]))
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
const script$f = {};
|
|
@@ -766,6 +766,7 @@ const _hoisted_2$b = {
|
|
|
766
766
|
key: 0,
|
|
767
767
|
class: "extended__multiselect-placeholder"
|
|
768
768
|
};
|
|
769
|
+
const _hoisted_3$7 = ["onClick"];
|
|
769
770
|
|
|
770
771
|
|
|
771
772
|
var script$b = {
|
|
@@ -1111,20 +1112,20 @@ return (_ctx, _cache) => {
|
|
|
1111
1112
|
}, [
|
|
1112
1113
|
vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(optionCreateLabel)(option)), 1 /* TEXT */),
|
|
1113
1114
|
vue.createElementVNode("div", {
|
|
1114
|
-
class: vue.normalizeClass(deselectClasses.value)
|
|
1115
|
+
class: vue.normalizeClass(deselectClasses.value),
|
|
1116
|
+
onClick: vue.withModifiers($event => (deselectBlock(index)), ["stop"])
|
|
1115
1117
|
}, [
|
|
1116
1118
|
(!showLoaderIcon.value)
|
|
1117
1119
|
? (vue.openBlock(), vue.createBlock(script$d, {
|
|
1118
1120
|
key: 0,
|
|
1119
|
-
class: "extended__multiselect_deselect-block-icon"
|
|
1120
|
-
|
|
1121
|
-
}, null, 8 /* PROPS */, ["onClick"]))
|
|
1121
|
+
class: "extended__multiselect_deselect-block-icon"
|
|
1122
|
+
}))
|
|
1122
1123
|
: (vue.openBlock(), vue.createBlock(script$e, {
|
|
1123
1124
|
key: 1,
|
|
1124
1125
|
"icon-filter": __props.iconFilter,
|
|
1125
1126
|
"icon-size": "deselect"
|
|
1126
1127
|
}, null, 8 /* PROPS */, ["icon-filter"]))
|
|
1127
|
-
],
|
|
1128
|
+
], 10 /* CLASS, PROPS */, _hoisted_3$7)
|
|
1128
1129
|
], 2 /* CLASS */)
|
|
1129
1130
|
])
|
|
1130
1131
|
]))
|
|
@@ -1577,7 +1578,7 @@ vue.watch(searchValue, (value) => {
|
|
|
1577
1578
|
* @function
|
|
1578
1579
|
* @emits extended:expand-options
|
|
1579
1580
|
*/
|
|
1580
|
-
const expand = () => {
|
|
1581
|
+
const expand = (event) => {
|
|
1581
1582
|
if (disabled.value) return;
|
|
1582
1583
|
|
|
1583
1584
|
searchFieldFocused.value = true;
|
|
@@ -1629,6 +1630,24 @@ const rollUp = () => {
|
|
|
1629
1630
|
emitter.value.emit("extended:rollup-options", true);
|
|
1630
1631
|
};
|
|
1631
1632
|
|
|
1633
|
+
/**
|
|
1634
|
+
* Rolls up options list after option selection
|
|
1635
|
+
* and sets single option label
|
|
1636
|
+
* @function
|
|
1637
|
+
* @param {UnionPropType} option - option to be selected
|
|
1638
|
+
*/
|
|
1639
|
+
const rollupIfSelected = (option) => {
|
|
1640
|
+
if (toggleOptionsBySelect.value) {
|
|
1641
|
+
rollUp();
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
if (multiple.value) {
|
|
1645
|
+
return;
|
|
1646
|
+
} else {
|
|
1647
|
+
singleLabel.value = option.label;
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
|
|
1632
1651
|
/**
|
|
1633
1652
|
* Activates debounced version of options list filter
|
|
1634
1653
|
* @function
|
|
@@ -1642,6 +1661,7 @@ const search = () => {
|
|
|
1642
1661
|
* @listens extended:field-focus
|
|
1643
1662
|
* @listens extended:rollup-options
|
|
1644
1663
|
* @listens extended:select-option
|
|
1664
|
+
* @listens extended:preselect-option
|
|
1645
1665
|
* @listens extended:deselect-option
|
|
1646
1666
|
* @listens extended:clean-options
|
|
1647
1667
|
* @listens extended:clear-field
|
|
@@ -1665,16 +1685,11 @@ vue.onBeforeMount(() => {
|
|
|
1665
1685
|
});
|
|
1666
1686
|
|
|
1667
1687
|
emitter.value.on("extended:select-option", (option) => {
|
|
1688
|
+
rollupIfSelected(option);
|
|
1689
|
+
});
|
|
1668
1690
|
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
if (multiple.value) {
|
|
1674
|
-
return;
|
|
1675
|
-
} else {
|
|
1676
|
-
singleLabel.value = option.label;
|
|
1677
|
-
}
|
|
1691
|
+
emitter.value.on("extended:preselect-option", (option) => {
|
|
1692
|
+
rollupIfSelected(option);
|
|
1678
1693
|
});
|
|
1679
1694
|
|
|
1680
1695
|
emitter.value.on("extended:deselect-option", () => {
|
|
@@ -3618,7 +3633,7 @@ const _hoisted_3 = { class: "extended__multiselect-cancel_wrapper" };
|
|
|
3618
3633
|
|
|
3619
3634
|
/**
|
|
3620
3635
|
* @author Ridiger Daniil Dmitrievich, 2022
|
|
3621
|
-
* @version 2.
|
|
3636
|
+
* @version 2.3.1
|
|
3622
3637
|
*/
|
|
3623
3638
|
|
|
3624
3639
|
var script = {
|
|
@@ -4289,6 +4304,7 @@ const togglePattern = /^extended__multiselect-toggle_wrapper/i;
|
|
|
4289
4304
|
const extendedMultiselect = vue.ref(null);
|
|
4290
4305
|
const extendedMultiselectToggle = vue.ref(null);
|
|
4291
4306
|
const extendedMultiselectWrapper = vue.ref(null);
|
|
4307
|
+
const extendedMultiselectOptions = vue.ref(null);
|
|
4292
4308
|
|
|
4293
4309
|
const {
|
|
4294
4310
|
defaultExpanded,
|
|
@@ -4700,7 +4716,7 @@ const selectByEnter = (keyboardEvent) => {
|
|
|
4700
4716
|
/**
|
|
4701
4717
|
* Sets preselected option provided by "preselectedOption" prop
|
|
4702
4718
|
* @function
|
|
4703
|
-
* @emits extended:
|
|
4719
|
+
* @emits extended:preselect-option
|
|
4704
4720
|
* @param {UnionPropType} preselectedOption - option to be selected
|
|
4705
4721
|
* @param {boolean} restriction - restriction of preselected option
|
|
4706
4722
|
*/
|
|
@@ -4725,7 +4741,7 @@ const setPreselectedOption = (preselectedOption, restriction = true) => {
|
|
|
4725
4741
|
const isObjectOrArray = typeof preselectedOption === "object";
|
|
4726
4742
|
const label = createLabel(isObjectOrArray, preselectedOption);
|
|
4727
4743
|
|
|
4728
|
-
emitter.value.emit("extended:
|
|
4744
|
+
emitter.value.emit("extended:preselect-option", {
|
|
4729
4745
|
label,
|
|
4730
4746
|
option: preselectedOption,
|
|
4731
4747
|
});
|
|
@@ -4735,7 +4751,7 @@ const setPreselectedOption = (preselectedOption, restriction = true) => {
|
|
|
4735
4751
|
* Sets preselected options provided by "preselectedOptions" prop
|
|
4736
4752
|
* if "multiple" prop equals true
|
|
4737
4753
|
* @function
|
|
4738
|
-
* @emits extended:
|
|
4754
|
+
* @emits extended:preselect-option
|
|
4739
4755
|
* @param {Array} preselectedOptions - options to be selected
|
|
4740
4756
|
* @param {boolean} restriction - restriction of preselected options
|
|
4741
4757
|
*/
|
|
@@ -4760,7 +4776,7 @@ const setPreselectedOptions = async (preselectedOptions, restriction = true) =>
|
|
|
4760
4776
|
|
|
4761
4777
|
allOptionsWereSelected++;
|
|
4762
4778
|
|
|
4763
|
-
emitter.value.emit("extended:
|
|
4779
|
+
emitter.value.emit("extended:preselect-option", {
|
|
4764
4780
|
label,
|
|
4765
4781
|
option: preselectedOption,
|
|
4766
4782
|
});
|
|
@@ -4784,7 +4800,7 @@ const setPreselectedOptionsByModelValue = (withRemoval = false) => {
|
|
|
4784
4800
|
|
|
4785
4801
|
if (withRemoval) selectedOptionsWatcher.value();
|
|
4786
4802
|
|
|
4787
|
-
if (multiple.value) {
|
|
4803
|
+
if (Array.isArray(modelValue.value) && multiple.value) {
|
|
4788
4804
|
if (withRemoval) removeSelectedOptions();
|
|
4789
4805
|
|
|
4790
4806
|
setPreselectedOptions(modelValue.value, false);
|
|
@@ -4821,7 +4837,7 @@ const setPreselectedOptionsByConditions = () => {
|
|
|
4821
4837
|
}
|
|
4822
4838
|
}
|
|
4823
4839
|
|
|
4824
|
-
if (preselectedOptions.value && multiple.value) {
|
|
4840
|
+
if (!!preselectedOptions.value.length && multiple.value) {
|
|
4825
4841
|
const initialLength = selectedOptions.value.length;
|
|
4826
4842
|
|
|
4827
4843
|
setPreselectedOptions(preselectedOptions.value);
|
|
@@ -4838,15 +4854,17 @@ const setPreselectedOptionsByConditions = () => {
|
|
|
4838
4854
|
* @returns {string} position
|
|
4839
4855
|
*/
|
|
4840
4856
|
const toggleAppearanceRestrictor = () => {
|
|
4841
|
-
if (!window) return "under";
|
|
4857
|
+
if (!window || !extendedMultiselectOptions.value.$el) return "under";
|
|
4842
4858
|
|
|
4843
4859
|
const innerHeight = window.innerHeight;
|
|
4860
|
+
const offsetHeight = extendedMultiselectOptions.value.$el.offsetHeight
|
|
4861
|
+
+ extendedMultiselect.value.offsetHeight;
|
|
4844
4862
|
const offsetTop = extendedMultiselect.value
|
|
4845
4863
|
? extendedMultiselect.value.getBoundingClientRect().y
|
|
4846
4864
|
: 0;
|
|
4847
4865
|
const difference = innerHeight - offsetTop;
|
|
4848
4866
|
|
|
4849
|
-
if (difference >
|
|
4867
|
+
if (difference > offsetHeight) {
|
|
4850
4868
|
return "under";
|
|
4851
4869
|
} else {
|
|
4852
4870
|
return "atop";
|
|
@@ -4858,7 +4876,7 @@ const toggleAppearanceRestrictor = () => {
|
|
|
4858
4876
|
* @function
|
|
4859
4877
|
*/
|
|
4860
4878
|
const toggleAppearanceRestrictorActivate = () => {
|
|
4861
|
-
if (
|
|
4879
|
+
if (dropdownActive.value) {
|
|
4862
4880
|
chosenToggleAppearanceSide.value = toggleAppearanceSide.value !== "auto"
|
|
4863
4881
|
? toggleAppearanceSide.value
|
|
4864
4882
|
: toggleAppearanceRestrictor();
|
|
@@ -4978,15 +4996,17 @@ const toggleDetector = (mouseEvent, pattern, mode) => {
|
|
|
4978
4996
|
const toggleOptions = () => {
|
|
4979
4997
|
if (internalLoading.value || disabled.value || dropdownDisabled.value) return;
|
|
4980
4998
|
|
|
4981
|
-
|
|
4999
|
+
dropdownActive.value = !dropdownActive.value;
|
|
5000
|
+
|
|
5001
|
+
vue.nextTick(() => {
|
|
5002
|
+
toggleAppearanceRestrictorActivate();
|
|
5003
|
+
});
|
|
4982
5004
|
|
|
4983
5005
|
if (!dropdownActive.value) {
|
|
4984
5006
|
activeEmitter();
|
|
4985
5007
|
} else {
|
|
4986
5008
|
closeEmitter();
|
|
4987
5009
|
}
|
|
4988
|
-
|
|
4989
|
-
dropdownActive.value = !dropdownActive.value;
|
|
4990
5010
|
};
|
|
4991
5011
|
|
|
4992
5012
|
/**
|
|
@@ -5060,6 +5080,7 @@ const updateModelValue = () => {
|
|
|
5060
5080
|
* @listens extended:rollup-options
|
|
5061
5081
|
* @listens extended:toggle-options
|
|
5062
5082
|
* @listens extended:select-option
|
|
5083
|
+
* @listens extended:preselect-option
|
|
5063
5084
|
* @listens extended:deselect-option
|
|
5064
5085
|
* @listens extended:create-option
|
|
5065
5086
|
* @listens extended:increase-display
|
|
@@ -5113,6 +5134,16 @@ vue.onBeforeMount(() => {
|
|
|
5113
5134
|
updateModelValue();
|
|
5114
5135
|
});
|
|
5115
5136
|
|
|
5137
|
+
emitter.value.on("extended:preselect-option", (option) => {
|
|
5138
|
+
if (multiple.value) {
|
|
5139
|
+
selectedOptions.value.push(option.option);
|
|
5140
|
+
} else {
|
|
5141
|
+
selectedOptions.value = [option.option];
|
|
5142
|
+
}
|
|
5143
|
+
|
|
5144
|
+
updateModelValue();
|
|
5145
|
+
});
|
|
5146
|
+
|
|
5116
5147
|
emitter.value.on("extended:deselect-option", (payload) => {
|
|
5117
5148
|
if (multiple.value && (payload && !payload.clearAll)) {
|
|
5118
5149
|
const deselectedOption = selectedOptions.value[payload.index];
|
|
@@ -5242,15 +5273,21 @@ vue.onMounted(() => {
|
|
|
5242
5273
|
&& typeof options.value !== "function"
|
|
5243
5274
|
) {
|
|
5244
5275
|
dropdownActive.value = true;
|
|
5276
|
+
|
|
5277
|
+
vue.nextTick(() => {
|
|
5278
|
+
toggleAppearanceRestrictorActivate();
|
|
5279
|
+
});
|
|
5245
5280
|
}
|
|
5246
5281
|
|
|
5247
5282
|
emitter.value.on("extended:expand-options", () => {
|
|
5248
5283
|
if (dropdownActive.value || dropdownDisabled.value) return;
|
|
5249
|
-
|
|
5250
|
-
toggleAppearanceRestrictorActivate();
|
|
5251
|
-
activeEmitter();
|
|
5252
|
-
|
|
5284
|
+
|
|
5253
5285
|
dropdownActive.value = true;
|
|
5286
|
+
|
|
5287
|
+
vue.nextTick(() => {
|
|
5288
|
+
toggleAppearanceRestrictorActivate();
|
|
5289
|
+
});
|
|
5290
|
+
activeEmitter();
|
|
5254
5291
|
});
|
|
5255
5292
|
|
|
5256
5293
|
emitter.value.on("extended:loader-pattern-changed", async (pattern) => {
|
|
@@ -5430,6 +5467,8 @@ return (_ctx, _cache) => {
|
|
|
5430
5467
|
(dropdownActive.value)
|
|
5431
5468
|
? (vue.openBlock(), vue.createBlock(script$9, {
|
|
5432
5469
|
key: 0,
|
|
5470
|
+
ref_key: "extendedMultiselectOptions",
|
|
5471
|
+
ref: extendedMultiselectOptions,
|
|
5433
5472
|
"auto-select-created-option": __props.autoSelectCreatedOption,
|
|
5434
5473
|
"clear-by-select-when-multiple": __props.clearBySelectWhenMultiple,
|
|
5435
5474
|
"create-on-the-go": __props.createOnTheGo,
|