@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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 2.0.37
2
+ * @danielgindi/selectbox 2.0.39
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  'use strict';
@@ -8966,14 +8966,14 @@ class DropList {
8966
8966
 
8967
8967
  // Inline search box not available, then support typing to focus by first letters
8968
8968
  if (!p.searchable)
8969
- this._keydownFreeType(event);
8969
+ this._keydownFreeType(event, !this.isVisible());
8970
8970
 
8971
8971
  preventDefault = false;
8972
8972
  }
8973
8973
  }
8974
8974
  }
8975
8975
 
8976
- _keydownFreeType(evt) {var _p$filteredItems13;
8976
+ _keydownFreeType(evt, autoSelect) {var _p$filteredItems13;
8977
8977
  const p = this._p;
8978
8978
 
8979
8979
  // noinspection JSDeprecatedSymbols
@@ -9032,6 +9032,10 @@ class DropList {
9032
9032
  let next = p.virtualListHelper.getItemElementAt(matchIndex);
9033
9033
  this._focus(evt, next || null, matchIndex, true);
9034
9034
 
9035
+ if (autoSelect) {
9036
+ this.triggerItemSelection(next ? null : items[matchIndex], evt);
9037
+ }
9038
+
9035
9039
  // Record the last filter used
9036
9040
  p.previousFilter = keyword;
9037
9041
 
@@ -9907,6 +9911,7 @@ const inputBackbufferCssProps = [
9907
9911
  * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderRestMultiItem]
9908
9912
  * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderRestMultiItem]
9909
9913
  * @property {boolean} [searchable=false] is it searchable?
9914
+ * @property {boolean} [allowTypeToSelect=true] default behavior of type to select (focus first item starting with the search term) when searchable is true
9910
9915
  * @property {string} [noResultsText='No matching results'] text for no results (empty for none)
9911
9916
  * @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.
9912
9917
  * @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
@@ -10037,6 +10042,7 @@ class SelectBox {
10037
10042
  showPlaceholderInTooltip: o.showPlaceholderInTooltip,
10038
10043
  multiPlaceholderFormatter: o.multiPlaceholderFormatter,
10039
10044
  searchable: o.searchable,
10045
+ allowTypeToSelect: o.allowTypeToSelect,
10040
10046
  noResultsText: o.noResultsText,
10041
10047
  autoSelectTextOnCheck: o.autoSelectTextOnCheck,
10042
10048
 
@@ -10819,6 +10825,20 @@ class SelectBox {
10819
10825
  return this;
10820
10826
  }
10821
10827
 
10828
+ /**
10829
+ * @param {boolean} allowTypeToSelect
10830
+ * @returns {SelectBox}
10831
+ */
10832
+ setAllowTypeToSelect(allowTypeToSelect) {
10833
+ const p = this._p;
10834
+ allowTypeToSelect = !!allowTypeToSelect;
10835
+ if (p.allowTypeToSelect === allowTypeToSelect)
10836
+ return this;
10837
+
10838
+ p.allowTypeToSelect = allowTypeToSelect;
10839
+ return this;
10840
+ }
10841
+
10822
10842
  /**
10823
10843
  * @returns {boolean}
10824
10844
  */
@@ -12018,11 +12038,17 @@ class SelectBox {
12018
12038
  break;
12019
12039
 
12020
12040
  default:
12021
- if (!dropList.isVisible()) {
12041
+ if (dropList.isVisible()) {
12042
+ dropList._keydownFreeType(evt, false);
12043
+ } else if (p.allowTypeToSelect) {
12044
+ dropList._keydownFreeType(evt, true);
12045
+ } else {
12022
12046
  this.openList();
12047
+ setTimeout(() => {
12048
+ if (this[DestroyedSymbol]) return; // destroyed by event handler
12049
+ dropList._keydownFreeType(evt, false);
12050
+ });
12023
12051
  }
12024
-
12025
- dropList._keydownFreeType(evt);
12026
12052
  break;
12027
12053
  }
12028
12054