@danielgindi/selectbox 2.0.57 → 2.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib.cjs.js +190 -160
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +190 -160
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +190 -160
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/dist/types/DropList.d.ts +343 -0
- package/dist/types/DropList.d.ts.map +1 -0
- package/dist/types/SelectBox.d.ts +497 -0
- package/dist/types/SelectBox.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +207 -0
- package/dist/types/types.d.ts.map +1 -0
- package/eslint.config.mjs +8 -0
- package/lib/DropList.js +1 -3430
- package/lib/SelectBox.js +1 -3689
- package/lib/index.js +1 -4
- package/package.json +9 -4
- package/tsconfig.json +35 -0
- package/vue/DropList.vue +495 -565
- package/vue/DropList.vue.d.ts +4 -0
- package/vue/SelectBox.vue +855 -981
- package/vue/SelectBox.vue.d.ts +4 -0
- package/vue/component-types.d.ts +210 -0
- package/vue/index.d.ts +4 -0
- package/vue/index.js +3 -4
- package/vue/utils/slots.js +89 -96
- package/lib/utils/escapeRegex.js +0 -1
- package/lib/utils/throttle.js +0 -48
package/dist/lib.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.58
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
(function(global, factory) {
|
|
@@ -40,14 +40,18 @@
|
|
|
40
40
|
_danielgindi_dom_utils_lib_DomEventsSink = __toESM(_danielgindi_dom_utils_lib_DomEventsSink);
|
|
41
41
|
_danielgindi_virtual_list_helper = __toESM(_danielgindi_virtual_list_helper);
|
|
42
42
|
mitt = __toESM(mitt);
|
|
43
|
-
//#region lib/utils/escapeRegex.
|
|
44
|
-
|
|
43
|
+
//#region src/lib/utils/escapeRegex.ts
|
|
44
|
+
/** @internal */
|
|
45
|
+
var escapeRegex = (value) => value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
45
46
|
//#endregion
|
|
46
|
-
//#region lib/utils/throttle.
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
//#region src/lib/utils/throttle.ts
|
|
48
|
+
/** @internal */
|
|
49
|
+
var throttle = (func, wait, options = {}) => {
|
|
50
|
+
let timeout;
|
|
51
|
+
let context;
|
|
52
|
+
let args;
|
|
53
|
+
let result;
|
|
49
54
|
let previous = 0;
|
|
50
|
-
if (!options) options = {};
|
|
51
55
|
const later = () => {
|
|
52
56
|
previous = options.leading === false ? 0 : Date.now();
|
|
53
57
|
timeout = null;
|
|
@@ -82,86 +86,30 @@
|
|
|
82
86
|
return throttled;
|
|
83
87
|
};
|
|
84
88
|
//#endregion
|
|
85
|
-
//#region lib/
|
|
89
|
+
//#region src/lib/utils/reportError.ts
|
|
90
|
+
/**
|
|
91
|
+
* Routes an error/warning to `handler` if supplied, falling back to the
|
|
92
|
+
* console (matching the previous hardcoded behaviour) if there is no
|
|
93
|
+
* handler, or if the handler itself throws.
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
var reportError = (handler, error, context) => {
|
|
97
|
+
if (handler) try {
|
|
98
|
+
handler(error, context);
|
|
99
|
+
return;
|
|
100
|
+
} catch (handlerError) {
|
|
101
|
+
console.error(handlerError);
|
|
102
|
+
}
|
|
103
|
+
if (context.level === "warn") console.warn(error);
|
|
104
|
+
else console.error(error);
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/lib/DropList.ts
|
|
86
108
|
var ItemSymbol = Symbol("item");
|
|
87
109
|
var DestroyedSymbol$1 = Symbol("destroyed");
|
|
88
110
|
var GhostSymbol = Symbol("ghost");
|
|
89
111
|
var NoResultsItemSymbol = Symbol("no_results_items");
|
|
90
112
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
91
|
-
/**
|
|
92
|
-
* @typedef {Object} DropList.Options
|
|
93
|
-
* @property {Element} [el] An element to attach to, instead of creating a new one
|
|
94
|
-
* @property {string} [baseClassName='droplist'] class name for the menu root element
|
|
95
|
-
* @property {string|string[]} [additionalClasses]
|
|
96
|
-
* @property {'ltr'|'rtl'|'auto'} [direction='auto']
|
|
97
|
-
* @property {boolean} [autoItemBlur=true] Should we automatically blur the focused item when the droplist loses focus?
|
|
98
|
-
* @property {number} [autoItemBlurDelay=300] How long to wait before deciding to blur the focused item (when the droplist loses focus)?
|
|
99
|
-
* @property {boolean} [capturesFocus=true] Should this DropList be added to the TAB-key stack?
|
|
100
|
-
* @property {boolean} [multi=false] Does this DropList show checkboxes for multiple item selection?
|
|
101
|
-
* @property {*} [singleSelectedValue] Current selected value when using single selection.
|
|
102
|
-
* @property {function} [keyDownHandler=null] An alternative "keydown" event handler. Return true to prevent default behaviour.
|
|
103
|
-
* @property {boolean} [autoCheckGroupChildren=true] When a group is checked/unchecked - all items beneath it will update accordingly
|
|
104
|
-
* @property {boolean} [useExactTargetWidth=false] Use the exact target's width, do not allow growing
|
|
105
|
-
* @property {boolean} [constrainToWindow=true] Should the position be constrained to the window, attaching to window's borders if needed?
|
|
106
|
-
* @property {Boolean} [autoFlipDirection=true] Should the position/anchor be flipped automatically when there's no space in the required direction?
|
|
107
|
-
* @property {number} [estimatedItemHeight=20] An estimated row height, for approximating scroll height.
|
|
108
|
-
* @property {boolean} [estimateWidth=false] Use an estimation for the width instead of measuring. May be faster - needs testing and may depend on the CSS.
|
|
109
|
-
* @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.
|
|
110
|
-
* @property {string} [labelProp='label']
|
|
111
|
-
* @property {string} [valueProp='value']
|
|
112
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderItem] Function to call when rendering an item element
|
|
113
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderItem] Function to call when rendering an item element
|
|
114
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderNoResultsItem]
|
|
115
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderNoResultsItem]
|
|
116
|
-
* @property {function(name: string, data: *)} [on]
|
|
117
|
-
* @property {boolean} [isHeaderVisible=false] show header element
|
|
118
|
-
* @property {boolean} [isFooterVisible=false] show footer element
|
|
119
|
-
* @property {boolean} [searchable=false] include inline search box
|
|
120
|
-
* @property {string} [searchPlaceholder=''] placeholder text for the inline search box
|
|
121
|
-
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
122
|
-
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
123
|
-
* @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
|
|
124
|
-
* @property {boolean} [filterGroups=false] should groups be filtered?
|
|
125
|
-
* @property {boolean} [filterEmptyGroups=false] should empty groups be filtered out?
|
|
126
|
-
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
127
|
-
* @property {function(dropList: DropList):DropList.PositionOptions} [positionOptionsProvider]
|
|
128
|
-
* */
|
|
129
|
-
/** */
|
|
130
|
-
/**
|
|
131
|
-
* @typedef {Object} DropList.PositionAnchor
|
|
132
|
-
* @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`)
|
|
133
|
-
* @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`)
|
|
134
|
-
* */
|
|
135
|
-
/** */
|
|
136
|
-
/**
|
|
137
|
-
* @typedef {Object} DropList.PositionOptions
|
|
138
|
-
* @property {Element?} [target] Target element to act as anchor
|
|
139
|
-
* @property {{left: number, top: number}?} [targetOffset] Override the offset of target. Automatically calculated if unspecified.
|
|
140
|
-
* @property {number?} [targetHeight] Override height of the target
|
|
141
|
-
* @property {number?} [targetWidth] Override width of the target
|
|
142
|
-
* @property {DropList.PositionAnchor?} [position]
|
|
143
|
-
* @property {DropList.PositionAnchor?} [anchor]
|
|
144
|
-
* @property {boolean|number?} [updateWidth=false] `true` to set width of the menu according to `target`'s width, or specify an arbitrary number.
|
|
145
|
-
* @property {string?} [targetRtl] Override for rtl mode of the target
|
|
146
|
-
* @property {{x: number, y: number}} [offset=undefined] Extra rtl-aware offset to the target
|
|
147
|
-
* */
|
|
148
|
-
/** */
|
|
149
|
-
/**
|
|
150
|
-
* @typedef {Object} DropList.ItemBase
|
|
151
|
-
* @property {string} [value]
|
|
152
|
-
* @property {string} [label]
|
|
153
|
-
* @property {boolean} [_group=false]
|
|
154
|
-
* @property {boolean} [_child=false]
|
|
155
|
-
* @property {boolean} [_nocheck=false]
|
|
156
|
-
* @property {boolean} [_nointeraction=false]
|
|
157
|
-
* @property {DropList.ItemBase[]} [_subitems]
|
|
158
|
-
* */
|
|
159
|
-
/**
|
|
160
|
-
* @typedef {DropList.ItemBase} DropList.Item
|
|
161
|
-
* @property {boolean} [_checked=false]
|
|
162
|
-
* */
|
|
163
|
-
/** */
|
|
164
|
-
/** @type {DropList.Options} */
|
|
165
113
|
var DefaultOptions = {
|
|
166
114
|
baseClassName: "droplist",
|
|
167
115
|
autoItemBlur: true,
|
|
@@ -226,6 +174,7 @@
|
|
|
226
174
|
unrenderNoResultsItem: o.unrenderNoResultsItem,
|
|
227
175
|
on: o.on || null,
|
|
228
176
|
positionOptionsProvider: o.positionOptionsProvider ?? null,
|
|
177
|
+
onError: o.onError,
|
|
229
178
|
searchable: o.searchable,
|
|
230
179
|
searchPlaceholder: o.searchPlaceholder,
|
|
231
180
|
isHeaderVisible: o.isHeaderVisible,
|
|
@@ -243,7 +192,14 @@
|
|
|
243
192
|
throttledRefilterItems: null,
|
|
244
193
|
focusItemIndex: -1,
|
|
245
194
|
focusItemEl: null,
|
|
246
|
-
sink: new _danielgindi_dom_utils_lib_DomEventsSink.default()
|
|
195
|
+
sink: new _danielgindi_dom_utils_lib_DomEventsSink.default(),
|
|
196
|
+
visible: false,
|
|
197
|
+
hiding: false,
|
|
198
|
+
singleSelectedItemEl: null,
|
|
199
|
+
onDocumentMouseDown: null,
|
|
200
|
+
lastKeyWasChar: false,
|
|
201
|
+
currentSubDropList: null,
|
|
202
|
+
_isFocusingItem: false
|
|
247
203
|
};
|
|
248
204
|
let classes = [p.baseClassName + "_wrapper"];
|
|
249
205
|
if (p.additionalClasses) classes = classes.concat((p.additionalClasses + "").split(" ").filter((x) => x));
|
|
@@ -309,7 +265,11 @@
|
|
|
309
265
|
};
|
|
310
266
|
else item = items[index];
|
|
311
267
|
}
|
|
312
|
-
if (!item)
|
|
268
|
+
if (!item) reportError(p.onError, `onItemRender called for (${index}) which has no item`, {
|
|
269
|
+
source: "renderItem",
|
|
270
|
+
level: "warn",
|
|
271
|
+
index
|
|
272
|
+
});
|
|
313
273
|
itemEl.className = `${p.baseClassName}__item`;
|
|
314
274
|
const classList = itemEl.classList;
|
|
315
275
|
if (item) {
|
|
@@ -467,6 +427,7 @@
|
|
|
467
427
|
}
|
|
468
428
|
/**
|
|
469
429
|
* @private
|
|
430
|
+
* @internal
|
|
470
431
|
*/
|
|
471
432
|
_setupUnrenderFunction() {
|
|
472
433
|
const p = this._p;
|
|
@@ -478,12 +439,20 @@
|
|
|
478
439
|
if (item === NoResultsItemSymbol) try {
|
|
479
440
|
fnNoResults(item, el);
|
|
480
441
|
} catch (err) {
|
|
481
|
-
|
|
442
|
+
reportError(p.onError, err, {
|
|
443
|
+
source: "unrenderNoResultsItem",
|
|
444
|
+
item,
|
|
445
|
+
el
|
|
446
|
+
});
|
|
482
447
|
}
|
|
483
448
|
else try {
|
|
484
449
|
fn(item[ItemSymbol], el);
|
|
485
450
|
} catch (err) {
|
|
486
|
-
|
|
451
|
+
reportError(p.onError, err, {
|
|
452
|
+
source: "unrenderItem",
|
|
453
|
+
item: item[ItemSymbol],
|
|
454
|
+
el
|
|
455
|
+
});
|
|
487
456
|
}
|
|
488
457
|
delete el[ItemSymbol];
|
|
489
458
|
if (p.focusItemEl === el) p.focusItemEl = null;
|
|
@@ -503,6 +472,7 @@
|
|
|
503
472
|
p.valueProp = prop;
|
|
504
473
|
return this;
|
|
505
474
|
}
|
|
475
|
+
/** @internal */
|
|
506
476
|
_syncBaseClasses() {
|
|
507
477
|
const p = this._p, el = p.el;
|
|
508
478
|
if (!el) return;
|
|
@@ -541,7 +511,7 @@
|
|
|
541
511
|
goToLast(event) {
|
|
542
512
|
this._move("last", event);
|
|
543
513
|
}
|
|
544
|
-
toggleFocusedItem() {
|
|
514
|
+
toggleFocusedItem(event) {
|
|
545
515
|
const p = this._p;
|
|
546
516
|
if (this.hasFocusedItem() && p.multi) {
|
|
547
517
|
let item = (p.filteredItems ?? p.items)[p.focusItemIndex];
|
|
@@ -662,7 +632,7 @@
|
|
|
662
632
|
if (hasOwnProperty.call(newItem, p.valueProp)) item.value = newItem[p.valueProp];
|
|
663
633
|
if (hasOwnProperty.call(newItem, "_nocheck")) item._nocheck = !!newItem._nocheck;
|
|
664
634
|
if (hasOwnProperty.call(newItem, "_nointeraction")) item._nointeraction = !!newItem._nointeraction;
|
|
665
|
-
if (hasOwnProperty.call(newItem, "_subitems")) item._subitems =
|
|
635
|
+
if (hasOwnProperty.call(newItem, "_subitems")) item._subitems = newItem._subitems;
|
|
666
636
|
if (p.multi) {
|
|
667
637
|
if (hasOwnProperty.call(newItem, "_checked")) item._checked = !!newItem._checked;
|
|
668
638
|
}
|
|
@@ -670,10 +640,10 @@
|
|
|
670
640
|
if (!!newItem._group !== item._group) {
|
|
671
641
|
if (item._group) p.groupCount--;
|
|
672
642
|
else p.groupCount++;
|
|
673
|
-
|
|
643
|
+
item._group = !!newItem._group;
|
|
674
644
|
}
|
|
675
645
|
}
|
|
676
|
-
if (hasOwnProperty.call(newItem, "_level"))
|
|
646
|
+
if (hasOwnProperty.call(newItem, "_level")) item._level = newItem._level;
|
|
677
647
|
if (hasOwnProperty.call(newItem, "_child")) item._child = !!newItem._child;
|
|
678
648
|
let virtualItemIndex = itemIndex;
|
|
679
649
|
if (p.filteredItems) {
|
|
@@ -820,6 +790,23 @@
|
|
|
820
790
|
return this._p.positionOptionsProvider;
|
|
821
791
|
}
|
|
822
792
|
/**
|
|
793
|
+
* Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderItem`/`unrenderItem`)
|
|
794
|
+
* instead of the default `console.error`/`console.warn`.
|
|
795
|
+
* @param {DropList.LibraryErrorHandler|null} [fn]
|
|
796
|
+
* @returns {DropList}
|
|
797
|
+
*/
|
|
798
|
+
setOnError(fn) {
|
|
799
|
+
const p = this._p;
|
|
800
|
+
p.onError = fn ?? void 0;
|
|
801
|
+
return this;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* @returns {DropList.LibraryErrorHandler|undefined}
|
|
805
|
+
*/
|
|
806
|
+
getOnError() {
|
|
807
|
+
return this._p.onError;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
823
810
|
* @param {string} term
|
|
824
811
|
* @param {boolean} [performSearch=false] should actually perform the search, or just set the input's text?
|
|
825
812
|
* @returns {DropList}
|
|
@@ -840,6 +827,7 @@
|
|
|
840
827
|
return !!(p.throttledRefilterItems.isScheduled() || !p.filteredItems && (p.filterTerm || p.filterOnEmptyTerm && p.filterFn));
|
|
841
828
|
}
|
|
842
829
|
/** @private */
|
|
830
|
+
/** @internal */
|
|
843
831
|
_refilterItems() {
|
|
844
832
|
const p = this._p;
|
|
845
833
|
const term = p.filterTerm;
|
|
@@ -874,7 +862,7 @@
|
|
|
874
862
|
});
|
|
875
863
|
}
|
|
876
864
|
if (!Array.isArray(filteredItems)) if (term) {
|
|
877
|
-
const matcher = new RegExp(
|
|
865
|
+
const matcher = new RegExp(escapeRegex(term), "i");
|
|
878
866
|
filteredItems = p.items.filter((x) => {
|
|
879
867
|
if (!filterGroups && x._group) return true;
|
|
880
868
|
return matcher.test(x.label);
|
|
@@ -951,7 +939,7 @@
|
|
|
951
939
|
p.filterThrottleWindow = window;
|
|
952
940
|
let isScheduled = p.throttledRefilterItems ? p.throttledRefilterItems.isScheduled() : false;
|
|
953
941
|
if (p.throttledRefilterItems) p.throttledRefilterItems.cancel();
|
|
954
|
-
p.throttledRefilterItems = throttle(() => this._refilterItems(), p.filterThrottleWindow
|
|
942
|
+
p.throttledRefilterItems = throttle(() => this._refilterItems(), p.filterThrottleWindow);
|
|
955
943
|
if (isScheduled) p.throttledRefilterItems();
|
|
956
944
|
return this;
|
|
957
945
|
}
|
|
@@ -1297,7 +1285,7 @@
|
|
|
1297
1285
|
if (this.isVisible()) this._trigger("show");
|
|
1298
1286
|
return this;
|
|
1299
1287
|
}
|
|
1300
|
-
hide() {
|
|
1288
|
+
hide(event) {
|
|
1301
1289
|
const p = this._p, el = p.el;
|
|
1302
1290
|
if (p.onDocumentMouseDown) {
|
|
1303
1291
|
p.sink.remove(document, "mousedown", p.onDocumentMouseDown);
|
|
@@ -1469,6 +1457,7 @@
|
|
|
1469
1457
|
}
|
|
1470
1458
|
return this;
|
|
1471
1459
|
}
|
|
1460
|
+
/** @internal */
|
|
1472
1461
|
_showSublist(item, itemElement) {
|
|
1473
1462
|
if (!item._subitems?.length) return;
|
|
1474
1463
|
const p = this._p;
|
|
@@ -1544,6 +1533,7 @@
|
|
|
1544
1533
|
droplist.show();
|
|
1545
1534
|
droplist.el.focus();
|
|
1546
1535
|
}
|
|
1536
|
+
/** @internal */
|
|
1547
1537
|
_hideSublist() {
|
|
1548
1538
|
const p = this._p;
|
|
1549
1539
|
if (!p.currentSubDropList) return;
|
|
@@ -1643,6 +1633,7 @@
|
|
|
1643
1633
|
}
|
|
1644
1634
|
return this;
|
|
1645
1635
|
}
|
|
1636
|
+
/** @internal */
|
|
1646
1637
|
_scrollItemIndexIntoView(itemIndex) {
|
|
1647
1638
|
const p = this._p;
|
|
1648
1639
|
if (this._hasScroll()) {
|
|
@@ -1706,6 +1697,7 @@
|
|
|
1706
1697
|
this._p.mitt.emit(event, value);
|
|
1707
1698
|
return this;
|
|
1708
1699
|
}
|
|
1700
|
+
/** @internal */
|
|
1709
1701
|
_getItemIndex(item) {
|
|
1710
1702
|
const p = this._p;
|
|
1711
1703
|
let itemIndex = -1;
|
|
@@ -1719,6 +1711,7 @@
|
|
|
1719
1711
|
}
|
|
1720
1712
|
return itemIndex;
|
|
1721
1713
|
}
|
|
1714
|
+
/** @internal */
|
|
1722
1715
|
_setSingleSelectedItemEl(itemEl, value) {
|
|
1723
1716
|
const p = this._p;
|
|
1724
1717
|
if (p.singleSelectedItemEl) {
|
|
@@ -1736,12 +1729,14 @@
|
|
|
1736
1729
|
* @param {string} event
|
|
1737
1730
|
* @param {*} [data]
|
|
1738
1731
|
* @private
|
|
1732
|
+
* @internal
|
|
1739
1733
|
*/
|
|
1740
1734
|
_trigger(event, data) {
|
|
1741
1735
|
const p = this._p;
|
|
1742
1736
|
if (p.on) p.on(event, ...data === void 0 ? [] : [data]);
|
|
1743
1737
|
p.mitt.emit(event, data);
|
|
1744
1738
|
}
|
|
1739
|
+
/** @internal */
|
|
1745
1740
|
_itemUpAction(event, itemEl) {
|
|
1746
1741
|
if ((0, _danielgindi_dom_utils_lib_Dom.closestUntil)(event.target, ".requires-pointer-events,button", itemEl)) return;
|
|
1747
1742
|
let p = this._p;
|
|
@@ -1754,6 +1749,7 @@
|
|
|
1754
1749
|
}, 0);
|
|
1755
1750
|
}
|
|
1756
1751
|
}
|
|
1752
|
+
/** @internal */
|
|
1757
1753
|
_hookMouseEvents() {
|
|
1758
1754
|
const p = this._p;
|
|
1759
1755
|
p.sink.add(p.el, "mouseup", (event) => {
|
|
@@ -1767,9 +1763,11 @@
|
|
|
1767
1763
|
this._handleMouseOver(event, li);
|
|
1768
1764
|
});
|
|
1769
1765
|
}
|
|
1766
|
+
/** @internal */
|
|
1770
1767
|
_handleMouseOver(event, itemEl) {
|
|
1771
1768
|
this._focus(event, itemEl, null, true);
|
|
1772
1769
|
}
|
|
1770
|
+
/** @internal */
|
|
1773
1771
|
_hookTouchEvents() {
|
|
1774
1772
|
const p = this._p;
|
|
1775
1773
|
let currentTouchId;
|
|
@@ -1809,6 +1807,7 @@
|
|
|
1809
1807
|
});
|
|
1810
1808
|
});
|
|
1811
1809
|
}
|
|
1810
|
+
/** @internal */
|
|
1812
1811
|
_hookFocusEvents() {
|
|
1813
1812
|
const p = this._p;
|
|
1814
1813
|
p.sink.add(p.el, "focus", (event) => {
|
|
@@ -1826,10 +1825,12 @@
|
|
|
1826
1825
|
});
|
|
1827
1826
|
}, true);
|
|
1828
1827
|
}
|
|
1828
|
+
/** @internal */
|
|
1829
1829
|
_hookKeyEvents() {
|
|
1830
1830
|
const p = this._p;
|
|
1831
1831
|
p.sink.add(p.el, "keydown", (evt) => this._keydown(evt));
|
|
1832
1832
|
}
|
|
1833
|
+
/** @internal */
|
|
1833
1834
|
_hookSearchEvents() {
|
|
1834
1835
|
const p = this._p;
|
|
1835
1836
|
if (!p.searchInput) return;
|
|
@@ -1840,6 +1841,7 @@
|
|
|
1840
1841
|
p.throttledRefilterItems();
|
|
1841
1842
|
});
|
|
1842
1843
|
}
|
|
1844
|
+
/** @internal */
|
|
1843
1845
|
_keydown(event) {
|
|
1844
1846
|
const p = this._p;
|
|
1845
1847
|
if (p.keyDownHandler && p.keyDownHandler.call(this, event)) return;
|
|
@@ -1902,6 +1904,7 @@
|
|
|
1902
1904
|
if (!p.searchable) this._keydownFreeType(event, !this.isVisible());
|
|
1903
1905
|
}
|
|
1904
1906
|
}
|
|
1907
|
+
/** @internal */
|
|
1905
1908
|
_keydownFreeType(evt, autoSelect) {
|
|
1906
1909
|
const p = this._p;
|
|
1907
1910
|
const character = evt.key || String.fromCharCode(evt.keyCode);
|
|
@@ -1910,7 +1913,7 @@
|
|
|
1910
1913
|
if (!isChar) return;
|
|
1911
1914
|
clearTimeout(p.filterTimer);
|
|
1912
1915
|
let keyword = (p.previousFilter || "") + character;
|
|
1913
|
-
let regex = new RegExp(`^${
|
|
1916
|
+
let regex = new RegExp(`^${escapeRegex(keyword)}`, "i");
|
|
1914
1917
|
let matchIndex = -1;
|
|
1915
1918
|
let item;
|
|
1916
1919
|
let focusItemIndex = p.focusItemIndex;
|
|
@@ -1925,7 +1928,7 @@
|
|
|
1925
1928
|
}
|
|
1926
1929
|
if (matchIndex === -1) {
|
|
1927
1930
|
keyword = character;
|
|
1928
|
-
regex = new RegExp(`^${
|
|
1931
|
+
regex = new RegExp(`^${escapeRegex(keyword)}`, "i");
|
|
1929
1932
|
for (let i = 0, count = items.length; i < count; i++) {
|
|
1930
1933
|
if (matchIndex !== -1 && i < focusItemIndex) continue;
|
|
1931
1934
|
item = items[i];
|
|
@@ -1945,6 +1948,7 @@
|
|
|
1945
1948
|
}, 1e3);
|
|
1946
1949
|
} else delete p.previousFilter;
|
|
1947
1950
|
}
|
|
1951
|
+
/** @internal */
|
|
1948
1952
|
_focus(event, itemEl, itemIndex, openSubitems) {
|
|
1949
1953
|
const p = this._p;
|
|
1950
1954
|
if (p._isFocusingItem) return;
|
|
@@ -1978,6 +1982,7 @@
|
|
|
1978
1982
|
p._isFocusingItem = false;
|
|
1979
1983
|
if (openSubitems) this._showSublist(item, focusItemEl);
|
|
1980
1984
|
}
|
|
1985
|
+
/** @internal */
|
|
1981
1986
|
_delayBlurItemOnBlur() {
|
|
1982
1987
|
if (this[DestroyedSymbol$1]) return;
|
|
1983
1988
|
const p = this._p;
|
|
@@ -1988,6 +1993,7 @@
|
|
|
1988
1993
|
this.blurFocusedItem();
|
|
1989
1994
|
}, p.autoItemBlurDelay);
|
|
1990
1995
|
}
|
|
1996
|
+
/** @internal */
|
|
1991
1997
|
_move(direction, event) {
|
|
1992
1998
|
const p = this._p;
|
|
1993
1999
|
let next, nextIndex, directionUp;
|
|
@@ -2057,10 +2063,12 @@
|
|
|
2057
2063
|
this._focus(event, next || null, nextIndex, false);
|
|
2058
2064
|
if (!this.isVisible()) this.triggerItemSelection(item, event);
|
|
2059
2065
|
}
|
|
2066
|
+
/** @internal */
|
|
2060
2067
|
_hasScroll() {
|
|
2061
2068
|
const menuEl = this._p.menuEl;
|
|
2062
2069
|
return menuEl.clientHeight < menuEl.scrollHeight;
|
|
2063
2070
|
}
|
|
2071
|
+
/** @internal */
|
|
2064
2072
|
_updateGroupStateForItem(item) {
|
|
2065
2073
|
const p = this._p;
|
|
2066
2074
|
if (!p.multi) return this;
|
|
@@ -2104,6 +2112,7 @@
|
|
|
2104
2112
|
}
|
|
2105
2113
|
return this;
|
|
2106
2114
|
}
|
|
2115
|
+
/** @internal */
|
|
2107
2116
|
_updateGroupCheckedState(groupIndex, fireEvents) {
|
|
2108
2117
|
const p = this._p;
|
|
2109
2118
|
if (!(p.multi && p.autoCheckGroupChildren && groupIndex > -1)) return this;
|
|
@@ -2137,6 +2146,7 @@
|
|
|
2137
2146
|
/**
|
|
2138
2147
|
* @private
|
|
2139
2148
|
* @returns {DropList} self
|
|
2149
|
+
* @internal
|
|
2140
2150
|
*/
|
|
2141
2151
|
_measureItem() {
|
|
2142
2152
|
const p = this._p;
|
|
@@ -2184,6 +2194,7 @@
|
|
|
2184
2194
|
* @param {number?} targetItemCount - item count we are expecting. Defaults to current item count
|
|
2185
2195
|
* @returns {DropList}
|
|
2186
2196
|
* @private
|
|
2197
|
+
* @internal
|
|
2187
2198
|
*/
|
|
2188
2199
|
_determineVirtualMode(targetItemCount) {
|
|
2189
2200
|
const p = this._p;
|
|
@@ -2193,6 +2204,7 @@
|
|
|
2193
2204
|
if (shouldBeVirtual !== p.virtualListHelper.isVirtual()) p.virtualListHelper.setVirtual(shouldBeVirtual).render();
|
|
2194
2205
|
return this;
|
|
2195
2206
|
}
|
|
2207
|
+
/** @internal */
|
|
2196
2208
|
_renderItemContent(item, itemEl) {
|
|
2197
2209
|
const p = this._p;
|
|
2198
2210
|
const originalItem = item[ItemSymbol];
|
|
@@ -2214,17 +2226,12 @@
|
|
|
2214
2226
|
}
|
|
2215
2227
|
}
|
|
2216
2228
|
}
|
|
2217
|
-
/**
|
|
2218
|
-
*
|
|
2219
|
-
* @param {DropList.PositionOptions} [positionOptions=undefined]
|
|
2220
|
-
* @returns {number} new outer width
|
|
2221
|
-
* @private
|
|
2222
|
-
*/
|
|
2229
|
+
/** @internal */
|
|
2223
2230
|
_updateWidth(positionOptions) {
|
|
2224
2231
|
const p = this._p, el = p.el;
|
|
2225
2232
|
let targetWidth = 0;
|
|
2226
2233
|
if (positionOptions) if (typeof positionOptions.updateWidth === "number") targetWidth = positionOptions.updateWidth;
|
|
2227
|
-
else if (positionOptions.targetWidth != null) targetWidth = positionOptions.
|
|
2234
|
+
else if (positionOptions.targetWidth != null) targetWidth = positionOptions.targetWidth;
|
|
2228
2235
|
else targetWidth = (0, _danielgindi_dom_utils_lib_Css.getElementWidth)(positionOptions.target, true, true);
|
|
2229
2236
|
let autoWidth = 0;
|
|
2230
2237
|
if (!p.useExactTargetWidth || !targetWidth) if (p.estimateWidth || p.virtualListHelper.isVirtual()) autoWidth = p.lastMeasureItemWidth;
|
|
@@ -2246,7 +2253,7 @@
|
|
|
2246
2253
|
}
|
|
2247
2254
|
};
|
|
2248
2255
|
//#endregion
|
|
2249
|
-
//#region lib/SelectBox.
|
|
2256
|
+
//#region src/lib/SelectBox.ts
|
|
2250
2257
|
var DestroyedSymbol = Symbol("destroyed");
|
|
2251
2258
|
var RestMultiItemsSymbol = Symbol("rest_multi_items");
|
|
2252
2259
|
var hasTouchCapability = !!("ontouchstart" in window || window.DocumentTouch && window.document instanceof window.DocumentTouch || window.navigator.maxTouchPoints);
|
|
@@ -2272,57 +2279,6 @@
|
|
|
2272
2279
|
"padding-left",
|
|
2273
2280
|
"padding-right"
|
|
2274
2281
|
];
|
|
2275
|
-
/**
|
|
2276
|
-
* @typedef {Object} SelectBox.Options
|
|
2277
|
-
* @property {DropList.Options} [listOptions] options to pass to the `DropList`
|
|
2278
|
-
* @property {Element} [el] An element to attach to, instead of creating a new one
|
|
2279
|
-
* @property {string} [baseClassName='selectbox'] class name for the menu root element
|
|
2280
|
-
* @property {string|string[]} [additionalClasses]
|
|
2281
|
-
* @property {'ltr'|'rtl'|'auto'} [direction='auto']
|
|
2282
|
-
* @property {boolean} [disabled=false] Should start as disabled?
|
|
2283
|
-
* @property {boolean} [readOnly=false] Should start as readOnly?
|
|
2284
|
-
* @property {boolean} [clearable=true] Has clear button?
|
|
2285
|
-
* @property {boolean} [hasOpenIndicator=true] has open/close indicator?
|
|
2286
|
-
* @property {string} [placeholder=''] Placeholder text
|
|
2287
|
-
* @property {boolean} [sortSelectedItems=true] Should the selected items be sorted?
|
|
2288
|
-
* @property {boolean} [sortListItems=false] Sort list items
|
|
2289
|
-
* @property {boolean} [sortListCheckedFirst=true] When sorting - put checked items first (applicable to `multi` mode only)
|
|
2290
|
-
* @property {boolean} [treatGroupSelectionAsItems=false] Treat group items as normal items
|
|
2291
|
-
* @property {*[]} [stickyValues]
|
|
2292
|
-
* @property {function(a: DropList.ItemBase, b: DropList.ItemBase):number} [sortItemComparator]
|
|
2293
|
-
* @property {boolean} [splitListCheckedGroups=true] Split groups to "checked" and "unchecked", works with `sortListCheckedFirst` only
|
|
2294
|
-
* @property {boolean|'touch'} [blurOnSingleSelection='touch']
|
|
2295
|
-
* @property {boolean} [multi=false] can multiple values be selected?
|
|
2296
|
-
* @property {boolean} [showSelection=true] show selection? if false, the placeholder will take effect
|
|
2297
|
-
* @property {boolean} [showPlaceholderInTooltip=false] show placeholder in title attribute
|
|
2298
|
-
* @property {function(items: DropList.ItemBase[]):string} [multiPlaceholderFormatter] formatter for placeholder for multi items mode
|
|
2299
|
-
* @property {string} [labelProp='label']
|
|
2300
|
-
* @property {string} [valueProp='value']
|
|
2301
|
-
* @property {string} [multiItemLabelProp='short_label']
|
|
2302
|
-
* @property {'after'|'before'|'none'} [multiItemRemovePosition='after']
|
|
2303
|
-
* @property {number} [maxMultiItems] maximum number of multi items. The rest will get a single item to represent.
|
|
2304
|
-
* @property {function(count: number, items: DropList.ItemBase[]):string} [multiItemsRestLabelProvider] label for the item representing the rest of the items.
|
|
2305
|
-
* @property {DropList.ItemBase[]|null} [items] initial items
|
|
2306
|
-
* @property {*[]|null} [selectedValues] initial selected values
|
|
2307
|
-
* @property {*|*[]|null} [value] initial selected value
|
|
2308
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderSingleItem]
|
|
2309
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderSingleItem]
|
|
2310
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderMultiItem]
|
|
2311
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderMultiItem]
|
|
2312
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderRestMultiItem]
|
|
2313
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderRestMultiItem]
|
|
2314
|
-
* @property {boolean} [searchable=false] is it searchable?
|
|
2315
|
-
* @property {boolean} [allowTypeToSelect=true] default behavior of type to select (focus first item starting with the search term) when searchable is true
|
|
2316
|
-
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
2317
|
-
* @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.
|
|
2318
|
-
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
2319
|
-
* @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
|
|
2320
|
-
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
2321
|
-
* @property {function(name: string, ...args)} [on]
|
|
2322
|
-
* @property {boolean} [isLoadingMode]
|
|
2323
|
-
* @property {boolean} [closeListWhenLoading] whether we should close the list automatically when loading
|
|
2324
|
-
* @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>
|
|
2325
|
-
* */
|
|
2326
2282
|
var DefaultOptions$1 = {
|
|
2327
2283
|
el: null,
|
|
2328
2284
|
baseClassName: "selectbox",
|
|
@@ -2441,6 +2397,7 @@
|
|
|
2441
2397
|
on: o.on || null,
|
|
2442
2398
|
silenceEvents: true,
|
|
2443
2399
|
mitt: (0, mitt.default)(),
|
|
2400
|
+
onError: o.onError,
|
|
2444
2401
|
isLoadingMode: !!o.isLoadingMode,
|
|
2445
2402
|
closeListWhenLoading: !!o.closeListWhenLoading,
|
|
2446
2403
|
clearInputWhen: Array.isArray(o.clearInputWhen) ? o.clearInputWhen.slice(0) : [],
|
|
@@ -2456,7 +2413,11 @@
|
|
|
2456
2413
|
filterThrottleWindow: o.filterThrottleWindow,
|
|
2457
2414
|
filterOnEmptyTerm: o.filterOnEmptyTerm,
|
|
2458
2415
|
filterFn: null,
|
|
2459
|
-
filterTerm: ""
|
|
2416
|
+
filterTerm: "",
|
|
2417
|
+
dropListVisible: false,
|
|
2418
|
+
lastActiveElement: null,
|
|
2419
|
+
lastKeyAllowsNonTypeKeys: false,
|
|
2420
|
+
presenceInt: null
|
|
2460
2421
|
};
|
|
2461
2422
|
let el = o.el;
|
|
2462
2423
|
if (el instanceof Element) p.ownsEl = false;
|
|
@@ -3194,7 +3155,7 @@
|
|
|
3194
3155
|
if (p.filterFn === fn) return this;
|
|
3195
3156
|
p.filterFn = fn;
|
|
3196
3157
|
if (!fn) fn = (items, term) => {
|
|
3197
|
-
const matcher = new RegExp(
|
|
3158
|
+
const matcher = new RegExp(escapeRegex(term), "i");
|
|
3198
3159
|
const labelProp = p.labelProp, multiItemLabelProp = p.multiItemLabelProp;
|
|
3199
3160
|
return p.items.filter((x) => {
|
|
3200
3161
|
if (!p.treatGroupSelectionAsItems && x._group) return true;
|
|
@@ -3212,6 +3173,25 @@
|
|
|
3212
3173
|
return this._p.filterFn;
|
|
3213
3174
|
}
|
|
3214
3175
|
/**
|
|
3176
|
+
* Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderMultiItem`/`unrenderSingleItem`)
|
|
3177
|
+
* instead of the default `console.error`/`console.warn`. Also used as the default `onError` for the internal
|
|
3178
|
+
* `DropList`, unless `listOptions.onError` is set explicitly.
|
|
3179
|
+
* @param {SelectBox.LibraryErrorHandler|null} [fn]
|
|
3180
|
+
* @returns {SelectBox}
|
|
3181
|
+
*/
|
|
3182
|
+
setOnError(fn) {
|
|
3183
|
+
const p = this._p;
|
|
3184
|
+
p.onError = fn ?? void 0;
|
|
3185
|
+
p.dropList?.setOnError(p.listOptions?.onError ?? p.onError);
|
|
3186
|
+
return this;
|
|
3187
|
+
}
|
|
3188
|
+
/**
|
|
3189
|
+
* @returns {SelectBox.LibraryErrorHandler|undefined}
|
|
3190
|
+
*/
|
|
3191
|
+
getOnError() {
|
|
3192
|
+
return this._p.onError;
|
|
3193
|
+
}
|
|
3194
|
+
/**
|
|
3215
3195
|
* Focus on input element
|
|
3216
3196
|
* @returns {SelectBox}
|
|
3217
3197
|
*/
|
|
@@ -3500,6 +3480,7 @@
|
|
|
3500
3480
|
* Prepare the mapping between values and items.
|
|
3501
3481
|
* This reduces search time greatly (i.e when checking items), especially when Vue proxies are in place.
|
|
3502
3482
|
* @private
|
|
3483
|
+
* @internal
|
|
3503
3484
|
*/
|
|
3504
3485
|
_refreshItemByValueMap() {
|
|
3505
3486
|
const p = this._p;
|
|
@@ -3512,6 +3493,7 @@
|
|
|
3512
3493
|
* @param {*} value
|
|
3513
3494
|
* @returns {DropList.ItemBase|undefined}
|
|
3514
3495
|
* @private
|
|
3496
|
+
* @internal
|
|
3515
3497
|
*/
|
|
3516
3498
|
_getItemByValue(value) {
|
|
3517
3499
|
const p = this._p;
|
|
@@ -3521,6 +3503,7 @@
|
|
|
3521
3503
|
return p.subitemByValueMap.get(value);
|
|
3522
3504
|
}
|
|
3523
3505
|
/** @private */
|
|
3506
|
+
/** @internal */
|
|
3524
3507
|
_refreshSubitemByValueMap() {
|
|
3525
3508
|
const p = this._p;
|
|
3526
3509
|
const subitemByValueMap = p.subitemByValueMap = /* @__PURE__ */ new Map();
|
|
@@ -3531,6 +3514,7 @@
|
|
|
3531
3514
|
* @param {Map<*, DropList.ItemBase>} itemByValueMap
|
|
3532
3515
|
* @param {string} valueProp
|
|
3533
3516
|
* @private
|
|
3517
|
+
* @internal
|
|
3534
3518
|
*/
|
|
3535
3519
|
_addSubitemsToValueMap(items, itemByValueMap, valueProp) {
|
|
3536
3520
|
for (let item of items) {
|
|
@@ -3540,6 +3524,7 @@
|
|
|
3540
3524
|
}
|
|
3541
3525
|
}
|
|
3542
3526
|
/** @private */
|
|
3527
|
+
/** @internal */
|
|
3543
3528
|
_renderBase() {
|
|
3544
3529
|
const p = this._p;
|
|
3545
3530
|
if (!p.inputBackBuffer) p.inputBackBuffer = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { css: {
|
|
@@ -3628,6 +3613,7 @@
|
|
|
3628
3613
|
}
|
|
3629
3614
|
/**
|
|
3630
3615
|
* @private
|
|
3616
|
+
* @internal
|
|
3631
3617
|
*/
|
|
3632
3618
|
_syncBaseClasses() {
|
|
3633
3619
|
const p = this._p, el = p.el;
|
|
@@ -3648,6 +3634,7 @@
|
|
|
3648
3634
|
el.className = classes.join(" ");
|
|
3649
3635
|
}
|
|
3650
3636
|
/** @private */
|
|
3637
|
+
/** @internal */
|
|
3651
3638
|
_setupDropdownMenu() {
|
|
3652
3639
|
const p = this._p;
|
|
3653
3640
|
p.valueProp;
|
|
@@ -3677,6 +3664,7 @@
|
|
|
3677
3664
|
filterGroups: p.treatGroupSelectionAsItems,
|
|
3678
3665
|
filterEmptyGroups: !p.treatGroupSelectionAsItems,
|
|
3679
3666
|
filterFn: p.actualFilterFn,
|
|
3667
|
+
onError: p.listOptions?.onError ?? p.onError,
|
|
3680
3668
|
positionOptionsProvider: () => this._getDropListPositionOptions(),
|
|
3681
3669
|
on: (name, event) => {
|
|
3682
3670
|
switch (name) {
|
|
@@ -3812,6 +3800,7 @@
|
|
|
3812
3800
|
p.sink.add(dropList.el, "mousedown", preventDropListMouseDownBlur);
|
|
3813
3801
|
this._registerDropdownEvents();
|
|
3814
3802
|
}
|
|
3803
|
+
/** @internal */
|
|
3815
3804
|
_handleOnBlur() {
|
|
3816
3805
|
const p = this._p;
|
|
3817
3806
|
setTimeout(() => {
|
|
@@ -3823,9 +3812,11 @@
|
|
|
3823
3812
|
this.closeList();
|
|
3824
3813
|
});
|
|
3825
3814
|
}
|
|
3815
|
+
/** @internal */
|
|
3826
3816
|
_unregisterDropdownEvents() {
|
|
3827
3817
|
this._p.sink.remove(null, ".dropdown");
|
|
3828
3818
|
}
|
|
3819
|
+
/** @internal */
|
|
3829
3820
|
_registerDropdownEvents() {
|
|
3830
3821
|
const p = this._p;
|
|
3831
3822
|
this._unregisterDropdownEvents();
|
|
@@ -3963,6 +3954,7 @@
|
|
|
3963
3954
|
}).add(p.el, "touchcancel.dropdown_touchextra", onTouchCancel);
|
|
3964
3955
|
});
|
|
3965
3956
|
}
|
|
3957
|
+
/** @internal */
|
|
3966
3958
|
_performSelectWithEvent(item, value) {
|
|
3967
3959
|
let cancellable = {
|
|
3968
3960
|
value,
|
|
@@ -3979,6 +3971,7 @@
|
|
|
3979
3971
|
});
|
|
3980
3972
|
return true;
|
|
3981
3973
|
}
|
|
3974
|
+
/** @internal */
|
|
3982
3975
|
_performClearWithEvent(clearInput = false) {
|
|
3983
3976
|
let cancellable = { cancel: false };
|
|
3984
3977
|
this._trigger("clear:before", cancellable);
|
|
@@ -3989,6 +3982,7 @@
|
|
|
3989
3982
|
this._trigger("clear");
|
|
3990
3983
|
return true;
|
|
3991
3984
|
}
|
|
3985
|
+
/** @internal */
|
|
3992
3986
|
_movePrev() {
|
|
3993
3987
|
const p = this._p;
|
|
3994
3988
|
if (this.isMultiEnabled()) return;
|
|
@@ -4002,6 +3996,7 @@
|
|
|
4002
3996
|
else this._performClearWithEvent();
|
|
4003
3997
|
}
|
|
4004
3998
|
}
|
|
3999
|
+
/** @internal */
|
|
4005
4000
|
_moveNext() {
|
|
4006
4001
|
const p = this._p;
|
|
4007
4002
|
if (this.isMultiEnabled()) return;
|
|
@@ -4016,6 +4011,7 @@
|
|
|
4016
4011
|
}
|
|
4017
4012
|
}
|
|
4018
4013
|
/** @private */
|
|
4014
|
+
/** @internal */
|
|
4019
4015
|
_updateListItems() {
|
|
4020
4016
|
const p = this._p;
|
|
4021
4017
|
const dropList = p.dropList;
|
|
@@ -4045,6 +4041,7 @@
|
|
|
4045
4041
|
if (hasRefocusedItem) p.dropList.setFocusedItemAtIndex(p.dropList.getFocusedItemIndex());
|
|
4046
4042
|
}
|
|
4047
4043
|
/** @private */
|
|
4044
|
+
/** @internal */
|
|
4048
4045
|
_setSelectedItems(items) {
|
|
4049
4046
|
const p = this._p, valueProp = p.valueProp;
|
|
4050
4047
|
if (p.multi) {
|
|
@@ -4060,6 +4057,7 @@
|
|
|
4060
4057
|
this._scheduleSync("full");
|
|
4061
4058
|
}
|
|
4062
4059
|
/** @private */
|
|
4060
|
+
/** @internal */
|
|
4063
4061
|
_scheduleSync(mode, data) {
|
|
4064
4062
|
const p = this._p;
|
|
4065
4063
|
if (!p.syncQueue) p.syncQueue = [];
|
|
@@ -4077,6 +4075,7 @@
|
|
|
4077
4075
|
});
|
|
4078
4076
|
}
|
|
4079
4077
|
/** @private */
|
|
4078
|
+
/** @internal */
|
|
4080
4079
|
_performSync(queue) {
|
|
4081
4080
|
const p = this._p;
|
|
4082
4081
|
if (this[DestroyedSymbol]) return;
|
|
@@ -4130,13 +4129,18 @@
|
|
|
4130
4129
|
}
|
|
4131
4130
|
}
|
|
4132
4131
|
/** @private */
|
|
4132
|
+
/** @internal */
|
|
4133
4133
|
_cleanupSingleWrapper() {
|
|
4134
4134
|
const p = this._p;
|
|
4135
4135
|
if (!p.singleWrapper) return;
|
|
4136
4136
|
if (p.unrenderSingleItem && p.singleWrapper.childNodes.length > 0) try {
|
|
4137
4137
|
p.unrenderSingleItem(p.singleWrapper[ItemSymbol], p.singleWrapper);
|
|
4138
4138
|
} catch (err) {
|
|
4139
|
-
|
|
4139
|
+
reportError(p.onError, err, {
|
|
4140
|
+
source: "unrenderSingleItem",
|
|
4141
|
+
item: p.singleWrapper[ItemSymbol],
|
|
4142
|
+
el: p.singleWrapper
|
|
4143
|
+
});
|
|
4140
4144
|
}
|
|
4141
4145
|
delete p.singleWrapper[ItemSymbol];
|
|
4142
4146
|
p.singleWrapper.innerHTML = "";
|
|
@@ -4144,6 +4148,7 @@
|
|
|
4144
4148
|
/**
|
|
4145
4149
|
* @param {number} index
|
|
4146
4150
|
* @private
|
|
4151
|
+
* @internal
|
|
4147
4152
|
*/
|
|
4148
4153
|
_removeMultiItemElementByIndex(index) {
|
|
4149
4154
|
const p = this._p, multiItemEls = p.multiItemEls;
|
|
@@ -4154,7 +4159,11 @@
|
|
|
4154
4159
|
if (unrender && itemEl.childNodes.length > 0) try {
|
|
4155
4160
|
unrender(item, itemEl);
|
|
4156
4161
|
} catch (err) {
|
|
4157
|
-
|
|
4162
|
+
reportError(p.onError, err, {
|
|
4163
|
+
source: item?.[p.valueProp] === RestMultiItemsSymbol ? "unrenderRestMultiItem" : "unrenderMultiItem",
|
|
4164
|
+
item,
|
|
4165
|
+
el: itemEl
|
|
4166
|
+
});
|
|
4158
4167
|
}
|
|
4159
4168
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(itemEl);
|
|
4160
4169
|
if (index === multiItemEls.length - 1) multiItemEls.pop();
|
|
@@ -4164,6 +4173,7 @@
|
|
|
4164
4173
|
/**
|
|
4165
4174
|
* @param {DropList.ItemBase} item
|
|
4166
4175
|
* @private
|
|
4176
|
+
* @internal
|
|
4167
4177
|
*/
|
|
4168
4178
|
_renderSingleItemContent(item) {
|
|
4169
4179
|
const p = this._p;
|
|
@@ -4178,6 +4188,7 @@
|
|
|
4178
4188
|
* @param {DropList.ItemBase} item
|
|
4179
4189
|
* @param {Element} itemEl
|
|
4180
4190
|
* @private
|
|
4191
|
+
* @internal
|
|
4181
4192
|
*/
|
|
4182
4193
|
_renderMultiItemContent(item, itemEl) {
|
|
4183
4194
|
const p = this._p;
|
|
@@ -4192,6 +4203,7 @@
|
|
|
4192
4203
|
* @param {DropList.ItemBase} item
|
|
4193
4204
|
* @returns {boolean} true if rendered, false if not
|
|
4194
4205
|
* @private
|
|
4206
|
+
* @internal
|
|
4195
4207
|
*/
|
|
4196
4208
|
_addMultiItemElement(item) {
|
|
4197
4209
|
const p = this._p;
|
|
@@ -4202,6 +4214,7 @@
|
|
|
4202
4214
|
return true;
|
|
4203
4215
|
}
|
|
4204
4216
|
/** @private */
|
|
4217
|
+
/** @internal */
|
|
4205
4218
|
_addMultiItemRestElement() {
|
|
4206
4219
|
const p = this._p;
|
|
4207
4220
|
let items = p.selectedItems.slice(0);
|
|
@@ -4214,6 +4227,7 @@
|
|
|
4214
4227
|
});
|
|
4215
4228
|
}
|
|
4216
4229
|
/** @private */
|
|
4230
|
+
/** @internal */
|
|
4217
4231
|
_syncClearButton() {
|
|
4218
4232
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
4219
4233
|
if (p.selectedItems.length > 0 && p.selectedItems.some((x) => x[multiItemLabelProp] !== false) && p.clearable && p.showSelection) {
|
|
@@ -4236,6 +4250,7 @@
|
|
|
4236
4250
|
}
|
|
4237
4251
|
}
|
|
4238
4252
|
/** @private */
|
|
4253
|
+
/** @internal */
|
|
4239
4254
|
_syncPlaceholder() {
|
|
4240
4255
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
4241
4256
|
let placeholder = "";
|
|
@@ -4247,6 +4262,7 @@
|
|
|
4247
4262
|
else p.input.removeAttribute("title");
|
|
4248
4263
|
}
|
|
4249
4264
|
/** @private */
|
|
4265
|
+
/** @internal */
|
|
4250
4266
|
_syncSingleItem() {
|
|
4251
4267
|
const p = this._p;
|
|
4252
4268
|
if (p.singleWrapper) this._cleanupSingleWrapper();
|
|
@@ -4261,6 +4277,7 @@
|
|
|
4261
4277
|
* @param {boolean=false} fullItemsRender Should re-render all items?
|
|
4262
4278
|
* @param {boolean=false} updateListItems Should call updateListItems?
|
|
4263
4279
|
* @returns {SelectBox}
|
|
4280
|
+
* @internal
|
|
4264
4281
|
*/
|
|
4265
4282
|
_syncFull(fullItemsRender, updateListItems) {
|
|
4266
4283
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
@@ -4321,6 +4338,7 @@
|
|
|
4321
4338
|
* @param {string} event
|
|
4322
4339
|
* @param {*} [data]
|
|
4323
4340
|
* @private
|
|
4341
|
+
* @internal
|
|
4324
4342
|
*/
|
|
4325
4343
|
_trigger(event, data) {
|
|
4326
4344
|
const p = this._p;
|
|
@@ -4333,6 +4351,7 @@
|
|
|
4333
4351
|
* @param {Object} item
|
|
4334
4352
|
* @returns {Element|null}
|
|
4335
4353
|
* @private
|
|
4354
|
+
* @internal
|
|
4336
4355
|
*/
|
|
4337
4356
|
_renderMultiItem(item) {
|
|
4338
4357
|
const p = this._p;
|
|
@@ -4360,6 +4379,7 @@
|
|
|
4360
4379
|
* @param {Event} originatingEvent
|
|
4361
4380
|
* @returns {SelectBox}
|
|
4362
4381
|
* @private
|
|
4382
|
+
* @internal
|
|
4363
4383
|
*/
|
|
4364
4384
|
_removeMultiItemFromEvent(itemEl, originatingEvent) {
|
|
4365
4385
|
const p = this._p;
|
|
@@ -4375,7 +4395,7 @@
|
|
|
4375
4395
|
let itemsToRemove = [];
|
|
4376
4396
|
for (let item of items) {
|
|
4377
4397
|
let removeselEvt = {
|
|
4378
|
-
value,
|
|
4398
|
+
value: item[p.valueProp],
|
|
4379
4399
|
item,
|
|
4380
4400
|
cancel: false
|
|
4381
4401
|
};
|
|
@@ -4386,7 +4406,7 @@
|
|
|
4386
4406
|
this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
|
|
4387
4407
|
for (let item of itemsToRemove) {
|
|
4388
4408
|
let idx = p.selectedItems.indexOf(item);
|
|
4389
|
-
if (idx === -1) idx = p.selectedValues.indexOf(
|
|
4409
|
+
if (idx === -1) idx = p.selectedValues.indexOf(item[p.valueProp]);
|
|
4390
4410
|
if (idx !== -1) {
|
|
4391
4411
|
p.selectedItems.splice(idx, 1);
|
|
4392
4412
|
p.selectedValues.splice(idx, 1);
|
|
@@ -4420,6 +4440,7 @@
|
|
|
4420
4440
|
* @param {DropList.ItemBase} item
|
|
4421
4441
|
* @param {boolean} [populate]
|
|
4422
4442
|
* @private
|
|
4443
|
+
* @internal
|
|
4423
4444
|
*/
|
|
4424
4445
|
_removeMultiItem(item, populate = false) {
|
|
4425
4446
|
const p = this._p;
|
|
@@ -4446,6 +4467,7 @@
|
|
|
4446
4467
|
/**
|
|
4447
4468
|
* @param {*} value
|
|
4448
4469
|
* @private
|
|
4470
|
+
* @internal
|
|
4449
4471
|
*/
|
|
4450
4472
|
_setInputText(value) {
|
|
4451
4473
|
const p = this._p;
|
|
@@ -4458,6 +4480,7 @@
|
|
|
4458
4480
|
* Update input size to current state
|
|
4459
4481
|
* @returns {SelectBox}
|
|
4460
4482
|
* @private
|
|
4483
|
+
* @internal
|
|
4461
4484
|
*/
|
|
4462
4485
|
_resizeInput() {
|
|
4463
4486
|
const p = this._p, el = p.el;
|
|
@@ -4515,6 +4538,7 @@
|
|
|
4515
4538
|
* Update autocomplete position if needed
|
|
4516
4539
|
* @returns {SelectBox}
|
|
4517
4540
|
* @private
|
|
4541
|
+
* @internal
|
|
4518
4542
|
*/
|
|
4519
4543
|
_repositionDropList() {
|
|
4520
4544
|
const p = this._p, el = p.el;
|
|
@@ -4530,6 +4554,7 @@
|
|
|
4530
4554
|
/**
|
|
4531
4555
|
* @param {KeyboardEvent} event
|
|
4532
4556
|
* @private
|
|
4557
|
+
* @internal
|
|
4533
4558
|
*/
|
|
4534
4559
|
_handleInputKeydown(event) {
|
|
4535
4560
|
const p = this._p;
|
|
@@ -4560,6 +4585,7 @@
|
|
|
4560
4585
|
/**
|
|
4561
4586
|
* @param {KeyboardEvent} event
|
|
4562
4587
|
* @private
|
|
4588
|
+
* @internal
|
|
4563
4589
|
*/
|
|
4564
4590
|
_handleMultiKeydown(event) {
|
|
4565
4591
|
const p = this._p;
|
|
@@ -4605,6 +4631,7 @@
|
|
|
4605
4631
|
/**
|
|
4606
4632
|
* @returns {DropList.PositionOptions}
|
|
4607
4633
|
* @private
|
|
4634
|
+
* @internal
|
|
4608
4635
|
*/
|
|
4609
4636
|
_getDropListPositionOptions() {
|
|
4610
4637
|
return {
|
|
@@ -4625,6 +4652,7 @@
|
|
|
4625
4652
|
};
|
|
4626
4653
|
}
|
|
4627
4654
|
/** @private */
|
|
4655
|
+
/** @internal */
|
|
4628
4656
|
_startTrackingPresence() {
|
|
4629
4657
|
const p = this._p;
|
|
4630
4658
|
this._stopTrackingPresence();
|
|
@@ -4633,6 +4661,7 @@
|
|
|
4633
4661
|
}, 200);
|
|
4634
4662
|
}
|
|
4635
4663
|
/** @private */
|
|
4664
|
+
/** @internal */
|
|
4636
4665
|
_stopTrackingPresence() {
|
|
4637
4666
|
const p = this._p;
|
|
4638
4667
|
if (p.presenceInt) {
|
|
@@ -4648,6 +4677,7 @@
|
|
|
4648
4677
|
* @param {boolean=false} sortCheckedFirst
|
|
4649
4678
|
* @param {boolean=false} splitCheckedGroups
|
|
4650
4679
|
* @returns {DropList.ItemBase[]}
|
|
4680
|
+
* @internal
|
|
4651
4681
|
*/
|
|
4652
4682
|
_sortItems(items, sort, sortCheckedFirst, splitCheckedGroups) {
|
|
4653
4683
|
const p = this._p;
|