@danielgindi/selectbox 1.0.120 → 1.0.122
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/dist/lib.cjs.js +2634 -161
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +19 -23
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +8215 -5742
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/lib/DropList.js +18 -22
- package/package.json +10 -10
- package/vue/SelectBox.vue +9 -5
package/dist/lib.es6.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 1.0.
|
|
2
|
+
* @danielgindi/selectbox 1.0.122
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
|
|
@@ -1745,53 +1745,49 @@ class DropList {
|
|
|
1745
1745
|
|
|
1746
1746
|
let regex = new RegExp(`^${escapeRegex(keyword)}`, 'i');
|
|
1747
1747
|
|
|
1748
|
-
let
|
|
1748
|
+
let matchIndex = -1;
|
|
1749
1749
|
let item;
|
|
1750
1750
|
|
|
1751
|
-
|
|
1751
|
+
let focusItemIndex = p.focusItemIndex;
|
|
1752
|
+
|
|
1753
|
+
// These are all the possible matches for the text typed in so far
|
|
1752
1754
|
for (let i = 0, count = p.items.length; i < count; i++) {
|
|
1755
|
+
if (matchIndex !== -1 && i < focusItemIndex)
|
|
1756
|
+
continue; // We are only interested in first match + match after the focused item
|
|
1757
|
+
|
|
1753
1758
|
item = p.items[i];
|
|
1754
1759
|
if (regex.test(item.label)) {
|
|
1755
|
-
|
|
1760
|
+
matchIndex = i;
|
|
1761
|
+
if (focusItemIndex === -1 || i >= focusItemIndex)
|
|
1762
|
+
break;
|
|
1756
1763
|
}
|
|
1757
1764
|
}
|
|
1758
1765
|
|
|
1759
1766
|
// Did we find anything?
|
|
1760
|
-
if (
|
|
1767
|
+
if (matchIndex === -1) {
|
|
1761
1768
|
// No... So start over with this character as the only one.
|
|
1762
1769
|
keyword = character;
|
|
1763
1770
|
regex = new RegExp(`^${escapeRegex(keyword)}`, 'i');
|
|
1764
1771
|
|
|
1765
1772
|
for (let i = 0, count = p.items.length; i < count; i++) {
|
|
1773
|
+
if (matchIndex !== -1 && i < focusItemIndex)
|
|
1774
|
+
continue; // We are only interested in first match + match after the focused item
|
|
1775
|
+
|
|
1766
1776
|
item = p.items[i];
|
|
1767
1777
|
if (regex.test(item.label)) {
|
|
1768
|
-
|
|
1778
|
+
matchIndex = i;
|
|
1779
|
+
if (focusItemIndex === -1 || i >= focusItemIndex)
|
|
1780
|
+
break;
|
|
1769
1781
|
}
|
|
1770
1782
|
}
|
|
1771
1783
|
}
|
|
1772
1784
|
|
|
1773
|
-
let focusItemIndex = p.focusItemIndex;
|
|
1774
|
-
let matchIndex = -1;
|
|
1775
|
-
|
|
1776
|
-
// Find a match *after* the focused item
|
|
1777
|
-
for (let i = 0, count = matchIndices.length; i < count; i++) {
|
|
1778
|
-
if (matchIndices[i] >= focusItemIndex) {
|
|
1779
|
-
matchIndex = matchIndices[i];
|
|
1780
|
-
break;
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
// Find a match from the beginning.
|
|
1785
|
-
if (matchIndex === -1 && matchIndices.length) {
|
|
1786
|
-
matchIndex = matchIndices[0];
|
|
1787
|
-
}
|
|
1788
|
-
|
|
1789
1785
|
if (matchIndex > -1) {
|
|
1790
1786
|
let next = p.virtualListHelper.getItemElementAt(matchIndex);
|
|
1791
1787
|
this._focus(evt, next || null, matchIndex);
|
|
1792
1788
|
|
|
1793
1789
|
if (!this.isVisible()) {
|
|
1794
|
-
this.triggerItemSelection(null, evt);
|
|
1790
|
+
this.triggerItemSelection(next ? null : p.items[matchIndex], evt);
|
|
1795
1791
|
}
|
|
1796
1792
|
|
|
1797
1793
|
// Record the last filter used
|