@danielgindi/selectbox 2.0.58 → 2.0.59

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.es6.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 2.0.58
2
+ * @danielgindi/selectbox 2.0.59
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  import { closestUntil, createElement, next, prev, setElementAttrs } from "@danielgindi/dom-utils/lib/Dom";
@@ -107,9 +107,6 @@ var DefaultOptions = {
107
107
  filterEmptyGroups: false
108
108
  };
109
109
  var DropList = class DropList {
110
- /**
111
- * @param {DropList.Options} options
112
- */
113
110
  constructor(options) {
114
111
  const o = { ...DefaultOptions };
115
112
  for (let [key, value] of Object.entries(
@@ -315,19 +312,13 @@ var DropList = class DropList {
315
312
  }
316
313
  /**
317
314
  * Returns true if other is an inclusive descendant of node, and false otherwise.
318
- * @param {Node} other
319
- * @param {boolean} [considerSubmenus=true]
320
- * @returns {boolean}
315
+ * Accepts `EventTarget` (not just `Node`) since callers pass `event.target`/`event.relatedTarget` directly.
321
316
  */
322
317
  elContains(other, considerSubmenus = true) {
323
318
  if (this.el.contains(other)) return true;
324
319
  if (considerSubmenus && this._p.currentSubDropList?.droplist?.elContains(other)) return true;
325
320
  return false;
326
321
  }
327
- /**
328
- * @param {string|string[]} classes
329
- * @returns {DropList}
330
- */
331
322
  setAdditionalClasses(classes) {
332
323
  const p = this._p;
333
324
  p.additionalClasses = classes;
@@ -336,8 +327,6 @@ var DropList = class DropList {
336
327
  }
337
328
  /**
338
329
  * Sets the appropriate direction for the droplist
339
- * @param {'ltr'|'rtl'|'auto'} direction
340
- * @return {DropList}
341
330
  */
342
331
  setDirection(direction) {
343
332
  const p = this._p;
@@ -347,46 +336,26 @@ var DropList = class DropList {
347
336
  }
348
337
  /**
349
338
  * Gets the supplied direction for the droplist
350
- * @return {'ltr'|'rtl'|'auto'}
351
339
  */
352
340
  getDirection() {
353
341
  return this._p.direction;
354
342
  }
355
- /**
356
- * @param {string} prop
357
- * @returns {DropList}
358
- */
359
343
  setLabelProp(prop) {
360
344
  const p = this._p;
361
345
  p.labelProp = prop;
362
346
  return this;
363
347
  }
364
- /**
365
- *
366
- * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [fn] Function to call when rendering an item element
367
- * @returns {DropList}
368
- */
369
348
  setRenderItem(fn) {
370
349
  const p = this._p;
371
350
  p.renderItem = fn;
372
351
  return this;
373
352
  }
374
- /**
375
- *
376
- * @property {function(item: DropList.ItemBase, itemEl: Element)} [fn] Function to call when rendering an item element
377
- * @returns {DropList}
378
- */
379
353
  setUnrenderItem(fn) {
380
354
  const p = this._p;
381
355
  p.unrenderItem = fn;
382
356
  this._setupUnrenderFunction();
383
357
  return this;
384
358
  }
385
- /**
386
- * @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
387
- * @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
388
- * @returns {DropList}
389
- */
390
359
  setRenderNoResultsItem(render, unrender) {
391
360
  const p = this._p;
392
361
  p.renderNoResultsItem = render;
@@ -432,10 +401,6 @@ var DropList = class DropList {
432
401
  });
433
402
  return this;
434
403
  }
435
- /**
436
- * @param {string} prop
437
- * @returns {DropList}
438
- */
439
404
  setValueProp(prop) {
440
405
  const p = this._p;
441
406
  p.valueProp = prop;
@@ -523,19 +488,16 @@ var DropList = class DropList {
523
488
  return true;
524
489
  }
525
490
  /**
526
- *
527
- * @param {DropList.Item} item The item to add. It is copied.
528
- * @param {number} [atIndex=-1] The index to insert at (or -1)
529
- * @returns {DropList}
491
+ * @param item The item to add. It is copied.
492
+ * @param atIndex The index to insert at (or -1)
530
493
  */
531
494
  addItem(item, atIndex = -1) {
532
495
  return this.addItems([item], atIndex);
533
496
  }
534
497
  /**
535
498
  * Adds items to the menu and renders
536
- * @param {DropList.Item[]} itemsToAdd The items to add. These are copied.
537
- * @param {number} [atIndex=-1] The index to insert at (or -1)
538
- * @returns {DropList}
499
+ * @param itemsToAdd The items to add. These are copied.
500
+ * @param atIndex The index to insert at (or -1)
539
501
  */
540
502
  addItems(itemsToAdd, atIndex = -1) {
541
503
  const p = this._p, labelProp = p.labelProp, valueProp = p.valueProp;
@@ -577,8 +539,7 @@ var DropList = class DropList {
577
539
  }
578
540
  /**
579
541
  * Replaces all current items with the supplied items
580
- * @param {DropList.Item[]} items The items to set. These are copied.
581
- * @returns {DropList}
542
+ * @param items The items to set. These are copied.
582
543
  */
583
544
  setItems(items) {
584
545
  const p = this._p;
@@ -723,8 +684,6 @@ var DropList = class DropList {
723
684
  /**
724
685
  * Return the item element at the given original index, if it exists.
725
686
  * The item may not be currently rendered, and null will be returned
726
- * @param index
727
- * @returns {HTMLElement|null}
728
687
  */
729
688
  itemElementAtIndex(index) {
730
689
  const p = this._p;
@@ -735,16 +694,10 @@ var DropList = class DropList {
735
694
  /**
736
695
  * Return the item element at the given index, if it exists.
737
696
  * The item may not be currently rendered, and null will be returned
738
- * @param index
739
- * @returns {HTMLElement|null}
740
697
  */
741
698
  filteredElementItemAtIndex(index) {
742
699
  return this._p.virtualListHelper.getItemElementAt(index) ?? null;
743
700
  }
744
- /**
745
- * @param {function(dropList: DropList):DropList.PositionOptions} fn
746
- * @returns {DropList}
747
- */
748
701
  setPositionOptionsProvider(fn) {
749
702
  const p = this._p;
750
703
  if (p.positionOptionsProvider === fn) return this;
@@ -752,17 +705,12 @@ var DropList = class DropList {
752
705
  this.relayout();
753
706
  return this;
754
707
  }
755
- /**
756
- * @returns {function(dropList: DropList):DropList.PositionOptions|null}
757
- */
758
708
  getPositionOptionsProvider() {
759
709
  return this._p.positionOptionsProvider;
760
710
  }
761
711
  /**
762
712
  * Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderItem`/`unrenderItem`)
763
713
  * instead of the default `console.error`/`console.warn`.
764
- * @param {DropList.LibraryErrorHandler|null} [fn]
765
- * @returns {DropList}
766
714
  */
767
715
  setOnError(fn) {
768
716
  const p = this._p;
@@ -770,15 +718,14 @@ var DropList = class DropList {
770
718
  return this;
771
719
  }
772
720
  /**
773
- * @returns {DropList.LibraryErrorHandler|undefined}
721
+ * Gets the current `onError` handler, if any.
774
722
  */
775
723
  getOnError() {
776
724
  return this._p.onError;
777
725
  }
778
726
  /**
779
- * @param {string} term
780
- * @param {boolean} [performSearch=false] should actually perform the search, or just set the input's text?
781
- * @returns {DropList}
727
+ * @param term the search term to set
728
+ * @param performSearch should actually perform the search, or just set the input's text?
782
729
  */
783
730
  setSearchTerm(term, performSearch = false) {
784
731
  const p = this._p;
@@ -883,26 +830,15 @@ var DropList = class DropList {
883
830
  if (p.items) return p.items.length;
884
831
  return 0;
885
832
  }
886
- /**
887
- * @param {string} noResultsText
888
- * @returns {DropList}
889
- */
890
833
  setNoResultsText(noResultsText) {
891
834
  const p = this._p;
892
835
  p.noResultsText = noResultsText;
893
836
  if (p.hasNoResultsItem) p.virtualListHelper.refreshItemAt(0).render();
894
837
  return this;
895
838
  }
896
- /**
897
- * @returns {string}
898
- */
899
839
  getNoResultsText() {
900
840
  return this._p.noResultsText;
901
841
  }
902
- /**
903
- * @param {number} window
904
- * @returns {DropList}
905
- */
906
842
  setFilterThrottleWindow(window) {
907
843
  const p = this._p;
908
844
  p.filterThrottleWindow = window;
@@ -912,16 +848,9 @@ var DropList = class DropList {
912
848
  if (isScheduled) p.throttledRefilterItems();
913
849
  return this;
914
850
  }
915
- /**
916
- * @returns {number}
917
- */
918
851
  getFilterThrottleWindow() {
919
852
  return this._p.filterThrottleWindow;
920
853
  }
921
- /**
922
- * @param {boolean} value
923
- * @returns {DropList}
924
- */
925
854
  setFilterOnEmptyTerm(value) {
926
855
  const p = this._p;
927
856
  if (p.filterOnEmptyTerm === value) return this;
@@ -929,16 +858,9 @@ var DropList = class DropList {
929
858
  p.throttledRefilterItems();
930
859
  return this;
931
860
  }
932
- /**
933
- * @returns {boolean}
934
- */
935
861
  getFilterOnEmptyTerm() {
936
862
  return this._p.filterOnEmptyTerm;
937
863
  }
938
- /**
939
- * @param {boolean} value
940
- * @returns {DropList}
941
- */
942
864
  setFilterGroups(value) {
943
865
  const p = this._p;
944
866
  if (p.filterGroups === value) return this;
@@ -946,52 +868,30 @@ var DropList = class DropList {
946
868
  p.throttledRefilterItems();
947
869
  return this;
948
870
  }
949
- /**
950
- * @returns {boolean}
951
- */
952
871
  getFilterGroups() {
953
872
  return this._p.filterGroups;
954
873
  }
955
- /**
956
- * @param {boolean} value
957
- * @returns {DropList}
958
- */
959
- setFilterEmptyGroups(value) {
874
+ setFilterEmptyGroups(value = true) {
960
875
  const p = this._p;
961
876
  if (p.filterEmptyGroups === value) return this;
962
877
  p.filterEmptyGroups = value;
963
878
  p.throttledRefilterItems();
964
879
  return this;
965
880
  }
966
- /**
967
- * @returns {boolean}
968
- */
969
881
  getFilterEmptyGroups() {
970
882
  return this._p.filterEmptyGroups;
971
883
  }
972
- /**
973
- * @param {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} fn
974
- * @returns {DropList}
975
- */
976
884
  setFilterFn(fn) {
977
885
  const p = this._p;
886
+ fn ??= null;
978
887
  if (p.filterFn === fn) return this;
979
888
  p.filterFn = fn;
980
889
  p.throttledRefilterItems();
981
890
  return this;
982
891
  }
983
- /**
984
- * @returns {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)}
985
- */
986
892
  getFilterFn() {
987
893
  return this._p.filterFn;
988
894
  }
989
- /**
990
- *
991
- * @param {DropList.PositionOptions} [positionOptions]
992
- * @returns {DropList}
993
- * @public
994
- */
995
895
  relayout(positionOptions) {
996
896
  const p = this._p, el = p.el, menuEl = p.menuEl;
997
897
  if (!this.isVisible()) return this;
@@ -1116,7 +1016,10 @@ var DropList = class DropList {
1116
1016
  viewCss.top += "px";
1117
1017
  setCssProps(el, viewCss);
1118
1018
  setElementHeight(el, viewSize.height, true, true);
1119
- if (menuEl !== el) setElementHeight(menuEl, viewSize.height - headerHeight - footerHeight - verticalBorderWidth - verticalPadding, true, true);
1019
+ if (menuEl !== el) {
1020
+ let menuHeight = viewSize.height - headerHeight - footerHeight - verticalBorderWidth - verticalPadding;
1021
+ setElementHeight(menuEl, menuHeight, true, true);
1022
+ }
1120
1023
  p.virtualListHelper.render();
1121
1024
  if (positionOptions && positionOptions.target) {
1122
1025
  p.lastPositionTarget = positionOptions.target;
@@ -1130,10 +1033,6 @@ var DropList = class DropList {
1130
1033
  }
1131
1034
  /**
1132
1035
  * Set the checked mode of a specific value.
1133
- * @public
1134
- * @param {*} value - array of values to check
1135
- * @param {boolean} checked - will the value be checked?
1136
- * @returns {DropList} self
1137
1036
  */
1138
1037
  setItemChecked(value, checked) {
1139
1038
  const p = this._p;
@@ -1153,9 +1052,6 @@ var DropList = class DropList {
1153
1052
  }
1154
1053
  /**
1155
1054
  * Set the checked values. All the other values will be unchecked,
1156
- * @public
1157
- * @param {Array<*>} values - array of values to check
1158
- * @returns {DropList} self
1159
1055
  */
1160
1056
  setCheckedValues(values) {
1161
1057
  const p = this._p;
@@ -1178,11 +1074,9 @@ var DropList = class DropList {
1178
1074
  }
1179
1075
  /**
1180
1076
  * Get all checked values. Returns array of item values.
1181
- * @public
1182
- * @param {boolean} excludeGroups=false Exclude group items
1183
- * @returns {Array<*>} self
1077
+ * @param excludeGroups Exclude group items
1184
1078
  */
1185
- getCheckedValues(excludeGroups) {
1079
+ getCheckedValues(excludeGroups = false) {
1186
1080
  const p = this._p;
1187
1081
  excludeGroups = excludeGroups && p.groupCount > 0;
1188
1082
  let values = [];
@@ -1196,11 +1090,9 @@ var DropList = class DropList {
1196
1090
  }
1197
1091
  /**
1198
1092
  * Get all checked items. Returns array of actual item data object.
1199
- * @public
1200
- * @param {boolean} excludeGroups=false Exclude group items
1201
- * @returns {DropList.Item[]}
1093
+ * @param excludeGroups Exclude group items
1202
1094
  */
1203
- getCheckedItems(excludeGroups) {
1095
+ getCheckedItems(excludeGroups = false) {
1204
1096
  const p = this._p;
1205
1097
  excludeGroups = excludeGroups && p.groupCount > 0;
1206
1098
  const items = [];
@@ -1212,12 +1104,6 @@ var DropList = class DropList {
1212
1104
  }
1213
1105
  return items;
1214
1106
  }
1215
- /**
1216
- *
1217
- * @param {DropList.PositionOptions?} [positionOptions]
1218
- * @returns {DropList}
1219
- * @public
1220
- */
1221
1107
  show(positionOptions) {
1222
1108
  const p = this._p;
1223
1109
  p.hiding = false;
@@ -1301,7 +1187,6 @@ var DropList = class DropList {
1301
1187
  /**
1302
1188
  * Change visibility of the header element
1303
1189
  * You should probably call `relayout()` after this.
1304
- * @param {boolean} visible
1305
1190
  */
1306
1191
  setHeaderVisible(visible) {
1307
1192
  if (this.isHeaderVisible() === !!visible) return;
@@ -1310,14 +1195,12 @@ var DropList = class DropList {
1310
1195
  }
1311
1196
  /**
1312
1197
  * Is the header element visible?
1313
- * @returns {boolean}
1314
1198
  */
1315
1199
  isHeaderVisible() {
1316
1200
  return !!this._p.headerEl.parentNode;
1317
1201
  }
1318
1202
  /**
1319
1203
  * Get a reference to the header element in order to add custom content.
1320
- * @returns {Element}
1321
1204
  */
1322
1205
  getHeaderElement() {
1323
1206
  return this._p.headerEl;
@@ -1325,7 +1208,6 @@ var DropList = class DropList {
1325
1208
  /**
1326
1209
  * Change visibility of the footer element
1327
1210
  * You should probably call `relayout()` after this.
1328
- * @param {boolean} visible
1329
1211
  */
1330
1212
  setFooterVisible(visible) {
1331
1213
  if (this.isFooterVisible() === !!visible) return;
@@ -1334,14 +1216,12 @@ var DropList = class DropList {
1334
1216
  }
1335
1217
  /**
1336
1218
  * Is the footer element visible?
1337
- * @returns {boolean}
1338
1219
  */
1339
1220
  isFooterVisible() {
1340
1221
  return !!this._p.footerEl.parentNode;
1341
1222
  }
1342
1223
  /**
1343
1224
  * Get a reference to the footer element in order to add custom content.
1344
- * @returns {Element}
1345
1225
  */
1346
1226
  getFooterElement() {
1347
1227
  return this._p.footerEl;
@@ -1349,7 +1229,6 @@ var DropList = class DropList {
1349
1229
  /**
1350
1230
  * Set inline search visibility
1351
1231
  * You should probably call `relayout()` after this.
1352
- * @param {boolean} searchable
1353
1232
  */
1354
1233
  setSearchable(searchable) {
1355
1234
  const p = this._p;
@@ -1375,7 +1254,6 @@ var DropList = class DropList {
1375
1254
  }
1376
1255
  /**
1377
1256
  * Set the placeholder text of the inline search box
1378
- * @param {string} placeholder
1379
1257
  */
1380
1258
  setSearchPlaceholder(placeholder) {
1381
1259
  const p = this._p;
@@ -1620,9 +1498,6 @@ var DropList = class DropList {
1620
1498
  }
1621
1499
  /**
1622
1500
  * Register an event handler
1623
- * @param {(string|'*')?} event
1624
- * @param {function(any)} handler
1625
- * @returns {DropList}
1626
1501
  */
1627
1502
  on(event, handler) {
1628
1503
  this._p.mitt.on(event, handler);
@@ -1630,9 +1505,6 @@ var DropList = class DropList {
1630
1505
  }
1631
1506
  /**
1632
1507
  * Register a one time event handler
1633
- * @param {(string|'*')?} event
1634
- * @param {function(any)} handler
1635
- * @returns {DropList}
1636
1508
  */
1637
1509
  once(event, handler) {
1638
1510
  let wrapped = (value) => {
@@ -1644,9 +1516,6 @@ var DropList = class DropList {
1644
1516
  }
1645
1517
  /**
1646
1518
  * Remove an `handler` for `event`, all events for `event`, or all events completely.
1647
- * @param {(string|'*')?} event
1648
- * @param {function(any)} handler
1649
- * @returns {DropList}
1650
1519
  */
1651
1520
  off(event, handler) {
1652
1521
  if (!event && !event) this._p.mitt.all.clear();
@@ -1655,9 +1524,6 @@ var DropList = class DropList {
1655
1524
  }
1656
1525
  /**
1657
1526
  * Emit an event
1658
- * @param {string} event
1659
- * @param {any} value
1660
- * @returns {DropList}
1661
1527
  */
1662
1528
  emit(event, value) {
1663
1529
  this._p.mitt.emit(event, value);
@@ -1692,8 +1558,6 @@ var DropList = class DropList {
1692
1558
  return this;
1693
1559
  }
1694
1560
  /**
1695
- * @param {string} event
1696
- * @param {*} [data]
1697
1561
  * @private
1698
1562
  * @internal
1699
1563
  */
@@ -1836,9 +1700,7 @@ var DropList = class DropList {
1836
1700
  case VALUE_UP:
1837
1701
  this.previous(event);
1838
1702
  break;
1839
- case VALUE_DOWN:
1840
- this.next(event);
1841
- break;
1703
+ case VALUE_DOWN: this.next(event);
1842
1704
  }
1843
1705
  break;
1844
1706
  case VALUE_LEFT:
@@ -2111,7 +1973,6 @@ var DropList = class DropList {
2111
1973
  }
2112
1974
  /**
2113
1975
  * @private
2114
- * @returns {DropList} self
2115
1976
  * @internal
2116
1977
  */
2117
1978
  _measureItem() {
@@ -2157,8 +2018,7 @@ var DropList = class DropList {
2157
2018
  }
2158
2019
  /**
2159
2020
  * Determines whether the list should be in virtual mode, depending on the item count.
2160
- * @param {number?} targetItemCount - item count we are expecting. Defaults to current item count
2161
- * @returns {DropList}
2021
+ * @param targetItemCount item count we are expecting. Defaults to current item count
2162
2022
  * @private
2163
2023
  * @internal
2164
2024
  */
@@ -2223,11 +2083,6 @@ var DropList = class DropList {
2223
2083
  var DestroyedSymbol = Symbol("destroyed");
2224
2084
  var RestMultiItemsSymbol = Symbol("rest_multi_items");
2225
2085
  var hasTouchCapability = !!("ontouchstart" in window || window.DocumentTouch && window.document instanceof window.DocumentTouch || window.navigator.maxTouchPoints);
2226
- /**
2227
- * @param {Element|EventTarget} el
2228
- * @param {string} className
2229
- * @returns {boolean}
2230
- */
2231
2086
  var hasClass = function(el, className) {
2232
2087
  if (el instanceof Element) return el.classList.contains(className);
2233
2088
  return false;
@@ -2283,12 +2138,6 @@ var DefaultOptions$1 = {
2283
2138
  closeListWhenLoading: true,
2284
2139
  clearInputWhen: ["single_close", "multi_select_single"]
2285
2140
  };
2286
- /**
2287
- *
2288
- * @param {DropList.ItemBase[]} items
2289
- * @param {string} labelProp
2290
- * @returns {string}
2291
- */
2292
2141
  var defaultMultiPlaceholderFormatter = (items, labelProp) => {
2293
2142
  if (items.length === 0) return "";
2294
2143
  let title = items[0][labelProp] + "";
@@ -2312,9 +2161,6 @@ function restoreFocusState(state) {
2312
2161
  return true;
2313
2162
  }
2314
2163
  var SelectBox = class {
2315
- /**
2316
- * @param {SelectBox.Options} options
2317
- */
2318
2164
  constructor(options) {
2319
2165
  const o = { ...DefaultOptions$1 };
2320
2166
  for (let [key, value] of Object.entries(
@@ -2502,21 +2348,15 @@ var SelectBox = class {
2502
2348
  }
2503
2349
  /**
2504
2350
  * Returns true if other is an inclusive descendant of droplist node, false otherwise, and undefined if the droplist is not initiated.
2505
- * @param {Node} other
2506
- * @param {boolean} [considerSubmenus=true]
2507
- * @returns {boolean|undefined}
2508
2351
  */
2509
2352
  droplistElContains(other, considerSubmenus = true) {
2510
2353
  return this._p.dropList?.elContains(other, considerSubmenus);
2511
2354
  }
2512
2355
  /**
2513
2356
  * Enables the control
2514
- * @param {boolean=true} enabled Should the control be enabled?
2515
- * @returns {SelectBox}
2516
2357
  */
2517
- enable(enabled) {
2358
+ enable(enabled = true) {
2518
2359
  const p = this._p;
2519
- if (enabled === void 0) enabled = true;
2520
2360
  p.disabled = !enabled;
2521
2361
  p.el.setAttribute("aria-disabled", p.disabled.toString());
2522
2362
  p.input.disabled = !!p.disabled;
@@ -2527,50 +2367,38 @@ var SelectBox = class {
2527
2367
  }
2528
2368
  /**
2529
2369
  * Is the control enabled?
2530
- * @returns {boolean}
2531
2370
  */
2532
2371
  isEnabled() {
2533
2372
  return !this._p.disabled;
2534
2373
  }
2535
2374
  /**
2536
2375
  * Disables the control
2537
- * @param {boolean=true} disabled Should the control be disabled?
2538
- * @returns {SelectBox}
2539
2376
  */
2540
- disable(disabled) {
2541
- return this.enable(disabled === void 0 ? false : !disabled);
2377
+ disable(disabled = true) {
2378
+ return this.enable(!disabled);
2542
2379
  }
2543
2380
  /**
2544
2381
  * Is the control disabled?
2545
- * @returns {boolean}
2546
2382
  */
2547
2383
  isDisabled() {
2548
2384
  return this._p.disabled;
2549
2385
  }
2550
2386
  /**
2551
2387
  * Sets read only mode
2552
- * @param {boolean=true} readOnly Should the control be read only?
2553
- * @returns {SelectBox}
2554
2388
  */
2555
- setReadOnly(readOnly) {
2389
+ setReadOnly(readOnly = true) {
2556
2390
  const p = this._p;
2557
- if (readOnly === void 0) readOnly = true;
2558
2391
  p.readOnly = readOnly;
2559
2392
  p.el.setAttribute("aria-readOnly", p.readOnly.toString());
2560
2393
  p.input.readOnly = !(p.searchable || p.multi) || !!p.readOnly;
2561
2394
  return this;
2562
2395
  }
2563
2396
  /**
2564
- * Is the control enabled?
2565
- * @returns {boolean}
2397
+ * Is the control read only?
2566
2398
  */
2567
2399
  isReadOnly() {
2568
2400
  return this._p.readOnly;
2569
2401
  }
2570
- /**
2571
- * @param {string|string[]} classes
2572
- * @returns {SelectBox}
2573
- */
2574
2402
  setAdditionalClasses(classes) {
2575
2403
  const p = this._p;
2576
2404
  p.additionalClasses = classes;
@@ -2578,10 +2406,8 @@ var SelectBox = class {
2578
2406
  return this;
2579
2407
  }
2580
2408
  /**
2581
- *
2582
- * @param {DropList.ItemBase[]} [items]
2583
- * @param {boolean} [resetValues=true] should reset values to current values (essentially refresh the data based on items & values). If set to false, use setValue to set a fresh value
2584
- * @returns {SelectBox}
2409
+ * @param items the items to set (not values)
2410
+ * @param resetValues should reset values to current values (essentially refresh the data based on items & values). If set to false, use setValue to set a fresh value
2585
2411
  */
2586
2412
  setItems(items, resetValues = true) {
2587
2413
  const p = this._p;
@@ -2617,16 +2443,9 @@ var SelectBox = class {
2617
2443
  }
2618
2444
  if (p.dropList) p.dropList.updateItemByValue(value, newItem);
2619
2445
  }
2620
- /**
2621
- * @returns {DropList.ItemBase[]|*}
2622
- */
2623
2446
  getItems() {
2624
2447
  return this._p.items;
2625
2448
  }
2626
- /**
2627
- * @param {boolean} clearable
2628
- * @returns {SelectBox}
2629
- */
2630
2449
  setClearable(clearable) {
2631
2450
  clearable = !!clearable;
2632
2451
  if (this._p.clearable === clearable) return this;
@@ -2634,16 +2453,9 @@ var SelectBox = class {
2634
2453
  this._scheduleSync("render_clear");
2635
2454
  return this;
2636
2455
  }
2637
- /**
2638
- * @returns {boolean}
2639
- */
2640
2456
  getClearable() {
2641
2457
  return this._p.clearable;
2642
2458
  }
2643
- /**
2644
- * @param {boolean} enabled
2645
- * @returns {SelectBox}
2646
- */
2647
2459
  setHasOpenIndicator(enabled) {
2648
2460
  enabled = !!enabled;
2649
2461
  if (this._p.hasOpenIndicator === enabled) return this;
@@ -2651,31 +2463,20 @@ var SelectBox = class {
2651
2463
  this._scheduleSync("render_base");
2652
2464
  return this;
2653
2465
  }
2654
- /**
2655
- * @returns {boolean}
2656
- */
2657
2466
  getHasOpenIndicator() {
2658
2467
  return this._p.hasOpenIndicator;
2659
2468
  }
2660
- /**
2661
- * @param {string} placeholder
2662
- * @returns {SelectBox}
2663
- */
2664
2469
  setPlaceholder(placeholder) {
2665
2470
  this._p.placeholder = placeholder == null ? "" : String(placeholder);
2666
2471
  this._scheduleSync("render_base");
2667
2472
  return this;
2668
2473
  }
2669
- /**
2670
- * @returns {string}
2671
- */
2672
2474
  getPlaceHolder() {
2673
2475
  return this._p.placeholder;
2674
2476
  }
2675
2477
  /**
2676
- * @param {string} term
2677
- * @param {boolean} [performSearch=false] should actually perform the search, or just set the input's text?
2678
- * @returns {SelectBox}
2478
+ * @param term the search term to set
2479
+ * @param performSearch should actually perform the search, or just set the input's text?
2679
2480
  */
2680
2481
  setSearchTerm(term, performSearch = false) {
2681
2482
  const p = this._p;
@@ -2689,9 +2490,6 @@ var SelectBox = class {
2689
2490
  }
2690
2491
  return this;
2691
2492
  }
2692
- /**
2693
- * @returns {string}
2694
- */
2695
2493
  getSearchTerm() {
2696
2494
  const p = this._p;
2697
2495
  if (p.input) return p.input.value;
@@ -2701,10 +2499,6 @@ var SelectBox = class {
2701
2499
  this._p.dropList?.invokeRefilter();
2702
2500
  return this;
2703
2501
  }
2704
- /**
2705
- * @param {boolean} sortSelectedItems
2706
- * @returns {SelectBox}
2707
- */
2708
2502
  setSortSelectedItems(sortSelectedItems) {
2709
2503
  const p = this._p;
2710
2504
  sortSelectedItems = !!sortSelectedItems;
@@ -2713,16 +2507,9 @@ var SelectBox = class {
2713
2507
  this._scheduleSync("render_items");
2714
2508
  return this;
2715
2509
  }
2716
- /**
2717
- * @returns {boolean}
2718
- */
2719
2510
  isSortSelectedItemsEnabled() {
2720
2511
  return this._p.sortSelectedItems;
2721
2512
  }
2722
- /**
2723
- * @param {boolean} sortListItems
2724
- * @returns {SelectBox}
2725
- */
2726
2513
  setSortListItems(sortListItems) {
2727
2514
  const p = this._p;
2728
2515
  sortListItems = !!sortListItems;
@@ -2732,16 +2519,9 @@ var SelectBox = class {
2732
2519
  this._scheduleSync("render_list");
2733
2520
  return this;
2734
2521
  }
2735
- /**
2736
- * @returns {boolean}
2737
- */
2738
2522
  isSortListItemsEnabled() {
2739
2523
  return this._p.sortListItems;
2740
2524
  }
2741
- /**
2742
- * @param {boolean} sortListCheckedFirst
2743
- * @returns {SelectBox}
2744
- */
2745
2525
  setSortListCheckedFirst(sortListCheckedFirst) {
2746
2526
  const p = this._p;
2747
2527
  sortListCheckedFirst = !!sortListCheckedFirst;
@@ -2751,16 +2531,9 @@ var SelectBox = class {
2751
2531
  this._scheduleSync("render_list");
2752
2532
  return this;
2753
2533
  }
2754
- /**
2755
- * @returns {boolean}
2756
- */
2757
2534
  isSortListCheckedFirstEnabled() {
2758
2535
  return this._p.sortListCheckedFirst;
2759
2536
  }
2760
- /**
2761
- * @param {*[]} values
2762
- * @returns {SelectBox}
2763
- */
2764
2537
  setStickyValues(values) {
2765
2538
  const p = this._p;
2766
2539
  p.stickyValues = Array.isArray(values) ? new Set(values) : null;
@@ -2768,16 +2541,9 @@ var SelectBox = class {
2768
2541
  this._scheduleSync("render_list");
2769
2542
  return this;
2770
2543
  }
2771
- /**
2772
- * @returns {*[]}
2773
- */
2774
2544
  getStickyValues() {
2775
2545
  return this._p.stickyValues ? Array.from(this._p.stickyValues) : null;
2776
2546
  }
2777
- /**
2778
- * @param {function(a: DropList.ItemBase, b: DropList.ItemBase):number} comparator
2779
- * @returns {SelectBox}
2780
- */
2781
2547
  setSortItemComparator(comparator) {
2782
2548
  const p = this._p;
2783
2549
  if (p.sortItemComparator === comparator) return this;
@@ -2786,16 +2552,9 @@ var SelectBox = class {
2786
2552
  this._scheduleSync("render_list");
2787
2553
  return this;
2788
2554
  }
2789
- /**
2790
- * @returns {function(a: DropList.ItemBase, b: DropList.ItemBase):number}
2791
- */
2792
2555
  getSortItemComparator() {
2793
2556
  return this._p.sortItemComparator;
2794
2557
  }
2795
- /**
2796
- * @param {boolean} treatGroupSelectionAsItems
2797
- * @returns {SelectBox}
2798
- */
2799
2558
  setTreatGroupSelectionAsItems(treatGroupSelectionAsItems) {
2800
2559
  const p = this._p;
2801
2560
  treatGroupSelectionAsItems = !!treatGroupSelectionAsItems;
@@ -2807,16 +2566,9 @@ var SelectBox = class {
2807
2566
  this._scheduleSync("render_list");
2808
2567
  return this;
2809
2568
  }
2810
- /**
2811
- * @returns {boolean}
2812
- */
2813
2569
  isTreatGroupSelectionAsItemsEnabled() {
2814
2570
  return !this._p.treatGroupSelectionAsItems;
2815
2571
  }
2816
- /**
2817
- * @param {boolean} splitListCheckedGroups
2818
- * @returns {SelectBox}
2819
- */
2820
2572
  setSplitListCheckedGroups(splitListCheckedGroups) {
2821
2573
  const p = this._p;
2822
2574
  splitListCheckedGroups = !!splitListCheckedGroups;
@@ -2826,16 +2578,9 @@ var SelectBox = class {
2826
2578
  this._scheduleSync("render_list");
2827
2579
  return this;
2828
2580
  }
2829
- /**
2830
- * @returns {boolean}
2831
- */
2832
2581
  isSplitListCheckedGroupsEnabled() {
2833
2582
  return this._p.splitListCheckedGroups;
2834
2583
  }
2835
- /**
2836
- * @param {boolean} showSelection
2837
- * @returns {SelectBox}
2838
- */
2839
2584
  setShowSelection(showSelection) {
2840
2585
  const p = this._p;
2841
2586
  showSelection = !!showSelection;
@@ -2844,16 +2589,9 @@ var SelectBox = class {
2844
2589
  this._scheduleSync("render_items");
2845
2590
  return this;
2846
2591
  }
2847
- /**
2848
- * @returns {boolean}
2849
- */
2850
2592
  isShowSelectionEnabled() {
2851
2593
  return this._p.showSelection;
2852
2594
  }
2853
- /**
2854
- * @param {boolean} showPlaceholderInTooltip
2855
- * @returns {SelectBox}
2856
- */
2857
2595
  setShowPlaceholderInTooltip(showPlaceholderInTooltip) {
2858
2596
  const p = this._p;
2859
2597
  showPlaceholderInTooltip = !!showPlaceholderInTooltip;
@@ -2862,16 +2600,9 @@ var SelectBox = class {
2862
2600
  this._scheduleSync("render_base");
2863
2601
  return this;
2864
2602
  }
2865
- /**
2866
- * @returns {boolean}
2867
- */
2868
2603
  isShowPlaceholderInTooltipEnabled() {
2869
2604
  return this._p.showPlaceholderInTooltip;
2870
2605
  }
2871
- /**
2872
- * @param {function(items: DropList.ItemBase[]):string} formatter
2873
- * @returns {SelectBox}
2874
- */
2875
2606
  setMultiPlaceholderFormatter(formatter) {
2876
2607
  const p = this._p;
2877
2608
  if (p.multiPlaceholderFormatter === formatter) return this;
@@ -2879,26 +2610,15 @@ var SelectBox = class {
2879
2610
  this._scheduleSync("render_base");
2880
2611
  return this;
2881
2612
  }
2882
- /**
2883
- * @param {boolean|'touch'} value
2884
- * @returns {SelectBox}
2885
- */
2886
2613
  setBlurOnSingleSelection(value) {
2887
2614
  const p = this._p;
2888
2615
  if (p.blurOnSingleSelection === value) return this;
2889
2616
  p.blurOnSingleSelection = value;
2890
2617
  return this;
2891
2618
  }
2892
- /**
2893
- * @returns {boolean|'touch'}
2894
- */
2895
2619
  getBlurOnSingleSelection() {
2896
2620
  return this._p.blurOnSingleSelection;
2897
2621
  }
2898
- /**
2899
- * @param {boolean} multi
2900
- * @returns {SelectBox}
2901
- */
2902
2622
  setMulti(multi) {
2903
2623
  const p = this._p;
2904
2624
  multi = !!multi;
@@ -2914,16 +2634,9 @@ var SelectBox = class {
2914
2634
  this._scheduleSync("full");
2915
2635
  return this;
2916
2636
  }
2917
- /**
2918
- * @returns {boolean}
2919
- */
2920
2637
  isMultiEnabled() {
2921
2638
  return this._p.multi;
2922
2639
  }
2923
- /**
2924
- * @param {boolean} searchable
2925
- * @returns {SelectBox}
2926
- */
2927
2640
  setSearchable(searchable) {
2928
2641
  const p = this._p;
2929
2642
  searchable = !!searchable;
@@ -2932,10 +2645,6 @@ var SelectBox = class {
2932
2645
  this._scheduleSync("full");
2933
2646
  return this;
2934
2647
  }
2935
- /**
2936
- * @param {boolean} allowTypeToSelect
2937
- * @returns {SelectBox}
2938
- */
2939
2648
  setAllowTypeToSelect(allowTypeToSelect) {
2940
2649
  const p = this._p;
2941
2650
  allowTypeToSelect = !!allowTypeToSelect;
@@ -2943,129 +2652,71 @@ var SelectBox = class {
2943
2652
  p.allowTypeToSelect = allowTypeToSelect;
2944
2653
  return this;
2945
2654
  }
2946
- /**
2947
- * @returns {boolean}
2948
- */
2949
2655
  isSearchableEnabled() {
2950
2656
  return this._p.searchable;
2951
2657
  }
2952
- /**
2953
- * @param {string} noResultsText
2954
- * @returns {SelectBox}
2955
- */
2956
2658
  setNoResultsText(noResultsText) {
2957
2659
  this._p.dropList?.setNoResultsText(noResultsText);
2958
2660
  return this;
2959
2661
  }
2960
- /**
2961
- * @returns {string}
2962
- */
2963
2662
  getNoResultsText() {
2964
2663
  return this._p.noResultsText;
2965
2664
  }
2966
- /**
2967
- * @param {boolean} autoSelectTextOnCheck
2968
- * @returns {SelectBox}
2969
- */
2970
2665
  setAutoSelectTextOnCheck(autoSelectTextOnCheck) {
2971
2666
  this._p.autoSelectTextOnCheck = autoSelectTextOnCheck;
2972
2667
  return this;
2973
2668
  }
2974
- /**
2975
- * @returns {boolean}
2976
- */
2977
2669
  getAutoSelectTextOnCheck() {
2978
2670
  return this._p.autoSelectTextOnCheck;
2979
2671
  }
2980
- /**
2981
- * @param {number} window
2982
- * @returns {SelectBox}
2983
- */
2984
2672
  setFilterThrottleWindow(window) {
2985
2673
  const p = this._p;
2986
2674
  p.filterThrottleWindow = window;
2987
2675
  p.dropList?.setFilterThrottleWindow(window);
2988
2676
  return this;
2989
2677
  }
2990
- /**
2991
- * @returns {number}
2992
- */
2993
2678
  getFilterThrottleWindow() {
2994
2679
  return this._p.filterThrottleWindow;
2995
2680
  }
2996
- /**
2997
- * @param {boolean} value
2998
- * @returns {SelectBox}
2999
- */
3000
2681
  setFilterOnEmptyTerm(value) {
3001
2682
  const p = this._p;
3002
2683
  if (p.filterOnEmptyTerm === value) return this;
3003
2684
  p.dropList?.setFilterOnEmptyTerm(value);
3004
2685
  return this;
3005
2686
  }
3006
- /**
3007
- * @returns {boolean}
3008
- */
3009
2687
  getFilterOnEmptyTerm() {
3010
2688
  return this._p.filterOnEmptyTerm;
3011
2689
  }
3012
- /**
3013
- * @param {DropList.Options} listOptions
3014
- * @returns {SelectBox}
3015
- */
3016
2690
  setListOptions(listOptions) {
3017
2691
  const p = this._p;
3018
2692
  p.listOptions = listOptions;
3019
2693
  this._setupDropdownMenu();
3020
2694
  return this;
3021
2695
  }
3022
- /**
3023
- * @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
3024
- * @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
3025
- * @returns {SelectBox})|null
3026
- */
3027
2696
  setRenderSingleItem(render, unrender) {
3028
2697
  const p = this._p;
3029
2698
  p.renderSingleItem = render;
3030
2699
  p.unrenderSingleItem = unrender;
3031
2700
  return this;
3032
2701
  }
3033
- /**
3034
- * @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
3035
- * @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
3036
- * @returns {SelectBox}
3037
- */
3038
2702
  setRenderMultiItem(render, unrender) {
3039
2703
  const p = this._p;
3040
2704
  p.renderMultiItem = render;
3041
2705
  p.unrenderMultiItem = unrender;
3042
2706
  return this;
3043
2707
  }
3044
- /**
3045
- * @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
3046
- * @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
3047
- * @returns {SelectBox}
3048
- */
3049
2708
  setRenderRestMultiItem(render, unrender) {
3050
2709
  const p = this._p;
3051
2710
  p.renderRestMultiItem = render;
3052
2711
  p.unrenderRestMultiItem = unrender;
3053
2712
  return this;
3054
2713
  }
3055
- /**
3056
- * @param {string} prop
3057
- * @returns {SelectBox}
3058
- */
3059
2714
  setLabelProp(prop) {
3060
2715
  const p = this._p;
3061
2716
  p.labelProp = prop;
3062
2717
  if (p.dropList) p.dropList.setLabelProp(prop);
3063
2718
  return this;
3064
2719
  }
3065
- /**
3066
- * @param {string} prop
3067
- * @returns {SelectBox}
3068
- */
3069
2720
  setValueProp(prop) {
3070
2721
  const p = this._p;
3071
2722
  if (p.valueProp === prop) return this;
@@ -3074,50 +2725,31 @@ var SelectBox = class {
3074
2725
  this._refreshItemByValueMap();
3075
2726
  return this;
3076
2727
  }
3077
- /**
3078
- * @param {string} prop
3079
- * @returns {SelectBox}
3080
- */
3081
2728
  setMultiItemLabelProp(prop) {
3082
2729
  const p = this._p;
3083
2730
  p.multiItemLabelProp = prop;
3084
2731
  this._scheduleSync("render_items");
3085
2732
  return this;
3086
2733
  }
3087
- /**
3088
- * @param {'before'|'after'|'none'} position
3089
- * @returns {SelectBox}
3090
- */
3091
2734
  setMultiItemRemovePosition(position) {
3092
2735
  const p = this._p;
3093
2736
  p.multiItemRemovePosition = position;
3094
2737
  this._scheduleSync("render_items");
3095
2738
  return this;
3096
2739
  }
3097
- /**
3098
- * @param {number|null|undefined} value
3099
- * @returns {SelectBox}
3100
- */
3101
2740
  setMaxMultiItems(value) {
3102
2741
  const p = this._p;
3103
2742
  p.maxMultiItems = value;
3104
2743
  return this;
3105
2744
  }
3106
- /**
3107
- * @param {function(count: number, items: DropList.ItemBase[]):string|null|undefined} value
3108
- * @returns {SelectBox}
3109
- */
3110
2745
  setMultiItemsRestLabelProvider(value) {
3111
2746
  const p = this._p;
3112
2747
  p.multiItemsRestLabelProvider = value;
3113
2748
  return this;
3114
2749
  }
3115
- /**
3116
- * @param {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} fn
3117
- * @returns {SelectBox}
3118
- */
3119
2750
  setFilterFn(fn) {
3120
2751
  const p = this._p;
2752
+ fn ??= null;
3121
2753
  if (p.filterFn === fn) return this;
3122
2754
  p.filterFn = fn;
3123
2755
  if (!fn) fn = (items, term) => {
@@ -3132,9 +2764,6 @@ var SelectBox = class {
3132
2764
  p.dropList?.setFilterFn(fn);
3133
2765
  return this;
3134
2766
  }
3135
- /**
3136
- * @returns {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)}
3137
- */
3138
2767
  getFilterFn() {
3139
2768
  return this._p.filterFn;
3140
2769
  }
@@ -3142,8 +2771,6 @@ var SelectBox = class {
3142
2771
  * Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderMultiItem`/`unrenderSingleItem`)
3143
2772
  * instead of the default `console.error`/`console.warn`. Also used as the default `onError` for the internal
3144
2773
  * `DropList`, unless `listOptions.onError` is set explicitly.
3145
- * @param {SelectBox.LibraryErrorHandler|null} [fn]
3146
- * @returns {SelectBox}
3147
2774
  */
3148
2775
  setOnError(fn) {
3149
2776
  const p = this._p;
@@ -3152,14 +2779,13 @@ var SelectBox = class {
3152
2779
  return this;
3153
2780
  }
3154
2781
  /**
3155
- * @returns {SelectBox.LibraryErrorHandler|undefined}
2782
+ * Gets the current `onError` handler, if any.
3156
2783
  */
3157
2784
  getOnError() {
3158
2785
  return this._p.onError;
3159
2786
  }
3160
2787
  /**
3161
2788
  * Focus on input element
3162
- * @returns {SelectBox}
3163
2789
  */
3164
2790
  focusInput() {
3165
2791
  const p = this._p;
@@ -3168,7 +2794,6 @@ var SelectBox = class {
3168
2794
  }
3169
2795
  /**
3170
2796
  * Remvoe focus from the input element
3171
- * @returns {SelectBox}
3172
2797
  */
3173
2798
  blurInput() {
3174
2799
  const p = this._p;
@@ -3177,7 +2802,6 @@ var SelectBox = class {
3177
2802
  }
3178
2803
  /**
3179
2804
  * Removes all selected items
3180
- * @returns {SelectBox}
3181
2805
  */
3182
2806
  clear() {
3183
2807
  if (!this._performClearWithEvent(true)) return this;
@@ -3186,8 +2810,6 @@ var SelectBox = class {
3186
2810
  }
3187
2811
  /**
3188
2812
  * Returns a single value or an array of selected values - depending on `multi` prop
3189
- * @public
3190
- * @returns {*[]}
3191
2813
  */
3192
2814
  getValue() {
3193
2815
  const p = this._p;
@@ -3196,9 +2818,7 @@ var SelectBox = class {
3196
2818
  }
3197
2819
  /**
3198
2820
  * Selects the specified value or multiple values - depending on `multi` prop
3199
- * @public
3200
- * @param {*|*[]} value - if `multi`, then an array of values to select, otherwise - a single value to select
3201
- * @returns {SelectBox}
2821
+ * @param value - if `multi`, then an array of values to select, otherwise - a single value to select
3202
2822
  */
3203
2823
  setValue(value) {
3204
2824
  if (this._p.multi) return this.setSelectedValues(Array.isArray(value) ? value : value !== void 0 ? [value] : []);
@@ -3206,17 +2826,12 @@ var SelectBox = class {
3206
2826
  }
3207
2827
  /**
3208
2828
  * Returns an array of selected values
3209
- * @public
3210
- * @returns {*[]}
3211
2829
  */
3212
2830
  getSelectedValues() {
3213
2831
  return this._p.selectedValues.slice(0);
3214
2832
  }
3215
2833
  /**
3216
2834
  * Selects the specified values
3217
- * @public
3218
- * @param {*[]} values - an array of *values* to select
3219
- * @returns {SelectBox}
3220
2835
  */
3221
2836
  setSelectedValues(values) {
3222
2837
  const p = this._p, valueProp = p.valueProp;
@@ -3241,16 +2856,12 @@ var SelectBox = class {
3241
2856
  }
3242
2857
  /**
3243
2858
  * Returns the count of selected values
3244
- * @public
3245
- * @returns {number}
3246
2859
  */
3247
2860
  getSelectedValueCount() {
3248
2861
  return this._p.selectedValues.length;
3249
2862
  }
3250
2863
  /**
3251
2864
  * Returns an array of selected items
3252
- * @public
3253
- * @returns {Array.<Object>}
3254
2865
  */
3255
2866
  getSelectedItems() {
3256
2867
  return this._p.selectedItems.slice(0);
@@ -3259,17 +2870,11 @@ var SelectBox = class {
3259
2870
  * Sets the specified items to "checked" mode.
3260
2871
  * An array of items is passed, not values, because we need to keep track if items,
3261
2872
  * and if we already have the array of items then this spares the process of searching for the items by values.
3262
- * @public
3263
- * @param {DropList.ItemBase[]} items - an array of *items* to select (not values)
3264
- * @returns {SelectBox}
3265
2873
  */
3266
2874
  setSelectedItems(items) {
3267
2875
  this._setSelectedItems(items);
3268
2876
  return this;
3269
2877
  }
3270
- /**
3271
- * @returns {SelectBox}
3272
- */
3273
2878
  openList() {
3274
2879
  const p = this._p;
3275
2880
  if (p.dropList.isVisible()) return this;
@@ -3284,9 +2889,6 @@ var SelectBox = class {
3284
2889
  else if (!p.multi && this.getValue() !== void 0) p.dropList.setFocusedItemByValue(this.getValue());
3285
2890
  return this;
3286
2891
  }
3287
- /**
3288
- * @returns {SelectBox}
3289
- */
3290
2892
  closeList() {
3291
2893
  const p = this._p;
3292
2894
  if (this[DestroyedSymbol]) return this;
@@ -3298,32 +2900,17 @@ var SelectBox = class {
3298
2900
  }
3299
2901
  return this;
3300
2902
  }
3301
- /**
3302
- * @param {boolean} [open]
3303
- * @returns {SelectBox}
3304
- */
3305
2903
  toggleList(open) {
3306
2904
  const p = this._p;
3307
2905
  if (open === void 0 ? !p.dropList.isVisible() : !!open) return this.openList();
3308
2906
  else return this.closeList();
3309
2907
  }
3310
- /**
3311
- * @returns {boolean}
3312
- */
3313
2908
  isListOpen() {
3314
2909
  return !!this._p.dropListVisible;
3315
2910
  }
3316
- /**
3317
- * @param {boolean} [on]
3318
- * @returns {SelectBox}
3319
- */
3320
2911
  toggleLoading(on) {
3321
2912
  return this.setIsLoadingMode(on === void 0 ? !this.getIsLoadingMode() : !!on);
3322
2913
  }
3323
- /**
3324
- * @param {boolean} isLoadingMode
3325
- * @returns {SelectBox}
3326
- */
3327
2914
  setIsLoadingMode(isLoadingMode) {
3328
2915
  const p = this._p;
3329
2916
  isLoadingMode = isLoadingMode === void 0 ? true : !!isLoadingMode;
@@ -3334,31 +2921,21 @@ var SelectBox = class {
3334
2921
  this._scheduleSync("render_base");
3335
2922
  return this;
3336
2923
  }
3337
- /**
3338
- * @returns {boolean}
3339
- */
3340
2924
  getIsLoadingMode() {
3341
2925
  return this._p.isLoadingMode;
3342
2926
  }
3343
2927
  /**
3344
2928
  * Sets whether to close the list when loading mode is enabled
3345
- * @param {boolean} closeListWhenLoading
3346
- * @returns {SelectBox}
3347
2929
  */
3348
2930
  setCloseListWhenLoading(closeListWhenLoading) {
3349
2931
  this._p.closeListWhenLoading = closeListWhenLoading;
3350
2932
  return this;
3351
2933
  }
3352
- /**
3353
- * @returns {boolean}
3354
- */
3355
2934
  getCloseListWhenLoading() {
3356
2935
  return this._p.closeListWhenLoading;
3357
2936
  }
3358
2937
  /**
3359
2938
  * Sets when to clear the input field
3360
- * @param {string[]} clearInputWhen
3361
- * @returns {SelectBox}
3362
2939
  */
3363
2940
  setClearInputWhen(clearInputWhen) {
3364
2941
  this._p.clearInputWhen = Array.isArray(clearInputWhen) ? clearInputWhen.slice(0) : [];
@@ -3366,15 +2943,12 @@ var SelectBox = class {
3366
2943
  }
3367
2944
  /**
3368
2945
  * Retrieves the settings for when to clear the input field
3369
- * @returns {string[]}
3370
2946
  */
3371
2947
  getClearInputWhen() {
3372
2948
  return this._p.clearInputWhen;
3373
2949
  }
3374
2950
  /**
3375
2951
  * Sets the appropriate direction for the selectbox
3376
- * @param {'ltr'|'rtl'|'auto'} direction
3377
- * @return {SelectBox}
3378
2952
  */
3379
2953
  setDirection(direction) {
3380
2954
  const p = this._p;
@@ -3384,14 +2958,12 @@ var SelectBox = class {
3384
2958
  }
3385
2959
  /**
3386
2960
  * Gets the supplied direction for the selectbox
3387
- * @return {'ltr'|'rtl'|'auto'}
3388
2961
  */
3389
2962
  getDirection() {
3390
2963
  return this._p.direction;
3391
2964
  }
3392
2965
  /**
3393
2966
  * Can be called in case that the selectbox was attached to the dom late and has a weird size.
3394
- * @returns {SelectBox}
3395
2967
  */
3396
2968
  refreshSize() {
3397
2969
  this._resizeInput();
@@ -3399,9 +2971,6 @@ var SelectBox = class {
3399
2971
  }
3400
2972
  /**
3401
2973
  * Register an event handler
3402
- * @param {(string|'*')?} event
3403
- * @param {function(any)} handler
3404
- * @returns {SelectBox}
3405
2974
  */
3406
2975
  on(event, handler) {
3407
2976
  this._p.mitt.on(event, handler);
@@ -3409,9 +2978,6 @@ var SelectBox = class {
3409
2978
  }
3410
2979
  /**
3411
2980
  * Register a one time event handler
3412
- * @param {(string|'*')?} event
3413
- * @param {function(any)} handler
3414
- * @returns {SelectBox}
3415
2981
  */
3416
2982
  once(event, handler) {
3417
2983
  let wrapped = (value) => {
@@ -3423,9 +2989,6 @@ var SelectBox = class {
3423
2989
  }
3424
2990
  /**
3425
2991
  * Remove an `handler` for `event`, all events for `event`, or all events completely.
3426
- * @param {(string|'*')?} event
3427
- * @param {function(any)} handler
3428
- * @returns {SelectBox}
3429
2992
  */
3430
2993
  off(event, handler) {
3431
2994
  if (!event && !event) this._p.mitt.all.clear();
@@ -3434,9 +2997,6 @@ var SelectBox = class {
3434
2997
  }
3435
2998
  /**
3436
2999
  * Emit an event
3437
- * @param {string} event
3438
- * @param {any} value
3439
- * @returns {SelectBox}
3440
3000
  */
3441
3001
  emit(event, value) {
3442
3002
  this._p.mitt.emit(event, value);
@@ -3456,8 +3016,6 @@ var SelectBox = class {
3456
3016
  p.subitemByValueMap = null;
3457
3017
  }
3458
3018
  /**
3459
- * @param {*} value
3460
- * @returns {DropList.ItemBase|undefined}
3461
3019
  * @private
3462
3020
  * @internal
3463
3021
  */
@@ -3476,9 +3034,6 @@ var SelectBox = class {
3476
3034
  this._addSubitemsToValueMap(p.items, subitemByValueMap, p.valueProp);
3477
3035
  }
3478
3036
  /**
3479
- * @param {DropList.ItemBase[]} items
3480
- * @param {Map<*, DropList.ItemBase>} itemByValueMap
3481
- * @param {string} valueProp
3482
3037
  * @private
3483
3038
  * @internal
3484
3039
  */
@@ -3757,9 +3312,7 @@ var SelectBox = class {
3757
3312
  case "search":
3758
3313
  this._trigger("search", event);
3759
3314
  break;
3760
- case "itemschanged":
3761
- this._trigger("itemschanged", event);
3762
- break;
3315
+ case "itemschanged": this._trigger("itemschanged", event);
3763
3316
  }
3764
3317
  }
3765
3318
  });
@@ -3827,9 +3380,7 @@ var SelectBox = class {
3827
3380
  case VALUE_HOME:
3828
3381
  dropList.goToFirst(evt);
3829
3382
  break;
3830
- case VALUE_END:
3831
- dropList.goToLast(evt);
3832
- break;
3383
+ case VALUE_END: dropList.goToLast(evt);
3833
3384
  }
3834
3385
  break;
3835
3386
  case VALUE_SPACE:
@@ -3859,17 +3410,15 @@ var SelectBox = class {
3859
3410
  evt.preventDefault();
3860
3411
  }
3861
3412
  break;
3862
- default:
3863
- if (dropList.isVisible()) dropList._keydownFreeType(evt, false);
3864
- else if (p.allowTypeToSelect) dropList._keydownFreeType(evt, true);
3865
- else {
3866
- this.openList();
3867
- setTimeout(() => {
3868
- if (this[DestroyedSymbol]) return;
3869
- dropList._keydownFreeType(evt, false);
3870
- });
3871
- }
3872
- break;
3413
+ default: if (dropList.isVisible()) dropList._keydownFreeType(evt, false);
3414
+ else if (p.allowTypeToSelect) dropList._keydownFreeType(evt, true);
3415
+ else {
3416
+ this.openList();
3417
+ setTimeout(() => {
3418
+ if (this[DestroyedSymbol]) return;
3419
+ dropList._keydownFreeType(evt, false);
3420
+ });
3421
+ }
3873
3422
  }
3874
3423
  if (!suppressEnterSpaceToggle) {
3875
3424
  if (evt.key === VALUE_ENTER || evt.key === VALUE_SPACE && p.lastKeyAllowsNonTypeKeys && !p.multi && !dropList.hasFocusedItem() && !p.disabled && !p.readOnly) {
@@ -4089,9 +3638,7 @@ var SelectBox = class {
4089
3638
  if (!p.showSelection) this._syncPlaceholder();
4090
3639
  else if (p.multiItemEls[p.multiItemEls.length - 1]?.[ItemSymbol]?.[p.valueProp] === RestMultiItemsSymbol) this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
4091
3640
  break;
4092
- case "resize_input":
4093
- this._resizeInput();
4094
- break;
3641
+ case "resize_input": this._resizeInput();
4095
3642
  }
4096
3643
  }
4097
3644
  /** @private */
@@ -4112,7 +3659,6 @@ var SelectBox = class {
4112
3659
  p.singleWrapper.innerHTML = "";
4113
3660
  }
4114
3661
  /**
4115
- * @param {number} index
4116
3662
  * @private
4117
3663
  * @internal
4118
3664
  */
@@ -4137,7 +3683,6 @@ var SelectBox = class {
4137
3683
  }
4138
3684
  }
4139
3685
  /**
4140
- * @param {DropList.ItemBase} item
4141
3686
  * @private
4142
3687
  * @internal
4143
3688
  */
@@ -4151,8 +3696,6 @@ var SelectBox = class {
4151
3696
  }
4152
3697
  }
4153
3698
  /**
4154
- * @param {DropList.ItemBase} item
4155
- * @param {Element} itemEl
4156
3699
  * @private
4157
3700
  * @internal
4158
3701
  */
@@ -4166,7 +3709,6 @@ var SelectBox = class {
4166
3709
  }
4167
3710
  }
4168
3711
  /**
4169
- * @param {DropList.ItemBase} item
4170
3712
  * @returns {boolean} true if rendered, false if not
4171
3713
  * @private
4172
3714
  * @internal
@@ -4240,9 +3782,6 @@ var SelectBox = class {
4240
3782
  }
4241
3783
  /**
4242
3784
  * Syncs render state, selected items, and position
4243
- * @param {boolean=false} fullItemsRender Should re-render all items?
4244
- * @param {boolean=false} updateListItems Should call updateListItems?
4245
- * @returns {SelectBox}
4246
3785
  * @internal
4247
3786
  */
4248
3787
  _syncFull(fullItemsRender, updateListItems) {
@@ -4301,8 +3840,6 @@ var SelectBox = class {
4301
3840
  return this;
4302
3841
  }
4303
3842
  /**
4304
- * @param {string} event
4305
- * @param {*} [data]
4306
3843
  * @private
4307
3844
  * @internal
4308
3845
  */
@@ -4314,8 +3851,6 @@ var SelectBox = class {
4314
3851
  }
4315
3852
  /**
4316
3853
  * Render a multi item
4317
- * @param {Object} item
4318
- * @returns {Element|null}
4319
3854
  * @private
4320
3855
  * @internal
4321
3856
  */
@@ -4341,9 +3876,6 @@ var SelectBox = class {
4341
3876
  }
4342
3877
  /**
4343
3878
  * Removes a specific multi item by user event
4344
- * @param {Element} itemEl
4345
- * @param {Event} originatingEvent
4346
- * @returns {SelectBox}
4347
3879
  * @private
4348
3880
  * @internal
4349
3881
  */
@@ -4403,8 +3935,6 @@ var SelectBox = class {
4403
3935
  return this;
4404
3936
  }
4405
3937
  /**
4406
- * @param {DropList.ItemBase} item
4407
- * @param {boolean} [populate]
4408
3938
  * @private
4409
3939
  * @internal
4410
3940
  */
@@ -4431,7 +3961,6 @@ var SelectBox = class {
4431
3961
  this._scheduleSync("render_list");
4432
3962
  }
4433
3963
  /**
4434
- * @param {*} value
4435
3964
  * @private
4436
3965
  * @internal
4437
3966
  */
@@ -4444,7 +3973,6 @@ var SelectBox = class {
4444
3973
  }
4445
3974
  /**
4446
3975
  * Update input size to current state
4447
- * @returns {SelectBox}
4448
3976
  * @private
4449
3977
  * @internal
4450
3978
  */
@@ -4502,7 +4030,6 @@ var SelectBox = class {
4502
4030
  }
4503
4031
  /**
4504
4032
  * Update autocomplete position if needed
4505
- * @returns {SelectBox}
4506
4033
  * @private
4507
4034
  * @internal
4508
4035
  */
@@ -4518,7 +4045,6 @@ var SelectBox = class {
4518
4045
  return this;
4519
4046
  }
4520
4047
  /**
4521
- * @param {KeyboardEvent} event
4522
4048
  * @private
4523
4049
  * @internal
4524
4050
  */
@@ -4549,7 +4075,6 @@ var SelectBox = class {
4549
4075
  }
4550
4076
  }
4551
4077
  /**
4552
- * @param {KeyboardEvent} event
4553
4078
  * @private
4554
4079
  * @internal
4555
4080
  */
@@ -4595,13 +4120,12 @@ var SelectBox = class {
4595
4120
  }
4596
4121
  }
4597
4122
  /**
4598
- * @returns {DropList.PositionOptions}
4599
4123
  * @private
4600
4124
  * @internal
4601
4125
  */
4602
4126
  _getDropListPositionOptions() {
4603
4127
  return {
4604
- target: this._p.el,
4128
+ target: /**@type Element*/ this._p.el,
4605
4129
  offset: {
4606
4130
  x: 0,
4607
4131
  y: 0
@@ -4638,11 +4162,6 @@ var SelectBox = class {
4638
4162
  /**
4639
4163
  * Handles sorting, and putting checked items first (according to selectedValues, not item.checked)
4640
4164
  * @private
4641
- * @param {DropList.ItemBase[]} items
4642
- * @param {boolean=false} sort
4643
- * @param {boolean=false} sortCheckedFirst
4644
- * @param {boolean=false} splitCheckedGroups
4645
- * @returns {DropList.ItemBase[]}
4646
4165
  * @internal
4647
4166
  */
4648
4167
  _sortItems(items, sort, sortCheckedFirst, splitCheckedGroups) {