vue3-extended-multiselect 2.2.3 → 2.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/README.md
CHANGED
|
@@ -1629,6 +1629,24 @@ const rollUp = () => {
|
|
|
1629
1629
|
emitter.value.emit("extended:rollup-options", true);
|
|
1630
1630
|
};
|
|
1631
1631
|
|
|
1632
|
+
/**
|
|
1633
|
+
* Rolls up options list after option selection
|
|
1634
|
+
* and sets single option label
|
|
1635
|
+
* @function
|
|
1636
|
+
* @param {UnionPropType} option - option to be selected
|
|
1637
|
+
*/
|
|
1638
|
+
const rollupIfSelected = (option) => {
|
|
1639
|
+
if (toggleOptionsBySelect.value) {
|
|
1640
|
+
rollUp();
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
if (multiple.value) {
|
|
1644
|
+
return;
|
|
1645
|
+
} else {
|
|
1646
|
+
singleLabel.value = option.label;
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
|
|
1632
1650
|
/**
|
|
1633
1651
|
* Activates debounced version of options list filter
|
|
1634
1652
|
* @function
|
|
@@ -1642,6 +1660,7 @@ const search = () => {
|
|
|
1642
1660
|
* @listens extended:field-focus
|
|
1643
1661
|
* @listens extended:rollup-options
|
|
1644
1662
|
* @listens extended:select-option
|
|
1663
|
+
* @listens extended:preselect-option
|
|
1645
1664
|
* @listens extended:deselect-option
|
|
1646
1665
|
* @listens extended:clean-options
|
|
1647
1666
|
* @listens extended:clear-field
|
|
@@ -1665,16 +1684,11 @@ vue.onBeforeMount(() => {
|
|
|
1665
1684
|
});
|
|
1666
1685
|
|
|
1667
1686
|
emitter.value.on("extended:select-option", (option) => {
|
|
1687
|
+
rollupIfSelected(option);
|
|
1688
|
+
});
|
|
1668
1689
|
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
if (multiple.value) {
|
|
1674
|
-
return;
|
|
1675
|
-
} else {
|
|
1676
|
-
singleLabel.value = option.label;
|
|
1677
|
-
}
|
|
1690
|
+
emitter.value.on("extended:preselect-option", (option) => {
|
|
1691
|
+
rollupIfSelected(option);
|
|
1678
1692
|
});
|
|
1679
1693
|
|
|
1680
1694
|
emitter.value.on("extended:deselect-option", () => {
|
|
@@ -3618,7 +3632,7 @@ const _hoisted_3 = { class: "extended__multiselect-cancel_wrapper" };
|
|
|
3618
3632
|
|
|
3619
3633
|
/**
|
|
3620
3634
|
* @author Ridiger Daniil Dmitrievich, 2022
|
|
3621
|
-
* @version 2.
|
|
3635
|
+
* @version 2.3.0
|
|
3622
3636
|
*/
|
|
3623
3637
|
|
|
3624
3638
|
var script = {
|
|
@@ -4700,7 +4714,7 @@ const selectByEnter = (keyboardEvent) => {
|
|
|
4700
4714
|
/**
|
|
4701
4715
|
* Sets preselected option provided by "preselectedOption" prop
|
|
4702
4716
|
* @function
|
|
4703
|
-
* @emits extended:
|
|
4717
|
+
* @emits extended:preselect-option
|
|
4704
4718
|
* @param {UnionPropType} preselectedOption - option to be selected
|
|
4705
4719
|
* @param {boolean} restriction - restriction of preselected option
|
|
4706
4720
|
*/
|
|
@@ -4725,7 +4739,7 @@ const setPreselectedOption = (preselectedOption, restriction = true) => {
|
|
|
4725
4739
|
const isObjectOrArray = typeof preselectedOption === "object";
|
|
4726
4740
|
const label = createLabel(isObjectOrArray, preselectedOption);
|
|
4727
4741
|
|
|
4728
|
-
emitter.value.emit("extended:
|
|
4742
|
+
emitter.value.emit("extended:preselect-option", {
|
|
4729
4743
|
label,
|
|
4730
4744
|
option: preselectedOption,
|
|
4731
4745
|
});
|
|
@@ -4735,7 +4749,7 @@ const setPreselectedOption = (preselectedOption, restriction = true) => {
|
|
|
4735
4749
|
* Sets preselected options provided by "preselectedOptions" prop
|
|
4736
4750
|
* if "multiple" prop equals true
|
|
4737
4751
|
* @function
|
|
4738
|
-
* @emits extended:
|
|
4752
|
+
* @emits extended:preselect-option
|
|
4739
4753
|
* @param {Array} preselectedOptions - options to be selected
|
|
4740
4754
|
* @param {boolean} restriction - restriction of preselected options
|
|
4741
4755
|
*/
|
|
@@ -4760,7 +4774,7 @@ const setPreselectedOptions = async (preselectedOptions, restriction = true) =>
|
|
|
4760
4774
|
|
|
4761
4775
|
allOptionsWereSelected++;
|
|
4762
4776
|
|
|
4763
|
-
emitter.value.emit("extended:
|
|
4777
|
+
emitter.value.emit("extended:preselect-option", {
|
|
4764
4778
|
label,
|
|
4765
4779
|
option: preselectedOption,
|
|
4766
4780
|
});
|
|
@@ -4784,7 +4798,7 @@ const setPreselectedOptionsByModelValue = (withRemoval = false) => {
|
|
|
4784
4798
|
|
|
4785
4799
|
if (withRemoval) selectedOptionsWatcher.value();
|
|
4786
4800
|
|
|
4787
|
-
if (multiple.value) {
|
|
4801
|
+
if (Array.isArray(modelValue.value) && multiple.value) {
|
|
4788
4802
|
if (withRemoval) removeSelectedOptions();
|
|
4789
4803
|
|
|
4790
4804
|
setPreselectedOptions(modelValue.value, false);
|
|
@@ -4821,7 +4835,7 @@ const setPreselectedOptionsByConditions = () => {
|
|
|
4821
4835
|
}
|
|
4822
4836
|
}
|
|
4823
4837
|
|
|
4824
|
-
if (preselectedOptions.value && multiple.value) {
|
|
4838
|
+
if (!!preselectedOptions.value.length && multiple.value) {
|
|
4825
4839
|
const initialLength = selectedOptions.value.length;
|
|
4826
4840
|
|
|
4827
4841
|
setPreselectedOptions(preselectedOptions.value);
|
|
@@ -5060,6 +5074,7 @@ const updateModelValue = () => {
|
|
|
5060
5074
|
* @listens extended:rollup-options
|
|
5061
5075
|
* @listens extended:toggle-options
|
|
5062
5076
|
* @listens extended:select-option
|
|
5077
|
+
* @listens extended:preselect-option
|
|
5063
5078
|
* @listens extended:deselect-option
|
|
5064
5079
|
* @listens extended:create-option
|
|
5065
5080
|
* @listens extended:increase-display
|
|
@@ -5113,6 +5128,16 @@ vue.onBeforeMount(() => {
|
|
|
5113
5128
|
updateModelValue();
|
|
5114
5129
|
});
|
|
5115
5130
|
|
|
5131
|
+
emitter.value.on("extended:preselect-option", (option) => {
|
|
5132
|
+
if (multiple.value) {
|
|
5133
|
+
selectedOptions.value.push(option.option);
|
|
5134
|
+
} else {
|
|
5135
|
+
selectedOptions.value = [option.option];
|
|
5136
|
+
}
|
|
5137
|
+
|
|
5138
|
+
updateModelValue();
|
|
5139
|
+
});
|
|
5140
|
+
|
|
5116
5141
|
emitter.value.on("extended:deselect-option", (payload) => {
|
|
5117
5142
|
if (multiple.value && (payload && !payload.clearAll)) {
|
|
5118
5143
|
const deselectedOption = selectedOptions.value[payload.index];
|