@danielgindi/selectbox 2.0.36 → 2.0.38

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.36
2
+ * @danielgindi/selectbox 2.0.38
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,7 +9032,7 @@ class DropList {
9032
9032
  let next = p.virtualListHelper.getItemElementAt(matchIndex);
9033
9033
  this._focus(evt, next || null, matchIndex, true);
9034
9034
 
9035
- if (!this.isVisible()) {
9035
+ if (autoSelect) {
9036
9036
  this.triggerItemSelection(next ? null : items[matchIndex], evt);
9037
9037
  }
9038
9038
 
@@ -9911,6 +9911,7 @@ const inputBackbufferCssProps = [
9911
9911
  * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderRestMultiItem]
9912
9912
  * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderRestMultiItem]
9913
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
9914
9915
  * @property {string} [noResultsText='No matching results'] text for no results (empty for none)
9915
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.
9916
9917
  * @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
@@ -10041,6 +10042,7 @@ class SelectBox {
10041
10042
  showPlaceholderInTooltip: o.showPlaceholderInTooltip,
10042
10043
  multiPlaceholderFormatter: o.multiPlaceholderFormatter,
10043
10044
  searchable: o.searchable,
10045
+ allowTypeToSelect: o.allowTypeToSelect,
10044
10046
  noResultsText: o.noResultsText,
10045
10047
  autoSelectTextOnCheck: o.autoSelectTextOnCheck,
10046
10048
 
@@ -10823,6 +10825,20 @@ class SelectBox {
10823
10825
  return this;
10824
10826
  }
10825
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
+
10826
10842
  /**
10827
10843
  * @returns {boolean}
10828
10844
  */
@@ -12022,7 +12038,15 @@ class SelectBox {
12022
12038
  break;
12023
12039
 
12024
12040
  default:
12025
- dropList._keydownFreeType(evt);
12041
+ if (p.allowTypeToSelect) {
12042
+ dropList._keydownFreeType(evt, true);
12043
+ } else {
12044
+ this.openList();
12045
+ setTimeout(() => {
12046
+ if (this[DestroyedSymbol]) return; // destroyed by event handler
12047
+ dropList._keydownFreeType(evt, false);
12048
+ });
12049
+ }
12026
12050
  break;
12027
12051
  }
12028
12052