@danielgindi/selectbox 2.0.37 → 2.0.39
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 +32 -6
- 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 +32 -6
- 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 +32 -6
- 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 +6 -2
- package/lib/SelectBox.js +25 -3
- package/package.json +1 -1
- package/vue/SelectBox.vue +10 -0
package/lib/DropList.js
CHANGED
|
@@ -2709,14 +2709,14 @@ class DropList {
|
|
|
2709
2709
|
|
|
2710
2710
|
// Inline search box not available, then support typing to focus by first letters
|
|
2711
2711
|
if (!p.searchable)
|
|
2712
|
-
this._keydownFreeType(event);
|
|
2712
|
+
this._keydownFreeType(event, !this.isVisible());
|
|
2713
2713
|
|
|
2714
2714
|
preventDefault = false;
|
|
2715
2715
|
}
|
|
2716
2716
|
}
|
|
2717
2717
|
}
|
|
2718
2718
|
|
|
2719
|
-
_keydownFreeType(evt) {
|
|
2719
|
+
_keydownFreeType(evt, autoSelect) {
|
|
2720
2720
|
const p = this._p;
|
|
2721
2721
|
|
|
2722
2722
|
// noinspection JSDeprecatedSymbols
|
|
@@ -2775,6 +2775,10 @@ class DropList {
|
|
|
2775
2775
|
let next = p.virtualListHelper.getItemElementAt(matchIndex);
|
|
2776
2776
|
this._focus(evt, next || null, matchIndex, true);
|
|
2777
2777
|
|
|
2778
|
+
if (autoSelect) {
|
|
2779
|
+
this.triggerItemSelection(next ? null : items[matchIndex], evt);
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2778
2782
|
// Record the last filter used
|
|
2779
2783
|
p.previousFilter = keyword;
|
|
2780
2784
|
|
package/lib/SelectBox.js
CHANGED
|
@@ -110,6 +110,7 @@ const inputBackbufferCssProps = [
|
|
|
110
110
|
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderRestMultiItem]
|
|
111
111
|
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderRestMultiItem]
|
|
112
112
|
* @property {boolean} [searchable=false] is it searchable?
|
|
113
|
+
* @property {boolean} [allowTypeToSelect=true] default behavior of type to select (focus first item starting with the search term) when searchable is true
|
|
113
114
|
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
114
115
|
* @property {boolean} [autoSelectTextOnCheck=true] automatically select text in input when an item is checked (multi mode). Used to allow the user to quickly type multiple items.
|
|
115
116
|
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
@@ -240,6 +241,7 @@ class SelectBox {
|
|
|
240
241
|
showPlaceholderInTooltip: o.showPlaceholderInTooltip,
|
|
241
242
|
multiPlaceholderFormatter: o.multiPlaceholderFormatter,
|
|
242
243
|
searchable: o.searchable,
|
|
244
|
+
allowTypeToSelect: o.allowTypeToSelect,
|
|
243
245
|
noResultsText: o.noResultsText,
|
|
244
246
|
autoSelectTextOnCheck: o.autoSelectTextOnCheck,
|
|
245
247
|
|
|
@@ -1022,6 +1024,20 @@ class SelectBox {
|
|
|
1022
1024
|
return this;
|
|
1023
1025
|
}
|
|
1024
1026
|
|
|
1027
|
+
/**
|
|
1028
|
+
* @param {boolean} allowTypeToSelect
|
|
1029
|
+
* @returns {SelectBox}
|
|
1030
|
+
*/
|
|
1031
|
+
setAllowTypeToSelect(allowTypeToSelect) {
|
|
1032
|
+
const p = this._p;
|
|
1033
|
+
allowTypeToSelect = !!allowTypeToSelect;
|
|
1034
|
+
if (p.allowTypeToSelect === allowTypeToSelect)
|
|
1035
|
+
return this;
|
|
1036
|
+
|
|
1037
|
+
p.allowTypeToSelect = allowTypeToSelect;
|
|
1038
|
+
return this;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1025
1041
|
/**
|
|
1026
1042
|
* @returns {boolean}
|
|
1027
1043
|
*/
|
|
@@ -2221,11 +2237,17 @@ class SelectBox {
|
|
|
2221
2237
|
break;
|
|
2222
2238
|
|
|
2223
2239
|
default:
|
|
2224
|
-
if (
|
|
2240
|
+
if (dropList.isVisible()) {
|
|
2241
|
+
dropList._keydownFreeType(evt, false);
|
|
2242
|
+
} else if (p.allowTypeToSelect) {
|
|
2243
|
+
dropList._keydownFreeType(evt, true);
|
|
2244
|
+
} else {
|
|
2225
2245
|
this.openList();
|
|
2246
|
+
setTimeout(() => {
|
|
2247
|
+
if (this[DestroyedSymbol]) return; // destroyed by event handler
|
|
2248
|
+
dropList._keydownFreeType(evt, false);
|
|
2249
|
+
});
|
|
2226
2250
|
}
|
|
2227
|
-
|
|
2228
|
-
dropList._keydownFreeType(evt);
|
|
2229
2251
|
break;
|
|
2230
2252
|
}
|
|
2231
2253
|
|
package/package.json
CHANGED
package/vue/SelectBox.vue
CHANGED
|
@@ -109,6 +109,10 @@ export const PropTypes = {
|
|
|
109
109
|
type: Boolean,
|
|
110
110
|
default: true,
|
|
111
111
|
},
|
|
112
|
+
allowTypeToSelect: {
|
|
113
|
+
type: Boolean,
|
|
114
|
+
default: true,
|
|
115
|
+
},
|
|
112
116
|
noResultsText: {
|
|
113
117
|
type: String,
|
|
114
118
|
required: false,
|
|
@@ -568,6 +572,11 @@ export default {
|
|
|
568
572
|
this.nonReactive.instance.setSearchable(value);
|
|
569
573
|
},
|
|
570
574
|
|
|
575
|
+
allowTypeToSelect(value) {
|
|
576
|
+
if (this.nonReactive.instance)
|
|
577
|
+
this.nonReactive.instance.setAllowTypeToSelect(value);
|
|
578
|
+
},
|
|
579
|
+
|
|
571
580
|
noResultsText(value) {
|
|
572
581
|
if (this.nonReactive.instance)
|
|
573
582
|
this.nonReactive.instance.setNoResultsText(value ?? DefaultOptions.noResultsText);
|
|
@@ -827,6 +836,7 @@ export default {
|
|
|
827
836
|
blurOnSingleSelection: this.blurOnSingleSelection,
|
|
828
837
|
multi: this.multi,
|
|
829
838
|
searchable: this.searchable,
|
|
839
|
+
allowTypeToSelect: this.allowTypeToSelect,
|
|
830
840
|
noResultsText: this.noResultsText ?? DefaultOptions.noResultsText,
|
|
831
841
|
filterThrottleWindow: this.filterThrottleWindow ?? DefaultOptions.filterThrottleWindow ?? 0,
|
|
832
842
|
filterOnEmptyTerm: this.filterOnEmptyTerm,
|