@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.cjs.js +227 -681
- 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 +230 -681
- 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 +227 -681
- 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 +205 -0
- package/dist/types/DropList.d.ts.map +1 -0
- package/dist/types/SelectBox.d.ts +209 -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 +222 -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 +17 -12
- package/tsconfig.json +35 -0
- package/vue/DropList.vue +508 -565
- package/vue/DropList.vue.d.ts +4 -0
- package/vue/SelectBox.vue +780 -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 +71 -96
- package/lib/utils/escapeRegex.js +0 -1
- package/lib/utils/throttle.js +0 -48
package/dist/lib.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.59
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -20,7 +20,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
24
24
|
value: mod,
|
|
25
25
|
enumerable: true
|
|
26
26
|
}) : target, mod));
|
|
@@ -35,14 +35,18 @@ _danielgindi_virtual_list_helper = __toESM(_danielgindi_virtual_list_helper);
|
|
|
35
35
|
let keycode_js = require("keycode-js");
|
|
36
36
|
let mitt = require("mitt");
|
|
37
37
|
mitt = __toESM(mitt);
|
|
38
|
-
//#region lib/utils/escapeRegex.
|
|
39
|
-
|
|
38
|
+
//#region src/lib/utils/escapeRegex.ts
|
|
39
|
+
/** @internal */
|
|
40
|
+
var escapeRegex = (value) => value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
40
41
|
//#endregion
|
|
41
|
-
//#region lib/utils/throttle.
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
//#region src/lib/utils/throttle.ts
|
|
43
|
+
/** @internal */
|
|
44
|
+
var throttle = (func, wait, options = {}) => {
|
|
45
|
+
let timeout;
|
|
46
|
+
let context;
|
|
47
|
+
let args;
|
|
48
|
+
let result;
|
|
44
49
|
let previous = 0;
|
|
45
|
-
if (!options) options = {};
|
|
46
50
|
const later = () => {
|
|
47
51
|
previous = options.leading === false ? 0 : Date.now();
|
|
48
52
|
timeout = null;
|
|
@@ -77,86 +81,30 @@ var throttle = (func, wait, options) => {
|
|
|
77
81
|
return throttled;
|
|
78
82
|
};
|
|
79
83
|
//#endregion
|
|
80
|
-
//#region lib/
|
|
84
|
+
//#region src/lib/utils/reportError.ts
|
|
85
|
+
/**
|
|
86
|
+
* Routes an error/warning to `handler` if supplied, falling back to the
|
|
87
|
+
* console (matching the previous hardcoded behaviour) if there is no
|
|
88
|
+
* handler, or if the handler itself throws.
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
var reportError = (handler, error, context) => {
|
|
92
|
+
if (handler) try {
|
|
93
|
+
handler(error, context);
|
|
94
|
+
return;
|
|
95
|
+
} catch (handlerError) {
|
|
96
|
+
console.error(handlerError);
|
|
97
|
+
}
|
|
98
|
+
if (context.level === "warn") console.warn(error);
|
|
99
|
+
else console.error(error);
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/lib/DropList.ts
|
|
81
103
|
var ItemSymbol = Symbol("item");
|
|
82
104
|
var DestroyedSymbol$1 = Symbol("destroyed");
|
|
83
105
|
var GhostSymbol = Symbol("ghost");
|
|
84
106
|
var NoResultsItemSymbol = Symbol("no_results_items");
|
|
85
107
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
86
|
-
/**
|
|
87
|
-
* @typedef {Object} DropList.Options
|
|
88
|
-
* @property {Element} [el] An element to attach to, instead of creating a new one
|
|
89
|
-
* @property {string} [baseClassName='droplist'] class name for the menu root element
|
|
90
|
-
* @property {string|string[]} [additionalClasses]
|
|
91
|
-
* @property {'ltr'|'rtl'|'auto'} [direction='auto']
|
|
92
|
-
* @property {boolean} [autoItemBlur=true] Should we automatically blur the focused item when the droplist loses focus?
|
|
93
|
-
* @property {number} [autoItemBlurDelay=300] How long to wait before deciding to blur the focused item (when the droplist loses focus)?
|
|
94
|
-
* @property {boolean} [capturesFocus=true] Should this DropList be added to the TAB-key stack?
|
|
95
|
-
* @property {boolean} [multi=false] Does this DropList show checkboxes for multiple item selection?
|
|
96
|
-
* @property {*} [singleSelectedValue] Current selected value when using single selection.
|
|
97
|
-
* @property {function} [keyDownHandler=null] An alternative "keydown" event handler. Return true to prevent default behaviour.
|
|
98
|
-
* @property {boolean} [autoCheckGroupChildren=true] When a group is checked/unchecked - all items beneath it will update accordingly
|
|
99
|
-
* @property {boolean} [useExactTargetWidth=false] Use the exact target's width, do not allow growing
|
|
100
|
-
* @property {boolean} [constrainToWindow=true] Should the position be constrained to the window, attaching to window's borders if needed?
|
|
101
|
-
* @property {Boolean} [autoFlipDirection=true] Should the position/anchor be flipped automatically when there's no space in the required direction?
|
|
102
|
-
* @property {number} [estimatedItemHeight=20] An estimated row height, for approximating scroll height.
|
|
103
|
-
* @property {boolean} [estimateWidth=false] Use an estimation for the width instead of measuring. May be faster - needs testing and may depend on the CSS.
|
|
104
|
-
* @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.
|
|
105
|
-
* @property {string} [labelProp='label']
|
|
106
|
-
* @property {string} [valueProp='value']
|
|
107
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderItem] Function to call when rendering an item element
|
|
108
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderItem] Function to call when rendering an item element
|
|
109
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderNoResultsItem]
|
|
110
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderNoResultsItem]
|
|
111
|
-
* @property {function(name: string, data: *)} [on]
|
|
112
|
-
* @property {boolean} [isHeaderVisible=false] show header element
|
|
113
|
-
* @property {boolean} [isFooterVisible=false] show footer element
|
|
114
|
-
* @property {boolean} [searchable=false] include inline search box
|
|
115
|
-
* @property {string} [searchPlaceholder=''] placeholder text for the inline search box
|
|
116
|
-
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
117
|
-
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
118
|
-
* @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
|
|
119
|
-
* @property {boolean} [filterGroups=false] should groups be filtered?
|
|
120
|
-
* @property {boolean} [filterEmptyGroups=false] should empty groups be filtered out?
|
|
121
|
-
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
122
|
-
* @property {function(dropList: DropList):DropList.PositionOptions} [positionOptionsProvider]
|
|
123
|
-
* */
|
|
124
|
-
/** */
|
|
125
|
-
/**
|
|
126
|
-
* @typedef {Object} DropList.PositionAnchor
|
|
127
|
-
* @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`)
|
|
128
|
-
* @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`)
|
|
129
|
-
* */
|
|
130
|
-
/** */
|
|
131
|
-
/**
|
|
132
|
-
* @typedef {Object} DropList.PositionOptions
|
|
133
|
-
* @property {Element?} [target] Target element to act as anchor
|
|
134
|
-
* @property {{left: number, top: number}?} [targetOffset] Override the offset of target. Automatically calculated if unspecified.
|
|
135
|
-
* @property {number?} [targetHeight] Override height of the target
|
|
136
|
-
* @property {number?} [targetWidth] Override width of the target
|
|
137
|
-
* @property {DropList.PositionAnchor?} [position]
|
|
138
|
-
* @property {DropList.PositionAnchor?} [anchor]
|
|
139
|
-
* @property {boolean|number?} [updateWidth=false] `true` to set width of the menu according to `target`'s width, or specify an arbitrary number.
|
|
140
|
-
* @property {string?} [targetRtl] Override for rtl mode of the target
|
|
141
|
-
* @property {{x: number, y: number}} [offset=undefined] Extra rtl-aware offset to the target
|
|
142
|
-
* */
|
|
143
|
-
/** */
|
|
144
|
-
/**
|
|
145
|
-
* @typedef {Object} DropList.ItemBase
|
|
146
|
-
* @property {string} [value]
|
|
147
|
-
* @property {string} [label]
|
|
148
|
-
* @property {boolean} [_group=false]
|
|
149
|
-
* @property {boolean} [_child=false]
|
|
150
|
-
* @property {boolean} [_nocheck=false]
|
|
151
|
-
* @property {boolean} [_nointeraction=false]
|
|
152
|
-
* @property {DropList.ItemBase[]} [_subitems]
|
|
153
|
-
* */
|
|
154
|
-
/**
|
|
155
|
-
* @typedef {DropList.ItemBase} DropList.Item
|
|
156
|
-
* @property {boolean} [_checked=false]
|
|
157
|
-
* */
|
|
158
|
-
/** */
|
|
159
|
-
/** @type {DropList.Options} */
|
|
160
108
|
var DefaultOptions = {
|
|
161
109
|
baseClassName: "droplist",
|
|
162
110
|
autoItemBlur: true,
|
|
@@ -185,9 +133,6 @@ var DefaultOptions = {
|
|
|
185
133
|
filterEmptyGroups: false
|
|
186
134
|
};
|
|
187
135
|
var DropList = class DropList {
|
|
188
|
-
/**
|
|
189
|
-
* @param {DropList.Options} options
|
|
190
|
-
*/
|
|
191
136
|
constructor(options) {
|
|
192
137
|
const o = { ...DefaultOptions };
|
|
193
138
|
for (let [key, value] of Object.entries(
|
|
@@ -221,6 +166,7 @@ var DropList = class DropList {
|
|
|
221
166
|
unrenderNoResultsItem: o.unrenderNoResultsItem,
|
|
222
167
|
on: o.on || null,
|
|
223
168
|
positionOptionsProvider: o.positionOptionsProvider ?? null,
|
|
169
|
+
onError: o.onError,
|
|
224
170
|
searchable: o.searchable,
|
|
225
171
|
searchPlaceholder: o.searchPlaceholder,
|
|
226
172
|
isHeaderVisible: o.isHeaderVisible,
|
|
@@ -238,7 +184,14 @@ var DropList = class DropList {
|
|
|
238
184
|
throttledRefilterItems: null,
|
|
239
185
|
focusItemIndex: -1,
|
|
240
186
|
focusItemEl: null,
|
|
241
|
-
sink: new _danielgindi_dom_utils_lib_DomEventsSink.default()
|
|
187
|
+
sink: new _danielgindi_dom_utils_lib_DomEventsSink.default(),
|
|
188
|
+
visible: false,
|
|
189
|
+
hiding: false,
|
|
190
|
+
singleSelectedItemEl: null,
|
|
191
|
+
onDocumentMouseDown: null,
|
|
192
|
+
lastKeyWasChar: false,
|
|
193
|
+
currentSubDropList: null,
|
|
194
|
+
_isFocusingItem: false
|
|
242
195
|
};
|
|
243
196
|
let classes = [p.baseClassName + "_wrapper"];
|
|
244
197
|
if (p.additionalClasses) classes = classes.concat((p.additionalClasses + "").split(" ").filter((x) => x));
|
|
@@ -304,7 +257,11 @@ var DropList = class DropList {
|
|
|
304
257
|
};
|
|
305
258
|
else item = items[index];
|
|
306
259
|
}
|
|
307
|
-
if (!item)
|
|
260
|
+
if (!item) reportError(p.onError, `onItemRender called for (${index}) which has no item`, {
|
|
261
|
+
source: "renderItem",
|
|
262
|
+
level: "warn",
|
|
263
|
+
index
|
|
264
|
+
});
|
|
308
265
|
itemEl.className = `${p.baseClassName}__item`;
|
|
309
266
|
const classList = itemEl.classList;
|
|
310
267
|
if (item) {
|
|
@@ -381,19 +338,13 @@ var DropList = class DropList {
|
|
|
381
338
|
}
|
|
382
339
|
/**
|
|
383
340
|
* Returns true if other is an inclusive descendant of node, and false otherwise.
|
|
384
|
-
*
|
|
385
|
-
* @param {boolean} [considerSubmenus=true]
|
|
386
|
-
* @returns {boolean}
|
|
341
|
+
* Accepts `EventTarget` (not just `Node`) since callers pass `event.target`/`event.relatedTarget` directly.
|
|
387
342
|
*/
|
|
388
343
|
elContains(other, considerSubmenus = true) {
|
|
389
344
|
if (this.el.contains(other)) return true;
|
|
390
345
|
if (considerSubmenus && this._p.currentSubDropList?.droplist?.elContains(other)) return true;
|
|
391
346
|
return false;
|
|
392
347
|
}
|
|
393
|
-
/**
|
|
394
|
-
* @param {string|string[]} classes
|
|
395
|
-
* @returns {DropList}
|
|
396
|
-
*/
|
|
397
348
|
setAdditionalClasses(classes) {
|
|
398
349
|
const p = this._p;
|
|
399
350
|
p.additionalClasses = classes;
|
|
@@ -402,8 +353,6 @@ var DropList = class DropList {
|
|
|
402
353
|
}
|
|
403
354
|
/**
|
|
404
355
|
* Sets the appropriate direction for the droplist
|
|
405
|
-
* @param {'ltr'|'rtl'|'auto'} direction
|
|
406
|
-
* @return {DropList}
|
|
407
356
|
*/
|
|
408
357
|
setDirection(direction) {
|
|
409
358
|
const p = this._p;
|
|
@@ -413,46 +362,26 @@ var DropList = class DropList {
|
|
|
413
362
|
}
|
|
414
363
|
/**
|
|
415
364
|
* Gets the supplied direction for the droplist
|
|
416
|
-
* @return {'ltr'|'rtl'|'auto'}
|
|
417
365
|
*/
|
|
418
366
|
getDirection() {
|
|
419
367
|
return this._p.direction;
|
|
420
368
|
}
|
|
421
|
-
/**
|
|
422
|
-
* @param {string} prop
|
|
423
|
-
* @returns {DropList}
|
|
424
|
-
*/
|
|
425
369
|
setLabelProp(prop) {
|
|
426
370
|
const p = this._p;
|
|
427
371
|
p.labelProp = prop;
|
|
428
372
|
return this;
|
|
429
373
|
}
|
|
430
|
-
/**
|
|
431
|
-
*
|
|
432
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [fn] Function to call when rendering an item element
|
|
433
|
-
* @returns {DropList}
|
|
434
|
-
*/
|
|
435
374
|
setRenderItem(fn) {
|
|
436
375
|
const p = this._p;
|
|
437
376
|
p.renderItem = fn;
|
|
438
377
|
return this;
|
|
439
378
|
}
|
|
440
|
-
/**
|
|
441
|
-
*
|
|
442
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [fn] Function to call when rendering an item element
|
|
443
|
-
* @returns {DropList}
|
|
444
|
-
*/
|
|
445
379
|
setUnrenderItem(fn) {
|
|
446
380
|
const p = this._p;
|
|
447
381
|
p.unrenderItem = fn;
|
|
448
382
|
this._setupUnrenderFunction();
|
|
449
383
|
return this;
|
|
450
384
|
}
|
|
451
|
-
/**
|
|
452
|
-
* @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
|
|
453
|
-
* @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
|
|
454
|
-
* @returns {DropList}
|
|
455
|
-
*/
|
|
456
385
|
setRenderNoResultsItem(render, unrender) {
|
|
457
386
|
const p = this._p;
|
|
458
387
|
p.renderNoResultsItem = render;
|
|
@@ -462,6 +391,7 @@ var DropList = class DropList {
|
|
|
462
391
|
}
|
|
463
392
|
/**
|
|
464
393
|
* @private
|
|
394
|
+
* @internal
|
|
465
395
|
*/
|
|
466
396
|
_setupUnrenderFunction() {
|
|
467
397
|
const p = this._p;
|
|
@@ -473,12 +403,20 @@ var DropList = class DropList {
|
|
|
473
403
|
if (item === NoResultsItemSymbol) try {
|
|
474
404
|
fnNoResults(item, el);
|
|
475
405
|
} catch (err) {
|
|
476
|
-
|
|
406
|
+
reportError(p.onError, err, {
|
|
407
|
+
source: "unrenderNoResultsItem",
|
|
408
|
+
item,
|
|
409
|
+
el
|
|
410
|
+
});
|
|
477
411
|
}
|
|
478
412
|
else try {
|
|
479
413
|
fn(item[ItemSymbol], el);
|
|
480
414
|
} catch (err) {
|
|
481
|
-
|
|
415
|
+
reportError(p.onError, err, {
|
|
416
|
+
source: "unrenderItem",
|
|
417
|
+
item: item[ItemSymbol],
|
|
418
|
+
el
|
|
419
|
+
});
|
|
482
420
|
}
|
|
483
421
|
delete el[ItemSymbol];
|
|
484
422
|
if (p.focusItemEl === el) p.focusItemEl = null;
|
|
@@ -489,15 +427,12 @@ var DropList = class DropList {
|
|
|
489
427
|
});
|
|
490
428
|
return this;
|
|
491
429
|
}
|
|
492
|
-
/**
|
|
493
|
-
* @param {string} prop
|
|
494
|
-
* @returns {DropList}
|
|
495
|
-
*/
|
|
496
430
|
setValueProp(prop) {
|
|
497
431
|
const p = this._p;
|
|
498
432
|
p.valueProp = prop;
|
|
499
433
|
return this;
|
|
500
434
|
}
|
|
435
|
+
/** @internal */
|
|
501
436
|
_syncBaseClasses() {
|
|
502
437
|
const p = this._p, el = p.el;
|
|
503
438
|
if (!el) return;
|
|
@@ -536,7 +471,7 @@ var DropList = class DropList {
|
|
|
536
471
|
goToLast(event) {
|
|
537
472
|
this._move("last", event);
|
|
538
473
|
}
|
|
539
|
-
toggleFocusedItem() {
|
|
474
|
+
toggleFocusedItem(event) {
|
|
540
475
|
const p = this._p;
|
|
541
476
|
if (this.hasFocusedItem() && p.multi) {
|
|
542
477
|
let item = (p.filteredItems ?? p.items)[p.focusItemIndex];
|
|
@@ -579,19 +514,16 @@ var DropList = class DropList {
|
|
|
579
514
|
return true;
|
|
580
515
|
}
|
|
581
516
|
/**
|
|
582
|
-
*
|
|
583
|
-
* @param
|
|
584
|
-
* @param {number} [atIndex=-1] The index to insert at (or -1)
|
|
585
|
-
* @returns {DropList}
|
|
517
|
+
* @param item The item to add. It is copied.
|
|
518
|
+
* @param atIndex The index to insert at (or -1)
|
|
586
519
|
*/
|
|
587
520
|
addItem(item, atIndex = -1) {
|
|
588
521
|
return this.addItems([item], atIndex);
|
|
589
522
|
}
|
|
590
523
|
/**
|
|
591
524
|
* Adds items to the menu and renders
|
|
592
|
-
* @param
|
|
593
|
-
* @param
|
|
594
|
-
* @returns {DropList}
|
|
525
|
+
* @param itemsToAdd The items to add. These are copied.
|
|
526
|
+
* @param atIndex The index to insert at (or -1)
|
|
595
527
|
*/
|
|
596
528
|
addItems(itemsToAdd, atIndex = -1) {
|
|
597
529
|
const p = this._p, labelProp = p.labelProp, valueProp = p.valueProp;
|
|
@@ -633,8 +565,7 @@ var DropList = class DropList {
|
|
|
633
565
|
}
|
|
634
566
|
/**
|
|
635
567
|
* Replaces all current items with the supplied items
|
|
636
|
-
* @param
|
|
637
|
-
* @returns {DropList}
|
|
568
|
+
* @param items The items to set. These are copied.
|
|
638
569
|
*/
|
|
639
570
|
setItems(items) {
|
|
640
571
|
const p = this._p;
|
|
@@ -657,7 +588,7 @@ var DropList = class DropList {
|
|
|
657
588
|
if (hasOwnProperty.call(newItem, p.valueProp)) item.value = newItem[p.valueProp];
|
|
658
589
|
if (hasOwnProperty.call(newItem, "_nocheck")) item._nocheck = !!newItem._nocheck;
|
|
659
590
|
if (hasOwnProperty.call(newItem, "_nointeraction")) item._nointeraction = !!newItem._nointeraction;
|
|
660
|
-
if (hasOwnProperty.call(newItem, "_subitems")) item._subitems =
|
|
591
|
+
if (hasOwnProperty.call(newItem, "_subitems")) item._subitems = newItem._subitems;
|
|
661
592
|
if (p.multi) {
|
|
662
593
|
if (hasOwnProperty.call(newItem, "_checked")) item._checked = !!newItem._checked;
|
|
663
594
|
}
|
|
@@ -665,10 +596,10 @@ var DropList = class DropList {
|
|
|
665
596
|
if (!!newItem._group !== item._group) {
|
|
666
597
|
if (item._group) p.groupCount--;
|
|
667
598
|
else p.groupCount++;
|
|
668
|
-
|
|
599
|
+
item._group = !!newItem._group;
|
|
669
600
|
}
|
|
670
601
|
}
|
|
671
|
-
if (hasOwnProperty.call(newItem, "_level"))
|
|
602
|
+
if (hasOwnProperty.call(newItem, "_level")) item._level = newItem._level;
|
|
672
603
|
if (hasOwnProperty.call(newItem, "_child")) item._child = !!newItem._child;
|
|
673
604
|
let virtualItemIndex = itemIndex;
|
|
674
605
|
if (p.filteredItems) {
|
|
@@ -779,8 +710,6 @@ var DropList = class DropList {
|
|
|
779
710
|
/**
|
|
780
711
|
* Return the item element at the given original index, if it exists.
|
|
781
712
|
* The item may not be currently rendered, and null will be returned
|
|
782
|
-
* @param index
|
|
783
|
-
* @returns {HTMLElement|null}
|
|
784
713
|
*/
|
|
785
714
|
itemElementAtIndex(index) {
|
|
786
715
|
const p = this._p;
|
|
@@ -791,16 +720,10 @@ var DropList = class DropList {
|
|
|
791
720
|
/**
|
|
792
721
|
* Return the item element at the given index, if it exists.
|
|
793
722
|
* The item may not be currently rendered, and null will be returned
|
|
794
|
-
* @param index
|
|
795
|
-
* @returns {HTMLElement|null}
|
|
796
723
|
*/
|
|
797
724
|
filteredElementItemAtIndex(index) {
|
|
798
725
|
return this._p.virtualListHelper.getItemElementAt(index) ?? null;
|
|
799
726
|
}
|
|
800
|
-
/**
|
|
801
|
-
* @param {function(dropList: DropList):DropList.PositionOptions} fn
|
|
802
|
-
* @returns {DropList}
|
|
803
|
-
*/
|
|
804
727
|
setPositionOptionsProvider(fn) {
|
|
805
728
|
const p = this._p;
|
|
806
729
|
if (p.positionOptionsProvider === fn) return this;
|
|
@@ -808,16 +731,27 @@ var DropList = class DropList {
|
|
|
808
731
|
this.relayout();
|
|
809
732
|
return this;
|
|
810
733
|
}
|
|
811
|
-
/**
|
|
812
|
-
* @returns {function(dropList: DropList):DropList.PositionOptions|null}
|
|
813
|
-
*/
|
|
814
734
|
getPositionOptionsProvider() {
|
|
815
735
|
return this._p.positionOptionsProvider;
|
|
816
736
|
}
|
|
817
737
|
/**
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
|
|
738
|
+
* Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderItem`/`unrenderItem`)
|
|
739
|
+
* instead of the default `console.error`/`console.warn`.
|
|
740
|
+
*/
|
|
741
|
+
setOnError(fn) {
|
|
742
|
+
const p = this._p;
|
|
743
|
+
p.onError = fn ?? void 0;
|
|
744
|
+
return this;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Gets the current `onError` handler, if any.
|
|
748
|
+
*/
|
|
749
|
+
getOnError() {
|
|
750
|
+
return this._p.onError;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* @param term the search term to set
|
|
754
|
+
* @param performSearch should actually perform the search, or just set the input's text?
|
|
821
755
|
*/
|
|
822
756
|
setSearchTerm(term, performSearch = false) {
|
|
823
757
|
const p = this._p;
|
|
@@ -835,6 +769,7 @@ var DropList = class DropList {
|
|
|
835
769
|
return !!(p.throttledRefilterItems.isScheduled() || !p.filteredItems && (p.filterTerm || p.filterOnEmptyTerm && p.filterFn));
|
|
836
770
|
}
|
|
837
771
|
/** @private */
|
|
772
|
+
/** @internal */
|
|
838
773
|
_refilterItems() {
|
|
839
774
|
const p = this._p;
|
|
840
775
|
const term = p.filterTerm;
|
|
@@ -869,7 +804,7 @@ var DropList = class DropList {
|
|
|
869
804
|
});
|
|
870
805
|
}
|
|
871
806
|
if (!Array.isArray(filteredItems)) if (term) {
|
|
872
|
-
const matcher = new RegExp(
|
|
807
|
+
const matcher = new RegExp(escapeRegex(term), "i");
|
|
873
808
|
filteredItems = p.items.filter((x) => {
|
|
874
809
|
if (!filterGroups && x._group) return true;
|
|
875
810
|
return matcher.test(x.label);
|
|
@@ -921,45 +856,27 @@ var DropList = class DropList {
|
|
|
921
856
|
if (p.items) return p.items.length;
|
|
922
857
|
return 0;
|
|
923
858
|
}
|
|
924
|
-
/**
|
|
925
|
-
* @param {string} noResultsText
|
|
926
|
-
* @returns {DropList}
|
|
927
|
-
*/
|
|
928
859
|
setNoResultsText(noResultsText) {
|
|
929
860
|
const p = this._p;
|
|
930
861
|
p.noResultsText = noResultsText;
|
|
931
862
|
if (p.hasNoResultsItem) p.virtualListHelper.refreshItemAt(0).render();
|
|
932
863
|
return this;
|
|
933
864
|
}
|
|
934
|
-
/**
|
|
935
|
-
* @returns {string}
|
|
936
|
-
*/
|
|
937
865
|
getNoResultsText() {
|
|
938
866
|
return this._p.noResultsText;
|
|
939
867
|
}
|
|
940
|
-
/**
|
|
941
|
-
* @param {number} window
|
|
942
|
-
* @returns {DropList}
|
|
943
|
-
*/
|
|
944
868
|
setFilterThrottleWindow(window) {
|
|
945
869
|
const p = this._p;
|
|
946
870
|
p.filterThrottleWindow = window;
|
|
947
871
|
let isScheduled = p.throttledRefilterItems ? p.throttledRefilterItems.isScheduled() : false;
|
|
948
872
|
if (p.throttledRefilterItems) p.throttledRefilterItems.cancel();
|
|
949
|
-
p.throttledRefilterItems = throttle(() => this._refilterItems(), p.filterThrottleWindow
|
|
873
|
+
p.throttledRefilterItems = throttle(() => this._refilterItems(), p.filterThrottleWindow);
|
|
950
874
|
if (isScheduled) p.throttledRefilterItems();
|
|
951
875
|
return this;
|
|
952
876
|
}
|
|
953
|
-
/**
|
|
954
|
-
* @returns {number}
|
|
955
|
-
*/
|
|
956
877
|
getFilterThrottleWindow() {
|
|
957
878
|
return this._p.filterThrottleWindow;
|
|
958
879
|
}
|
|
959
|
-
/**
|
|
960
|
-
* @param {boolean} value
|
|
961
|
-
* @returns {DropList}
|
|
962
|
-
*/
|
|
963
880
|
setFilterOnEmptyTerm(value) {
|
|
964
881
|
const p = this._p;
|
|
965
882
|
if (p.filterOnEmptyTerm === value) return this;
|
|
@@ -967,16 +884,9 @@ var DropList = class DropList {
|
|
|
967
884
|
p.throttledRefilterItems();
|
|
968
885
|
return this;
|
|
969
886
|
}
|
|
970
|
-
/**
|
|
971
|
-
* @returns {boolean}
|
|
972
|
-
*/
|
|
973
887
|
getFilterOnEmptyTerm() {
|
|
974
888
|
return this._p.filterOnEmptyTerm;
|
|
975
889
|
}
|
|
976
|
-
/**
|
|
977
|
-
* @param {boolean} value
|
|
978
|
-
* @returns {DropList}
|
|
979
|
-
*/
|
|
980
890
|
setFilterGroups(value) {
|
|
981
891
|
const p = this._p;
|
|
982
892
|
if (p.filterGroups === value) return this;
|
|
@@ -984,52 +894,30 @@ var DropList = class DropList {
|
|
|
984
894
|
p.throttledRefilterItems();
|
|
985
895
|
return this;
|
|
986
896
|
}
|
|
987
|
-
/**
|
|
988
|
-
* @returns {boolean}
|
|
989
|
-
*/
|
|
990
897
|
getFilterGroups() {
|
|
991
898
|
return this._p.filterGroups;
|
|
992
899
|
}
|
|
993
|
-
|
|
994
|
-
* @param {boolean} value
|
|
995
|
-
* @returns {DropList}
|
|
996
|
-
*/
|
|
997
|
-
setFilterEmptyGroups(value) {
|
|
900
|
+
setFilterEmptyGroups(value = true) {
|
|
998
901
|
const p = this._p;
|
|
999
902
|
if (p.filterEmptyGroups === value) return this;
|
|
1000
903
|
p.filterEmptyGroups = value;
|
|
1001
904
|
p.throttledRefilterItems();
|
|
1002
905
|
return this;
|
|
1003
906
|
}
|
|
1004
|
-
/**
|
|
1005
|
-
* @returns {boolean}
|
|
1006
|
-
*/
|
|
1007
907
|
getFilterEmptyGroups() {
|
|
1008
908
|
return this._p.filterEmptyGroups;
|
|
1009
909
|
}
|
|
1010
|
-
/**
|
|
1011
|
-
* @param {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} fn
|
|
1012
|
-
* @returns {DropList}
|
|
1013
|
-
*/
|
|
1014
910
|
setFilterFn(fn) {
|
|
1015
911
|
const p = this._p;
|
|
912
|
+
fn ??= null;
|
|
1016
913
|
if (p.filterFn === fn) return this;
|
|
1017
914
|
p.filterFn = fn;
|
|
1018
915
|
p.throttledRefilterItems();
|
|
1019
916
|
return this;
|
|
1020
917
|
}
|
|
1021
|
-
/**
|
|
1022
|
-
* @returns {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)}
|
|
1023
|
-
*/
|
|
1024
918
|
getFilterFn() {
|
|
1025
919
|
return this._p.filterFn;
|
|
1026
920
|
}
|
|
1027
|
-
/**
|
|
1028
|
-
*
|
|
1029
|
-
* @param {DropList.PositionOptions} [positionOptions]
|
|
1030
|
-
* @returns {DropList}
|
|
1031
|
-
* @public
|
|
1032
|
-
*/
|
|
1033
921
|
relayout(positionOptions) {
|
|
1034
922
|
const p = this._p, el = p.el, menuEl = p.menuEl;
|
|
1035
923
|
if (!this.isVisible()) return this;
|
|
@@ -1171,10 +1059,6 @@ var DropList = class DropList {
|
|
|
1171
1059
|
}
|
|
1172
1060
|
/**
|
|
1173
1061
|
* Set the checked mode of a specific value.
|
|
1174
|
-
* @public
|
|
1175
|
-
* @param {*} value - array of values to check
|
|
1176
|
-
* @param {boolean} checked - will the value be checked?
|
|
1177
|
-
* @returns {DropList} self
|
|
1178
1062
|
*/
|
|
1179
1063
|
setItemChecked(value, checked) {
|
|
1180
1064
|
const p = this._p;
|
|
@@ -1194,9 +1078,6 @@ var DropList = class DropList {
|
|
|
1194
1078
|
}
|
|
1195
1079
|
/**
|
|
1196
1080
|
* Set the checked values. All the other values will be unchecked,
|
|
1197
|
-
* @public
|
|
1198
|
-
* @param {Array<*>} values - array of values to check
|
|
1199
|
-
* @returns {DropList} self
|
|
1200
1081
|
*/
|
|
1201
1082
|
setCheckedValues(values) {
|
|
1202
1083
|
const p = this._p;
|
|
@@ -1219,11 +1100,9 @@ var DropList = class DropList {
|
|
|
1219
1100
|
}
|
|
1220
1101
|
/**
|
|
1221
1102
|
* Get all checked values. Returns array of item values.
|
|
1222
|
-
* @
|
|
1223
|
-
* @param {boolean} excludeGroups=false Exclude group items
|
|
1224
|
-
* @returns {Array<*>} self
|
|
1103
|
+
* @param excludeGroups Exclude group items
|
|
1225
1104
|
*/
|
|
1226
|
-
getCheckedValues(excludeGroups) {
|
|
1105
|
+
getCheckedValues(excludeGroups = false) {
|
|
1227
1106
|
const p = this._p;
|
|
1228
1107
|
excludeGroups = excludeGroups && p.groupCount > 0;
|
|
1229
1108
|
let values = [];
|
|
@@ -1237,11 +1116,9 @@ var DropList = class DropList {
|
|
|
1237
1116
|
}
|
|
1238
1117
|
/**
|
|
1239
1118
|
* Get all checked items. Returns array of actual item data object.
|
|
1240
|
-
* @
|
|
1241
|
-
* @param {boolean} excludeGroups=false Exclude group items
|
|
1242
|
-
* @returns {DropList.Item[]}
|
|
1119
|
+
* @param excludeGroups Exclude group items
|
|
1243
1120
|
*/
|
|
1244
|
-
getCheckedItems(excludeGroups) {
|
|
1121
|
+
getCheckedItems(excludeGroups = false) {
|
|
1245
1122
|
const p = this._p;
|
|
1246
1123
|
excludeGroups = excludeGroups && p.groupCount > 0;
|
|
1247
1124
|
const items = [];
|
|
@@ -1253,12 +1130,6 @@ var DropList = class DropList {
|
|
|
1253
1130
|
}
|
|
1254
1131
|
return items;
|
|
1255
1132
|
}
|
|
1256
|
-
/**
|
|
1257
|
-
*
|
|
1258
|
-
* @param {DropList.PositionOptions?} [positionOptions]
|
|
1259
|
-
* @returns {DropList}
|
|
1260
|
-
* @public
|
|
1261
|
-
*/
|
|
1262
1133
|
show(positionOptions) {
|
|
1263
1134
|
const p = this._p;
|
|
1264
1135
|
p.hiding = false;
|
|
@@ -1292,7 +1163,7 @@ var DropList = class DropList {
|
|
|
1292
1163
|
if (this.isVisible()) this._trigger("show");
|
|
1293
1164
|
return this;
|
|
1294
1165
|
}
|
|
1295
|
-
hide() {
|
|
1166
|
+
hide(event) {
|
|
1296
1167
|
const p = this._p, el = p.el;
|
|
1297
1168
|
if (p.onDocumentMouseDown) {
|
|
1298
1169
|
p.sink.remove(document, "mousedown", p.onDocumentMouseDown);
|
|
@@ -1342,7 +1213,6 @@ var DropList = class DropList {
|
|
|
1342
1213
|
/**
|
|
1343
1214
|
* Change visibility of the header element
|
|
1344
1215
|
* You should probably call `relayout()` after this.
|
|
1345
|
-
* @param {boolean} visible
|
|
1346
1216
|
*/
|
|
1347
1217
|
setHeaderVisible(visible) {
|
|
1348
1218
|
if (this.isHeaderVisible() === !!visible) return;
|
|
@@ -1351,14 +1221,12 @@ var DropList = class DropList {
|
|
|
1351
1221
|
}
|
|
1352
1222
|
/**
|
|
1353
1223
|
* Is the header element visible?
|
|
1354
|
-
* @returns {boolean}
|
|
1355
1224
|
*/
|
|
1356
1225
|
isHeaderVisible() {
|
|
1357
1226
|
return !!this._p.headerEl.parentNode;
|
|
1358
1227
|
}
|
|
1359
1228
|
/**
|
|
1360
1229
|
* Get a reference to the header element in order to add custom content.
|
|
1361
|
-
* @returns {Element}
|
|
1362
1230
|
*/
|
|
1363
1231
|
getHeaderElement() {
|
|
1364
1232
|
return this._p.headerEl;
|
|
@@ -1366,7 +1234,6 @@ var DropList = class DropList {
|
|
|
1366
1234
|
/**
|
|
1367
1235
|
* Change visibility of the footer element
|
|
1368
1236
|
* You should probably call `relayout()` after this.
|
|
1369
|
-
* @param {boolean} visible
|
|
1370
1237
|
*/
|
|
1371
1238
|
setFooterVisible(visible) {
|
|
1372
1239
|
if (this.isFooterVisible() === !!visible) return;
|
|
@@ -1375,14 +1242,12 @@ var DropList = class DropList {
|
|
|
1375
1242
|
}
|
|
1376
1243
|
/**
|
|
1377
1244
|
* Is the footer element visible?
|
|
1378
|
-
* @returns {boolean}
|
|
1379
1245
|
*/
|
|
1380
1246
|
isFooterVisible() {
|
|
1381
1247
|
return !!this._p.footerEl.parentNode;
|
|
1382
1248
|
}
|
|
1383
1249
|
/**
|
|
1384
1250
|
* Get a reference to the footer element in order to add custom content.
|
|
1385
|
-
* @returns {Element}
|
|
1386
1251
|
*/
|
|
1387
1252
|
getFooterElement() {
|
|
1388
1253
|
return this._p.footerEl;
|
|
@@ -1390,7 +1255,6 @@ var DropList = class DropList {
|
|
|
1390
1255
|
/**
|
|
1391
1256
|
* Set inline search visibility
|
|
1392
1257
|
* You should probably call `relayout()` after this.
|
|
1393
|
-
* @param {boolean} searchable
|
|
1394
1258
|
*/
|
|
1395
1259
|
setSearchable(searchable) {
|
|
1396
1260
|
const p = this._p;
|
|
@@ -1416,7 +1280,6 @@ var DropList = class DropList {
|
|
|
1416
1280
|
}
|
|
1417
1281
|
/**
|
|
1418
1282
|
* Set the placeholder text of the inline search box
|
|
1419
|
-
* @param {string} placeholder
|
|
1420
1283
|
*/
|
|
1421
1284
|
setSearchPlaceholder(placeholder) {
|
|
1422
1285
|
const p = this._p;
|
|
@@ -1464,6 +1327,7 @@ var DropList = class DropList {
|
|
|
1464
1327
|
}
|
|
1465
1328
|
return this;
|
|
1466
1329
|
}
|
|
1330
|
+
/** @internal */
|
|
1467
1331
|
_showSublist(item, itemElement) {
|
|
1468
1332
|
if (!item._subitems?.length) return;
|
|
1469
1333
|
const p = this._p;
|
|
@@ -1539,6 +1403,7 @@ var DropList = class DropList {
|
|
|
1539
1403
|
droplist.show();
|
|
1540
1404
|
droplist.el.focus();
|
|
1541
1405
|
}
|
|
1406
|
+
/** @internal */
|
|
1542
1407
|
_hideSublist() {
|
|
1543
1408
|
const p = this._p;
|
|
1544
1409
|
if (!p.currentSubDropList) return;
|
|
@@ -1638,6 +1503,7 @@ var DropList = class DropList {
|
|
|
1638
1503
|
}
|
|
1639
1504
|
return this;
|
|
1640
1505
|
}
|
|
1506
|
+
/** @internal */
|
|
1641
1507
|
_scrollItemIndexIntoView(itemIndex) {
|
|
1642
1508
|
const p = this._p;
|
|
1643
1509
|
if (this._hasScroll()) {
|
|
@@ -1658,9 +1524,6 @@ var DropList = class DropList {
|
|
|
1658
1524
|
}
|
|
1659
1525
|
/**
|
|
1660
1526
|
* Register an event handler
|
|
1661
|
-
* @param {(string|'*')?} event
|
|
1662
|
-
* @param {function(any)} handler
|
|
1663
|
-
* @returns {DropList}
|
|
1664
1527
|
*/
|
|
1665
1528
|
on(event, handler) {
|
|
1666
1529
|
this._p.mitt.on(event, handler);
|
|
@@ -1668,9 +1531,6 @@ var DropList = class DropList {
|
|
|
1668
1531
|
}
|
|
1669
1532
|
/**
|
|
1670
1533
|
* Register a one time event handler
|
|
1671
|
-
* @param {(string|'*')?} event
|
|
1672
|
-
* @param {function(any)} handler
|
|
1673
|
-
* @returns {DropList}
|
|
1674
1534
|
*/
|
|
1675
1535
|
once(event, handler) {
|
|
1676
1536
|
let wrapped = (value) => {
|
|
@@ -1682,9 +1542,6 @@ var DropList = class DropList {
|
|
|
1682
1542
|
}
|
|
1683
1543
|
/**
|
|
1684
1544
|
* Remove an `handler` for `event`, all events for `event`, or all events completely.
|
|
1685
|
-
* @param {(string|'*')?} event
|
|
1686
|
-
* @param {function(any)} handler
|
|
1687
|
-
* @returns {DropList}
|
|
1688
1545
|
*/
|
|
1689
1546
|
off(event, handler) {
|
|
1690
1547
|
if (!event && !event) this._p.mitt.all.clear();
|
|
@@ -1693,14 +1550,12 @@ var DropList = class DropList {
|
|
|
1693
1550
|
}
|
|
1694
1551
|
/**
|
|
1695
1552
|
* Emit an event
|
|
1696
|
-
* @param {string} event
|
|
1697
|
-
* @param {any} value
|
|
1698
|
-
* @returns {DropList}
|
|
1699
1553
|
*/
|
|
1700
1554
|
emit(event, value) {
|
|
1701
1555
|
this._p.mitt.emit(event, value);
|
|
1702
1556
|
return this;
|
|
1703
1557
|
}
|
|
1558
|
+
/** @internal */
|
|
1704
1559
|
_getItemIndex(item) {
|
|
1705
1560
|
const p = this._p;
|
|
1706
1561
|
let itemIndex = -1;
|
|
@@ -1714,6 +1569,7 @@ var DropList = class DropList {
|
|
|
1714
1569
|
}
|
|
1715
1570
|
return itemIndex;
|
|
1716
1571
|
}
|
|
1572
|
+
/** @internal */
|
|
1717
1573
|
_setSingleSelectedItemEl(itemEl, value) {
|
|
1718
1574
|
const p = this._p;
|
|
1719
1575
|
if (p.singleSelectedItemEl) {
|
|
@@ -1728,15 +1584,15 @@ var DropList = class DropList {
|
|
|
1728
1584
|
return this;
|
|
1729
1585
|
}
|
|
1730
1586
|
/**
|
|
1731
|
-
* @param {string} event
|
|
1732
|
-
* @param {*} [data]
|
|
1733
1587
|
* @private
|
|
1588
|
+
* @internal
|
|
1734
1589
|
*/
|
|
1735
1590
|
_trigger(event, data) {
|
|
1736
1591
|
const p = this._p;
|
|
1737
1592
|
if (p.on) p.on(event, ...data === void 0 ? [] : [data]);
|
|
1738
1593
|
p.mitt.emit(event, data);
|
|
1739
1594
|
}
|
|
1595
|
+
/** @internal */
|
|
1740
1596
|
_itemUpAction(event, itemEl) {
|
|
1741
1597
|
if ((0, _danielgindi_dom_utils_lib_Dom.closestUntil)(event.target, ".requires-pointer-events,button", itemEl)) return;
|
|
1742
1598
|
let p = this._p;
|
|
@@ -1749,6 +1605,7 @@ var DropList = class DropList {
|
|
|
1749
1605
|
}, 0);
|
|
1750
1606
|
}
|
|
1751
1607
|
}
|
|
1608
|
+
/** @internal */
|
|
1752
1609
|
_hookMouseEvents() {
|
|
1753
1610
|
const p = this._p;
|
|
1754
1611
|
p.sink.add(p.el, "mouseup", (event) => {
|
|
@@ -1762,9 +1619,11 @@ var DropList = class DropList {
|
|
|
1762
1619
|
this._handleMouseOver(event, li);
|
|
1763
1620
|
});
|
|
1764
1621
|
}
|
|
1622
|
+
/** @internal */
|
|
1765
1623
|
_handleMouseOver(event, itemEl) {
|
|
1766
1624
|
this._focus(event, itemEl, null, true);
|
|
1767
1625
|
}
|
|
1626
|
+
/** @internal */
|
|
1768
1627
|
_hookTouchEvents() {
|
|
1769
1628
|
const p = this._p;
|
|
1770
1629
|
let currentTouchId;
|
|
@@ -1804,6 +1663,7 @@ var DropList = class DropList {
|
|
|
1804
1663
|
});
|
|
1805
1664
|
});
|
|
1806
1665
|
}
|
|
1666
|
+
/** @internal */
|
|
1807
1667
|
_hookFocusEvents() {
|
|
1808
1668
|
const p = this._p;
|
|
1809
1669
|
p.sink.add(p.el, "focus", (event) => {
|
|
@@ -1821,10 +1681,12 @@ var DropList = class DropList {
|
|
|
1821
1681
|
});
|
|
1822
1682
|
}, true);
|
|
1823
1683
|
}
|
|
1684
|
+
/** @internal */
|
|
1824
1685
|
_hookKeyEvents() {
|
|
1825
1686
|
const p = this._p;
|
|
1826
1687
|
p.sink.add(p.el, "keydown", (evt) => this._keydown(evt));
|
|
1827
1688
|
}
|
|
1689
|
+
/** @internal */
|
|
1828
1690
|
_hookSearchEvents() {
|
|
1829
1691
|
const p = this._p;
|
|
1830
1692
|
if (!p.searchInput) return;
|
|
@@ -1835,6 +1697,7 @@ var DropList = class DropList {
|
|
|
1835
1697
|
p.throttledRefilterItems();
|
|
1836
1698
|
});
|
|
1837
1699
|
}
|
|
1700
|
+
/** @internal */
|
|
1838
1701
|
_keydown(event) {
|
|
1839
1702
|
const p = this._p;
|
|
1840
1703
|
if (p.keyDownHandler && p.keyDownHandler.call(this, event)) return;
|
|
@@ -1863,9 +1726,7 @@ var DropList = class DropList {
|
|
|
1863
1726
|
case keycode_js.VALUE_UP:
|
|
1864
1727
|
this.previous(event);
|
|
1865
1728
|
break;
|
|
1866
|
-
case keycode_js.VALUE_DOWN:
|
|
1867
|
-
this.next(event);
|
|
1868
|
-
break;
|
|
1729
|
+
case keycode_js.VALUE_DOWN: this.next(event);
|
|
1869
1730
|
}
|
|
1870
1731
|
break;
|
|
1871
1732
|
case keycode_js.VALUE_LEFT:
|
|
@@ -1897,6 +1758,7 @@ var DropList = class DropList {
|
|
|
1897
1758
|
if (!p.searchable) this._keydownFreeType(event, !this.isVisible());
|
|
1898
1759
|
}
|
|
1899
1760
|
}
|
|
1761
|
+
/** @internal */
|
|
1900
1762
|
_keydownFreeType(evt, autoSelect) {
|
|
1901
1763
|
const p = this._p;
|
|
1902
1764
|
const character = evt.key || String.fromCharCode(evt.keyCode);
|
|
@@ -1905,7 +1767,7 @@ var DropList = class DropList {
|
|
|
1905
1767
|
if (!isChar) return;
|
|
1906
1768
|
clearTimeout(p.filterTimer);
|
|
1907
1769
|
let keyword = (p.previousFilter || "") + character;
|
|
1908
|
-
let regex = new RegExp(`^${
|
|
1770
|
+
let regex = new RegExp(`^${escapeRegex(keyword)}`, "i");
|
|
1909
1771
|
let matchIndex = -1;
|
|
1910
1772
|
let item;
|
|
1911
1773
|
let focusItemIndex = p.focusItemIndex;
|
|
@@ -1920,7 +1782,7 @@ var DropList = class DropList {
|
|
|
1920
1782
|
}
|
|
1921
1783
|
if (matchIndex === -1) {
|
|
1922
1784
|
keyword = character;
|
|
1923
|
-
regex = new RegExp(`^${
|
|
1785
|
+
regex = new RegExp(`^${escapeRegex(keyword)}`, "i");
|
|
1924
1786
|
for (let i = 0, count = items.length; i < count; i++) {
|
|
1925
1787
|
if (matchIndex !== -1 && i < focusItemIndex) continue;
|
|
1926
1788
|
item = items[i];
|
|
@@ -1940,6 +1802,7 @@ var DropList = class DropList {
|
|
|
1940
1802
|
}, 1e3);
|
|
1941
1803
|
} else delete p.previousFilter;
|
|
1942
1804
|
}
|
|
1805
|
+
/** @internal */
|
|
1943
1806
|
_focus(event, itemEl, itemIndex, openSubitems) {
|
|
1944
1807
|
const p = this._p;
|
|
1945
1808
|
if (p._isFocusingItem) return;
|
|
@@ -1973,6 +1836,7 @@ var DropList = class DropList {
|
|
|
1973
1836
|
p._isFocusingItem = false;
|
|
1974
1837
|
if (openSubitems) this._showSublist(item, focusItemEl);
|
|
1975
1838
|
}
|
|
1839
|
+
/** @internal */
|
|
1976
1840
|
_delayBlurItemOnBlur() {
|
|
1977
1841
|
if (this[DestroyedSymbol$1]) return;
|
|
1978
1842
|
const p = this._p;
|
|
@@ -1983,6 +1847,7 @@ var DropList = class DropList {
|
|
|
1983
1847
|
this.blurFocusedItem();
|
|
1984
1848
|
}, p.autoItemBlurDelay);
|
|
1985
1849
|
}
|
|
1850
|
+
/** @internal */
|
|
1986
1851
|
_move(direction, event) {
|
|
1987
1852
|
const p = this._p;
|
|
1988
1853
|
let next, nextIndex, directionUp;
|
|
@@ -2052,10 +1917,12 @@ var DropList = class DropList {
|
|
|
2052
1917
|
this._focus(event, next || null, nextIndex, false);
|
|
2053
1918
|
if (!this.isVisible()) this.triggerItemSelection(item, event);
|
|
2054
1919
|
}
|
|
1920
|
+
/** @internal */
|
|
2055
1921
|
_hasScroll() {
|
|
2056
1922
|
const menuEl = this._p.menuEl;
|
|
2057
1923
|
return menuEl.clientHeight < menuEl.scrollHeight;
|
|
2058
1924
|
}
|
|
1925
|
+
/** @internal */
|
|
2059
1926
|
_updateGroupStateForItem(item) {
|
|
2060
1927
|
const p = this._p;
|
|
2061
1928
|
if (!p.multi) return this;
|
|
@@ -2099,6 +1966,7 @@ var DropList = class DropList {
|
|
|
2099
1966
|
}
|
|
2100
1967
|
return this;
|
|
2101
1968
|
}
|
|
1969
|
+
/** @internal */
|
|
2102
1970
|
_updateGroupCheckedState(groupIndex, fireEvents) {
|
|
2103
1971
|
const p = this._p;
|
|
2104
1972
|
if (!(p.multi && p.autoCheckGroupChildren && groupIndex > -1)) return this;
|
|
@@ -2131,7 +1999,7 @@ var DropList = class DropList {
|
|
|
2131
1999
|
}
|
|
2132
2000
|
/**
|
|
2133
2001
|
* @private
|
|
2134
|
-
* @
|
|
2002
|
+
* @internal
|
|
2135
2003
|
*/
|
|
2136
2004
|
_measureItem() {
|
|
2137
2005
|
const p = this._p;
|
|
@@ -2176,9 +2044,9 @@ var DropList = class DropList {
|
|
|
2176
2044
|
}
|
|
2177
2045
|
/**
|
|
2178
2046
|
* Determines whether the list should be in virtual mode, depending on the item count.
|
|
2179
|
-
* @param
|
|
2180
|
-
* @returns {DropList}
|
|
2047
|
+
* @param targetItemCount item count we are expecting. Defaults to current item count
|
|
2181
2048
|
* @private
|
|
2049
|
+
* @internal
|
|
2182
2050
|
*/
|
|
2183
2051
|
_determineVirtualMode(targetItemCount) {
|
|
2184
2052
|
const p = this._p;
|
|
@@ -2188,6 +2056,7 @@ var DropList = class DropList {
|
|
|
2188
2056
|
if (shouldBeVirtual !== p.virtualListHelper.isVirtual()) p.virtualListHelper.setVirtual(shouldBeVirtual).render();
|
|
2189
2057
|
return this;
|
|
2190
2058
|
}
|
|
2059
|
+
/** @internal */
|
|
2191
2060
|
_renderItemContent(item, itemEl) {
|
|
2192
2061
|
const p = this._p;
|
|
2193
2062
|
const originalItem = item[ItemSymbol];
|
|
@@ -2209,17 +2078,12 @@ var DropList = class DropList {
|
|
|
2209
2078
|
}
|
|
2210
2079
|
}
|
|
2211
2080
|
}
|
|
2212
|
-
/**
|
|
2213
|
-
*
|
|
2214
|
-
* @param {DropList.PositionOptions} [positionOptions=undefined]
|
|
2215
|
-
* @returns {number} new outer width
|
|
2216
|
-
* @private
|
|
2217
|
-
*/
|
|
2081
|
+
/** @internal */
|
|
2218
2082
|
_updateWidth(positionOptions) {
|
|
2219
2083
|
const p = this._p, el = p.el;
|
|
2220
2084
|
let targetWidth = 0;
|
|
2221
2085
|
if (positionOptions) if (typeof positionOptions.updateWidth === "number") targetWidth = positionOptions.updateWidth;
|
|
2222
|
-
else if (positionOptions.targetWidth != null) targetWidth = positionOptions.
|
|
2086
|
+
else if (positionOptions.targetWidth != null) targetWidth = positionOptions.targetWidth;
|
|
2223
2087
|
else targetWidth = (0, _danielgindi_dom_utils_lib_Css.getElementWidth)(positionOptions.target, true, true);
|
|
2224
2088
|
let autoWidth = 0;
|
|
2225
2089
|
if (!p.useExactTargetWidth || !targetWidth) if (p.estimateWidth || p.virtualListHelper.isVirtual()) autoWidth = p.lastMeasureItemWidth;
|
|
@@ -2241,15 +2105,10 @@ var DropList = class DropList {
|
|
|
2241
2105
|
}
|
|
2242
2106
|
};
|
|
2243
2107
|
//#endregion
|
|
2244
|
-
//#region lib/SelectBox.
|
|
2108
|
+
//#region src/lib/SelectBox.ts
|
|
2245
2109
|
var DestroyedSymbol = Symbol("destroyed");
|
|
2246
2110
|
var RestMultiItemsSymbol = Symbol("rest_multi_items");
|
|
2247
2111
|
var hasTouchCapability = !!("ontouchstart" in window || window.DocumentTouch && window.document instanceof window.DocumentTouch || window.navigator.maxTouchPoints);
|
|
2248
|
-
/**
|
|
2249
|
-
* @param {Element|EventTarget} el
|
|
2250
|
-
* @param {string} className
|
|
2251
|
-
* @returns {boolean}
|
|
2252
|
-
*/
|
|
2253
2112
|
var hasClass = function(el, className) {
|
|
2254
2113
|
if (el instanceof Element) return el.classList.contains(className);
|
|
2255
2114
|
return false;
|
|
@@ -2267,57 +2126,6 @@ var inputBackbufferCssProps = [
|
|
|
2267
2126
|
"padding-left",
|
|
2268
2127
|
"padding-right"
|
|
2269
2128
|
];
|
|
2270
|
-
/**
|
|
2271
|
-
* @typedef {Object} SelectBox.Options
|
|
2272
|
-
* @property {DropList.Options} [listOptions] options to pass to the `DropList`
|
|
2273
|
-
* @property {Element} [el] An element to attach to, instead of creating a new one
|
|
2274
|
-
* @property {string} [baseClassName='selectbox'] class name for the menu root element
|
|
2275
|
-
* @property {string|string[]} [additionalClasses]
|
|
2276
|
-
* @property {'ltr'|'rtl'|'auto'} [direction='auto']
|
|
2277
|
-
* @property {boolean} [disabled=false] Should start as disabled?
|
|
2278
|
-
* @property {boolean} [readOnly=false] Should start as readOnly?
|
|
2279
|
-
* @property {boolean} [clearable=true] Has clear button?
|
|
2280
|
-
* @property {boolean} [hasOpenIndicator=true] has open/close indicator?
|
|
2281
|
-
* @property {string} [placeholder=''] Placeholder text
|
|
2282
|
-
* @property {boolean} [sortSelectedItems=true] Should the selected items be sorted?
|
|
2283
|
-
* @property {boolean} [sortListItems=false] Sort list items
|
|
2284
|
-
* @property {boolean} [sortListCheckedFirst=true] When sorting - put checked items first (applicable to `multi` mode only)
|
|
2285
|
-
* @property {boolean} [treatGroupSelectionAsItems=false] Treat group items as normal items
|
|
2286
|
-
* @property {*[]} [stickyValues]
|
|
2287
|
-
* @property {function(a: DropList.ItemBase, b: DropList.ItemBase):number} [sortItemComparator]
|
|
2288
|
-
* @property {boolean} [splitListCheckedGroups=true] Split groups to "checked" and "unchecked", works with `sortListCheckedFirst` only
|
|
2289
|
-
* @property {boolean|'touch'} [blurOnSingleSelection='touch']
|
|
2290
|
-
* @property {boolean} [multi=false] can multiple values be selected?
|
|
2291
|
-
* @property {boolean} [showSelection=true] show selection? if false, the placeholder will take effect
|
|
2292
|
-
* @property {boolean} [showPlaceholderInTooltip=false] show placeholder in title attribute
|
|
2293
|
-
* @property {function(items: DropList.ItemBase[]):string} [multiPlaceholderFormatter] formatter for placeholder for multi items mode
|
|
2294
|
-
* @property {string} [labelProp='label']
|
|
2295
|
-
* @property {string} [valueProp='value']
|
|
2296
|
-
* @property {string} [multiItemLabelProp='short_label']
|
|
2297
|
-
* @property {'after'|'before'|'none'} [multiItemRemovePosition='after']
|
|
2298
|
-
* @property {number} [maxMultiItems] maximum number of multi items. The rest will get a single item to represent.
|
|
2299
|
-
* @property {function(count: number, items: DropList.ItemBase[]):string} [multiItemsRestLabelProvider] label for the item representing the rest of the items.
|
|
2300
|
-
* @property {DropList.ItemBase[]|null} [items] initial items
|
|
2301
|
-
* @property {*[]|null} [selectedValues] initial selected values
|
|
2302
|
-
* @property {*|*[]|null} [value] initial selected value
|
|
2303
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderSingleItem]
|
|
2304
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderSingleItem]
|
|
2305
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderMultiItem]
|
|
2306
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderMultiItem]
|
|
2307
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderRestMultiItem]
|
|
2308
|
-
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderRestMultiItem]
|
|
2309
|
-
* @property {boolean} [searchable=false] is it searchable?
|
|
2310
|
-
* @property {boolean} [allowTypeToSelect=true] default behavior of type to select (focus first item starting with the search term) when searchable is true
|
|
2311
|
-
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
2312
|
-
* @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.
|
|
2313
|
-
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
2314
|
-
* @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
|
|
2315
|
-
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
2316
|
-
* @property {function(name: string, ...args)} [on]
|
|
2317
|
-
* @property {boolean} [isLoadingMode]
|
|
2318
|
-
* @property {boolean} [closeListWhenLoading] whether we should close the list automatically when loading
|
|
2319
|
-
* @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>
|
|
2320
|
-
* */
|
|
2321
2129
|
var DefaultOptions$1 = {
|
|
2322
2130
|
el: null,
|
|
2323
2131
|
baseClassName: "selectbox",
|
|
@@ -2356,12 +2164,6 @@ var DefaultOptions$1 = {
|
|
|
2356
2164
|
closeListWhenLoading: true,
|
|
2357
2165
|
clearInputWhen: ["single_close", "multi_select_single"]
|
|
2358
2166
|
};
|
|
2359
|
-
/**
|
|
2360
|
-
*
|
|
2361
|
-
* @param {DropList.ItemBase[]} items
|
|
2362
|
-
* @param {string} labelProp
|
|
2363
|
-
* @returns {string}
|
|
2364
|
-
*/
|
|
2365
2167
|
var defaultMultiPlaceholderFormatter = (items, labelProp) => {
|
|
2366
2168
|
if (items.length === 0) return "";
|
|
2367
2169
|
let title = items[0][labelProp] + "";
|
|
@@ -2385,9 +2187,6 @@ function restoreFocusState(state) {
|
|
|
2385
2187
|
return true;
|
|
2386
2188
|
}
|
|
2387
2189
|
var SelectBox = class {
|
|
2388
|
-
/**
|
|
2389
|
-
* @param {SelectBox.Options} options
|
|
2390
|
-
*/
|
|
2391
2190
|
constructor(options) {
|
|
2392
2191
|
const o = { ...DefaultOptions$1 };
|
|
2393
2192
|
for (let [key, value] of Object.entries(
|
|
@@ -2436,6 +2235,7 @@ var SelectBox = class {
|
|
|
2436
2235
|
on: o.on || null,
|
|
2437
2236
|
silenceEvents: true,
|
|
2438
2237
|
mitt: (0, mitt.default)(),
|
|
2238
|
+
onError: o.onError,
|
|
2439
2239
|
isLoadingMode: !!o.isLoadingMode,
|
|
2440
2240
|
closeListWhenLoading: !!o.closeListWhenLoading,
|
|
2441
2241
|
clearInputWhen: Array.isArray(o.clearInputWhen) ? o.clearInputWhen.slice(0) : [],
|
|
@@ -2451,7 +2251,11 @@ var SelectBox = class {
|
|
|
2451
2251
|
filterThrottleWindow: o.filterThrottleWindow,
|
|
2452
2252
|
filterOnEmptyTerm: o.filterOnEmptyTerm,
|
|
2453
2253
|
filterFn: null,
|
|
2454
|
-
filterTerm: ""
|
|
2254
|
+
filterTerm: "",
|
|
2255
|
+
dropListVisible: false,
|
|
2256
|
+
lastActiveElement: null,
|
|
2257
|
+
lastKeyAllowsNonTypeKeys: false,
|
|
2258
|
+
presenceInt: null
|
|
2455
2259
|
};
|
|
2456
2260
|
let el = o.el;
|
|
2457
2261
|
if (el instanceof Element) p.ownsEl = false;
|
|
@@ -2570,21 +2374,15 @@ var SelectBox = class {
|
|
|
2570
2374
|
}
|
|
2571
2375
|
/**
|
|
2572
2376
|
* Returns true if other is an inclusive descendant of droplist node, false otherwise, and undefined if the droplist is not initiated.
|
|
2573
|
-
* @param {Node} other
|
|
2574
|
-
* @param {boolean} [considerSubmenus=true]
|
|
2575
|
-
* @returns {boolean|undefined}
|
|
2576
2377
|
*/
|
|
2577
2378
|
droplistElContains(other, considerSubmenus = true) {
|
|
2578
2379
|
return this._p.dropList?.elContains(other, considerSubmenus);
|
|
2579
2380
|
}
|
|
2580
2381
|
/**
|
|
2581
2382
|
* Enables the control
|
|
2582
|
-
* @param {boolean=true} enabled Should the control be enabled?
|
|
2583
|
-
* @returns {SelectBox}
|
|
2584
2383
|
*/
|
|
2585
|
-
enable(enabled) {
|
|
2384
|
+
enable(enabled = true) {
|
|
2586
2385
|
const p = this._p;
|
|
2587
|
-
if (enabled === void 0) enabled = true;
|
|
2588
2386
|
p.disabled = !enabled;
|
|
2589
2387
|
p.el.setAttribute("aria-disabled", p.disabled.toString());
|
|
2590
2388
|
p.input.disabled = !!p.disabled;
|
|
@@ -2595,50 +2393,38 @@ var SelectBox = class {
|
|
|
2595
2393
|
}
|
|
2596
2394
|
/**
|
|
2597
2395
|
* Is the control enabled?
|
|
2598
|
-
* @returns {boolean}
|
|
2599
2396
|
*/
|
|
2600
2397
|
isEnabled() {
|
|
2601
2398
|
return !this._p.disabled;
|
|
2602
2399
|
}
|
|
2603
2400
|
/**
|
|
2604
2401
|
* Disables the control
|
|
2605
|
-
* @param {boolean=true} disabled Should the control be disabled?
|
|
2606
|
-
* @returns {SelectBox}
|
|
2607
2402
|
*/
|
|
2608
|
-
disable(disabled) {
|
|
2609
|
-
return this.enable(
|
|
2403
|
+
disable(disabled = true) {
|
|
2404
|
+
return this.enable(!disabled);
|
|
2610
2405
|
}
|
|
2611
2406
|
/**
|
|
2612
2407
|
* Is the control disabled?
|
|
2613
|
-
* @returns {boolean}
|
|
2614
2408
|
*/
|
|
2615
2409
|
isDisabled() {
|
|
2616
2410
|
return this._p.disabled;
|
|
2617
2411
|
}
|
|
2618
2412
|
/**
|
|
2619
2413
|
* Sets read only mode
|
|
2620
|
-
* @param {boolean=true} readOnly Should the control be read only?
|
|
2621
|
-
* @returns {SelectBox}
|
|
2622
2414
|
*/
|
|
2623
|
-
setReadOnly(readOnly) {
|
|
2415
|
+
setReadOnly(readOnly = true) {
|
|
2624
2416
|
const p = this._p;
|
|
2625
|
-
if (readOnly === void 0) readOnly = true;
|
|
2626
2417
|
p.readOnly = readOnly;
|
|
2627
2418
|
p.el.setAttribute("aria-readOnly", p.readOnly.toString());
|
|
2628
2419
|
p.input.readOnly = !(p.searchable || p.multi) || !!p.readOnly;
|
|
2629
2420
|
return this;
|
|
2630
2421
|
}
|
|
2631
2422
|
/**
|
|
2632
|
-
* Is the control
|
|
2633
|
-
* @returns {boolean}
|
|
2423
|
+
* Is the control read only?
|
|
2634
2424
|
*/
|
|
2635
2425
|
isReadOnly() {
|
|
2636
2426
|
return this._p.readOnly;
|
|
2637
2427
|
}
|
|
2638
|
-
/**
|
|
2639
|
-
* @param {string|string[]} classes
|
|
2640
|
-
* @returns {SelectBox}
|
|
2641
|
-
*/
|
|
2642
2428
|
setAdditionalClasses(classes) {
|
|
2643
2429
|
const p = this._p;
|
|
2644
2430
|
p.additionalClasses = classes;
|
|
@@ -2646,10 +2432,8 @@ var SelectBox = class {
|
|
|
2646
2432
|
return this;
|
|
2647
2433
|
}
|
|
2648
2434
|
/**
|
|
2649
|
-
*
|
|
2650
|
-
* @param
|
|
2651
|
-
* @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
|
|
2652
|
-
* @returns {SelectBox}
|
|
2435
|
+
* @param items the items to set (not values)
|
|
2436
|
+
* @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
|
|
2653
2437
|
*/
|
|
2654
2438
|
setItems(items, resetValues = true) {
|
|
2655
2439
|
const p = this._p;
|
|
@@ -2685,16 +2469,9 @@ var SelectBox = class {
|
|
|
2685
2469
|
}
|
|
2686
2470
|
if (p.dropList) p.dropList.updateItemByValue(value, newItem);
|
|
2687
2471
|
}
|
|
2688
|
-
/**
|
|
2689
|
-
* @returns {DropList.ItemBase[]|*}
|
|
2690
|
-
*/
|
|
2691
2472
|
getItems() {
|
|
2692
2473
|
return this._p.items;
|
|
2693
2474
|
}
|
|
2694
|
-
/**
|
|
2695
|
-
* @param {boolean} clearable
|
|
2696
|
-
* @returns {SelectBox}
|
|
2697
|
-
*/
|
|
2698
2475
|
setClearable(clearable) {
|
|
2699
2476
|
clearable = !!clearable;
|
|
2700
2477
|
if (this._p.clearable === clearable) return this;
|
|
@@ -2702,16 +2479,9 @@ var SelectBox = class {
|
|
|
2702
2479
|
this._scheduleSync("render_clear");
|
|
2703
2480
|
return this;
|
|
2704
2481
|
}
|
|
2705
|
-
/**
|
|
2706
|
-
* @returns {boolean}
|
|
2707
|
-
*/
|
|
2708
2482
|
getClearable() {
|
|
2709
2483
|
return this._p.clearable;
|
|
2710
2484
|
}
|
|
2711
|
-
/**
|
|
2712
|
-
* @param {boolean} enabled
|
|
2713
|
-
* @returns {SelectBox}
|
|
2714
|
-
*/
|
|
2715
2485
|
setHasOpenIndicator(enabled) {
|
|
2716
2486
|
enabled = !!enabled;
|
|
2717
2487
|
if (this._p.hasOpenIndicator === enabled) return this;
|
|
@@ -2719,31 +2489,20 @@ var SelectBox = class {
|
|
|
2719
2489
|
this._scheduleSync("render_base");
|
|
2720
2490
|
return this;
|
|
2721
2491
|
}
|
|
2722
|
-
/**
|
|
2723
|
-
* @returns {boolean}
|
|
2724
|
-
*/
|
|
2725
2492
|
getHasOpenIndicator() {
|
|
2726
2493
|
return this._p.hasOpenIndicator;
|
|
2727
2494
|
}
|
|
2728
|
-
/**
|
|
2729
|
-
* @param {string} placeholder
|
|
2730
|
-
* @returns {SelectBox}
|
|
2731
|
-
*/
|
|
2732
2495
|
setPlaceholder(placeholder) {
|
|
2733
2496
|
this._p.placeholder = placeholder == null ? "" : String(placeholder);
|
|
2734
2497
|
this._scheduleSync("render_base");
|
|
2735
2498
|
return this;
|
|
2736
2499
|
}
|
|
2737
|
-
/**
|
|
2738
|
-
* @returns {string}
|
|
2739
|
-
*/
|
|
2740
2500
|
getPlaceHolder() {
|
|
2741
2501
|
return this._p.placeholder;
|
|
2742
2502
|
}
|
|
2743
2503
|
/**
|
|
2744
|
-
* @param
|
|
2745
|
-
* @param
|
|
2746
|
-
* @returns {SelectBox}
|
|
2504
|
+
* @param term the search term to set
|
|
2505
|
+
* @param performSearch should actually perform the search, or just set the input's text?
|
|
2747
2506
|
*/
|
|
2748
2507
|
setSearchTerm(term, performSearch = false) {
|
|
2749
2508
|
const p = this._p;
|
|
@@ -2757,9 +2516,6 @@ var SelectBox = class {
|
|
|
2757
2516
|
}
|
|
2758
2517
|
return this;
|
|
2759
2518
|
}
|
|
2760
|
-
/**
|
|
2761
|
-
* @returns {string}
|
|
2762
|
-
*/
|
|
2763
2519
|
getSearchTerm() {
|
|
2764
2520
|
const p = this._p;
|
|
2765
2521
|
if (p.input) return p.input.value;
|
|
@@ -2769,10 +2525,6 @@ var SelectBox = class {
|
|
|
2769
2525
|
this._p.dropList?.invokeRefilter();
|
|
2770
2526
|
return this;
|
|
2771
2527
|
}
|
|
2772
|
-
/**
|
|
2773
|
-
* @param {boolean} sortSelectedItems
|
|
2774
|
-
* @returns {SelectBox}
|
|
2775
|
-
*/
|
|
2776
2528
|
setSortSelectedItems(sortSelectedItems) {
|
|
2777
2529
|
const p = this._p;
|
|
2778
2530
|
sortSelectedItems = !!sortSelectedItems;
|
|
@@ -2781,16 +2533,9 @@ var SelectBox = class {
|
|
|
2781
2533
|
this._scheduleSync("render_items");
|
|
2782
2534
|
return this;
|
|
2783
2535
|
}
|
|
2784
|
-
/**
|
|
2785
|
-
* @returns {boolean}
|
|
2786
|
-
*/
|
|
2787
2536
|
isSortSelectedItemsEnabled() {
|
|
2788
2537
|
return this._p.sortSelectedItems;
|
|
2789
2538
|
}
|
|
2790
|
-
/**
|
|
2791
|
-
* @param {boolean} sortListItems
|
|
2792
|
-
* @returns {SelectBox}
|
|
2793
|
-
*/
|
|
2794
2539
|
setSortListItems(sortListItems) {
|
|
2795
2540
|
const p = this._p;
|
|
2796
2541
|
sortListItems = !!sortListItems;
|
|
@@ -2800,16 +2545,9 @@ var SelectBox = class {
|
|
|
2800
2545
|
this._scheduleSync("render_list");
|
|
2801
2546
|
return this;
|
|
2802
2547
|
}
|
|
2803
|
-
/**
|
|
2804
|
-
* @returns {boolean}
|
|
2805
|
-
*/
|
|
2806
2548
|
isSortListItemsEnabled() {
|
|
2807
2549
|
return this._p.sortListItems;
|
|
2808
2550
|
}
|
|
2809
|
-
/**
|
|
2810
|
-
* @param {boolean} sortListCheckedFirst
|
|
2811
|
-
* @returns {SelectBox}
|
|
2812
|
-
*/
|
|
2813
2551
|
setSortListCheckedFirst(sortListCheckedFirst) {
|
|
2814
2552
|
const p = this._p;
|
|
2815
2553
|
sortListCheckedFirst = !!sortListCheckedFirst;
|
|
@@ -2819,16 +2557,9 @@ var SelectBox = class {
|
|
|
2819
2557
|
this._scheduleSync("render_list");
|
|
2820
2558
|
return this;
|
|
2821
2559
|
}
|
|
2822
|
-
/**
|
|
2823
|
-
* @returns {boolean}
|
|
2824
|
-
*/
|
|
2825
2560
|
isSortListCheckedFirstEnabled() {
|
|
2826
2561
|
return this._p.sortListCheckedFirst;
|
|
2827
2562
|
}
|
|
2828
|
-
/**
|
|
2829
|
-
* @param {*[]} values
|
|
2830
|
-
* @returns {SelectBox}
|
|
2831
|
-
*/
|
|
2832
2563
|
setStickyValues(values) {
|
|
2833
2564
|
const p = this._p;
|
|
2834
2565
|
p.stickyValues = Array.isArray(values) ? new Set(values) : null;
|
|
@@ -2836,16 +2567,9 @@ var SelectBox = class {
|
|
|
2836
2567
|
this._scheduleSync("render_list");
|
|
2837
2568
|
return this;
|
|
2838
2569
|
}
|
|
2839
|
-
/**
|
|
2840
|
-
* @returns {*[]}
|
|
2841
|
-
*/
|
|
2842
2570
|
getStickyValues() {
|
|
2843
2571
|
return this._p.stickyValues ? Array.from(this._p.stickyValues) : null;
|
|
2844
2572
|
}
|
|
2845
|
-
/**
|
|
2846
|
-
* @param {function(a: DropList.ItemBase, b: DropList.ItemBase):number} comparator
|
|
2847
|
-
* @returns {SelectBox}
|
|
2848
|
-
*/
|
|
2849
2573
|
setSortItemComparator(comparator) {
|
|
2850
2574
|
const p = this._p;
|
|
2851
2575
|
if (p.sortItemComparator === comparator) return this;
|
|
@@ -2854,16 +2578,9 @@ var SelectBox = class {
|
|
|
2854
2578
|
this._scheduleSync("render_list");
|
|
2855
2579
|
return this;
|
|
2856
2580
|
}
|
|
2857
|
-
/**
|
|
2858
|
-
* @returns {function(a: DropList.ItemBase, b: DropList.ItemBase):number}
|
|
2859
|
-
*/
|
|
2860
2581
|
getSortItemComparator() {
|
|
2861
2582
|
return this._p.sortItemComparator;
|
|
2862
2583
|
}
|
|
2863
|
-
/**
|
|
2864
|
-
* @param {boolean} treatGroupSelectionAsItems
|
|
2865
|
-
* @returns {SelectBox}
|
|
2866
|
-
*/
|
|
2867
2584
|
setTreatGroupSelectionAsItems(treatGroupSelectionAsItems) {
|
|
2868
2585
|
const p = this._p;
|
|
2869
2586
|
treatGroupSelectionAsItems = !!treatGroupSelectionAsItems;
|
|
@@ -2875,16 +2592,9 @@ var SelectBox = class {
|
|
|
2875
2592
|
this._scheduleSync("render_list");
|
|
2876
2593
|
return this;
|
|
2877
2594
|
}
|
|
2878
|
-
/**
|
|
2879
|
-
* @returns {boolean}
|
|
2880
|
-
*/
|
|
2881
2595
|
isTreatGroupSelectionAsItemsEnabled() {
|
|
2882
2596
|
return !this._p.treatGroupSelectionAsItems;
|
|
2883
2597
|
}
|
|
2884
|
-
/**
|
|
2885
|
-
* @param {boolean} splitListCheckedGroups
|
|
2886
|
-
* @returns {SelectBox}
|
|
2887
|
-
*/
|
|
2888
2598
|
setSplitListCheckedGroups(splitListCheckedGroups) {
|
|
2889
2599
|
const p = this._p;
|
|
2890
2600
|
splitListCheckedGroups = !!splitListCheckedGroups;
|
|
@@ -2894,16 +2604,9 @@ var SelectBox = class {
|
|
|
2894
2604
|
this._scheduleSync("render_list");
|
|
2895
2605
|
return this;
|
|
2896
2606
|
}
|
|
2897
|
-
/**
|
|
2898
|
-
* @returns {boolean}
|
|
2899
|
-
*/
|
|
2900
2607
|
isSplitListCheckedGroupsEnabled() {
|
|
2901
2608
|
return this._p.splitListCheckedGroups;
|
|
2902
2609
|
}
|
|
2903
|
-
/**
|
|
2904
|
-
* @param {boolean} showSelection
|
|
2905
|
-
* @returns {SelectBox}
|
|
2906
|
-
*/
|
|
2907
2610
|
setShowSelection(showSelection) {
|
|
2908
2611
|
const p = this._p;
|
|
2909
2612
|
showSelection = !!showSelection;
|
|
@@ -2912,16 +2615,9 @@ var SelectBox = class {
|
|
|
2912
2615
|
this._scheduleSync("render_items");
|
|
2913
2616
|
return this;
|
|
2914
2617
|
}
|
|
2915
|
-
/**
|
|
2916
|
-
* @returns {boolean}
|
|
2917
|
-
*/
|
|
2918
2618
|
isShowSelectionEnabled() {
|
|
2919
2619
|
return this._p.showSelection;
|
|
2920
2620
|
}
|
|
2921
|
-
/**
|
|
2922
|
-
* @param {boolean} showPlaceholderInTooltip
|
|
2923
|
-
* @returns {SelectBox}
|
|
2924
|
-
*/
|
|
2925
2621
|
setShowPlaceholderInTooltip(showPlaceholderInTooltip) {
|
|
2926
2622
|
const p = this._p;
|
|
2927
2623
|
showPlaceholderInTooltip = !!showPlaceholderInTooltip;
|
|
@@ -2930,16 +2626,9 @@ var SelectBox = class {
|
|
|
2930
2626
|
this._scheduleSync("render_base");
|
|
2931
2627
|
return this;
|
|
2932
2628
|
}
|
|
2933
|
-
/**
|
|
2934
|
-
* @returns {boolean}
|
|
2935
|
-
*/
|
|
2936
2629
|
isShowPlaceholderInTooltipEnabled() {
|
|
2937
2630
|
return this._p.showPlaceholderInTooltip;
|
|
2938
2631
|
}
|
|
2939
|
-
/**
|
|
2940
|
-
* @param {function(items: DropList.ItemBase[]):string} formatter
|
|
2941
|
-
* @returns {SelectBox}
|
|
2942
|
-
*/
|
|
2943
2632
|
setMultiPlaceholderFormatter(formatter) {
|
|
2944
2633
|
const p = this._p;
|
|
2945
2634
|
if (p.multiPlaceholderFormatter === formatter) return this;
|
|
@@ -2947,26 +2636,15 @@ var SelectBox = class {
|
|
|
2947
2636
|
this._scheduleSync("render_base");
|
|
2948
2637
|
return this;
|
|
2949
2638
|
}
|
|
2950
|
-
/**
|
|
2951
|
-
* @param {boolean|'touch'} value
|
|
2952
|
-
* @returns {SelectBox}
|
|
2953
|
-
*/
|
|
2954
2639
|
setBlurOnSingleSelection(value) {
|
|
2955
2640
|
const p = this._p;
|
|
2956
2641
|
if (p.blurOnSingleSelection === value) return this;
|
|
2957
2642
|
p.blurOnSingleSelection = value;
|
|
2958
2643
|
return this;
|
|
2959
2644
|
}
|
|
2960
|
-
/**
|
|
2961
|
-
* @returns {boolean|'touch'}
|
|
2962
|
-
*/
|
|
2963
2645
|
getBlurOnSingleSelection() {
|
|
2964
2646
|
return this._p.blurOnSingleSelection;
|
|
2965
2647
|
}
|
|
2966
|
-
/**
|
|
2967
|
-
* @param {boolean} multi
|
|
2968
|
-
* @returns {SelectBox}
|
|
2969
|
-
*/
|
|
2970
2648
|
setMulti(multi) {
|
|
2971
2649
|
const p = this._p;
|
|
2972
2650
|
multi = !!multi;
|
|
@@ -2982,16 +2660,9 @@ var SelectBox = class {
|
|
|
2982
2660
|
this._scheduleSync("full");
|
|
2983
2661
|
return this;
|
|
2984
2662
|
}
|
|
2985
|
-
/**
|
|
2986
|
-
* @returns {boolean}
|
|
2987
|
-
*/
|
|
2988
2663
|
isMultiEnabled() {
|
|
2989
2664
|
return this._p.multi;
|
|
2990
2665
|
}
|
|
2991
|
-
/**
|
|
2992
|
-
* @param {boolean} searchable
|
|
2993
|
-
* @returns {SelectBox}
|
|
2994
|
-
*/
|
|
2995
2666
|
setSearchable(searchable) {
|
|
2996
2667
|
const p = this._p;
|
|
2997
2668
|
searchable = !!searchable;
|
|
@@ -3000,10 +2671,6 @@ var SelectBox = class {
|
|
|
3000
2671
|
this._scheduleSync("full");
|
|
3001
2672
|
return this;
|
|
3002
2673
|
}
|
|
3003
|
-
/**
|
|
3004
|
-
* @param {boolean} allowTypeToSelect
|
|
3005
|
-
* @returns {SelectBox}
|
|
3006
|
-
*/
|
|
3007
2674
|
setAllowTypeToSelect(allowTypeToSelect) {
|
|
3008
2675
|
const p = this._p;
|
|
3009
2676
|
allowTypeToSelect = !!allowTypeToSelect;
|
|
@@ -3011,129 +2678,71 @@ var SelectBox = class {
|
|
|
3011
2678
|
p.allowTypeToSelect = allowTypeToSelect;
|
|
3012
2679
|
return this;
|
|
3013
2680
|
}
|
|
3014
|
-
/**
|
|
3015
|
-
* @returns {boolean}
|
|
3016
|
-
*/
|
|
3017
2681
|
isSearchableEnabled() {
|
|
3018
2682
|
return this._p.searchable;
|
|
3019
2683
|
}
|
|
3020
|
-
/**
|
|
3021
|
-
* @param {string} noResultsText
|
|
3022
|
-
* @returns {SelectBox}
|
|
3023
|
-
*/
|
|
3024
2684
|
setNoResultsText(noResultsText) {
|
|
3025
2685
|
this._p.dropList?.setNoResultsText(noResultsText);
|
|
3026
2686
|
return this;
|
|
3027
2687
|
}
|
|
3028
|
-
/**
|
|
3029
|
-
* @returns {string}
|
|
3030
|
-
*/
|
|
3031
2688
|
getNoResultsText() {
|
|
3032
2689
|
return this._p.noResultsText;
|
|
3033
2690
|
}
|
|
3034
|
-
/**
|
|
3035
|
-
* @param {boolean} autoSelectTextOnCheck
|
|
3036
|
-
* @returns {SelectBox}
|
|
3037
|
-
*/
|
|
3038
2691
|
setAutoSelectTextOnCheck(autoSelectTextOnCheck) {
|
|
3039
2692
|
this._p.autoSelectTextOnCheck = autoSelectTextOnCheck;
|
|
3040
2693
|
return this;
|
|
3041
2694
|
}
|
|
3042
|
-
/**
|
|
3043
|
-
* @returns {boolean}
|
|
3044
|
-
*/
|
|
3045
2695
|
getAutoSelectTextOnCheck() {
|
|
3046
2696
|
return this._p.autoSelectTextOnCheck;
|
|
3047
2697
|
}
|
|
3048
|
-
/**
|
|
3049
|
-
* @param {number} window
|
|
3050
|
-
* @returns {SelectBox}
|
|
3051
|
-
*/
|
|
3052
2698
|
setFilterThrottleWindow(window) {
|
|
3053
2699
|
const p = this._p;
|
|
3054
2700
|
p.filterThrottleWindow = window;
|
|
3055
2701
|
p.dropList?.setFilterThrottleWindow(window);
|
|
3056
2702
|
return this;
|
|
3057
2703
|
}
|
|
3058
|
-
/**
|
|
3059
|
-
* @returns {number}
|
|
3060
|
-
*/
|
|
3061
2704
|
getFilterThrottleWindow() {
|
|
3062
2705
|
return this._p.filterThrottleWindow;
|
|
3063
2706
|
}
|
|
3064
|
-
/**
|
|
3065
|
-
* @param {boolean} value
|
|
3066
|
-
* @returns {SelectBox}
|
|
3067
|
-
*/
|
|
3068
2707
|
setFilterOnEmptyTerm(value) {
|
|
3069
2708
|
const p = this._p;
|
|
3070
2709
|
if (p.filterOnEmptyTerm === value) return this;
|
|
3071
2710
|
p.dropList?.setFilterOnEmptyTerm(value);
|
|
3072
2711
|
return this;
|
|
3073
2712
|
}
|
|
3074
|
-
/**
|
|
3075
|
-
* @returns {boolean}
|
|
3076
|
-
*/
|
|
3077
2713
|
getFilterOnEmptyTerm() {
|
|
3078
2714
|
return this._p.filterOnEmptyTerm;
|
|
3079
2715
|
}
|
|
3080
|
-
/**
|
|
3081
|
-
* @param {DropList.Options} listOptions
|
|
3082
|
-
* @returns {SelectBox}
|
|
3083
|
-
*/
|
|
3084
2716
|
setListOptions(listOptions) {
|
|
3085
2717
|
const p = this._p;
|
|
3086
2718
|
p.listOptions = listOptions;
|
|
3087
2719
|
this._setupDropdownMenu();
|
|
3088
2720
|
return this;
|
|
3089
2721
|
}
|
|
3090
|
-
/**
|
|
3091
|
-
* @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
|
|
3092
|
-
* @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
|
|
3093
|
-
* @returns {SelectBox})|null
|
|
3094
|
-
*/
|
|
3095
2722
|
setRenderSingleItem(render, unrender) {
|
|
3096
2723
|
const p = this._p;
|
|
3097
2724
|
p.renderSingleItem = render;
|
|
3098
2725
|
p.unrenderSingleItem = unrender;
|
|
3099
2726
|
return this;
|
|
3100
2727
|
}
|
|
3101
|
-
/**
|
|
3102
|
-
* @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
|
|
3103
|
-
* @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
|
|
3104
|
-
* @returns {SelectBox}
|
|
3105
|
-
*/
|
|
3106
2728
|
setRenderMultiItem(render, unrender) {
|
|
3107
2729
|
const p = this._p;
|
|
3108
2730
|
p.renderMultiItem = render;
|
|
3109
2731
|
p.unrenderMultiItem = unrender;
|
|
3110
2732
|
return this;
|
|
3111
2733
|
}
|
|
3112
|
-
/**
|
|
3113
|
-
* @param {(function(item: DropList.ItemBase, itemEl: Element):(*|false))|null} render
|
|
3114
|
-
* @param {(function(item: DropList.ItemBase, itemEl: Element))|null} unrender
|
|
3115
|
-
* @returns {SelectBox}
|
|
3116
|
-
*/
|
|
3117
2734
|
setRenderRestMultiItem(render, unrender) {
|
|
3118
2735
|
const p = this._p;
|
|
3119
2736
|
p.renderRestMultiItem = render;
|
|
3120
2737
|
p.unrenderRestMultiItem = unrender;
|
|
3121
2738
|
return this;
|
|
3122
2739
|
}
|
|
3123
|
-
/**
|
|
3124
|
-
* @param {string} prop
|
|
3125
|
-
* @returns {SelectBox}
|
|
3126
|
-
*/
|
|
3127
2740
|
setLabelProp(prop) {
|
|
3128
2741
|
const p = this._p;
|
|
3129
2742
|
p.labelProp = prop;
|
|
3130
2743
|
if (p.dropList) p.dropList.setLabelProp(prop);
|
|
3131
2744
|
return this;
|
|
3132
2745
|
}
|
|
3133
|
-
/**
|
|
3134
|
-
* @param {string} prop
|
|
3135
|
-
* @returns {SelectBox}
|
|
3136
|
-
*/
|
|
3137
2746
|
setValueProp(prop) {
|
|
3138
2747
|
const p = this._p;
|
|
3139
2748
|
if (p.valueProp === prop) return this;
|
|
@@ -3142,54 +2751,35 @@ var SelectBox = class {
|
|
|
3142
2751
|
this._refreshItemByValueMap();
|
|
3143
2752
|
return this;
|
|
3144
2753
|
}
|
|
3145
|
-
/**
|
|
3146
|
-
* @param {string} prop
|
|
3147
|
-
* @returns {SelectBox}
|
|
3148
|
-
*/
|
|
3149
2754
|
setMultiItemLabelProp(prop) {
|
|
3150
2755
|
const p = this._p;
|
|
3151
2756
|
p.multiItemLabelProp = prop;
|
|
3152
2757
|
this._scheduleSync("render_items");
|
|
3153
2758
|
return this;
|
|
3154
2759
|
}
|
|
3155
|
-
/**
|
|
3156
|
-
* @param {'before'|'after'|'none'} position
|
|
3157
|
-
* @returns {SelectBox}
|
|
3158
|
-
*/
|
|
3159
2760
|
setMultiItemRemovePosition(position) {
|
|
3160
2761
|
const p = this._p;
|
|
3161
2762
|
p.multiItemRemovePosition = position;
|
|
3162
2763
|
this._scheduleSync("render_items");
|
|
3163
2764
|
return this;
|
|
3164
2765
|
}
|
|
3165
|
-
/**
|
|
3166
|
-
* @param {number|null|undefined} value
|
|
3167
|
-
* @returns {SelectBox}
|
|
3168
|
-
*/
|
|
3169
2766
|
setMaxMultiItems(value) {
|
|
3170
2767
|
const p = this._p;
|
|
3171
2768
|
p.maxMultiItems = value;
|
|
3172
2769
|
return this;
|
|
3173
2770
|
}
|
|
3174
|
-
/**
|
|
3175
|
-
* @param {function(count: number, items: DropList.ItemBase[]):string|null|undefined} value
|
|
3176
|
-
* @returns {SelectBox}
|
|
3177
|
-
*/
|
|
3178
2771
|
setMultiItemsRestLabelProvider(value) {
|
|
3179
2772
|
const p = this._p;
|
|
3180
2773
|
p.multiItemsRestLabelProvider = value;
|
|
3181
2774
|
return this;
|
|
3182
2775
|
}
|
|
3183
|
-
/**
|
|
3184
|
-
* @param {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} fn
|
|
3185
|
-
* @returns {SelectBox}
|
|
3186
|
-
*/
|
|
3187
2776
|
setFilterFn(fn) {
|
|
3188
2777
|
const p = this._p;
|
|
2778
|
+
fn ??= null;
|
|
3189
2779
|
if (p.filterFn === fn) return this;
|
|
3190
2780
|
p.filterFn = fn;
|
|
3191
2781
|
if (!fn) fn = (items, term) => {
|
|
3192
|
-
const matcher = new RegExp(
|
|
2782
|
+
const matcher = new RegExp(escapeRegex(term), "i");
|
|
3193
2783
|
const labelProp = p.labelProp, multiItemLabelProp = p.multiItemLabelProp;
|
|
3194
2784
|
return p.items.filter((x) => {
|
|
3195
2785
|
if (!p.treatGroupSelectionAsItems && x._group) return true;
|
|
@@ -3200,15 +2790,28 @@ var SelectBox = class {
|
|
|
3200
2790
|
p.dropList?.setFilterFn(fn);
|
|
3201
2791
|
return this;
|
|
3202
2792
|
}
|
|
3203
|
-
/**
|
|
3204
|
-
* @returns {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)}
|
|
3205
|
-
*/
|
|
3206
2793
|
getFilterFn() {
|
|
3207
2794
|
return this._p.filterFn;
|
|
3208
2795
|
}
|
|
3209
2796
|
/**
|
|
2797
|
+
* Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderMultiItem`/`unrenderSingleItem`)
|
|
2798
|
+
* instead of the default `console.error`/`console.warn`. Also used as the default `onError` for the internal
|
|
2799
|
+
* `DropList`, unless `listOptions.onError` is set explicitly.
|
|
2800
|
+
*/
|
|
2801
|
+
setOnError(fn) {
|
|
2802
|
+
const p = this._p;
|
|
2803
|
+
p.onError = fn ?? void 0;
|
|
2804
|
+
p.dropList?.setOnError(p.listOptions?.onError ?? p.onError);
|
|
2805
|
+
return this;
|
|
2806
|
+
}
|
|
2807
|
+
/**
|
|
2808
|
+
* Gets the current `onError` handler, if any.
|
|
2809
|
+
*/
|
|
2810
|
+
getOnError() {
|
|
2811
|
+
return this._p.onError;
|
|
2812
|
+
}
|
|
2813
|
+
/**
|
|
3210
2814
|
* Focus on input element
|
|
3211
|
-
* @returns {SelectBox}
|
|
3212
2815
|
*/
|
|
3213
2816
|
focusInput() {
|
|
3214
2817
|
const p = this._p;
|
|
@@ -3217,7 +2820,6 @@ var SelectBox = class {
|
|
|
3217
2820
|
}
|
|
3218
2821
|
/**
|
|
3219
2822
|
* Remvoe focus from the input element
|
|
3220
|
-
* @returns {SelectBox}
|
|
3221
2823
|
*/
|
|
3222
2824
|
blurInput() {
|
|
3223
2825
|
const p = this._p;
|
|
@@ -3226,7 +2828,6 @@ var SelectBox = class {
|
|
|
3226
2828
|
}
|
|
3227
2829
|
/**
|
|
3228
2830
|
* Removes all selected items
|
|
3229
|
-
* @returns {SelectBox}
|
|
3230
2831
|
*/
|
|
3231
2832
|
clear() {
|
|
3232
2833
|
if (!this._performClearWithEvent(true)) return this;
|
|
@@ -3235,8 +2836,6 @@ var SelectBox = class {
|
|
|
3235
2836
|
}
|
|
3236
2837
|
/**
|
|
3237
2838
|
* Returns a single value or an array of selected values - depending on `multi` prop
|
|
3238
|
-
* @public
|
|
3239
|
-
* @returns {*[]}
|
|
3240
2839
|
*/
|
|
3241
2840
|
getValue() {
|
|
3242
2841
|
const p = this._p;
|
|
@@ -3245,9 +2844,7 @@ var SelectBox = class {
|
|
|
3245
2844
|
}
|
|
3246
2845
|
/**
|
|
3247
2846
|
* Selects the specified value or multiple values - depending on `multi` prop
|
|
3248
|
-
* @
|
|
3249
|
-
* @param {*|*[]} value - if `multi`, then an array of values to select, otherwise - a single value to select
|
|
3250
|
-
* @returns {SelectBox}
|
|
2847
|
+
* @param value - if `multi`, then an array of values to select, otherwise - a single value to select
|
|
3251
2848
|
*/
|
|
3252
2849
|
setValue(value) {
|
|
3253
2850
|
if (this._p.multi) return this.setSelectedValues(Array.isArray(value) ? value : value !== void 0 ? [value] : []);
|
|
@@ -3255,17 +2852,12 @@ var SelectBox = class {
|
|
|
3255
2852
|
}
|
|
3256
2853
|
/**
|
|
3257
2854
|
* Returns an array of selected values
|
|
3258
|
-
* @public
|
|
3259
|
-
* @returns {*[]}
|
|
3260
2855
|
*/
|
|
3261
2856
|
getSelectedValues() {
|
|
3262
2857
|
return this._p.selectedValues.slice(0);
|
|
3263
2858
|
}
|
|
3264
2859
|
/**
|
|
3265
2860
|
* Selects the specified values
|
|
3266
|
-
* @public
|
|
3267
|
-
* @param {*[]} values - an array of *values* to select
|
|
3268
|
-
* @returns {SelectBox}
|
|
3269
2861
|
*/
|
|
3270
2862
|
setSelectedValues(values) {
|
|
3271
2863
|
const p = this._p, valueProp = p.valueProp;
|
|
@@ -3290,16 +2882,12 @@ var SelectBox = class {
|
|
|
3290
2882
|
}
|
|
3291
2883
|
/**
|
|
3292
2884
|
* Returns the count of selected values
|
|
3293
|
-
* @public
|
|
3294
|
-
* @returns {number}
|
|
3295
2885
|
*/
|
|
3296
2886
|
getSelectedValueCount() {
|
|
3297
2887
|
return this._p.selectedValues.length;
|
|
3298
2888
|
}
|
|
3299
2889
|
/**
|
|
3300
2890
|
* Returns an array of selected items
|
|
3301
|
-
* @public
|
|
3302
|
-
* @returns {Array.<Object>}
|
|
3303
2891
|
*/
|
|
3304
2892
|
getSelectedItems() {
|
|
3305
2893
|
return this._p.selectedItems.slice(0);
|
|
@@ -3308,17 +2896,11 @@ var SelectBox = class {
|
|
|
3308
2896
|
* Sets the specified items to "checked" mode.
|
|
3309
2897
|
* An array of items is passed, not values, because we need to keep track if items,
|
|
3310
2898
|
* and if we already have the array of items then this spares the process of searching for the items by values.
|
|
3311
|
-
* @public
|
|
3312
|
-
* @param {DropList.ItemBase[]} items - an array of *items* to select (not values)
|
|
3313
|
-
* @returns {SelectBox}
|
|
3314
2899
|
*/
|
|
3315
2900
|
setSelectedItems(items) {
|
|
3316
2901
|
this._setSelectedItems(items);
|
|
3317
2902
|
return this;
|
|
3318
2903
|
}
|
|
3319
|
-
/**
|
|
3320
|
-
* @returns {SelectBox}
|
|
3321
|
-
*/
|
|
3322
2904
|
openList() {
|
|
3323
2905
|
const p = this._p;
|
|
3324
2906
|
if (p.dropList.isVisible()) return this;
|
|
@@ -3333,9 +2915,6 @@ var SelectBox = class {
|
|
|
3333
2915
|
else if (!p.multi && this.getValue() !== void 0) p.dropList.setFocusedItemByValue(this.getValue());
|
|
3334
2916
|
return this;
|
|
3335
2917
|
}
|
|
3336
|
-
/**
|
|
3337
|
-
* @returns {SelectBox}
|
|
3338
|
-
*/
|
|
3339
2918
|
closeList() {
|
|
3340
2919
|
const p = this._p;
|
|
3341
2920
|
if (this[DestroyedSymbol]) return this;
|
|
@@ -3347,32 +2926,17 @@ var SelectBox = class {
|
|
|
3347
2926
|
}
|
|
3348
2927
|
return this;
|
|
3349
2928
|
}
|
|
3350
|
-
/**
|
|
3351
|
-
* @param {boolean} [open]
|
|
3352
|
-
* @returns {SelectBox}
|
|
3353
|
-
*/
|
|
3354
2929
|
toggleList(open) {
|
|
3355
2930
|
const p = this._p;
|
|
3356
2931
|
if (open === void 0 ? !p.dropList.isVisible() : !!open) return this.openList();
|
|
3357
2932
|
else return this.closeList();
|
|
3358
2933
|
}
|
|
3359
|
-
/**
|
|
3360
|
-
* @returns {boolean}
|
|
3361
|
-
*/
|
|
3362
2934
|
isListOpen() {
|
|
3363
2935
|
return !!this._p.dropListVisible;
|
|
3364
2936
|
}
|
|
3365
|
-
/**
|
|
3366
|
-
* @param {boolean} [on]
|
|
3367
|
-
* @returns {SelectBox}
|
|
3368
|
-
*/
|
|
3369
2937
|
toggleLoading(on) {
|
|
3370
2938
|
return this.setIsLoadingMode(on === void 0 ? !this.getIsLoadingMode() : !!on);
|
|
3371
2939
|
}
|
|
3372
|
-
/**
|
|
3373
|
-
* @param {boolean} isLoadingMode
|
|
3374
|
-
* @returns {SelectBox}
|
|
3375
|
-
*/
|
|
3376
2940
|
setIsLoadingMode(isLoadingMode) {
|
|
3377
2941
|
const p = this._p;
|
|
3378
2942
|
isLoadingMode = isLoadingMode === void 0 ? true : !!isLoadingMode;
|
|
@@ -3383,31 +2947,21 @@ var SelectBox = class {
|
|
|
3383
2947
|
this._scheduleSync("render_base");
|
|
3384
2948
|
return this;
|
|
3385
2949
|
}
|
|
3386
|
-
/**
|
|
3387
|
-
* @returns {boolean}
|
|
3388
|
-
*/
|
|
3389
2950
|
getIsLoadingMode() {
|
|
3390
2951
|
return this._p.isLoadingMode;
|
|
3391
2952
|
}
|
|
3392
2953
|
/**
|
|
3393
2954
|
* Sets whether to close the list when loading mode is enabled
|
|
3394
|
-
* @param {boolean} closeListWhenLoading
|
|
3395
|
-
* @returns {SelectBox}
|
|
3396
2955
|
*/
|
|
3397
2956
|
setCloseListWhenLoading(closeListWhenLoading) {
|
|
3398
2957
|
this._p.closeListWhenLoading = closeListWhenLoading;
|
|
3399
2958
|
return this;
|
|
3400
2959
|
}
|
|
3401
|
-
/**
|
|
3402
|
-
* @returns {boolean}
|
|
3403
|
-
*/
|
|
3404
2960
|
getCloseListWhenLoading() {
|
|
3405
2961
|
return this._p.closeListWhenLoading;
|
|
3406
2962
|
}
|
|
3407
2963
|
/**
|
|
3408
2964
|
* Sets when to clear the input field
|
|
3409
|
-
* @param {string[]} clearInputWhen
|
|
3410
|
-
* @returns {SelectBox}
|
|
3411
2965
|
*/
|
|
3412
2966
|
setClearInputWhen(clearInputWhen) {
|
|
3413
2967
|
this._p.clearInputWhen = Array.isArray(clearInputWhen) ? clearInputWhen.slice(0) : [];
|
|
@@ -3415,15 +2969,12 @@ var SelectBox = class {
|
|
|
3415
2969
|
}
|
|
3416
2970
|
/**
|
|
3417
2971
|
* Retrieves the settings for when to clear the input field
|
|
3418
|
-
* @returns {string[]}
|
|
3419
2972
|
*/
|
|
3420
2973
|
getClearInputWhen() {
|
|
3421
2974
|
return this._p.clearInputWhen;
|
|
3422
2975
|
}
|
|
3423
2976
|
/**
|
|
3424
2977
|
* Sets the appropriate direction for the selectbox
|
|
3425
|
-
* @param {'ltr'|'rtl'|'auto'} direction
|
|
3426
|
-
* @return {SelectBox}
|
|
3427
2978
|
*/
|
|
3428
2979
|
setDirection(direction) {
|
|
3429
2980
|
const p = this._p;
|
|
@@ -3433,14 +2984,12 @@ var SelectBox = class {
|
|
|
3433
2984
|
}
|
|
3434
2985
|
/**
|
|
3435
2986
|
* Gets the supplied direction for the selectbox
|
|
3436
|
-
* @return {'ltr'|'rtl'|'auto'}
|
|
3437
2987
|
*/
|
|
3438
2988
|
getDirection() {
|
|
3439
2989
|
return this._p.direction;
|
|
3440
2990
|
}
|
|
3441
2991
|
/**
|
|
3442
2992
|
* Can be called in case that the selectbox was attached to the dom late and has a weird size.
|
|
3443
|
-
* @returns {SelectBox}
|
|
3444
2993
|
*/
|
|
3445
2994
|
refreshSize() {
|
|
3446
2995
|
this._resizeInput();
|
|
@@ -3448,9 +2997,6 @@ var SelectBox = class {
|
|
|
3448
2997
|
}
|
|
3449
2998
|
/**
|
|
3450
2999
|
* Register an event handler
|
|
3451
|
-
* @param {(string|'*')?} event
|
|
3452
|
-
* @param {function(any)} handler
|
|
3453
|
-
* @returns {SelectBox}
|
|
3454
3000
|
*/
|
|
3455
3001
|
on(event, handler) {
|
|
3456
3002
|
this._p.mitt.on(event, handler);
|
|
@@ -3458,9 +3004,6 @@ var SelectBox = class {
|
|
|
3458
3004
|
}
|
|
3459
3005
|
/**
|
|
3460
3006
|
* Register a one time event handler
|
|
3461
|
-
* @param {(string|'*')?} event
|
|
3462
|
-
* @param {function(any)} handler
|
|
3463
|
-
* @returns {SelectBox}
|
|
3464
3007
|
*/
|
|
3465
3008
|
once(event, handler) {
|
|
3466
3009
|
let wrapped = (value) => {
|
|
@@ -3472,9 +3015,6 @@ var SelectBox = class {
|
|
|
3472
3015
|
}
|
|
3473
3016
|
/**
|
|
3474
3017
|
* Remove an `handler` for `event`, all events for `event`, or all events completely.
|
|
3475
|
-
* @param {(string|'*')?} event
|
|
3476
|
-
* @param {function(any)} handler
|
|
3477
|
-
* @returns {SelectBox}
|
|
3478
3018
|
*/
|
|
3479
3019
|
off(event, handler) {
|
|
3480
3020
|
if (!event && !event) this._p.mitt.all.clear();
|
|
@@ -3483,9 +3023,6 @@ var SelectBox = class {
|
|
|
3483
3023
|
}
|
|
3484
3024
|
/**
|
|
3485
3025
|
* Emit an event
|
|
3486
|
-
* @param {string} event
|
|
3487
|
-
* @param {any} value
|
|
3488
|
-
* @returns {SelectBox}
|
|
3489
3026
|
*/
|
|
3490
3027
|
emit(event, value) {
|
|
3491
3028
|
this._p.mitt.emit(event, value);
|
|
@@ -3495,6 +3032,7 @@ var SelectBox = class {
|
|
|
3495
3032
|
* Prepare the mapping between values and items.
|
|
3496
3033
|
* This reduces search time greatly (i.e when checking items), especially when Vue proxies are in place.
|
|
3497
3034
|
* @private
|
|
3035
|
+
* @internal
|
|
3498
3036
|
*/
|
|
3499
3037
|
_refreshItemByValueMap() {
|
|
3500
3038
|
const p = this._p;
|
|
@@ -3504,9 +3042,8 @@ var SelectBox = class {
|
|
|
3504
3042
|
p.subitemByValueMap = null;
|
|
3505
3043
|
}
|
|
3506
3044
|
/**
|
|
3507
|
-
* @param {*} value
|
|
3508
|
-
* @returns {DropList.ItemBase|undefined}
|
|
3509
3045
|
* @private
|
|
3046
|
+
* @internal
|
|
3510
3047
|
*/
|
|
3511
3048
|
_getItemByValue(value) {
|
|
3512
3049
|
const p = this._p;
|
|
@@ -3516,16 +3053,15 @@ var SelectBox = class {
|
|
|
3516
3053
|
return p.subitemByValueMap.get(value);
|
|
3517
3054
|
}
|
|
3518
3055
|
/** @private */
|
|
3056
|
+
/** @internal */
|
|
3519
3057
|
_refreshSubitemByValueMap() {
|
|
3520
3058
|
const p = this._p;
|
|
3521
3059
|
const subitemByValueMap = p.subitemByValueMap = /* @__PURE__ */ new Map();
|
|
3522
3060
|
this._addSubitemsToValueMap(p.items, subitemByValueMap, p.valueProp);
|
|
3523
3061
|
}
|
|
3524
3062
|
/**
|
|
3525
|
-
* @param {DropList.ItemBase[]} items
|
|
3526
|
-
* @param {Map<*, DropList.ItemBase>} itemByValueMap
|
|
3527
|
-
* @param {string} valueProp
|
|
3528
3063
|
* @private
|
|
3064
|
+
* @internal
|
|
3529
3065
|
*/
|
|
3530
3066
|
_addSubitemsToValueMap(items, itemByValueMap, valueProp) {
|
|
3531
3067
|
for (let item of items) {
|
|
@@ -3535,6 +3071,7 @@ var SelectBox = class {
|
|
|
3535
3071
|
}
|
|
3536
3072
|
}
|
|
3537
3073
|
/** @private */
|
|
3074
|
+
/** @internal */
|
|
3538
3075
|
_renderBase() {
|
|
3539
3076
|
const p = this._p;
|
|
3540
3077
|
if (!p.inputBackBuffer) p.inputBackBuffer = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { css: {
|
|
@@ -3623,6 +3160,7 @@ var SelectBox = class {
|
|
|
3623
3160
|
}
|
|
3624
3161
|
/**
|
|
3625
3162
|
* @private
|
|
3163
|
+
* @internal
|
|
3626
3164
|
*/
|
|
3627
3165
|
_syncBaseClasses() {
|
|
3628
3166
|
const p = this._p, el = p.el;
|
|
@@ -3643,6 +3181,7 @@ var SelectBox = class {
|
|
|
3643
3181
|
el.className = classes.join(" ");
|
|
3644
3182
|
}
|
|
3645
3183
|
/** @private */
|
|
3184
|
+
/** @internal */
|
|
3646
3185
|
_setupDropdownMenu() {
|
|
3647
3186
|
const p = this._p;
|
|
3648
3187
|
p.valueProp;
|
|
@@ -3672,6 +3211,7 @@ var SelectBox = class {
|
|
|
3672
3211
|
filterGroups: p.treatGroupSelectionAsItems,
|
|
3673
3212
|
filterEmptyGroups: !p.treatGroupSelectionAsItems,
|
|
3674
3213
|
filterFn: p.actualFilterFn,
|
|
3214
|
+
onError: p.listOptions?.onError ?? p.onError,
|
|
3675
3215
|
positionOptionsProvider: () => this._getDropListPositionOptions(),
|
|
3676
3216
|
on: (name, event) => {
|
|
3677
3217
|
switch (name) {
|
|
@@ -3798,15 +3338,14 @@ var SelectBox = class {
|
|
|
3798
3338
|
case "search":
|
|
3799
3339
|
this._trigger("search", event);
|
|
3800
3340
|
break;
|
|
3801
|
-
case "itemschanged":
|
|
3802
|
-
this._trigger("itemschanged", event);
|
|
3803
|
-
break;
|
|
3341
|
+
case "itemschanged": this._trigger("itemschanged", event);
|
|
3804
3342
|
}
|
|
3805
3343
|
}
|
|
3806
3344
|
});
|
|
3807
3345
|
p.sink.add(dropList.el, "mousedown", preventDropListMouseDownBlur);
|
|
3808
3346
|
this._registerDropdownEvents();
|
|
3809
3347
|
}
|
|
3348
|
+
/** @internal */
|
|
3810
3349
|
_handleOnBlur() {
|
|
3811
3350
|
const p = this._p;
|
|
3812
3351
|
setTimeout(() => {
|
|
@@ -3818,9 +3357,11 @@ var SelectBox = class {
|
|
|
3818
3357
|
this.closeList();
|
|
3819
3358
|
});
|
|
3820
3359
|
}
|
|
3360
|
+
/** @internal */
|
|
3821
3361
|
_unregisterDropdownEvents() {
|
|
3822
3362
|
this._p.sink.remove(null, ".dropdown");
|
|
3823
3363
|
}
|
|
3364
|
+
/** @internal */
|
|
3824
3365
|
_registerDropdownEvents() {
|
|
3825
3366
|
const p = this._p;
|
|
3826
3367
|
this._unregisterDropdownEvents();
|
|
@@ -3865,9 +3406,7 @@ var SelectBox = class {
|
|
|
3865
3406
|
case keycode_js.VALUE_HOME:
|
|
3866
3407
|
dropList.goToFirst(evt);
|
|
3867
3408
|
break;
|
|
3868
|
-
case keycode_js.VALUE_END:
|
|
3869
|
-
dropList.goToLast(evt);
|
|
3870
|
-
break;
|
|
3409
|
+
case keycode_js.VALUE_END: dropList.goToLast(evt);
|
|
3871
3410
|
}
|
|
3872
3411
|
break;
|
|
3873
3412
|
case keycode_js.VALUE_SPACE:
|
|
@@ -3897,17 +3436,15 @@ var SelectBox = class {
|
|
|
3897
3436
|
evt.preventDefault();
|
|
3898
3437
|
}
|
|
3899
3438
|
break;
|
|
3900
|
-
default:
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
}
|
|
3910
|
-
break;
|
|
3439
|
+
default: if (dropList.isVisible()) dropList._keydownFreeType(evt, false);
|
|
3440
|
+
else if (p.allowTypeToSelect) dropList._keydownFreeType(evt, true);
|
|
3441
|
+
else {
|
|
3442
|
+
this.openList();
|
|
3443
|
+
setTimeout(() => {
|
|
3444
|
+
if (this[DestroyedSymbol]) return;
|
|
3445
|
+
dropList._keydownFreeType(evt, false);
|
|
3446
|
+
});
|
|
3447
|
+
}
|
|
3911
3448
|
}
|
|
3912
3449
|
if (!suppressEnterSpaceToggle) {
|
|
3913
3450
|
if (evt.key === keycode_js.VALUE_ENTER || evt.key === keycode_js.VALUE_SPACE && p.lastKeyAllowsNonTypeKeys && !p.multi && !dropList.hasFocusedItem() && !p.disabled && !p.readOnly) {
|
|
@@ -3958,6 +3495,7 @@ var SelectBox = class {
|
|
|
3958
3495
|
}).add(p.el, "touchcancel.dropdown_touchextra", onTouchCancel);
|
|
3959
3496
|
});
|
|
3960
3497
|
}
|
|
3498
|
+
/** @internal */
|
|
3961
3499
|
_performSelectWithEvent(item, value) {
|
|
3962
3500
|
let cancellable = {
|
|
3963
3501
|
value,
|
|
@@ -3974,6 +3512,7 @@ var SelectBox = class {
|
|
|
3974
3512
|
});
|
|
3975
3513
|
return true;
|
|
3976
3514
|
}
|
|
3515
|
+
/** @internal */
|
|
3977
3516
|
_performClearWithEvent(clearInput = false) {
|
|
3978
3517
|
let cancellable = { cancel: false };
|
|
3979
3518
|
this._trigger("clear:before", cancellable);
|
|
@@ -3984,6 +3523,7 @@ var SelectBox = class {
|
|
|
3984
3523
|
this._trigger("clear");
|
|
3985
3524
|
return true;
|
|
3986
3525
|
}
|
|
3526
|
+
/** @internal */
|
|
3987
3527
|
_movePrev() {
|
|
3988
3528
|
const p = this._p;
|
|
3989
3529
|
if (this.isMultiEnabled()) return;
|
|
@@ -3997,6 +3537,7 @@ var SelectBox = class {
|
|
|
3997
3537
|
else this._performClearWithEvent();
|
|
3998
3538
|
}
|
|
3999
3539
|
}
|
|
3540
|
+
/** @internal */
|
|
4000
3541
|
_moveNext() {
|
|
4001
3542
|
const p = this._p;
|
|
4002
3543
|
if (this.isMultiEnabled()) return;
|
|
@@ -4011,6 +3552,7 @@ var SelectBox = class {
|
|
|
4011
3552
|
}
|
|
4012
3553
|
}
|
|
4013
3554
|
/** @private */
|
|
3555
|
+
/** @internal */
|
|
4014
3556
|
_updateListItems() {
|
|
4015
3557
|
const p = this._p;
|
|
4016
3558
|
const dropList = p.dropList;
|
|
@@ -4040,6 +3582,7 @@ var SelectBox = class {
|
|
|
4040
3582
|
if (hasRefocusedItem) p.dropList.setFocusedItemAtIndex(p.dropList.getFocusedItemIndex());
|
|
4041
3583
|
}
|
|
4042
3584
|
/** @private */
|
|
3585
|
+
/** @internal */
|
|
4043
3586
|
_setSelectedItems(items) {
|
|
4044
3587
|
const p = this._p, valueProp = p.valueProp;
|
|
4045
3588
|
if (p.multi) {
|
|
@@ -4055,6 +3598,7 @@ var SelectBox = class {
|
|
|
4055
3598
|
this._scheduleSync("full");
|
|
4056
3599
|
}
|
|
4057
3600
|
/** @private */
|
|
3601
|
+
/** @internal */
|
|
4058
3602
|
_scheduleSync(mode, data) {
|
|
4059
3603
|
const p = this._p;
|
|
4060
3604
|
if (!p.syncQueue) p.syncQueue = [];
|
|
@@ -4072,6 +3616,7 @@ var SelectBox = class {
|
|
|
4072
3616
|
});
|
|
4073
3617
|
}
|
|
4074
3618
|
/** @private */
|
|
3619
|
+
/** @internal */
|
|
4075
3620
|
_performSync(queue) {
|
|
4076
3621
|
const p = this._p;
|
|
4077
3622
|
if (this[DestroyedSymbol]) return;
|
|
@@ -4119,26 +3664,29 @@ var SelectBox = class {
|
|
|
4119
3664
|
if (!p.showSelection) this._syncPlaceholder();
|
|
4120
3665
|
else if (p.multiItemEls[p.multiItemEls.length - 1]?.[ItemSymbol]?.[p.valueProp] === RestMultiItemsSymbol) this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
|
|
4121
3666
|
break;
|
|
4122
|
-
case "resize_input":
|
|
4123
|
-
this._resizeInput();
|
|
4124
|
-
break;
|
|
3667
|
+
case "resize_input": this._resizeInput();
|
|
4125
3668
|
}
|
|
4126
3669
|
}
|
|
4127
3670
|
/** @private */
|
|
3671
|
+
/** @internal */
|
|
4128
3672
|
_cleanupSingleWrapper() {
|
|
4129
3673
|
const p = this._p;
|
|
4130
3674
|
if (!p.singleWrapper) return;
|
|
4131
3675
|
if (p.unrenderSingleItem && p.singleWrapper.childNodes.length > 0) try {
|
|
4132
3676
|
p.unrenderSingleItem(p.singleWrapper[ItemSymbol], p.singleWrapper);
|
|
4133
3677
|
} catch (err) {
|
|
4134
|
-
|
|
3678
|
+
reportError(p.onError, err, {
|
|
3679
|
+
source: "unrenderSingleItem",
|
|
3680
|
+
item: p.singleWrapper[ItemSymbol],
|
|
3681
|
+
el: p.singleWrapper
|
|
3682
|
+
});
|
|
4135
3683
|
}
|
|
4136
3684
|
delete p.singleWrapper[ItemSymbol];
|
|
4137
3685
|
p.singleWrapper.innerHTML = "";
|
|
4138
3686
|
}
|
|
4139
3687
|
/**
|
|
4140
|
-
* @param {number} index
|
|
4141
3688
|
* @private
|
|
3689
|
+
* @internal
|
|
4142
3690
|
*/
|
|
4143
3691
|
_removeMultiItemElementByIndex(index) {
|
|
4144
3692
|
const p = this._p, multiItemEls = p.multiItemEls;
|
|
@@ -4149,7 +3697,11 @@ var SelectBox = class {
|
|
|
4149
3697
|
if (unrender && itemEl.childNodes.length > 0) try {
|
|
4150
3698
|
unrender(item, itemEl);
|
|
4151
3699
|
} catch (err) {
|
|
4152
|
-
|
|
3700
|
+
reportError(p.onError, err, {
|
|
3701
|
+
source: item?.[p.valueProp] === RestMultiItemsSymbol ? "unrenderRestMultiItem" : "unrenderMultiItem",
|
|
3702
|
+
item,
|
|
3703
|
+
el: itemEl
|
|
3704
|
+
});
|
|
4153
3705
|
}
|
|
4154
3706
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(itemEl);
|
|
4155
3707
|
if (index === multiItemEls.length - 1) multiItemEls.pop();
|
|
@@ -4157,8 +3709,8 @@ var SelectBox = class {
|
|
|
4157
3709
|
}
|
|
4158
3710
|
}
|
|
4159
3711
|
/**
|
|
4160
|
-
* @param {DropList.ItemBase} item
|
|
4161
3712
|
* @private
|
|
3713
|
+
* @internal
|
|
4162
3714
|
*/
|
|
4163
3715
|
_renderSingleItemContent(item) {
|
|
4164
3716
|
const p = this._p;
|
|
@@ -4170,9 +3722,8 @@ var SelectBox = class {
|
|
|
4170
3722
|
}
|
|
4171
3723
|
}
|
|
4172
3724
|
/**
|
|
4173
|
-
* @param {DropList.ItemBase} item
|
|
4174
|
-
* @param {Element} itemEl
|
|
4175
3725
|
* @private
|
|
3726
|
+
* @internal
|
|
4176
3727
|
*/
|
|
4177
3728
|
_renderMultiItemContent(item, itemEl) {
|
|
4178
3729
|
const p = this._p;
|
|
@@ -4184,9 +3735,9 @@ var SelectBox = class {
|
|
|
4184
3735
|
}
|
|
4185
3736
|
}
|
|
4186
3737
|
/**
|
|
4187
|
-
* @param {DropList.ItemBase} item
|
|
4188
3738
|
* @returns {boolean} true if rendered, false if not
|
|
4189
3739
|
* @private
|
|
3740
|
+
* @internal
|
|
4190
3741
|
*/
|
|
4191
3742
|
_addMultiItemElement(item) {
|
|
4192
3743
|
const p = this._p;
|
|
@@ -4197,6 +3748,7 @@ var SelectBox = class {
|
|
|
4197
3748
|
return true;
|
|
4198
3749
|
}
|
|
4199
3750
|
/** @private */
|
|
3751
|
+
/** @internal */
|
|
4200
3752
|
_addMultiItemRestElement() {
|
|
4201
3753
|
const p = this._p;
|
|
4202
3754
|
let items = p.selectedItems.slice(0);
|
|
@@ -4209,6 +3761,7 @@ var SelectBox = class {
|
|
|
4209
3761
|
});
|
|
4210
3762
|
}
|
|
4211
3763
|
/** @private */
|
|
3764
|
+
/** @internal */
|
|
4212
3765
|
_syncClearButton() {
|
|
4213
3766
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
4214
3767
|
if (p.selectedItems.length > 0 && p.selectedItems.some((x) => x[multiItemLabelProp] !== false) && p.clearable && p.showSelection) {
|
|
@@ -4231,6 +3784,7 @@ var SelectBox = class {
|
|
|
4231
3784
|
}
|
|
4232
3785
|
}
|
|
4233
3786
|
/** @private */
|
|
3787
|
+
/** @internal */
|
|
4234
3788
|
_syncPlaceholder() {
|
|
4235
3789
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
4236
3790
|
let placeholder = "";
|
|
@@ -4242,6 +3796,7 @@ var SelectBox = class {
|
|
|
4242
3796
|
else p.input.removeAttribute("title");
|
|
4243
3797
|
}
|
|
4244
3798
|
/** @private */
|
|
3799
|
+
/** @internal */
|
|
4245
3800
|
_syncSingleItem() {
|
|
4246
3801
|
const p = this._p;
|
|
4247
3802
|
if (p.singleWrapper) this._cleanupSingleWrapper();
|
|
@@ -4253,9 +3808,7 @@ var SelectBox = class {
|
|
|
4253
3808
|
}
|
|
4254
3809
|
/**
|
|
4255
3810
|
* Syncs render state, selected items, and position
|
|
4256
|
-
* @
|
|
4257
|
-
* @param {boolean=false} updateListItems Should call updateListItems?
|
|
4258
|
-
* @returns {SelectBox}
|
|
3811
|
+
* @internal
|
|
4259
3812
|
*/
|
|
4260
3813
|
_syncFull(fullItemsRender, updateListItems) {
|
|
4261
3814
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
@@ -4313,9 +3866,8 @@ var SelectBox = class {
|
|
|
4313
3866
|
return this;
|
|
4314
3867
|
}
|
|
4315
3868
|
/**
|
|
4316
|
-
* @param {string} event
|
|
4317
|
-
* @param {*} [data]
|
|
4318
3869
|
* @private
|
|
3870
|
+
* @internal
|
|
4319
3871
|
*/
|
|
4320
3872
|
_trigger(event, data) {
|
|
4321
3873
|
const p = this._p;
|
|
@@ -4325,9 +3877,8 @@ var SelectBox = class {
|
|
|
4325
3877
|
}
|
|
4326
3878
|
/**
|
|
4327
3879
|
* Render a multi item
|
|
4328
|
-
* @param {Object} item
|
|
4329
|
-
* @returns {Element|null}
|
|
4330
3880
|
* @private
|
|
3881
|
+
* @internal
|
|
4331
3882
|
*/
|
|
4332
3883
|
_renderMultiItem(item) {
|
|
4333
3884
|
const p = this._p;
|
|
@@ -4351,10 +3902,8 @@ var SelectBox = class {
|
|
|
4351
3902
|
}
|
|
4352
3903
|
/**
|
|
4353
3904
|
* Removes a specific multi item by user event
|
|
4354
|
-
* @param {Element} itemEl
|
|
4355
|
-
* @param {Event} originatingEvent
|
|
4356
|
-
* @returns {SelectBox}
|
|
4357
3905
|
* @private
|
|
3906
|
+
* @internal
|
|
4358
3907
|
*/
|
|
4359
3908
|
_removeMultiItemFromEvent(itemEl, originatingEvent) {
|
|
4360
3909
|
const p = this._p;
|
|
@@ -4370,7 +3919,7 @@ var SelectBox = class {
|
|
|
4370
3919
|
let itemsToRemove = [];
|
|
4371
3920
|
for (let item of items) {
|
|
4372
3921
|
let removeselEvt = {
|
|
4373
|
-
value,
|
|
3922
|
+
value: item[p.valueProp],
|
|
4374
3923
|
item,
|
|
4375
3924
|
cancel: false
|
|
4376
3925
|
};
|
|
@@ -4381,7 +3930,7 @@ var SelectBox = class {
|
|
|
4381
3930
|
this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
|
|
4382
3931
|
for (let item of itemsToRemove) {
|
|
4383
3932
|
let idx = p.selectedItems.indexOf(item);
|
|
4384
|
-
if (idx === -1) idx = p.selectedValues.indexOf(
|
|
3933
|
+
if (idx === -1) idx = p.selectedValues.indexOf(item[p.valueProp]);
|
|
4385
3934
|
if (idx !== -1) {
|
|
4386
3935
|
p.selectedItems.splice(idx, 1);
|
|
4387
3936
|
p.selectedValues.splice(idx, 1);
|
|
@@ -4412,9 +3961,8 @@ var SelectBox = class {
|
|
|
4412
3961
|
return this;
|
|
4413
3962
|
}
|
|
4414
3963
|
/**
|
|
4415
|
-
* @param {DropList.ItemBase} item
|
|
4416
|
-
* @param {boolean} [populate]
|
|
4417
3964
|
* @private
|
|
3965
|
+
* @internal
|
|
4418
3966
|
*/
|
|
4419
3967
|
_removeMultiItem(item, populate = false) {
|
|
4420
3968
|
const p = this._p;
|
|
@@ -4439,8 +3987,8 @@ var SelectBox = class {
|
|
|
4439
3987
|
this._scheduleSync("render_list");
|
|
4440
3988
|
}
|
|
4441
3989
|
/**
|
|
4442
|
-
* @param {*} value
|
|
4443
3990
|
* @private
|
|
3991
|
+
* @internal
|
|
4444
3992
|
*/
|
|
4445
3993
|
_setInputText(value) {
|
|
4446
3994
|
const p = this._p;
|
|
@@ -4451,8 +3999,8 @@ var SelectBox = class {
|
|
|
4451
3999
|
}
|
|
4452
4000
|
/**
|
|
4453
4001
|
* Update input size to current state
|
|
4454
|
-
* @returns {SelectBox}
|
|
4455
4002
|
* @private
|
|
4003
|
+
* @internal
|
|
4456
4004
|
*/
|
|
4457
4005
|
_resizeInput() {
|
|
4458
4006
|
const p = this._p, el = p.el;
|
|
@@ -4508,8 +4056,8 @@ var SelectBox = class {
|
|
|
4508
4056
|
}
|
|
4509
4057
|
/**
|
|
4510
4058
|
* Update autocomplete position if needed
|
|
4511
|
-
* @returns {SelectBox}
|
|
4512
4059
|
* @private
|
|
4060
|
+
* @internal
|
|
4513
4061
|
*/
|
|
4514
4062
|
_repositionDropList() {
|
|
4515
4063
|
const p = this._p, el = p.el;
|
|
@@ -4523,8 +4071,8 @@ var SelectBox = class {
|
|
|
4523
4071
|
return this;
|
|
4524
4072
|
}
|
|
4525
4073
|
/**
|
|
4526
|
-
* @param {KeyboardEvent} event
|
|
4527
4074
|
* @private
|
|
4075
|
+
* @internal
|
|
4528
4076
|
*/
|
|
4529
4077
|
_handleInputKeydown(event) {
|
|
4530
4078
|
const p = this._p;
|
|
@@ -4553,8 +4101,8 @@ var SelectBox = class {
|
|
|
4553
4101
|
}
|
|
4554
4102
|
}
|
|
4555
4103
|
/**
|
|
4556
|
-
* @param {KeyboardEvent} event
|
|
4557
4104
|
* @private
|
|
4105
|
+
* @internal
|
|
4558
4106
|
*/
|
|
4559
4107
|
_handleMultiKeydown(event) {
|
|
4560
4108
|
const p = this._p;
|
|
@@ -4598,12 +4146,12 @@ var SelectBox = class {
|
|
|
4598
4146
|
}
|
|
4599
4147
|
}
|
|
4600
4148
|
/**
|
|
4601
|
-
* @returns {DropList.PositionOptions}
|
|
4602
4149
|
* @private
|
|
4150
|
+
* @internal
|
|
4603
4151
|
*/
|
|
4604
4152
|
_getDropListPositionOptions() {
|
|
4605
4153
|
return {
|
|
4606
|
-
target: this._p.el,
|
|
4154
|
+
target: /**@type Element*/ this._p.el,
|
|
4607
4155
|
offset: {
|
|
4608
4156
|
x: 0,
|
|
4609
4157
|
y: 0
|
|
@@ -4620,6 +4168,7 @@ var SelectBox = class {
|
|
|
4620
4168
|
};
|
|
4621
4169
|
}
|
|
4622
4170
|
/** @private */
|
|
4171
|
+
/** @internal */
|
|
4623
4172
|
_startTrackingPresence() {
|
|
4624
4173
|
const p = this._p;
|
|
4625
4174
|
this._stopTrackingPresence();
|
|
@@ -4628,6 +4177,7 @@ var SelectBox = class {
|
|
|
4628
4177
|
}, 200);
|
|
4629
4178
|
}
|
|
4630
4179
|
/** @private */
|
|
4180
|
+
/** @internal */
|
|
4631
4181
|
_stopTrackingPresence() {
|
|
4632
4182
|
const p = this._p;
|
|
4633
4183
|
if (p.presenceInt) {
|
|
@@ -4638,11 +4188,7 @@ var SelectBox = class {
|
|
|
4638
4188
|
/**
|
|
4639
4189
|
* Handles sorting, and putting checked items first (according to selectedValues, not item.checked)
|
|
4640
4190
|
* @private
|
|
4641
|
-
* @
|
|
4642
|
-
* @param {boolean=false} sort
|
|
4643
|
-
* @param {boolean=false} sortCheckedFirst
|
|
4644
|
-
* @param {boolean=false} splitCheckedGroups
|
|
4645
|
-
* @returns {DropList.ItemBase[]}
|
|
4191
|
+
* @internal
|
|
4646
4192
|
*/
|
|
4647
4193
|
_sortItems(items, sort, sortCheckedFirst, splitCheckedGroups) {
|
|
4648
4194
|
const p = this._p;
|