@danielgindi/selectbox 2.0.57 → 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.57
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";
@@ -9,14 +9,18 @@ import DomEventsSink from "@danielgindi/dom-utils/lib/DomEventsSink";
9
9
  import VirtualListHelper from "@danielgindi/virtual-list-helper";
10
10
  import { VALUE_BACK_SPACE, VALUE_DELETE, VALUE_DOWN, VALUE_END, VALUE_ENTER, VALUE_ESCAPE, VALUE_HOME, VALUE_LEFT, VALUE_PAGE_DOWN, VALUE_PAGE_UP, VALUE_RIGHT, VALUE_SPACE, VALUE_TAB, VALUE_UP } from "keycode-js";
11
11
  import mitt from "mitt";
12
- //#region lib/utils/escapeRegex.js
13
- var escapeRegex_default = (value) => value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
12
+ //#region src/lib/utils/escapeRegex.ts
13
+ /** @internal */
14
+ var escapeRegex = (value) => value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
14
15
  //#endregion
15
- //#region lib/utils/throttle.js
16
- var throttle = (func, wait, options) => {
17
- let timeout, context, args, result;
16
+ //#region src/lib/utils/throttle.ts
17
+ /** @internal */
18
+ var throttle = (func, wait, options = {}) => {
19
+ let timeout;
20
+ let context;
21
+ let args;
22
+ let result;
18
23
  let previous = 0;
19
- if (!options) options = {};
20
24
  const later = () => {
21
25
  previous = options.leading === false ? 0 : Date.now();
22
26
  timeout = null;
@@ -51,86 +55,30 @@ var throttle = (func, wait, options) => {
51
55
  return throttled;
52
56
  };
53
57
  //#endregion
54
- //#region lib/DropList.js
58
+ //#region src/lib/utils/reportError.ts
59
+ /**
60
+ * Routes an error/warning to `handler` if supplied, falling back to the
61
+ * console (matching the previous hardcoded behaviour) if there is no
62
+ * handler, or if the handler itself throws.
63
+ * @internal
64
+ */
65
+ var reportError = (handler, error, context) => {
66
+ if (handler) try {
67
+ handler(error, context);
68
+ return;
69
+ } catch (handlerError) {
70
+ console.error(handlerError);
71
+ }
72
+ if (context.level === "warn") console.warn(error);
73
+ else console.error(error);
74
+ };
75
+ //#endregion
76
+ //#region src/lib/DropList.ts
55
77
  var ItemSymbol = Symbol("item");
56
78
  var DestroyedSymbol$1 = Symbol("destroyed");
57
79
  var GhostSymbol = Symbol("ghost");
58
80
  var NoResultsItemSymbol = Symbol("no_results_items");
59
81
  var hasOwnProperty = Object.prototype.hasOwnProperty;
60
- /**
61
- * @typedef {Object} DropList.Options
62
- * @property {Element} [el] An element to attach to, instead of creating a new one
63
- * @property {string} [baseClassName='droplist'] class name for the menu root element
64
- * @property {string|string[]} [additionalClasses]
65
- * @property {'ltr'|'rtl'|'auto'} [direction='auto']
66
- * @property {boolean} [autoItemBlur=true] Should we automatically blur the focused item when the droplist loses focus?
67
- * @property {number} [autoItemBlurDelay=300] How long to wait before deciding to blur the focused item (when the droplist loses focus)?
68
- * @property {boolean} [capturesFocus=true] Should this DropList be added to the TAB-key stack?
69
- * @property {boolean} [multi=false] Does this DropList show checkboxes for multiple item selection?
70
- * @property {*} [singleSelectedValue] Current selected value when using single selection.
71
- * @property {function} [keyDownHandler=null] An alternative "keydown" event handler. Return true to prevent default behaviour.
72
- * @property {boolean} [autoCheckGroupChildren=true] When a group is checked/unchecked - all items beneath it will update accordingly
73
- * @property {boolean} [useExactTargetWidth=false] Use the exact target's width, do not allow growing
74
- * @property {boolean} [constrainToWindow=true] Should the position be constrained to the window, attaching to window's borders if needed?
75
- * @property {Boolean} [autoFlipDirection=true] Should the position/anchor be flipped automatically when there's no space in the required direction?
76
- * @property {number} [estimatedItemHeight=20] An estimated row height, for approximating scroll height.
77
- * @property {boolean} [estimateWidth=false] Use an estimation for the width instead of measuring. May be faster - needs testing and may depend on the CSS.
78
- * @property {number} [virtualMinItems=100] Turns into a virtual list - with items being created and showing up on viewport only. The value specified the minimum item count where a virtual list will be created.
79
- * @property {string} [labelProp='label']
80
- * @property {string} [valueProp='value']
81
- * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderItem] Function to call when rendering an item element
82
- * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderItem] Function to call when rendering an item element
83
- * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderNoResultsItem]
84
- * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderNoResultsItem]
85
- * @property {function(name: string, data: *)} [on]
86
- * @property {boolean} [isHeaderVisible=false] show header element
87
- * @property {boolean} [isFooterVisible=false] show footer element
88
- * @property {boolean} [searchable=false] include inline search box
89
- * @property {string} [searchPlaceholder=''] placeholder text for the inline search box
90
- * @property {string} [noResultsText='No matching results'] text for no results (empty for none)
91
- * @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
92
- * @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
93
- * @property {boolean} [filterGroups=false] should groups be filtered?
94
- * @property {boolean} [filterEmptyGroups=false] should empty groups be filtered out?
95
- * @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
96
- * @property {function(dropList: DropList):DropList.PositionOptions} [positionOptionsProvider]
97
- * */
98
- /** */
99
- /**
100
- * @typedef {Object} DropList.PositionAnchor
101
- * @property {'left'|'center'|'right'|'start'|'end'|string|number} x - horizontal anchor specification (could be either `'left'|'center'|'right'|'start'|'end'` or a percentage `'50%'` or a fixed decimal `Number`)
102
- * @property {'top'|'center'|'bottom'|string|number} y - vertical anchor specification (could be either `'top'|'center'|'bottom'` or a percentage `'50%'` or a fixed decimal `Number`)
103
- * */
104
- /** */
105
- /**
106
- * @typedef {Object} DropList.PositionOptions
107
- * @property {Element?} [target] Target element to act as anchor
108
- * @property {{left: number, top: number}?} [targetOffset] Override the offset of target. Automatically calculated if unspecified.
109
- * @property {number?} [targetHeight] Override height of the target
110
- * @property {number?} [targetWidth] Override width of the target
111
- * @property {DropList.PositionAnchor?} [position]
112
- * @property {DropList.PositionAnchor?} [anchor]
113
- * @property {boolean|number?} [updateWidth=false] `true` to set width of the menu according to `target`'s width, or specify an arbitrary number.
114
- * @property {string?} [targetRtl] Override for rtl mode of the target
115
- * @property {{x: number, y: number}} [offset=undefined] Extra rtl-aware offset to the target
116
- * */
117
- /** */
118
- /**
119
- * @typedef {Object} DropList.ItemBase
120
- * @property {string} [value]
121
- * @property {string} [label]
122
- * @property {boolean} [_group=false]
123
- * @property {boolean} [_child=false]
124
- * @property {boolean} [_nocheck=false]
125
- * @property {boolean} [_nointeraction=false]
126
- * @property {DropList.ItemBase[]} [_subitems]
127
- * */
128
- /**
129
- * @typedef {DropList.ItemBase} DropList.Item
130
- * @property {boolean} [_checked=false]
131
- * */
132
- /** */
133
- /** @type {DropList.Options} */
134
82
  var DefaultOptions = {
135
83
  baseClassName: "droplist",
136
84
  autoItemBlur: true,
@@ -159,9 +107,6 @@ var DefaultOptions = {
159
107
  filterEmptyGroups: false
160
108
  };
161
109
  var DropList = class DropList {
162
- /**
163
- * @param {DropList.Options} options
164
- */
165
110
  constructor(options) {
166
111
  const o = { ...DefaultOptions };
167
112
  for (let [key, value] of Object.entries(
@@ -195,6 +140,7 @@ var DropList = class DropList {
195
140
  unrenderNoResultsItem: o.unrenderNoResultsItem,
196
141
  on: o.on || null,
197
142
  positionOptionsProvider: o.positionOptionsProvider ?? null,
143
+ onError: o.onError,
198
144
  searchable: o.searchable,
199
145
  searchPlaceholder: o.searchPlaceholder,
200
146
  isHeaderVisible: o.isHeaderVisible,
@@ -212,7 +158,14 @@ var DropList = class DropList {
212
158
  throttledRefilterItems: null,
213
159
  focusItemIndex: -1,
214
160
  focusItemEl: null,
215
- sink: new DomEventsSink()
161
+ sink: new DomEventsSink(),
162
+ visible: false,
163
+ hiding: false,
164
+ singleSelectedItemEl: null,
165
+ onDocumentMouseDown: null,
166
+ lastKeyWasChar: false,
167
+ currentSubDropList: null,
168
+ _isFocusingItem: false
216
169
  };
217
170
  let classes = [p.baseClassName + "_wrapper"];
218
171
  if (p.additionalClasses) classes = classes.concat((p.additionalClasses + "").split(" ").filter((x) => x));
@@ -278,7 +231,11 @@ var DropList = class DropList {
278
231
  };
279
232
  else item = items[index];
280
233
  }
281
- if (!item) console.warn("onItemRender called for (" + index + ") which has no item");
234
+ if (!item) reportError(p.onError, `onItemRender called for (${index}) which has no item`, {
235
+ source: "renderItem",
236
+ level: "warn",
237
+ index
238
+ });
282
239
  itemEl.className = `${p.baseClassName}__item`;
283
240
  const classList = itemEl.classList;
284
241
  if (item) {
@@ -355,19 +312,13 @@ var DropList = class DropList {
355
312
  }
356
313
  /**
357
314
  * Returns true if other is an inclusive descendant of node, and false otherwise.
358
- * @param {Node} other
359
- * @param {boolean} [considerSubmenus=true]
360
- * @returns {boolean}
315
+ * Accepts `EventTarget` (not just `Node`) since callers pass `event.target`/`event.relatedTarget` directly.
361
316
  */
362
317
  elContains(other, considerSubmenus = true) {
363
318
  if (this.el.contains(other)) return true;
364
319
  if (considerSubmenus && this._p.currentSubDropList?.droplist?.elContains(other)) return true;
365
320
  return false;
366
321
  }
367
- /**
368
- * @param {string|string[]} classes
369
- * @returns {DropList}
370
- */
371
322
  setAdditionalClasses(classes) {
372
323
  const p = this._p;
373
324
  p.additionalClasses = classes;
@@ -376,8 +327,6 @@ var DropList = class DropList {
376
327
  }
377
328
  /**
378
329
  * Sets the appropriate direction for the droplist
379
- * @param {'ltr'|'rtl'|'auto'} direction
380
- * @return {DropList}
381
330
  */
382
331
  setDirection(direction) {
383
332
  const p = this._p;
@@ -387,46 +336,26 @@ var DropList = class DropList {
387
336
  }
388
337
  /**
389
338
  * Gets the supplied direction for the droplist
390
- * @return {'ltr'|'rtl'|'auto'}
391
339
  */
392
340
  getDirection() {
393
341
  return this._p.direction;
394
342
  }
395
- /**
396
- * @param {string} prop
397
- * @returns {DropList}
398
- */
399
343
  setLabelProp(prop) {
400
344
  const p = this._p;
401
345
  p.labelProp = prop;
402
346
  return this;
403
347
  }
404
- /**
405
- *
406
- * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [fn] Function to call when rendering an item element
407
- * @returns {DropList}
408
- */
409
348
  setRenderItem(fn) {
410
349
  const p = this._p;
411
350
  p.renderItem = fn;
412
351
  return this;
413
352
  }
414
- /**
415
- *
416
- * @property {function(item: DropList.ItemBase, itemEl: Element)} [fn] Function to call when rendering an item element
417
- * @returns {DropList}
418
- */
419
353
  setUnrenderItem(fn) {
420
354
  const p = this._p;
421
355
  p.unrenderItem = fn;
422
356
  this._setupUnrenderFunction();
423
357
  return this;
424
358
  }
425
- /**
426
- * @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
427
- * @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
428
- * @returns {DropList}
429
- */
430
359
  setRenderNoResultsItem(render, unrender) {
431
360
  const p = this._p;
432
361
  p.renderNoResultsItem = render;
@@ -436,6 +365,7 @@ var DropList = class DropList {
436
365
  }
437
366
  /**
438
367
  * @private
368
+ * @internal
439
369
  */
440
370
  _setupUnrenderFunction() {
441
371
  const p = this._p;
@@ -447,12 +377,20 @@ var DropList = class DropList {
447
377
  if (item === NoResultsItemSymbol) try {
448
378
  fnNoResults(item, el);
449
379
  } catch (err) {
450
- console.error(err);
380
+ reportError(p.onError, err, {
381
+ source: "unrenderNoResultsItem",
382
+ item,
383
+ el
384
+ });
451
385
  }
452
386
  else try {
453
387
  fn(item[ItemSymbol], el);
454
388
  } catch (err) {
455
- console.error(err);
389
+ reportError(p.onError, err, {
390
+ source: "unrenderItem",
391
+ item: item[ItemSymbol],
392
+ el
393
+ });
456
394
  }
457
395
  delete el[ItemSymbol];
458
396
  if (p.focusItemEl === el) p.focusItemEl = null;
@@ -463,15 +401,12 @@ var DropList = class DropList {
463
401
  });
464
402
  return this;
465
403
  }
466
- /**
467
- * @param {string} prop
468
- * @returns {DropList}
469
- */
470
404
  setValueProp(prop) {
471
405
  const p = this._p;
472
406
  p.valueProp = prop;
473
407
  return this;
474
408
  }
409
+ /** @internal */
475
410
  _syncBaseClasses() {
476
411
  const p = this._p, el = p.el;
477
412
  if (!el) return;
@@ -510,7 +445,7 @@ var DropList = class DropList {
510
445
  goToLast(event) {
511
446
  this._move("last", event);
512
447
  }
513
- toggleFocusedItem() {
448
+ toggleFocusedItem(event) {
514
449
  const p = this._p;
515
450
  if (this.hasFocusedItem() && p.multi) {
516
451
  let item = (p.filteredItems ?? p.items)[p.focusItemIndex];
@@ -553,19 +488,16 @@ var DropList = class DropList {
553
488
  return true;
554
489
  }
555
490
  /**
556
- *
557
- * @param {DropList.Item} item The item to add. It is copied.
558
- * @param {number} [atIndex=-1] The index to insert at (or -1)
559
- * @returns {DropList}
491
+ * @param item The item to add. It is copied.
492
+ * @param atIndex The index to insert at (or -1)
560
493
  */
561
494
  addItem(item, atIndex = -1) {
562
495
  return this.addItems([item], atIndex);
563
496
  }
564
497
  /**
565
498
  * Adds items to the menu and renders
566
- * @param {DropList.Item[]} itemsToAdd The items to add. These are copied.
567
- * @param {number} [atIndex=-1] The index to insert at (or -1)
568
- * @returns {DropList}
499
+ * @param itemsToAdd The items to add. These are copied.
500
+ * @param atIndex The index to insert at (or -1)
569
501
  */
570
502
  addItems(itemsToAdd, atIndex = -1) {
571
503
  const p = this._p, labelProp = p.labelProp, valueProp = p.valueProp;
@@ -607,8 +539,7 @@ var DropList = class DropList {
607
539
  }
608
540
  /**
609
541
  * Replaces all current items with the supplied items
610
- * @param {DropList.Item[]} items The items to set. These are copied.
611
- * @returns {DropList}
542
+ * @param items The items to set. These are copied.
612
543
  */
613
544
  setItems(items) {
614
545
  const p = this._p;
@@ -631,7 +562,7 @@ var DropList = class DropList {
631
562
  if (hasOwnProperty.call(newItem, p.valueProp)) item.value = newItem[p.valueProp];
632
563
  if (hasOwnProperty.call(newItem, "_nocheck")) item._nocheck = !!newItem._nocheck;
633
564
  if (hasOwnProperty.call(newItem, "_nointeraction")) item._nointeraction = !!newItem._nointeraction;
634
- if (hasOwnProperty.call(newItem, "_subitems")) item._subitems = !!newItem._subitems;
565
+ if (hasOwnProperty.call(newItem, "_subitems")) item._subitems = newItem._subitems;
635
566
  if (p.multi) {
636
567
  if (hasOwnProperty.call(newItem, "_checked")) item._checked = !!newItem._checked;
637
568
  }
@@ -639,10 +570,10 @@ var DropList = class DropList {
639
570
  if (!!newItem._group !== item._group) {
640
571
  if (item._group) p.groupCount--;
641
572
  else p.groupCount++;
642
- newItem._group = !!item._group;
573
+ item._group = !!newItem._group;
643
574
  }
644
575
  }
645
- if (hasOwnProperty.call(newItem, "_level")) newItem._level = item._level;
576
+ if (hasOwnProperty.call(newItem, "_level")) item._level = newItem._level;
646
577
  if (hasOwnProperty.call(newItem, "_child")) item._child = !!newItem._child;
647
578
  let virtualItemIndex = itemIndex;
648
579
  if (p.filteredItems) {
@@ -753,8 +684,6 @@ var DropList = class DropList {
753
684
  /**
754
685
  * Return the item element at the given original index, if it exists.
755
686
  * The item may not be currently rendered, and null will be returned
756
- * @param index
757
- * @returns {HTMLElement|null}
758
687
  */
759
688
  itemElementAtIndex(index) {
760
689
  const p = this._p;
@@ -765,16 +694,10 @@ var DropList = class DropList {
765
694
  /**
766
695
  * Return the item element at the given index, if it exists.
767
696
  * The item may not be currently rendered, and null will be returned
768
- * @param index
769
- * @returns {HTMLElement|null}
770
697
  */
771
698
  filteredElementItemAtIndex(index) {
772
699
  return this._p.virtualListHelper.getItemElementAt(index) ?? null;
773
700
  }
774
- /**
775
- * @param {function(dropList: DropList):DropList.PositionOptions} fn
776
- * @returns {DropList}
777
- */
778
701
  setPositionOptionsProvider(fn) {
779
702
  const p = this._p;
780
703
  if (p.positionOptionsProvider === fn) return this;
@@ -782,16 +705,27 @@ var DropList = class DropList {
782
705
  this.relayout();
783
706
  return this;
784
707
  }
785
- /**
786
- * @returns {function(dropList: DropList):DropList.PositionOptions|null}
787
- */
788
708
  getPositionOptionsProvider() {
789
709
  return this._p.positionOptionsProvider;
790
710
  }
791
711
  /**
792
- * @param {string} term
793
- * @param {boolean} [performSearch=false] should actually perform the search, or just set the input's text?
794
- * @returns {DropList}
712
+ * Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderItem`/`unrenderItem`)
713
+ * instead of the default `console.error`/`console.warn`.
714
+ */
715
+ setOnError(fn) {
716
+ const p = this._p;
717
+ p.onError = fn ?? void 0;
718
+ return this;
719
+ }
720
+ /**
721
+ * Gets the current `onError` handler, if any.
722
+ */
723
+ getOnError() {
724
+ return this._p.onError;
725
+ }
726
+ /**
727
+ * @param term the search term to set
728
+ * @param performSearch should actually perform the search, or just set the input's text?
795
729
  */
796
730
  setSearchTerm(term, performSearch = false) {
797
731
  const p = this._p;
@@ -809,6 +743,7 @@ var DropList = class DropList {
809
743
  return !!(p.throttledRefilterItems.isScheduled() || !p.filteredItems && (p.filterTerm || p.filterOnEmptyTerm && p.filterFn));
810
744
  }
811
745
  /** @private */
746
+ /** @internal */
812
747
  _refilterItems() {
813
748
  const p = this._p;
814
749
  const term = p.filterTerm;
@@ -843,7 +778,7 @@ var DropList = class DropList {
843
778
  });
844
779
  }
845
780
  if (!Array.isArray(filteredItems)) if (term) {
846
- const matcher = new RegExp(escapeRegex_default(term), "i");
781
+ const matcher = new RegExp(escapeRegex(term), "i");
847
782
  filteredItems = p.items.filter((x) => {
848
783
  if (!filterGroups && x._group) return true;
849
784
  return matcher.test(x.label);
@@ -895,45 +830,27 @@ var DropList = class DropList {
895
830
  if (p.items) return p.items.length;
896
831
  return 0;
897
832
  }
898
- /**
899
- * @param {string} noResultsText
900
- * @returns {DropList}
901
- */
902
833
  setNoResultsText(noResultsText) {
903
834
  const p = this._p;
904
835
  p.noResultsText = noResultsText;
905
836
  if (p.hasNoResultsItem) p.virtualListHelper.refreshItemAt(0).render();
906
837
  return this;
907
838
  }
908
- /**
909
- * @returns {string}
910
- */
911
839
  getNoResultsText() {
912
840
  return this._p.noResultsText;
913
841
  }
914
- /**
915
- * @param {number} window
916
- * @returns {DropList}
917
- */
918
842
  setFilterThrottleWindow(window) {
919
843
  const p = this._p;
920
844
  p.filterThrottleWindow = window;
921
845
  let isScheduled = p.throttledRefilterItems ? p.throttledRefilterItems.isScheduled() : false;
922
846
  if (p.throttledRefilterItems) p.throttledRefilterItems.cancel();
923
- p.throttledRefilterItems = throttle(() => this._refilterItems(), p.filterThrottleWindow, true);
847
+ p.throttledRefilterItems = throttle(() => this._refilterItems(), p.filterThrottleWindow);
924
848
  if (isScheduled) p.throttledRefilterItems();
925
849
  return this;
926
850
  }
927
- /**
928
- * @returns {number}
929
- */
930
851
  getFilterThrottleWindow() {
931
852
  return this._p.filterThrottleWindow;
932
853
  }
933
- /**
934
- * @param {boolean} value
935
- * @returns {DropList}
936
- */
937
854
  setFilterOnEmptyTerm(value) {
938
855
  const p = this._p;
939
856
  if (p.filterOnEmptyTerm === value) return this;
@@ -941,16 +858,9 @@ var DropList = class DropList {
941
858
  p.throttledRefilterItems();
942
859
  return this;
943
860
  }
944
- /**
945
- * @returns {boolean}
946
- */
947
861
  getFilterOnEmptyTerm() {
948
862
  return this._p.filterOnEmptyTerm;
949
863
  }
950
- /**
951
- * @param {boolean} value
952
- * @returns {DropList}
953
- */
954
864
  setFilterGroups(value) {
955
865
  const p = this._p;
956
866
  if (p.filterGroups === value) return this;
@@ -958,52 +868,30 @@ var DropList = class DropList {
958
868
  p.throttledRefilterItems();
959
869
  return this;
960
870
  }
961
- /**
962
- * @returns {boolean}
963
- */
964
871
  getFilterGroups() {
965
872
  return this._p.filterGroups;
966
873
  }
967
- /**
968
- * @param {boolean} value
969
- * @returns {DropList}
970
- */
971
- setFilterEmptyGroups(value) {
874
+ setFilterEmptyGroups(value = true) {
972
875
  const p = this._p;
973
876
  if (p.filterEmptyGroups === value) return this;
974
877
  p.filterEmptyGroups = value;
975
878
  p.throttledRefilterItems();
976
879
  return this;
977
880
  }
978
- /**
979
- * @returns {boolean}
980
- */
981
881
  getFilterEmptyGroups() {
982
882
  return this._p.filterEmptyGroups;
983
883
  }
984
- /**
985
- * @param {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} fn
986
- * @returns {DropList}
987
- */
988
884
  setFilterFn(fn) {
989
885
  const p = this._p;
886
+ fn ??= null;
990
887
  if (p.filterFn === fn) return this;
991
888
  p.filterFn = fn;
992
889
  p.throttledRefilterItems();
993
890
  return this;
994
891
  }
995
- /**
996
- * @returns {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)}
997
- */
998
892
  getFilterFn() {
999
893
  return this._p.filterFn;
1000
894
  }
1001
- /**
1002
- *
1003
- * @param {DropList.PositionOptions} [positionOptions]
1004
- * @returns {DropList}
1005
- * @public
1006
- */
1007
895
  relayout(positionOptions) {
1008
896
  const p = this._p, el = p.el, menuEl = p.menuEl;
1009
897
  if (!this.isVisible()) return this;
@@ -1128,7 +1016,10 @@ var DropList = class DropList {
1128
1016
  viewCss.top += "px";
1129
1017
  setCssProps(el, viewCss);
1130
1018
  setElementHeight(el, viewSize.height, true, true);
1131
- 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
+ }
1132
1023
  p.virtualListHelper.render();
1133
1024
  if (positionOptions && positionOptions.target) {
1134
1025
  p.lastPositionTarget = positionOptions.target;
@@ -1142,10 +1033,6 @@ var DropList = class DropList {
1142
1033
  }
1143
1034
  /**
1144
1035
  * Set the checked mode of a specific value.
1145
- * @public
1146
- * @param {*} value - array of values to check
1147
- * @param {boolean} checked - will the value be checked?
1148
- * @returns {DropList} self
1149
1036
  */
1150
1037
  setItemChecked(value, checked) {
1151
1038
  const p = this._p;
@@ -1165,9 +1052,6 @@ var DropList = class DropList {
1165
1052
  }
1166
1053
  /**
1167
1054
  * Set the checked values. All the other values will be unchecked,
1168
- * @public
1169
- * @param {Array<*>} values - array of values to check
1170
- * @returns {DropList} self
1171
1055
  */
1172
1056
  setCheckedValues(values) {
1173
1057
  const p = this._p;
@@ -1190,11 +1074,9 @@ var DropList = class DropList {
1190
1074
  }
1191
1075
  /**
1192
1076
  * Get all checked values. Returns array of item values.
1193
- * @public
1194
- * @param {boolean} excludeGroups=false Exclude group items
1195
- * @returns {Array<*>} self
1077
+ * @param excludeGroups Exclude group items
1196
1078
  */
1197
- getCheckedValues(excludeGroups) {
1079
+ getCheckedValues(excludeGroups = false) {
1198
1080
  const p = this._p;
1199
1081
  excludeGroups = excludeGroups && p.groupCount > 0;
1200
1082
  let values = [];
@@ -1208,11 +1090,9 @@ var DropList = class DropList {
1208
1090
  }
1209
1091
  /**
1210
1092
  * Get all checked items. Returns array of actual item data object.
1211
- * @public
1212
- * @param {boolean} excludeGroups=false Exclude group items
1213
- * @returns {DropList.Item[]}
1093
+ * @param excludeGroups Exclude group items
1214
1094
  */
1215
- getCheckedItems(excludeGroups) {
1095
+ getCheckedItems(excludeGroups = false) {
1216
1096
  const p = this._p;
1217
1097
  excludeGroups = excludeGroups && p.groupCount > 0;
1218
1098
  const items = [];
@@ -1224,12 +1104,6 @@ var DropList = class DropList {
1224
1104
  }
1225
1105
  return items;
1226
1106
  }
1227
- /**
1228
- *
1229
- * @param {DropList.PositionOptions?} [positionOptions]
1230
- * @returns {DropList}
1231
- * @public
1232
- */
1233
1107
  show(positionOptions) {
1234
1108
  const p = this._p;
1235
1109
  p.hiding = false;
@@ -1263,7 +1137,7 @@ var DropList = class DropList {
1263
1137
  if (this.isVisible()) this._trigger("show");
1264
1138
  return this;
1265
1139
  }
1266
- hide() {
1140
+ hide(event) {
1267
1141
  const p = this._p, el = p.el;
1268
1142
  if (p.onDocumentMouseDown) {
1269
1143
  p.sink.remove(document, "mousedown", p.onDocumentMouseDown);
@@ -1313,7 +1187,6 @@ var DropList = class DropList {
1313
1187
  /**
1314
1188
  * Change visibility of the header element
1315
1189
  * You should probably call `relayout()` after this.
1316
- * @param {boolean} visible
1317
1190
  */
1318
1191
  setHeaderVisible(visible) {
1319
1192
  if (this.isHeaderVisible() === !!visible) return;
@@ -1322,14 +1195,12 @@ var DropList = class DropList {
1322
1195
  }
1323
1196
  /**
1324
1197
  * Is the header element visible?
1325
- * @returns {boolean}
1326
1198
  */
1327
1199
  isHeaderVisible() {
1328
1200
  return !!this._p.headerEl.parentNode;
1329
1201
  }
1330
1202
  /**
1331
1203
  * Get a reference to the header element in order to add custom content.
1332
- * @returns {Element}
1333
1204
  */
1334
1205
  getHeaderElement() {
1335
1206
  return this._p.headerEl;
@@ -1337,7 +1208,6 @@ var DropList = class DropList {
1337
1208
  /**
1338
1209
  * Change visibility of the footer element
1339
1210
  * You should probably call `relayout()` after this.
1340
- * @param {boolean} visible
1341
1211
  */
1342
1212
  setFooterVisible(visible) {
1343
1213
  if (this.isFooterVisible() === !!visible) return;
@@ -1346,14 +1216,12 @@ var DropList = class DropList {
1346
1216
  }
1347
1217
  /**
1348
1218
  * Is the footer element visible?
1349
- * @returns {boolean}
1350
1219
  */
1351
1220
  isFooterVisible() {
1352
1221
  return !!this._p.footerEl.parentNode;
1353
1222
  }
1354
1223
  /**
1355
1224
  * Get a reference to the footer element in order to add custom content.
1356
- * @returns {Element}
1357
1225
  */
1358
1226
  getFooterElement() {
1359
1227
  return this._p.footerEl;
@@ -1361,7 +1229,6 @@ var DropList = class DropList {
1361
1229
  /**
1362
1230
  * Set inline search visibility
1363
1231
  * You should probably call `relayout()` after this.
1364
- * @param {boolean} searchable
1365
1232
  */
1366
1233
  setSearchable(searchable) {
1367
1234
  const p = this._p;
@@ -1387,7 +1254,6 @@ var DropList = class DropList {
1387
1254
  }
1388
1255
  /**
1389
1256
  * Set the placeholder text of the inline search box
1390
- * @param {string} placeholder
1391
1257
  */
1392
1258
  setSearchPlaceholder(placeholder) {
1393
1259
  const p = this._p;
@@ -1435,6 +1301,7 @@ var DropList = class DropList {
1435
1301
  }
1436
1302
  return this;
1437
1303
  }
1304
+ /** @internal */
1438
1305
  _showSublist(item, itemElement) {
1439
1306
  if (!item._subitems?.length) return;
1440
1307
  const p = this._p;
@@ -1510,6 +1377,7 @@ var DropList = class DropList {
1510
1377
  droplist.show();
1511
1378
  droplist.el.focus();
1512
1379
  }
1380
+ /** @internal */
1513
1381
  _hideSublist() {
1514
1382
  const p = this._p;
1515
1383
  if (!p.currentSubDropList) return;
@@ -1609,6 +1477,7 @@ var DropList = class DropList {
1609
1477
  }
1610
1478
  return this;
1611
1479
  }
1480
+ /** @internal */
1612
1481
  _scrollItemIndexIntoView(itemIndex) {
1613
1482
  const p = this._p;
1614
1483
  if (this._hasScroll()) {
@@ -1629,9 +1498,6 @@ var DropList = class DropList {
1629
1498
  }
1630
1499
  /**
1631
1500
  * Register an event handler
1632
- * @param {(string|'*')?} event
1633
- * @param {function(any)} handler
1634
- * @returns {DropList}
1635
1501
  */
1636
1502
  on(event, handler) {
1637
1503
  this._p.mitt.on(event, handler);
@@ -1639,9 +1505,6 @@ var DropList = class DropList {
1639
1505
  }
1640
1506
  /**
1641
1507
  * Register a one time event handler
1642
- * @param {(string|'*')?} event
1643
- * @param {function(any)} handler
1644
- * @returns {DropList}
1645
1508
  */
1646
1509
  once(event, handler) {
1647
1510
  let wrapped = (value) => {
@@ -1653,9 +1516,6 @@ var DropList = class DropList {
1653
1516
  }
1654
1517
  /**
1655
1518
  * Remove an `handler` for `event`, all events for `event`, or all events completely.
1656
- * @param {(string|'*')?} event
1657
- * @param {function(any)} handler
1658
- * @returns {DropList}
1659
1519
  */
1660
1520
  off(event, handler) {
1661
1521
  if (!event && !event) this._p.mitt.all.clear();
@@ -1664,14 +1524,12 @@ var DropList = class DropList {
1664
1524
  }
1665
1525
  /**
1666
1526
  * Emit an event
1667
- * @param {string} event
1668
- * @param {any} value
1669
- * @returns {DropList}
1670
1527
  */
1671
1528
  emit(event, value) {
1672
1529
  this._p.mitt.emit(event, value);
1673
1530
  return this;
1674
1531
  }
1532
+ /** @internal */
1675
1533
  _getItemIndex(item) {
1676
1534
  const p = this._p;
1677
1535
  let itemIndex = -1;
@@ -1685,6 +1543,7 @@ var DropList = class DropList {
1685
1543
  }
1686
1544
  return itemIndex;
1687
1545
  }
1546
+ /** @internal */
1688
1547
  _setSingleSelectedItemEl(itemEl, value) {
1689
1548
  const p = this._p;
1690
1549
  if (p.singleSelectedItemEl) {
@@ -1699,15 +1558,15 @@ var DropList = class DropList {
1699
1558
  return this;
1700
1559
  }
1701
1560
  /**
1702
- * @param {string} event
1703
- * @param {*} [data]
1704
1561
  * @private
1562
+ * @internal
1705
1563
  */
1706
1564
  _trigger(event, data) {
1707
1565
  const p = this._p;
1708
1566
  if (p.on) p.on(event, ...data === void 0 ? [] : [data]);
1709
1567
  p.mitt.emit(event, data);
1710
1568
  }
1569
+ /** @internal */
1711
1570
  _itemUpAction(event, itemEl) {
1712
1571
  if (closestUntil(event.target, ".requires-pointer-events,button", itemEl)) return;
1713
1572
  let p = this._p;
@@ -1720,6 +1579,7 @@ var DropList = class DropList {
1720
1579
  }, 0);
1721
1580
  }
1722
1581
  }
1582
+ /** @internal */
1723
1583
  _hookMouseEvents() {
1724
1584
  const p = this._p;
1725
1585
  p.sink.add(p.el, "mouseup", (event) => {
@@ -1733,9 +1593,11 @@ var DropList = class DropList {
1733
1593
  this._handleMouseOver(event, li);
1734
1594
  });
1735
1595
  }
1596
+ /** @internal */
1736
1597
  _handleMouseOver(event, itemEl) {
1737
1598
  this._focus(event, itemEl, null, true);
1738
1599
  }
1600
+ /** @internal */
1739
1601
  _hookTouchEvents() {
1740
1602
  const p = this._p;
1741
1603
  let currentTouchId;
@@ -1775,6 +1637,7 @@ var DropList = class DropList {
1775
1637
  });
1776
1638
  });
1777
1639
  }
1640
+ /** @internal */
1778
1641
  _hookFocusEvents() {
1779
1642
  const p = this._p;
1780
1643
  p.sink.add(p.el, "focus", (event) => {
@@ -1792,10 +1655,12 @@ var DropList = class DropList {
1792
1655
  });
1793
1656
  }, true);
1794
1657
  }
1658
+ /** @internal */
1795
1659
  _hookKeyEvents() {
1796
1660
  const p = this._p;
1797
1661
  p.sink.add(p.el, "keydown", (evt) => this._keydown(evt));
1798
1662
  }
1663
+ /** @internal */
1799
1664
  _hookSearchEvents() {
1800
1665
  const p = this._p;
1801
1666
  if (!p.searchInput) return;
@@ -1806,6 +1671,7 @@ var DropList = class DropList {
1806
1671
  p.throttledRefilterItems();
1807
1672
  });
1808
1673
  }
1674
+ /** @internal */
1809
1675
  _keydown(event) {
1810
1676
  const p = this._p;
1811
1677
  if (p.keyDownHandler && p.keyDownHandler.call(this, event)) return;
@@ -1834,9 +1700,7 @@ var DropList = class DropList {
1834
1700
  case VALUE_UP:
1835
1701
  this.previous(event);
1836
1702
  break;
1837
- case VALUE_DOWN:
1838
- this.next(event);
1839
- break;
1703
+ case VALUE_DOWN: this.next(event);
1840
1704
  }
1841
1705
  break;
1842
1706
  case VALUE_LEFT:
@@ -1868,6 +1732,7 @@ var DropList = class DropList {
1868
1732
  if (!p.searchable) this._keydownFreeType(event, !this.isVisible());
1869
1733
  }
1870
1734
  }
1735
+ /** @internal */
1871
1736
  _keydownFreeType(evt, autoSelect) {
1872
1737
  const p = this._p;
1873
1738
  const character = evt.key || String.fromCharCode(evt.keyCode);
@@ -1876,7 +1741,7 @@ var DropList = class DropList {
1876
1741
  if (!isChar) return;
1877
1742
  clearTimeout(p.filterTimer);
1878
1743
  let keyword = (p.previousFilter || "") + character;
1879
- let regex = new RegExp(`^${escapeRegex_default(keyword)}`, "i");
1744
+ let regex = new RegExp(`^${escapeRegex(keyword)}`, "i");
1880
1745
  let matchIndex = -1;
1881
1746
  let item;
1882
1747
  let focusItemIndex = p.focusItemIndex;
@@ -1891,7 +1756,7 @@ var DropList = class DropList {
1891
1756
  }
1892
1757
  if (matchIndex === -1) {
1893
1758
  keyword = character;
1894
- regex = new RegExp(`^${escapeRegex_default(keyword)}`, "i");
1759
+ regex = new RegExp(`^${escapeRegex(keyword)}`, "i");
1895
1760
  for (let i = 0, count = items.length; i < count; i++) {
1896
1761
  if (matchIndex !== -1 && i < focusItemIndex) continue;
1897
1762
  item = items[i];
@@ -1911,6 +1776,7 @@ var DropList = class DropList {
1911
1776
  }, 1e3);
1912
1777
  } else delete p.previousFilter;
1913
1778
  }
1779
+ /** @internal */
1914
1780
  _focus(event, itemEl, itemIndex, openSubitems) {
1915
1781
  const p = this._p;
1916
1782
  if (p._isFocusingItem) return;
@@ -1944,6 +1810,7 @@ var DropList = class DropList {
1944
1810
  p._isFocusingItem = false;
1945
1811
  if (openSubitems) this._showSublist(item, focusItemEl);
1946
1812
  }
1813
+ /** @internal */
1947
1814
  _delayBlurItemOnBlur() {
1948
1815
  if (this[DestroyedSymbol$1]) return;
1949
1816
  const p = this._p;
@@ -1954,6 +1821,7 @@ var DropList = class DropList {
1954
1821
  this.blurFocusedItem();
1955
1822
  }, p.autoItemBlurDelay);
1956
1823
  }
1824
+ /** @internal */
1957
1825
  _move(direction, event) {
1958
1826
  const p = this._p;
1959
1827
  let next, nextIndex, directionUp;
@@ -2023,10 +1891,12 @@ var DropList = class DropList {
2023
1891
  this._focus(event, next || null, nextIndex, false);
2024
1892
  if (!this.isVisible()) this.triggerItemSelection(item, event);
2025
1893
  }
1894
+ /** @internal */
2026
1895
  _hasScroll() {
2027
1896
  const menuEl = this._p.menuEl;
2028
1897
  return menuEl.clientHeight < menuEl.scrollHeight;
2029
1898
  }
1899
+ /** @internal */
2030
1900
  _updateGroupStateForItem(item) {
2031
1901
  const p = this._p;
2032
1902
  if (!p.multi) return this;
@@ -2070,6 +1940,7 @@ var DropList = class DropList {
2070
1940
  }
2071
1941
  return this;
2072
1942
  }
1943
+ /** @internal */
2073
1944
  _updateGroupCheckedState(groupIndex, fireEvents) {
2074
1945
  const p = this._p;
2075
1946
  if (!(p.multi && p.autoCheckGroupChildren && groupIndex > -1)) return this;
@@ -2102,7 +1973,7 @@ var DropList = class DropList {
2102
1973
  }
2103
1974
  /**
2104
1975
  * @private
2105
- * @returns {DropList} self
1976
+ * @internal
2106
1977
  */
2107
1978
  _measureItem() {
2108
1979
  const p = this._p;
@@ -2147,9 +2018,9 @@ var DropList = class DropList {
2147
2018
  }
2148
2019
  /**
2149
2020
  * Determines whether the list should be in virtual mode, depending on the item count.
2150
- * @param {number?} targetItemCount - item count we are expecting. Defaults to current item count
2151
- * @returns {DropList}
2021
+ * @param targetItemCount item count we are expecting. Defaults to current item count
2152
2022
  * @private
2023
+ * @internal
2153
2024
  */
2154
2025
  _determineVirtualMode(targetItemCount) {
2155
2026
  const p = this._p;
@@ -2159,6 +2030,7 @@ var DropList = class DropList {
2159
2030
  if (shouldBeVirtual !== p.virtualListHelper.isVirtual()) p.virtualListHelper.setVirtual(shouldBeVirtual).render();
2160
2031
  return this;
2161
2032
  }
2033
+ /** @internal */
2162
2034
  _renderItemContent(item, itemEl) {
2163
2035
  const p = this._p;
2164
2036
  const originalItem = item[ItemSymbol];
@@ -2180,17 +2052,12 @@ var DropList = class DropList {
2180
2052
  }
2181
2053
  }
2182
2054
  }
2183
- /**
2184
- *
2185
- * @param {DropList.PositionOptions} [positionOptions=undefined]
2186
- * @returns {number} new outer width
2187
- * @private
2188
- */
2055
+ /** @internal */
2189
2056
  _updateWidth(positionOptions) {
2190
2057
  const p = this._p, el = p.el;
2191
2058
  let targetWidth = 0;
2192
2059
  if (positionOptions) if (typeof positionOptions.updateWidth === "number") targetWidth = positionOptions.updateWidth;
2193
- else if (positionOptions.targetWidth != null) targetWidth = positionOptions.updateWidth;
2060
+ else if (positionOptions.targetWidth != null) targetWidth = positionOptions.targetWidth;
2194
2061
  else targetWidth = getElementWidth(positionOptions.target, true, true);
2195
2062
  let autoWidth = 0;
2196
2063
  if (!p.useExactTargetWidth || !targetWidth) if (p.estimateWidth || p.virtualListHelper.isVirtual()) autoWidth = p.lastMeasureItemWidth;
@@ -2212,15 +2079,10 @@ var DropList = class DropList {
2212
2079
  }
2213
2080
  };
2214
2081
  //#endregion
2215
- //#region lib/SelectBox.js
2082
+ //#region src/lib/SelectBox.ts
2216
2083
  var DestroyedSymbol = Symbol("destroyed");
2217
2084
  var RestMultiItemsSymbol = Symbol("rest_multi_items");
2218
2085
  var hasTouchCapability = !!("ontouchstart" in window || window.DocumentTouch && window.document instanceof window.DocumentTouch || window.navigator.maxTouchPoints);
2219
- /**
2220
- * @param {Element|EventTarget} el
2221
- * @param {string} className
2222
- * @returns {boolean}
2223
- */
2224
2086
  var hasClass = function(el, className) {
2225
2087
  if (el instanceof Element) return el.classList.contains(className);
2226
2088
  return false;
@@ -2238,57 +2100,6 @@ var inputBackbufferCssProps = [
2238
2100
  "padding-left",
2239
2101
  "padding-right"
2240
2102
  ];
2241
- /**
2242
- * @typedef {Object} SelectBox.Options
2243
- * @property {DropList.Options} [listOptions] options to pass to the `DropList`
2244
- * @property {Element} [el] An element to attach to, instead of creating a new one
2245
- * @property {string} [baseClassName='selectbox'] class name for the menu root element
2246
- * @property {string|string[]} [additionalClasses]
2247
- * @property {'ltr'|'rtl'|'auto'} [direction='auto']
2248
- * @property {boolean} [disabled=false] Should start as disabled?
2249
- * @property {boolean} [readOnly=false] Should start as readOnly?
2250
- * @property {boolean} [clearable=true] Has clear button?
2251
- * @property {boolean} [hasOpenIndicator=true] has open/close indicator?
2252
- * @property {string} [placeholder=''] Placeholder text
2253
- * @property {boolean} [sortSelectedItems=true] Should the selected items be sorted?
2254
- * @property {boolean} [sortListItems=false] Sort list items
2255
- * @property {boolean} [sortListCheckedFirst=true] When sorting - put checked items first (applicable to `multi` mode only)
2256
- * @property {boolean} [treatGroupSelectionAsItems=false] Treat group items as normal items
2257
- * @property {*[]} [stickyValues]
2258
- * @property {function(a: DropList.ItemBase, b: DropList.ItemBase):number} [sortItemComparator]
2259
- * @property {boolean} [splitListCheckedGroups=true] Split groups to "checked" and "unchecked", works with `sortListCheckedFirst` only
2260
- * @property {boolean|'touch'} [blurOnSingleSelection='touch']
2261
- * @property {boolean} [multi=false] can multiple values be selected?
2262
- * @property {boolean} [showSelection=true] show selection? if false, the placeholder will take effect
2263
- * @property {boolean} [showPlaceholderInTooltip=false] show placeholder in title attribute
2264
- * @property {function(items: DropList.ItemBase[]):string} [multiPlaceholderFormatter] formatter for placeholder for multi items mode
2265
- * @property {string} [labelProp='label']
2266
- * @property {string} [valueProp='value']
2267
- * @property {string} [multiItemLabelProp='short_label']
2268
- * @property {'after'|'before'|'none'} [multiItemRemovePosition='after']
2269
- * @property {number} [maxMultiItems] maximum number of multi items. The rest will get a single item to represent.
2270
- * @property {function(count: number, items: DropList.ItemBase[]):string} [multiItemsRestLabelProvider] label for the item representing the rest of the items.
2271
- * @property {DropList.ItemBase[]|null} [items] initial items
2272
- * @property {*[]|null} [selectedValues] initial selected values
2273
- * @property {*|*[]|null} [value] initial selected value
2274
- * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderSingleItem]
2275
- * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderSingleItem]
2276
- * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderMultiItem]
2277
- * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderMultiItem]
2278
- * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderRestMultiItem]
2279
- * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderRestMultiItem]
2280
- * @property {boolean} [searchable=false] is it searchable?
2281
- * @property {boolean} [allowTypeToSelect=true] default behavior of type to select (focus first item starting with the search term) when searchable is true
2282
- * @property {string} [noResultsText='No matching results'] text for no results (empty for none)
2283
- * @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.
2284
- * @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
2285
- * @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
2286
- * @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
2287
- * @property {function(name: string, ...args)} [on]
2288
- * @property {boolean} [isLoadingMode]
2289
- * @property {boolean} [closeListWhenLoading] whether we should close the list automatically when loading
2290
- * @property {string[]} [clearInputWhen=['single_close','multi_select_single']] clear input box when closing the droplist or selecting <code>['single_close', 'multi_close', 'multi_select_single']</code>
2291
- * */
2292
2103
  var DefaultOptions$1 = {
2293
2104
  el: null,
2294
2105
  baseClassName: "selectbox",
@@ -2327,12 +2138,6 @@ var DefaultOptions$1 = {
2327
2138
  closeListWhenLoading: true,
2328
2139
  clearInputWhen: ["single_close", "multi_select_single"]
2329
2140
  };
2330
- /**
2331
- *
2332
- * @param {DropList.ItemBase[]} items
2333
- * @param {string} labelProp
2334
- * @returns {string}
2335
- */
2336
2141
  var defaultMultiPlaceholderFormatter = (items, labelProp) => {
2337
2142
  if (items.length === 0) return "";
2338
2143
  let title = items[0][labelProp] + "";
@@ -2356,9 +2161,6 @@ function restoreFocusState(state) {
2356
2161
  return true;
2357
2162
  }
2358
2163
  var SelectBox = class {
2359
- /**
2360
- * @param {SelectBox.Options} options
2361
- */
2362
2164
  constructor(options) {
2363
2165
  const o = { ...DefaultOptions$1 };
2364
2166
  for (let [key, value] of Object.entries(
@@ -2407,6 +2209,7 @@ var SelectBox = class {
2407
2209
  on: o.on || null,
2408
2210
  silenceEvents: true,
2409
2211
  mitt: mitt(),
2212
+ onError: o.onError,
2410
2213
  isLoadingMode: !!o.isLoadingMode,
2411
2214
  closeListWhenLoading: !!o.closeListWhenLoading,
2412
2215
  clearInputWhen: Array.isArray(o.clearInputWhen) ? o.clearInputWhen.slice(0) : [],
@@ -2422,7 +2225,11 @@ var SelectBox = class {
2422
2225
  filterThrottleWindow: o.filterThrottleWindow,
2423
2226
  filterOnEmptyTerm: o.filterOnEmptyTerm,
2424
2227
  filterFn: null,
2425
- filterTerm: ""
2228
+ filterTerm: "",
2229
+ dropListVisible: false,
2230
+ lastActiveElement: null,
2231
+ lastKeyAllowsNonTypeKeys: false,
2232
+ presenceInt: null
2426
2233
  };
2427
2234
  let el = o.el;
2428
2235
  if (el instanceof Element) p.ownsEl = false;
@@ -2541,21 +2348,15 @@ var SelectBox = class {
2541
2348
  }
2542
2349
  /**
2543
2350
  * Returns true if other is an inclusive descendant of droplist node, false otherwise, and undefined if the droplist is not initiated.
2544
- * @param {Node} other
2545
- * @param {boolean} [considerSubmenus=true]
2546
- * @returns {boolean|undefined}
2547
2351
  */
2548
2352
  droplistElContains(other, considerSubmenus = true) {
2549
2353
  return this._p.dropList?.elContains(other, considerSubmenus);
2550
2354
  }
2551
2355
  /**
2552
2356
  * Enables the control
2553
- * @param {boolean=true} enabled Should the control be enabled?
2554
- * @returns {SelectBox}
2555
2357
  */
2556
- enable(enabled) {
2358
+ enable(enabled = true) {
2557
2359
  const p = this._p;
2558
- if (enabled === void 0) enabled = true;
2559
2360
  p.disabled = !enabled;
2560
2361
  p.el.setAttribute("aria-disabled", p.disabled.toString());
2561
2362
  p.input.disabled = !!p.disabled;
@@ -2566,50 +2367,38 @@ var SelectBox = class {
2566
2367
  }
2567
2368
  /**
2568
2369
  * Is the control enabled?
2569
- * @returns {boolean}
2570
2370
  */
2571
2371
  isEnabled() {
2572
2372
  return !this._p.disabled;
2573
2373
  }
2574
2374
  /**
2575
2375
  * Disables the control
2576
- * @param {boolean=true} disabled Should the control be disabled?
2577
- * @returns {SelectBox}
2578
2376
  */
2579
- disable(disabled) {
2580
- return this.enable(disabled === void 0 ? false : !disabled);
2377
+ disable(disabled = true) {
2378
+ return this.enable(!disabled);
2581
2379
  }
2582
2380
  /**
2583
2381
  * Is the control disabled?
2584
- * @returns {boolean}
2585
2382
  */
2586
2383
  isDisabled() {
2587
2384
  return this._p.disabled;
2588
2385
  }
2589
2386
  /**
2590
2387
  * Sets read only mode
2591
- * @param {boolean=true} readOnly Should the control be read only?
2592
- * @returns {SelectBox}
2593
2388
  */
2594
- setReadOnly(readOnly) {
2389
+ setReadOnly(readOnly = true) {
2595
2390
  const p = this._p;
2596
- if (readOnly === void 0) readOnly = true;
2597
2391
  p.readOnly = readOnly;
2598
2392
  p.el.setAttribute("aria-readOnly", p.readOnly.toString());
2599
2393
  p.input.readOnly = !(p.searchable || p.multi) || !!p.readOnly;
2600
2394
  return this;
2601
2395
  }
2602
2396
  /**
2603
- * Is the control enabled?
2604
- * @returns {boolean}
2397
+ * Is the control read only?
2605
2398
  */
2606
2399
  isReadOnly() {
2607
2400
  return this._p.readOnly;
2608
2401
  }
2609
- /**
2610
- * @param {string|string[]} classes
2611
- * @returns {SelectBox}
2612
- */
2613
2402
  setAdditionalClasses(classes) {
2614
2403
  const p = this._p;
2615
2404
  p.additionalClasses = classes;
@@ -2617,10 +2406,8 @@ var SelectBox = class {
2617
2406
  return this;
2618
2407
  }
2619
2408
  /**
2620
- *
2621
- * @param {DropList.ItemBase[]} [items]
2622
- * @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
2623
- * @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
2624
2411
  */
2625
2412
  setItems(items, resetValues = true) {
2626
2413
  const p = this._p;
@@ -2656,16 +2443,9 @@ var SelectBox = class {
2656
2443
  }
2657
2444
  if (p.dropList) p.dropList.updateItemByValue(value, newItem);
2658
2445
  }
2659
- /**
2660
- * @returns {DropList.ItemBase[]|*}
2661
- */
2662
2446
  getItems() {
2663
2447
  return this._p.items;
2664
2448
  }
2665
- /**
2666
- * @param {boolean} clearable
2667
- * @returns {SelectBox}
2668
- */
2669
2449
  setClearable(clearable) {
2670
2450
  clearable = !!clearable;
2671
2451
  if (this._p.clearable === clearable) return this;
@@ -2673,16 +2453,9 @@ var SelectBox = class {
2673
2453
  this._scheduleSync("render_clear");
2674
2454
  return this;
2675
2455
  }
2676
- /**
2677
- * @returns {boolean}
2678
- */
2679
2456
  getClearable() {
2680
2457
  return this._p.clearable;
2681
2458
  }
2682
- /**
2683
- * @param {boolean} enabled
2684
- * @returns {SelectBox}
2685
- */
2686
2459
  setHasOpenIndicator(enabled) {
2687
2460
  enabled = !!enabled;
2688
2461
  if (this._p.hasOpenIndicator === enabled) return this;
@@ -2690,31 +2463,20 @@ var SelectBox = class {
2690
2463
  this._scheduleSync("render_base");
2691
2464
  return this;
2692
2465
  }
2693
- /**
2694
- * @returns {boolean}
2695
- */
2696
2466
  getHasOpenIndicator() {
2697
2467
  return this._p.hasOpenIndicator;
2698
2468
  }
2699
- /**
2700
- * @param {string} placeholder
2701
- * @returns {SelectBox}
2702
- */
2703
2469
  setPlaceholder(placeholder) {
2704
2470
  this._p.placeholder = placeholder == null ? "" : String(placeholder);
2705
2471
  this._scheduleSync("render_base");
2706
2472
  return this;
2707
2473
  }
2708
- /**
2709
- * @returns {string}
2710
- */
2711
2474
  getPlaceHolder() {
2712
2475
  return this._p.placeholder;
2713
2476
  }
2714
2477
  /**
2715
- * @param {string} term
2716
- * @param {boolean} [performSearch=false] should actually perform the search, or just set the input's text?
2717
- * @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?
2718
2480
  */
2719
2481
  setSearchTerm(term, performSearch = false) {
2720
2482
  const p = this._p;
@@ -2728,9 +2490,6 @@ var SelectBox = class {
2728
2490
  }
2729
2491
  return this;
2730
2492
  }
2731
- /**
2732
- * @returns {string}
2733
- */
2734
2493
  getSearchTerm() {
2735
2494
  const p = this._p;
2736
2495
  if (p.input) return p.input.value;
@@ -2740,10 +2499,6 @@ var SelectBox = class {
2740
2499
  this._p.dropList?.invokeRefilter();
2741
2500
  return this;
2742
2501
  }
2743
- /**
2744
- * @param {boolean} sortSelectedItems
2745
- * @returns {SelectBox}
2746
- */
2747
2502
  setSortSelectedItems(sortSelectedItems) {
2748
2503
  const p = this._p;
2749
2504
  sortSelectedItems = !!sortSelectedItems;
@@ -2752,16 +2507,9 @@ var SelectBox = class {
2752
2507
  this._scheduleSync("render_items");
2753
2508
  return this;
2754
2509
  }
2755
- /**
2756
- * @returns {boolean}
2757
- */
2758
2510
  isSortSelectedItemsEnabled() {
2759
2511
  return this._p.sortSelectedItems;
2760
2512
  }
2761
- /**
2762
- * @param {boolean} sortListItems
2763
- * @returns {SelectBox}
2764
- */
2765
2513
  setSortListItems(sortListItems) {
2766
2514
  const p = this._p;
2767
2515
  sortListItems = !!sortListItems;
@@ -2771,16 +2519,9 @@ var SelectBox = class {
2771
2519
  this._scheduleSync("render_list");
2772
2520
  return this;
2773
2521
  }
2774
- /**
2775
- * @returns {boolean}
2776
- */
2777
2522
  isSortListItemsEnabled() {
2778
2523
  return this._p.sortListItems;
2779
2524
  }
2780
- /**
2781
- * @param {boolean} sortListCheckedFirst
2782
- * @returns {SelectBox}
2783
- */
2784
2525
  setSortListCheckedFirst(sortListCheckedFirst) {
2785
2526
  const p = this._p;
2786
2527
  sortListCheckedFirst = !!sortListCheckedFirst;
@@ -2790,16 +2531,9 @@ var SelectBox = class {
2790
2531
  this._scheduleSync("render_list");
2791
2532
  return this;
2792
2533
  }
2793
- /**
2794
- * @returns {boolean}
2795
- */
2796
2534
  isSortListCheckedFirstEnabled() {
2797
2535
  return this._p.sortListCheckedFirst;
2798
2536
  }
2799
- /**
2800
- * @param {*[]} values
2801
- * @returns {SelectBox}
2802
- */
2803
2537
  setStickyValues(values) {
2804
2538
  const p = this._p;
2805
2539
  p.stickyValues = Array.isArray(values) ? new Set(values) : null;
@@ -2807,16 +2541,9 @@ var SelectBox = class {
2807
2541
  this._scheduleSync("render_list");
2808
2542
  return this;
2809
2543
  }
2810
- /**
2811
- * @returns {*[]}
2812
- */
2813
2544
  getStickyValues() {
2814
2545
  return this._p.stickyValues ? Array.from(this._p.stickyValues) : null;
2815
2546
  }
2816
- /**
2817
- * @param {function(a: DropList.ItemBase, b: DropList.ItemBase):number} comparator
2818
- * @returns {SelectBox}
2819
- */
2820
2547
  setSortItemComparator(comparator) {
2821
2548
  const p = this._p;
2822
2549
  if (p.sortItemComparator === comparator) return this;
@@ -2825,16 +2552,9 @@ var SelectBox = class {
2825
2552
  this._scheduleSync("render_list");
2826
2553
  return this;
2827
2554
  }
2828
- /**
2829
- * @returns {function(a: DropList.ItemBase, b: DropList.ItemBase):number}
2830
- */
2831
2555
  getSortItemComparator() {
2832
2556
  return this._p.sortItemComparator;
2833
2557
  }
2834
- /**
2835
- * @param {boolean} treatGroupSelectionAsItems
2836
- * @returns {SelectBox}
2837
- */
2838
2558
  setTreatGroupSelectionAsItems(treatGroupSelectionAsItems) {
2839
2559
  const p = this._p;
2840
2560
  treatGroupSelectionAsItems = !!treatGroupSelectionAsItems;
@@ -2846,16 +2566,9 @@ var SelectBox = class {
2846
2566
  this._scheduleSync("render_list");
2847
2567
  return this;
2848
2568
  }
2849
- /**
2850
- * @returns {boolean}
2851
- */
2852
2569
  isTreatGroupSelectionAsItemsEnabled() {
2853
2570
  return !this._p.treatGroupSelectionAsItems;
2854
2571
  }
2855
- /**
2856
- * @param {boolean} splitListCheckedGroups
2857
- * @returns {SelectBox}
2858
- */
2859
2572
  setSplitListCheckedGroups(splitListCheckedGroups) {
2860
2573
  const p = this._p;
2861
2574
  splitListCheckedGroups = !!splitListCheckedGroups;
@@ -2865,16 +2578,9 @@ var SelectBox = class {
2865
2578
  this._scheduleSync("render_list");
2866
2579
  return this;
2867
2580
  }
2868
- /**
2869
- * @returns {boolean}
2870
- */
2871
2581
  isSplitListCheckedGroupsEnabled() {
2872
2582
  return this._p.splitListCheckedGroups;
2873
2583
  }
2874
- /**
2875
- * @param {boolean} showSelection
2876
- * @returns {SelectBox}
2877
- */
2878
2584
  setShowSelection(showSelection) {
2879
2585
  const p = this._p;
2880
2586
  showSelection = !!showSelection;
@@ -2883,16 +2589,9 @@ var SelectBox = class {
2883
2589
  this._scheduleSync("render_items");
2884
2590
  return this;
2885
2591
  }
2886
- /**
2887
- * @returns {boolean}
2888
- */
2889
2592
  isShowSelectionEnabled() {
2890
2593
  return this._p.showSelection;
2891
2594
  }
2892
- /**
2893
- * @param {boolean} showPlaceholderInTooltip
2894
- * @returns {SelectBox}
2895
- */
2896
2595
  setShowPlaceholderInTooltip(showPlaceholderInTooltip) {
2897
2596
  const p = this._p;
2898
2597
  showPlaceholderInTooltip = !!showPlaceholderInTooltip;
@@ -2901,16 +2600,9 @@ var SelectBox = class {
2901
2600
  this._scheduleSync("render_base");
2902
2601
  return this;
2903
2602
  }
2904
- /**
2905
- * @returns {boolean}
2906
- */
2907
2603
  isShowPlaceholderInTooltipEnabled() {
2908
2604
  return this._p.showPlaceholderInTooltip;
2909
2605
  }
2910
- /**
2911
- * @param {function(items: DropList.ItemBase[]):string} formatter
2912
- * @returns {SelectBox}
2913
- */
2914
2606
  setMultiPlaceholderFormatter(formatter) {
2915
2607
  const p = this._p;
2916
2608
  if (p.multiPlaceholderFormatter === formatter) return this;
@@ -2918,26 +2610,15 @@ var SelectBox = class {
2918
2610
  this._scheduleSync("render_base");
2919
2611
  return this;
2920
2612
  }
2921
- /**
2922
- * @param {boolean|'touch'} value
2923
- * @returns {SelectBox}
2924
- */
2925
2613
  setBlurOnSingleSelection(value) {
2926
2614
  const p = this._p;
2927
2615
  if (p.blurOnSingleSelection === value) return this;
2928
2616
  p.blurOnSingleSelection = value;
2929
2617
  return this;
2930
2618
  }
2931
- /**
2932
- * @returns {boolean|'touch'}
2933
- */
2934
2619
  getBlurOnSingleSelection() {
2935
2620
  return this._p.blurOnSingleSelection;
2936
2621
  }
2937
- /**
2938
- * @param {boolean} multi
2939
- * @returns {SelectBox}
2940
- */
2941
2622
  setMulti(multi) {
2942
2623
  const p = this._p;
2943
2624
  multi = !!multi;
@@ -2953,16 +2634,9 @@ var SelectBox = class {
2953
2634
  this._scheduleSync("full");
2954
2635
  return this;
2955
2636
  }
2956
- /**
2957
- * @returns {boolean}
2958
- */
2959
2637
  isMultiEnabled() {
2960
2638
  return this._p.multi;
2961
2639
  }
2962
- /**
2963
- * @param {boolean} searchable
2964
- * @returns {SelectBox}
2965
- */
2966
2640
  setSearchable(searchable) {
2967
2641
  const p = this._p;
2968
2642
  searchable = !!searchable;
@@ -2971,10 +2645,6 @@ var SelectBox = class {
2971
2645
  this._scheduleSync("full");
2972
2646
  return this;
2973
2647
  }
2974
- /**
2975
- * @param {boolean} allowTypeToSelect
2976
- * @returns {SelectBox}
2977
- */
2978
2648
  setAllowTypeToSelect(allowTypeToSelect) {
2979
2649
  const p = this._p;
2980
2650
  allowTypeToSelect = !!allowTypeToSelect;
@@ -2982,129 +2652,71 @@ var SelectBox = class {
2982
2652
  p.allowTypeToSelect = allowTypeToSelect;
2983
2653
  return this;
2984
2654
  }
2985
- /**
2986
- * @returns {boolean}
2987
- */
2988
2655
  isSearchableEnabled() {
2989
2656
  return this._p.searchable;
2990
2657
  }
2991
- /**
2992
- * @param {string} noResultsText
2993
- * @returns {SelectBox}
2994
- */
2995
2658
  setNoResultsText(noResultsText) {
2996
2659
  this._p.dropList?.setNoResultsText(noResultsText);
2997
2660
  return this;
2998
2661
  }
2999
- /**
3000
- * @returns {string}
3001
- */
3002
2662
  getNoResultsText() {
3003
2663
  return this._p.noResultsText;
3004
2664
  }
3005
- /**
3006
- * @param {boolean} autoSelectTextOnCheck
3007
- * @returns {SelectBox}
3008
- */
3009
2665
  setAutoSelectTextOnCheck(autoSelectTextOnCheck) {
3010
2666
  this._p.autoSelectTextOnCheck = autoSelectTextOnCheck;
3011
2667
  return this;
3012
2668
  }
3013
- /**
3014
- * @returns {boolean}
3015
- */
3016
2669
  getAutoSelectTextOnCheck() {
3017
2670
  return this._p.autoSelectTextOnCheck;
3018
2671
  }
3019
- /**
3020
- * @param {number} window
3021
- * @returns {SelectBox}
3022
- */
3023
2672
  setFilterThrottleWindow(window) {
3024
2673
  const p = this._p;
3025
2674
  p.filterThrottleWindow = window;
3026
2675
  p.dropList?.setFilterThrottleWindow(window);
3027
2676
  return this;
3028
2677
  }
3029
- /**
3030
- * @returns {number}
3031
- */
3032
2678
  getFilterThrottleWindow() {
3033
2679
  return this._p.filterThrottleWindow;
3034
2680
  }
3035
- /**
3036
- * @param {boolean} value
3037
- * @returns {SelectBox}
3038
- */
3039
2681
  setFilterOnEmptyTerm(value) {
3040
2682
  const p = this._p;
3041
2683
  if (p.filterOnEmptyTerm === value) return this;
3042
2684
  p.dropList?.setFilterOnEmptyTerm(value);
3043
2685
  return this;
3044
2686
  }
3045
- /**
3046
- * @returns {boolean}
3047
- */
3048
2687
  getFilterOnEmptyTerm() {
3049
2688
  return this._p.filterOnEmptyTerm;
3050
2689
  }
3051
- /**
3052
- * @param {DropList.Options} listOptions
3053
- * @returns {SelectBox}
3054
- */
3055
2690
  setListOptions(listOptions) {
3056
2691
  const p = this._p;
3057
2692
  p.listOptions = listOptions;
3058
2693
  this._setupDropdownMenu();
3059
2694
  return this;
3060
2695
  }
3061
- /**
3062
- * @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
3063
- * @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
3064
- * @returns {SelectBox})|null
3065
- */
3066
2696
  setRenderSingleItem(render, unrender) {
3067
2697
  const p = this._p;
3068
2698
  p.renderSingleItem = render;
3069
2699
  p.unrenderSingleItem = unrender;
3070
2700
  return this;
3071
2701
  }
3072
- /**
3073
- * @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
3074
- * @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
3075
- * @returns {SelectBox}
3076
- */
3077
2702
  setRenderMultiItem(render, unrender) {
3078
2703
  const p = this._p;
3079
2704
  p.renderMultiItem = render;
3080
2705
  p.unrenderMultiItem = unrender;
3081
2706
  return this;
3082
2707
  }
3083
- /**
3084
- * @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
3085
- * @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
3086
- * @returns {SelectBox}
3087
- */
3088
2708
  setRenderRestMultiItem(render, unrender) {
3089
2709
  const p = this._p;
3090
2710
  p.renderRestMultiItem = render;
3091
2711
  p.unrenderRestMultiItem = unrender;
3092
2712
  return this;
3093
2713
  }
3094
- /**
3095
- * @param {string} prop
3096
- * @returns {SelectBox}
3097
- */
3098
2714
  setLabelProp(prop) {
3099
2715
  const p = this._p;
3100
2716
  p.labelProp = prop;
3101
2717
  if (p.dropList) p.dropList.setLabelProp(prop);
3102
2718
  return this;
3103
2719
  }
3104
- /**
3105
- * @param {string} prop
3106
- * @returns {SelectBox}
3107
- */
3108
2720
  setValueProp(prop) {
3109
2721
  const p = this._p;
3110
2722
  if (p.valueProp === prop) return this;
@@ -3113,54 +2725,35 @@ var SelectBox = class {
3113
2725
  this._refreshItemByValueMap();
3114
2726
  return this;
3115
2727
  }
3116
- /**
3117
- * @param {string} prop
3118
- * @returns {SelectBox}
3119
- */
3120
2728
  setMultiItemLabelProp(prop) {
3121
2729
  const p = this._p;
3122
2730
  p.multiItemLabelProp = prop;
3123
2731
  this._scheduleSync("render_items");
3124
2732
  return this;
3125
2733
  }
3126
- /**
3127
- * @param {'before'|'after'|'none'} position
3128
- * @returns {SelectBox}
3129
- */
3130
2734
  setMultiItemRemovePosition(position) {
3131
2735
  const p = this._p;
3132
2736
  p.multiItemRemovePosition = position;
3133
2737
  this._scheduleSync("render_items");
3134
2738
  return this;
3135
2739
  }
3136
- /**
3137
- * @param {number|null|undefined} value
3138
- * @returns {SelectBox}
3139
- */
3140
2740
  setMaxMultiItems(value) {
3141
2741
  const p = this._p;
3142
2742
  p.maxMultiItems = value;
3143
2743
  return this;
3144
2744
  }
3145
- /**
3146
- * @param {function(count: number, items: DropList.ItemBase[]):string|null|undefined} value
3147
- * @returns {SelectBox}
3148
- */
3149
2745
  setMultiItemsRestLabelProvider(value) {
3150
2746
  const p = this._p;
3151
2747
  p.multiItemsRestLabelProvider = value;
3152
2748
  return this;
3153
2749
  }
3154
- /**
3155
- * @param {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} fn
3156
- * @returns {SelectBox}
3157
- */
3158
2750
  setFilterFn(fn) {
3159
2751
  const p = this._p;
2752
+ fn ??= null;
3160
2753
  if (p.filterFn === fn) return this;
3161
2754
  p.filterFn = fn;
3162
2755
  if (!fn) fn = (items, term) => {
3163
- const matcher = new RegExp(escapeRegex_default(term), "i");
2756
+ const matcher = new RegExp(escapeRegex(term), "i");
3164
2757
  const labelProp = p.labelProp, multiItemLabelProp = p.multiItemLabelProp;
3165
2758
  return p.items.filter((x) => {
3166
2759
  if (!p.treatGroupSelectionAsItems && x._group) return true;
@@ -3171,15 +2764,28 @@ var SelectBox = class {
3171
2764
  p.dropList?.setFilterFn(fn);
3172
2765
  return this;
3173
2766
  }
3174
- /**
3175
- * @returns {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)}
3176
- */
3177
2767
  getFilterFn() {
3178
2768
  return this._p.filterFn;
3179
2769
  }
3180
2770
  /**
2771
+ * Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderMultiItem`/`unrenderSingleItem`)
2772
+ * instead of the default `console.error`/`console.warn`. Also used as the default `onError` for the internal
2773
+ * `DropList`, unless `listOptions.onError` is set explicitly.
2774
+ */
2775
+ setOnError(fn) {
2776
+ const p = this._p;
2777
+ p.onError = fn ?? void 0;
2778
+ p.dropList?.setOnError(p.listOptions?.onError ?? p.onError);
2779
+ return this;
2780
+ }
2781
+ /**
2782
+ * Gets the current `onError` handler, if any.
2783
+ */
2784
+ getOnError() {
2785
+ return this._p.onError;
2786
+ }
2787
+ /**
3181
2788
  * Focus on input element
3182
- * @returns {SelectBox}
3183
2789
  */
3184
2790
  focusInput() {
3185
2791
  const p = this._p;
@@ -3188,7 +2794,6 @@ var SelectBox = class {
3188
2794
  }
3189
2795
  /**
3190
2796
  * Remvoe focus from the input element
3191
- * @returns {SelectBox}
3192
2797
  */
3193
2798
  blurInput() {
3194
2799
  const p = this._p;
@@ -3197,7 +2802,6 @@ var SelectBox = class {
3197
2802
  }
3198
2803
  /**
3199
2804
  * Removes all selected items
3200
- * @returns {SelectBox}
3201
2805
  */
3202
2806
  clear() {
3203
2807
  if (!this._performClearWithEvent(true)) return this;
@@ -3206,8 +2810,6 @@ var SelectBox = class {
3206
2810
  }
3207
2811
  /**
3208
2812
  * Returns a single value or an array of selected values - depending on `multi` prop
3209
- * @public
3210
- * @returns {*[]}
3211
2813
  */
3212
2814
  getValue() {
3213
2815
  const p = this._p;
@@ -3216,9 +2818,7 @@ var SelectBox = class {
3216
2818
  }
3217
2819
  /**
3218
2820
  * Selects the specified value or multiple values - depending on `multi` prop
3219
- * @public
3220
- * @param {*|*[]} value - if `multi`, then an array of values to select, otherwise - a single value to select
3221
- * @returns {SelectBox}
2821
+ * @param value - if `multi`, then an array of values to select, otherwise - a single value to select
3222
2822
  */
3223
2823
  setValue(value) {
3224
2824
  if (this._p.multi) return this.setSelectedValues(Array.isArray(value) ? value : value !== void 0 ? [value] : []);
@@ -3226,17 +2826,12 @@ var SelectBox = class {
3226
2826
  }
3227
2827
  /**
3228
2828
  * Returns an array of selected values
3229
- * @public
3230
- * @returns {*[]}
3231
2829
  */
3232
2830
  getSelectedValues() {
3233
2831
  return this._p.selectedValues.slice(0);
3234
2832
  }
3235
2833
  /**
3236
2834
  * Selects the specified values
3237
- * @public
3238
- * @param {*[]} values - an array of *values* to select
3239
- * @returns {SelectBox}
3240
2835
  */
3241
2836
  setSelectedValues(values) {
3242
2837
  const p = this._p, valueProp = p.valueProp;
@@ -3261,16 +2856,12 @@ var SelectBox = class {
3261
2856
  }
3262
2857
  /**
3263
2858
  * Returns the count of selected values
3264
- * @public
3265
- * @returns {number}
3266
2859
  */
3267
2860
  getSelectedValueCount() {
3268
2861
  return this._p.selectedValues.length;
3269
2862
  }
3270
2863
  /**
3271
2864
  * Returns an array of selected items
3272
- * @public
3273
- * @returns {Array.<Object>}
3274
2865
  */
3275
2866
  getSelectedItems() {
3276
2867
  return this._p.selectedItems.slice(0);
@@ -3279,17 +2870,11 @@ var SelectBox = class {
3279
2870
  * Sets the specified items to "checked" mode.
3280
2871
  * An array of items is passed, not values, because we need to keep track if items,
3281
2872
  * and if we already have the array of items then this spares the process of searching for the items by values.
3282
- * @public
3283
- * @param {DropList.ItemBase[]} items - an array of *items* to select (not values)
3284
- * @returns {SelectBox}
3285
2873
  */
3286
2874
  setSelectedItems(items) {
3287
2875
  this._setSelectedItems(items);
3288
2876
  return this;
3289
2877
  }
3290
- /**
3291
- * @returns {SelectBox}
3292
- */
3293
2878
  openList() {
3294
2879
  const p = this._p;
3295
2880
  if (p.dropList.isVisible()) return this;
@@ -3304,9 +2889,6 @@ var SelectBox = class {
3304
2889
  else if (!p.multi && this.getValue() !== void 0) p.dropList.setFocusedItemByValue(this.getValue());
3305
2890
  return this;
3306
2891
  }
3307
- /**
3308
- * @returns {SelectBox}
3309
- */
3310
2892
  closeList() {
3311
2893
  const p = this._p;
3312
2894
  if (this[DestroyedSymbol]) return this;
@@ -3318,32 +2900,17 @@ var SelectBox = class {
3318
2900
  }
3319
2901
  return this;
3320
2902
  }
3321
- /**
3322
- * @param {boolean} [open]
3323
- * @returns {SelectBox}
3324
- */
3325
2903
  toggleList(open) {
3326
2904
  const p = this._p;
3327
2905
  if (open === void 0 ? !p.dropList.isVisible() : !!open) return this.openList();
3328
2906
  else return this.closeList();
3329
2907
  }
3330
- /**
3331
- * @returns {boolean}
3332
- */
3333
2908
  isListOpen() {
3334
2909
  return !!this._p.dropListVisible;
3335
2910
  }
3336
- /**
3337
- * @param {boolean} [on]
3338
- * @returns {SelectBox}
3339
- */
3340
2911
  toggleLoading(on) {
3341
2912
  return this.setIsLoadingMode(on === void 0 ? !this.getIsLoadingMode() : !!on);
3342
2913
  }
3343
- /**
3344
- * @param {boolean} isLoadingMode
3345
- * @returns {SelectBox}
3346
- */
3347
2914
  setIsLoadingMode(isLoadingMode) {
3348
2915
  const p = this._p;
3349
2916
  isLoadingMode = isLoadingMode === void 0 ? true : !!isLoadingMode;
@@ -3354,31 +2921,21 @@ var SelectBox = class {
3354
2921
  this._scheduleSync("render_base");
3355
2922
  return this;
3356
2923
  }
3357
- /**
3358
- * @returns {boolean}
3359
- */
3360
2924
  getIsLoadingMode() {
3361
2925
  return this._p.isLoadingMode;
3362
2926
  }
3363
2927
  /**
3364
2928
  * Sets whether to close the list when loading mode is enabled
3365
- * @param {boolean} closeListWhenLoading
3366
- * @returns {SelectBox}
3367
2929
  */
3368
2930
  setCloseListWhenLoading(closeListWhenLoading) {
3369
2931
  this._p.closeListWhenLoading = closeListWhenLoading;
3370
2932
  return this;
3371
2933
  }
3372
- /**
3373
- * @returns {boolean}
3374
- */
3375
2934
  getCloseListWhenLoading() {
3376
2935
  return this._p.closeListWhenLoading;
3377
2936
  }
3378
2937
  /**
3379
2938
  * Sets when to clear the input field
3380
- * @param {string[]} clearInputWhen
3381
- * @returns {SelectBox}
3382
2939
  */
3383
2940
  setClearInputWhen(clearInputWhen) {
3384
2941
  this._p.clearInputWhen = Array.isArray(clearInputWhen) ? clearInputWhen.slice(0) : [];
@@ -3386,15 +2943,12 @@ var SelectBox = class {
3386
2943
  }
3387
2944
  /**
3388
2945
  * Retrieves the settings for when to clear the input field
3389
- * @returns {string[]}
3390
2946
  */
3391
2947
  getClearInputWhen() {
3392
2948
  return this._p.clearInputWhen;
3393
2949
  }
3394
2950
  /**
3395
2951
  * Sets the appropriate direction for the selectbox
3396
- * @param {'ltr'|'rtl'|'auto'} direction
3397
- * @return {SelectBox}
3398
2952
  */
3399
2953
  setDirection(direction) {
3400
2954
  const p = this._p;
@@ -3404,14 +2958,12 @@ var SelectBox = class {
3404
2958
  }
3405
2959
  /**
3406
2960
  * Gets the supplied direction for the selectbox
3407
- * @return {'ltr'|'rtl'|'auto'}
3408
2961
  */
3409
2962
  getDirection() {
3410
2963
  return this._p.direction;
3411
2964
  }
3412
2965
  /**
3413
2966
  * Can be called in case that the selectbox was attached to the dom late and has a weird size.
3414
- * @returns {SelectBox}
3415
2967
  */
3416
2968
  refreshSize() {
3417
2969
  this._resizeInput();
@@ -3419,9 +2971,6 @@ var SelectBox = class {
3419
2971
  }
3420
2972
  /**
3421
2973
  * Register an event handler
3422
- * @param {(string|'*')?} event
3423
- * @param {function(any)} handler
3424
- * @returns {SelectBox}
3425
2974
  */
3426
2975
  on(event, handler) {
3427
2976
  this._p.mitt.on(event, handler);
@@ -3429,9 +2978,6 @@ var SelectBox = class {
3429
2978
  }
3430
2979
  /**
3431
2980
  * Register a one time event handler
3432
- * @param {(string|'*')?} event
3433
- * @param {function(any)} handler
3434
- * @returns {SelectBox}
3435
2981
  */
3436
2982
  once(event, handler) {
3437
2983
  let wrapped = (value) => {
@@ -3443,9 +2989,6 @@ var SelectBox = class {
3443
2989
  }
3444
2990
  /**
3445
2991
  * Remove an `handler` for `event`, all events for `event`, or all events completely.
3446
- * @param {(string|'*')?} event
3447
- * @param {function(any)} handler
3448
- * @returns {SelectBox}
3449
2992
  */
3450
2993
  off(event, handler) {
3451
2994
  if (!event && !event) this._p.mitt.all.clear();
@@ -3454,9 +2997,6 @@ var SelectBox = class {
3454
2997
  }
3455
2998
  /**
3456
2999
  * Emit an event
3457
- * @param {string} event
3458
- * @param {any} value
3459
- * @returns {SelectBox}
3460
3000
  */
3461
3001
  emit(event, value) {
3462
3002
  this._p.mitt.emit(event, value);
@@ -3466,6 +3006,7 @@ var SelectBox = class {
3466
3006
  * Prepare the mapping between values and items.
3467
3007
  * This reduces search time greatly (i.e when checking items), especially when Vue proxies are in place.
3468
3008
  * @private
3009
+ * @internal
3469
3010
  */
3470
3011
  _refreshItemByValueMap() {
3471
3012
  const p = this._p;
@@ -3475,9 +3016,8 @@ var SelectBox = class {
3475
3016
  p.subitemByValueMap = null;
3476
3017
  }
3477
3018
  /**
3478
- * @param {*} value
3479
- * @returns {DropList.ItemBase|undefined}
3480
3019
  * @private
3020
+ * @internal
3481
3021
  */
3482
3022
  _getItemByValue(value) {
3483
3023
  const p = this._p;
@@ -3487,16 +3027,15 @@ var SelectBox = class {
3487
3027
  return p.subitemByValueMap.get(value);
3488
3028
  }
3489
3029
  /** @private */
3030
+ /** @internal */
3490
3031
  _refreshSubitemByValueMap() {
3491
3032
  const p = this._p;
3492
3033
  const subitemByValueMap = p.subitemByValueMap = /* @__PURE__ */ new Map();
3493
3034
  this._addSubitemsToValueMap(p.items, subitemByValueMap, p.valueProp);
3494
3035
  }
3495
3036
  /**
3496
- * @param {DropList.ItemBase[]} items
3497
- * @param {Map<*, DropList.ItemBase>} itemByValueMap
3498
- * @param {string} valueProp
3499
3037
  * @private
3038
+ * @internal
3500
3039
  */
3501
3040
  _addSubitemsToValueMap(items, itemByValueMap, valueProp) {
3502
3041
  for (let item of items) {
@@ -3506,6 +3045,7 @@ var SelectBox = class {
3506
3045
  }
3507
3046
  }
3508
3047
  /** @private */
3048
+ /** @internal */
3509
3049
  _renderBase() {
3510
3050
  const p = this._p;
3511
3051
  if (!p.inputBackBuffer) p.inputBackBuffer = createElement("span", { css: {
@@ -3594,6 +3134,7 @@ var SelectBox = class {
3594
3134
  }
3595
3135
  /**
3596
3136
  * @private
3137
+ * @internal
3597
3138
  */
3598
3139
  _syncBaseClasses() {
3599
3140
  const p = this._p, el = p.el;
@@ -3614,6 +3155,7 @@ var SelectBox = class {
3614
3155
  el.className = classes.join(" ");
3615
3156
  }
3616
3157
  /** @private */
3158
+ /** @internal */
3617
3159
  _setupDropdownMenu() {
3618
3160
  const p = this._p;
3619
3161
  p.valueProp;
@@ -3643,6 +3185,7 @@ var SelectBox = class {
3643
3185
  filterGroups: p.treatGroupSelectionAsItems,
3644
3186
  filterEmptyGroups: !p.treatGroupSelectionAsItems,
3645
3187
  filterFn: p.actualFilterFn,
3188
+ onError: p.listOptions?.onError ?? p.onError,
3646
3189
  positionOptionsProvider: () => this._getDropListPositionOptions(),
3647
3190
  on: (name, event) => {
3648
3191
  switch (name) {
@@ -3769,15 +3312,14 @@ var SelectBox = class {
3769
3312
  case "search":
3770
3313
  this._trigger("search", event);
3771
3314
  break;
3772
- case "itemschanged":
3773
- this._trigger("itemschanged", event);
3774
- break;
3315
+ case "itemschanged": this._trigger("itemschanged", event);
3775
3316
  }
3776
3317
  }
3777
3318
  });
3778
3319
  p.sink.add(dropList.el, "mousedown", preventDropListMouseDownBlur);
3779
3320
  this._registerDropdownEvents();
3780
3321
  }
3322
+ /** @internal */
3781
3323
  _handleOnBlur() {
3782
3324
  const p = this._p;
3783
3325
  setTimeout(() => {
@@ -3789,9 +3331,11 @@ var SelectBox = class {
3789
3331
  this.closeList();
3790
3332
  });
3791
3333
  }
3334
+ /** @internal */
3792
3335
  _unregisterDropdownEvents() {
3793
3336
  this._p.sink.remove(null, ".dropdown");
3794
3337
  }
3338
+ /** @internal */
3795
3339
  _registerDropdownEvents() {
3796
3340
  const p = this._p;
3797
3341
  this._unregisterDropdownEvents();
@@ -3836,9 +3380,7 @@ var SelectBox = class {
3836
3380
  case VALUE_HOME:
3837
3381
  dropList.goToFirst(evt);
3838
3382
  break;
3839
- case VALUE_END:
3840
- dropList.goToLast(evt);
3841
- break;
3383
+ case VALUE_END: dropList.goToLast(evt);
3842
3384
  }
3843
3385
  break;
3844
3386
  case VALUE_SPACE:
@@ -3868,17 +3410,15 @@ var SelectBox = class {
3868
3410
  evt.preventDefault();
3869
3411
  }
3870
3412
  break;
3871
- default:
3872
- if (dropList.isVisible()) dropList._keydownFreeType(evt, false);
3873
- else if (p.allowTypeToSelect) dropList._keydownFreeType(evt, true);
3874
- else {
3875
- this.openList();
3876
- setTimeout(() => {
3877
- if (this[DestroyedSymbol]) return;
3878
- dropList._keydownFreeType(evt, false);
3879
- });
3880
- }
3881
- 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
+ }
3882
3422
  }
3883
3423
  if (!suppressEnterSpaceToggle) {
3884
3424
  if (evt.key === VALUE_ENTER || evt.key === VALUE_SPACE && p.lastKeyAllowsNonTypeKeys && !p.multi && !dropList.hasFocusedItem() && !p.disabled && !p.readOnly) {
@@ -3929,6 +3469,7 @@ var SelectBox = class {
3929
3469
  }).add(p.el, "touchcancel.dropdown_touchextra", onTouchCancel);
3930
3470
  });
3931
3471
  }
3472
+ /** @internal */
3932
3473
  _performSelectWithEvent(item, value) {
3933
3474
  let cancellable = {
3934
3475
  value,
@@ -3945,6 +3486,7 @@ var SelectBox = class {
3945
3486
  });
3946
3487
  return true;
3947
3488
  }
3489
+ /** @internal */
3948
3490
  _performClearWithEvent(clearInput = false) {
3949
3491
  let cancellable = { cancel: false };
3950
3492
  this._trigger("clear:before", cancellable);
@@ -3955,6 +3497,7 @@ var SelectBox = class {
3955
3497
  this._trigger("clear");
3956
3498
  return true;
3957
3499
  }
3500
+ /** @internal */
3958
3501
  _movePrev() {
3959
3502
  const p = this._p;
3960
3503
  if (this.isMultiEnabled()) return;
@@ -3968,6 +3511,7 @@ var SelectBox = class {
3968
3511
  else this._performClearWithEvent();
3969
3512
  }
3970
3513
  }
3514
+ /** @internal */
3971
3515
  _moveNext() {
3972
3516
  const p = this._p;
3973
3517
  if (this.isMultiEnabled()) return;
@@ -3982,6 +3526,7 @@ var SelectBox = class {
3982
3526
  }
3983
3527
  }
3984
3528
  /** @private */
3529
+ /** @internal */
3985
3530
  _updateListItems() {
3986
3531
  const p = this._p;
3987
3532
  const dropList = p.dropList;
@@ -4011,6 +3556,7 @@ var SelectBox = class {
4011
3556
  if (hasRefocusedItem) p.dropList.setFocusedItemAtIndex(p.dropList.getFocusedItemIndex());
4012
3557
  }
4013
3558
  /** @private */
3559
+ /** @internal */
4014
3560
  _setSelectedItems(items) {
4015
3561
  const p = this._p, valueProp = p.valueProp;
4016
3562
  if (p.multi) {
@@ -4026,6 +3572,7 @@ var SelectBox = class {
4026
3572
  this._scheduleSync("full");
4027
3573
  }
4028
3574
  /** @private */
3575
+ /** @internal */
4029
3576
  _scheduleSync(mode, data) {
4030
3577
  const p = this._p;
4031
3578
  if (!p.syncQueue) p.syncQueue = [];
@@ -4043,6 +3590,7 @@ var SelectBox = class {
4043
3590
  });
4044
3591
  }
4045
3592
  /** @private */
3593
+ /** @internal */
4046
3594
  _performSync(queue) {
4047
3595
  const p = this._p;
4048
3596
  if (this[DestroyedSymbol]) return;
@@ -4090,26 +3638,29 @@ var SelectBox = class {
4090
3638
  if (!p.showSelection) this._syncPlaceholder();
4091
3639
  else if (p.multiItemEls[p.multiItemEls.length - 1]?.[ItemSymbol]?.[p.valueProp] === RestMultiItemsSymbol) this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
4092
3640
  break;
4093
- case "resize_input":
4094
- this._resizeInput();
4095
- break;
3641
+ case "resize_input": this._resizeInput();
4096
3642
  }
4097
3643
  }
4098
3644
  /** @private */
3645
+ /** @internal */
4099
3646
  _cleanupSingleWrapper() {
4100
3647
  const p = this._p;
4101
3648
  if (!p.singleWrapper) return;
4102
3649
  if (p.unrenderSingleItem && p.singleWrapper.childNodes.length > 0) try {
4103
3650
  p.unrenderSingleItem(p.singleWrapper[ItemSymbol], p.singleWrapper);
4104
3651
  } catch (err) {
4105
- console.error(err);
3652
+ reportError(p.onError, err, {
3653
+ source: "unrenderSingleItem",
3654
+ item: p.singleWrapper[ItemSymbol],
3655
+ el: p.singleWrapper
3656
+ });
4106
3657
  }
4107
3658
  delete p.singleWrapper[ItemSymbol];
4108
3659
  p.singleWrapper.innerHTML = "";
4109
3660
  }
4110
3661
  /**
4111
- * @param {number} index
4112
3662
  * @private
3663
+ * @internal
4113
3664
  */
4114
3665
  _removeMultiItemElementByIndex(index) {
4115
3666
  const p = this._p, multiItemEls = p.multiItemEls;
@@ -4120,7 +3671,11 @@ var SelectBox = class {
4120
3671
  if (unrender && itemEl.childNodes.length > 0) try {
4121
3672
  unrender(item, itemEl);
4122
3673
  } catch (err) {
4123
- console.error(err);
3674
+ reportError(p.onError, err, {
3675
+ source: item?.[p.valueProp] === RestMultiItemsSymbol ? "unrenderRestMultiItem" : "unrenderMultiItem",
3676
+ item,
3677
+ el: itemEl
3678
+ });
4124
3679
  }
4125
3680
  remove(itemEl);
4126
3681
  if (index === multiItemEls.length - 1) multiItemEls.pop();
@@ -4128,8 +3683,8 @@ var SelectBox = class {
4128
3683
  }
4129
3684
  }
4130
3685
  /**
4131
- * @param {DropList.ItemBase} item
4132
3686
  * @private
3687
+ * @internal
4133
3688
  */
4134
3689
  _renderSingleItemContent(item) {
4135
3690
  const p = this._p;
@@ -4141,9 +3696,8 @@ var SelectBox = class {
4141
3696
  }
4142
3697
  }
4143
3698
  /**
4144
- * @param {DropList.ItemBase} item
4145
- * @param {Element} itemEl
4146
3699
  * @private
3700
+ * @internal
4147
3701
  */
4148
3702
  _renderMultiItemContent(item, itemEl) {
4149
3703
  const p = this._p;
@@ -4155,9 +3709,9 @@ var SelectBox = class {
4155
3709
  }
4156
3710
  }
4157
3711
  /**
4158
- * @param {DropList.ItemBase} item
4159
3712
  * @returns {boolean} true if rendered, false if not
4160
3713
  * @private
3714
+ * @internal
4161
3715
  */
4162
3716
  _addMultiItemElement(item) {
4163
3717
  const p = this._p;
@@ -4168,6 +3722,7 @@ var SelectBox = class {
4168
3722
  return true;
4169
3723
  }
4170
3724
  /** @private */
3725
+ /** @internal */
4171
3726
  _addMultiItemRestElement() {
4172
3727
  const p = this._p;
4173
3728
  let items = p.selectedItems.slice(0);
@@ -4180,6 +3735,7 @@ var SelectBox = class {
4180
3735
  });
4181
3736
  }
4182
3737
  /** @private */
3738
+ /** @internal */
4183
3739
  _syncClearButton() {
4184
3740
  const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
4185
3741
  if (p.selectedItems.length > 0 && p.selectedItems.some((x) => x[multiItemLabelProp] !== false) && p.clearable && p.showSelection) {
@@ -4202,6 +3758,7 @@ var SelectBox = class {
4202
3758
  }
4203
3759
  }
4204
3760
  /** @private */
3761
+ /** @internal */
4205
3762
  _syncPlaceholder() {
4206
3763
  const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
4207
3764
  let placeholder = "";
@@ -4213,6 +3770,7 @@ var SelectBox = class {
4213
3770
  else p.input.removeAttribute("title");
4214
3771
  }
4215
3772
  /** @private */
3773
+ /** @internal */
4216
3774
  _syncSingleItem() {
4217
3775
  const p = this._p;
4218
3776
  if (p.singleWrapper) this._cleanupSingleWrapper();
@@ -4224,9 +3782,7 @@ var SelectBox = class {
4224
3782
  }
4225
3783
  /**
4226
3784
  * Syncs render state, selected items, and position
4227
- * @param {boolean=false} fullItemsRender Should re-render all items?
4228
- * @param {boolean=false} updateListItems Should call updateListItems?
4229
- * @returns {SelectBox}
3785
+ * @internal
4230
3786
  */
4231
3787
  _syncFull(fullItemsRender, updateListItems) {
4232
3788
  const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
@@ -4284,9 +3840,8 @@ var SelectBox = class {
4284
3840
  return this;
4285
3841
  }
4286
3842
  /**
4287
- * @param {string} event
4288
- * @param {*} [data]
4289
3843
  * @private
3844
+ * @internal
4290
3845
  */
4291
3846
  _trigger(event, data) {
4292
3847
  const p = this._p;
@@ -4296,9 +3851,8 @@ var SelectBox = class {
4296
3851
  }
4297
3852
  /**
4298
3853
  * Render a multi item
4299
- * @param {Object} item
4300
- * @returns {Element|null}
4301
3854
  * @private
3855
+ * @internal
4302
3856
  */
4303
3857
  _renderMultiItem(item) {
4304
3858
  const p = this._p;
@@ -4322,10 +3876,8 @@ var SelectBox = class {
4322
3876
  }
4323
3877
  /**
4324
3878
  * Removes a specific multi item by user event
4325
- * @param {Element} itemEl
4326
- * @param {Event} originatingEvent
4327
- * @returns {SelectBox}
4328
3879
  * @private
3880
+ * @internal
4329
3881
  */
4330
3882
  _removeMultiItemFromEvent(itemEl, originatingEvent) {
4331
3883
  const p = this._p;
@@ -4341,7 +3893,7 @@ var SelectBox = class {
4341
3893
  let itemsToRemove = [];
4342
3894
  for (let item of items) {
4343
3895
  let removeselEvt = {
4344
- value,
3896
+ value: item[p.valueProp],
4345
3897
  item,
4346
3898
  cancel: false
4347
3899
  };
@@ -4352,7 +3904,7 @@ var SelectBox = class {
4352
3904
  this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
4353
3905
  for (let item of itemsToRemove) {
4354
3906
  let idx = p.selectedItems.indexOf(item);
4355
- if (idx === -1) idx = p.selectedValues.indexOf(value[p.valueProp]);
3907
+ if (idx === -1) idx = p.selectedValues.indexOf(item[p.valueProp]);
4356
3908
  if (idx !== -1) {
4357
3909
  p.selectedItems.splice(idx, 1);
4358
3910
  p.selectedValues.splice(idx, 1);
@@ -4383,9 +3935,8 @@ var SelectBox = class {
4383
3935
  return this;
4384
3936
  }
4385
3937
  /**
4386
- * @param {DropList.ItemBase} item
4387
- * @param {boolean} [populate]
4388
3938
  * @private
3939
+ * @internal
4389
3940
  */
4390
3941
  _removeMultiItem(item, populate = false) {
4391
3942
  const p = this._p;
@@ -4410,8 +3961,8 @@ var SelectBox = class {
4410
3961
  this._scheduleSync("render_list");
4411
3962
  }
4412
3963
  /**
4413
- * @param {*} value
4414
3964
  * @private
3965
+ * @internal
4415
3966
  */
4416
3967
  _setInputText(value) {
4417
3968
  const p = this._p;
@@ -4422,8 +3973,8 @@ var SelectBox = class {
4422
3973
  }
4423
3974
  /**
4424
3975
  * Update input size to current state
4425
- * @returns {SelectBox}
4426
3976
  * @private
3977
+ * @internal
4427
3978
  */
4428
3979
  _resizeInput() {
4429
3980
  const p = this._p, el = p.el;
@@ -4479,8 +4030,8 @@ var SelectBox = class {
4479
4030
  }
4480
4031
  /**
4481
4032
  * Update autocomplete position if needed
4482
- * @returns {SelectBox}
4483
4033
  * @private
4034
+ * @internal
4484
4035
  */
4485
4036
  _repositionDropList() {
4486
4037
  const p = this._p, el = p.el;
@@ -4494,8 +4045,8 @@ var SelectBox = class {
4494
4045
  return this;
4495
4046
  }
4496
4047
  /**
4497
- * @param {KeyboardEvent} event
4498
4048
  * @private
4049
+ * @internal
4499
4050
  */
4500
4051
  _handleInputKeydown(event) {
4501
4052
  const p = this._p;
@@ -4524,8 +4075,8 @@ var SelectBox = class {
4524
4075
  }
4525
4076
  }
4526
4077
  /**
4527
- * @param {KeyboardEvent} event
4528
4078
  * @private
4079
+ * @internal
4529
4080
  */
4530
4081
  _handleMultiKeydown(event) {
4531
4082
  const p = this._p;
@@ -4569,12 +4120,12 @@ var SelectBox = class {
4569
4120
  }
4570
4121
  }
4571
4122
  /**
4572
- * @returns {DropList.PositionOptions}
4573
4123
  * @private
4124
+ * @internal
4574
4125
  */
4575
4126
  _getDropListPositionOptions() {
4576
4127
  return {
4577
- target: this._p.el,
4128
+ target: /**@type Element*/ this._p.el,
4578
4129
  offset: {
4579
4130
  x: 0,
4580
4131
  y: 0
@@ -4591,6 +4142,7 @@ var SelectBox = class {
4591
4142
  };
4592
4143
  }
4593
4144
  /** @private */
4145
+ /** @internal */
4594
4146
  _startTrackingPresence() {
4595
4147
  const p = this._p;
4596
4148
  this._stopTrackingPresence();
@@ -4599,6 +4151,7 @@ var SelectBox = class {
4599
4151
  }, 200);
4600
4152
  }
4601
4153
  /** @private */
4154
+ /** @internal */
4602
4155
  _stopTrackingPresence() {
4603
4156
  const p = this._p;
4604
4157
  if (p.presenceInt) {
@@ -4609,11 +4162,7 @@ var SelectBox = class {
4609
4162
  /**
4610
4163
  * Handles sorting, and putting checked items first (according to selectedValues, not item.checked)
4611
4164
  * @private
4612
- * @param {DropList.ItemBase[]} items
4613
- * @param {boolean=false} sort
4614
- * @param {boolean=false} sortCheckedFirst
4615
- * @param {boolean=false} splitCheckedGroups
4616
- * @returns {DropList.ItemBase[]}
4165
+ * @internal
4617
4166
  */
4618
4167
  _sortItems(items, sort, sortCheckedFirst, splitCheckedGroups) {
4619
4168
  const p = this._p;