@danielgindi/selectbox 2.0.12 → 2.0.13
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 +58 -8
- 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 +58 -8
- 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 +58 -8
- 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/lib/DropList.js +8 -1
- package/lib/SelectBox.js +49 -6
- package/package.json +1 -1
package/dist/lib.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.13
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
@@ -7554,7 +7554,14 @@ class DropList {
|
|
|
7554
7554
|
* @returns {DropList}
|
|
7555
7555
|
*/
|
|
7556
7556
|
setNoResultsText(noResultsText) {
|
|
7557
|
-
this._p
|
|
7557
|
+
const p = this._p;
|
|
7558
|
+
|
|
7559
|
+
p.noResultsText = noResultsText;
|
|
7560
|
+
|
|
7561
|
+
if (p.hasNoResultsItem) {
|
|
7562
|
+
p.virtualListHelper.refreshItemAt(0).render();
|
|
7563
|
+
}
|
|
7564
|
+
|
|
7558
7565
|
return this;
|
|
7559
7566
|
}
|
|
7560
7567
|
|
|
@@ -9911,6 +9918,8 @@ const inputBackbufferCssProps = [
|
|
|
9911
9918
|
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
9912
9919
|
* @property {function(name: string, ...args)} [on]
|
|
9913
9920
|
* @property {boolean} [isLoadingMode]
|
|
9921
|
+
* @property {boolean} [closeListWhenLoading] whether we should close the list automatically when loading
|
|
9922
|
+
* @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>
|
|
9914
9923
|
* */
|
|
9915
9924
|
const defaultOptions = {
|
|
9916
9925
|
el: null,
|
|
@@ -9944,7 +9953,9 @@ const defaultOptions = {
|
|
|
9944
9953
|
items: [],
|
|
9945
9954
|
selectedValues: undefined,
|
|
9946
9955
|
value: undefined,
|
|
9947
|
-
isLoadingMode: false
|
|
9956
|
+
isLoadingMode: false,
|
|
9957
|
+
closeListWhenLoading: true,
|
|
9958
|
+
clearInputWhen: ['single_close', 'multi_select_single']
|
|
9948
9959
|
};
|
|
9949
9960
|
|
|
9950
9961
|
/**
|
|
@@ -10050,6 +10061,8 @@ class SelectBox {
|
|
|
10050
10061
|
mitt: mitt(),
|
|
10051
10062
|
|
|
10052
10063
|
isLoadingMode: !!o.isLoadingMode,
|
|
10064
|
+
closeListWhenLoading: !!o.closeListWhenLoading,
|
|
10065
|
+
clearInputWhen: Array.isArray(o.clearInputWhen) ? o.clearInputWhen.slice(0) : [],
|
|
10053
10066
|
|
|
10054
10067
|
items: [],
|
|
10055
10068
|
itemsChanged: true,
|
|
@@ -11263,9 +11276,9 @@ class SelectBox {
|
|
|
11263
11276
|
|
|
11264
11277
|
p.isLoadingMode = isLoadingMode;
|
|
11265
11278
|
|
|
11266
|
-
if (p.isLoadingMode && p.items.length === 0 && this.isListOpen()) {
|
|
11279
|
+
if (p.isLoadingMode && p.closeListWhenLoading && p.items.length === 0 && this.isListOpen()) {
|
|
11267
11280
|
this.closeList();
|
|
11268
|
-
} else if (!p.isLoadingMode && document.activeElement && (
|
|
11281
|
+
} else if (!p.isLoadingMode && p.closeListWhenLoading && document.activeElement && (
|
|
11269
11282
|
(p.multi || p.searchable) && p.input.contains(document.activeElement) ||
|
|
11270
11283
|
!p.multi && !p.searchable && p.el.contains(document.activeElement))) {
|
|
11271
11284
|
this.openList();
|
|
@@ -11282,6 +11295,41 @@ class SelectBox {
|
|
|
11282
11295
|
return this._p.isLoadingMode;
|
|
11283
11296
|
}
|
|
11284
11297
|
|
|
11298
|
+
/**
|
|
11299
|
+
* Sets whether to close the list when loading mode is enabled
|
|
11300
|
+
* @param {boolean} closeListWhenLoading
|
|
11301
|
+
* @returns {SelectBox}
|
|
11302
|
+
*/
|
|
11303
|
+
setCloseListWhenLoading(closeListWhenLoading) {
|
|
11304
|
+
this._p.closeListWhenLoading = closeListWhenLoading;
|
|
11305
|
+
return this;
|
|
11306
|
+
}
|
|
11307
|
+
|
|
11308
|
+
/**
|
|
11309
|
+
* @returns {boolean}
|
|
11310
|
+
*/
|
|
11311
|
+
getCloseListWhenLoading() {
|
|
11312
|
+
return this._p.closeListWhenLoading;
|
|
11313
|
+
}
|
|
11314
|
+
|
|
11315
|
+
/**
|
|
11316
|
+
* Sets when to clear the input field
|
|
11317
|
+
* @param {string[]} clearInputWhen
|
|
11318
|
+
* @returns {SelectBox}
|
|
11319
|
+
*/
|
|
11320
|
+
setClearInputWhen(clearInputWhen) {
|
|
11321
|
+
this._p.clearInputWhen = Array.isArray(clearInputWhen) ? clearInputWhen.slice(0) : [];
|
|
11322
|
+
return this;
|
|
11323
|
+
}
|
|
11324
|
+
|
|
11325
|
+
/**
|
|
11326
|
+
* Retrieves the settings for when to clear the input field
|
|
11327
|
+
* @returns {string[]}
|
|
11328
|
+
*/
|
|
11329
|
+
getClearInputWhen() {
|
|
11330
|
+
return this._p.clearInputWhen;
|
|
11331
|
+
}
|
|
11332
|
+
|
|
11285
11333
|
/**
|
|
11286
11334
|
* Sets the appropriate direction for the selectbox
|
|
11287
11335
|
* @param {'ltr'|'rtl'|'auto'} direction
|
|
@@ -11655,8 +11703,12 @@ class SelectBox {
|
|
|
11655
11703
|
p.el.classList.add("".concat(p.baseClassName, "__closed_list"));
|
|
11656
11704
|
|
|
11657
11705
|
if (!p.multi) {
|
|
11706
|
+
if (p.clearInputWhen.includes('single_close'))
|
|
11658
11707
|
this._setInputText('');
|
|
11659
11708
|
this._scheduleSync('render_base');
|
|
11709
|
+
} else {
|
|
11710
|
+
if (p.clearInputWhen.includes('multi_close'))
|
|
11711
|
+
this._setInputText('');
|
|
11660
11712
|
}
|
|
11661
11713
|
|
|
11662
11714
|
this._trigger('close');
|
|
@@ -11712,7 +11764,7 @@ class SelectBox {
|
|
|
11712
11764
|
|
|
11713
11765
|
if (p.showSelection) {
|
|
11714
11766
|
if (checked) {
|
|
11715
|
-
if (dropList.itemCount() === 1) {
|
|
11767
|
+
if (dropList.itemCount() === 1 && p.clearInputWhen.includes('multi_select_single')) {
|
|
11716
11768
|
this._setInputText('');
|
|
11717
11769
|
}
|
|
11718
11770
|
|
|
@@ -11982,8 +12034,6 @@ class SelectBox {
|
|
|
11982
12034
|
|
|
11983
12035
|
p.filterTerm = p.input.value.trim();
|
|
11984
12036
|
(_p$dropList9 = p.dropList) === null || _p$dropList9 === void 0 || _p$dropList9.setSearchTerm(p.filterTerm, true);
|
|
11985
|
-
|
|
11986
|
-
this._trigger('search', { value: p.input.value });
|
|
11987
12037
|
}).
|
|
11988
12038
|
add(p.input, 'click.dropdown', () => {
|
|
11989
12039
|
if (p.disabled) return;
|