@danielgindi/selectbox 2.0.11 → 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 +60 -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 +60 -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 +60 -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 +51 -6
- package/package.json +1 -1
- package/vue/DropList.vue +1 -1
- package/vue/SelectBox.vue +1 -1
package/dist/lib.umd.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
|
(function (global, factory) {
|
|
@@ -7550,7 +7550,14 @@
|
|
|
7550
7550
|
* @returns {DropList}
|
|
7551
7551
|
*/
|
|
7552
7552
|
setNoResultsText(noResultsText) {
|
|
7553
|
-
this._p
|
|
7553
|
+
const p = this._p;
|
|
7554
|
+
|
|
7555
|
+
p.noResultsText = noResultsText;
|
|
7556
|
+
|
|
7557
|
+
if (p.hasNoResultsItem) {
|
|
7558
|
+
p.virtualListHelper.refreshItemAt(0).render();
|
|
7559
|
+
}
|
|
7560
|
+
|
|
7554
7561
|
return this;
|
|
7555
7562
|
}
|
|
7556
7563
|
|
|
@@ -9907,6 +9914,8 @@
|
|
|
9907
9914
|
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
9908
9915
|
* @property {function(name: string, ...args)} [on]
|
|
9909
9916
|
* @property {boolean} [isLoadingMode]
|
|
9917
|
+
* @property {boolean} [closeListWhenLoading] whether we should close the list automatically when loading
|
|
9918
|
+
* @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>
|
|
9910
9919
|
* */
|
|
9911
9920
|
const defaultOptions = {
|
|
9912
9921
|
el: null,
|
|
@@ -9940,7 +9949,9 @@
|
|
|
9940
9949
|
items: [],
|
|
9941
9950
|
selectedValues: undefined,
|
|
9942
9951
|
value: undefined,
|
|
9943
|
-
isLoadingMode: false
|
|
9952
|
+
isLoadingMode: false,
|
|
9953
|
+
closeListWhenLoading: true,
|
|
9954
|
+
clearInputWhen: ['single_close', 'multi_select_single']
|
|
9944
9955
|
};
|
|
9945
9956
|
|
|
9946
9957
|
/**
|
|
@@ -10046,6 +10057,8 @@
|
|
|
10046
10057
|
mitt: mitt(),
|
|
10047
10058
|
|
|
10048
10059
|
isLoadingMode: !!o.isLoadingMode,
|
|
10060
|
+
closeListWhenLoading: !!o.closeListWhenLoading,
|
|
10061
|
+
clearInputWhen: Array.isArray(o.clearInputWhen) ? o.clearInputWhen.slice(0) : [],
|
|
10049
10062
|
|
|
10050
10063
|
items: [],
|
|
10051
10064
|
itemsChanged: true,
|
|
@@ -11192,6 +11205,8 @@
|
|
|
11192
11205
|
|
|
11193
11206
|
if (p.dropList.hasFocusedItem()) {
|
|
11194
11207
|
p.dropList.setFocusedItemAtIndex(p.dropList.getFocusedItemIndex());
|
|
11208
|
+
} else if (!p.multi && this.getValue() !== undefined) {
|
|
11209
|
+
p.dropList.setFocusedItemByValue(this.getValue());
|
|
11195
11210
|
}
|
|
11196
11211
|
|
|
11197
11212
|
return this;
|
|
@@ -11257,9 +11272,9 @@
|
|
|
11257
11272
|
|
|
11258
11273
|
p.isLoadingMode = isLoadingMode;
|
|
11259
11274
|
|
|
11260
|
-
if (p.isLoadingMode && p.items.length === 0 && this.isListOpen()) {
|
|
11275
|
+
if (p.isLoadingMode && p.closeListWhenLoading && p.items.length === 0 && this.isListOpen()) {
|
|
11261
11276
|
this.closeList();
|
|
11262
|
-
} else if (!p.isLoadingMode && document.activeElement && (
|
|
11277
|
+
} else if (!p.isLoadingMode && p.closeListWhenLoading && document.activeElement && (
|
|
11263
11278
|
(p.multi || p.searchable) && p.input.contains(document.activeElement) ||
|
|
11264
11279
|
!p.multi && !p.searchable && p.el.contains(document.activeElement))) {
|
|
11265
11280
|
this.openList();
|
|
@@ -11276,6 +11291,41 @@
|
|
|
11276
11291
|
return this._p.isLoadingMode;
|
|
11277
11292
|
}
|
|
11278
11293
|
|
|
11294
|
+
/**
|
|
11295
|
+
* Sets whether to close the list when loading mode is enabled
|
|
11296
|
+
* @param {boolean} closeListWhenLoading
|
|
11297
|
+
* @returns {SelectBox}
|
|
11298
|
+
*/
|
|
11299
|
+
setCloseListWhenLoading(closeListWhenLoading) {
|
|
11300
|
+
this._p.closeListWhenLoading = closeListWhenLoading;
|
|
11301
|
+
return this;
|
|
11302
|
+
}
|
|
11303
|
+
|
|
11304
|
+
/**
|
|
11305
|
+
* @returns {boolean}
|
|
11306
|
+
*/
|
|
11307
|
+
getCloseListWhenLoading() {
|
|
11308
|
+
return this._p.closeListWhenLoading;
|
|
11309
|
+
}
|
|
11310
|
+
|
|
11311
|
+
/**
|
|
11312
|
+
* Sets when to clear the input field
|
|
11313
|
+
* @param {string[]} clearInputWhen
|
|
11314
|
+
* @returns {SelectBox}
|
|
11315
|
+
*/
|
|
11316
|
+
setClearInputWhen(clearInputWhen) {
|
|
11317
|
+
this._p.clearInputWhen = Array.isArray(clearInputWhen) ? clearInputWhen.slice(0) : [];
|
|
11318
|
+
return this;
|
|
11319
|
+
}
|
|
11320
|
+
|
|
11321
|
+
/**
|
|
11322
|
+
* Retrieves the settings for when to clear the input field
|
|
11323
|
+
* @returns {string[]}
|
|
11324
|
+
*/
|
|
11325
|
+
getClearInputWhen() {
|
|
11326
|
+
return this._p.clearInputWhen;
|
|
11327
|
+
}
|
|
11328
|
+
|
|
11279
11329
|
/**
|
|
11280
11330
|
* Sets the appropriate direction for the selectbox
|
|
11281
11331
|
* @param {'ltr'|'rtl'|'auto'} direction
|
|
@@ -11649,8 +11699,12 @@
|
|
|
11649
11699
|
p.el.classList.add("".concat(p.baseClassName, "__closed_list"));
|
|
11650
11700
|
|
|
11651
11701
|
if (!p.multi) {
|
|
11702
|
+
if (p.clearInputWhen.includes('single_close'))
|
|
11652
11703
|
this._setInputText('');
|
|
11653
11704
|
this._scheduleSync('render_base');
|
|
11705
|
+
} else {
|
|
11706
|
+
if (p.clearInputWhen.includes('multi_close'))
|
|
11707
|
+
this._setInputText('');
|
|
11654
11708
|
}
|
|
11655
11709
|
|
|
11656
11710
|
this._trigger('close');
|
|
@@ -11706,7 +11760,7 @@
|
|
|
11706
11760
|
|
|
11707
11761
|
if (p.showSelection) {
|
|
11708
11762
|
if (checked) {
|
|
11709
|
-
if (dropList.itemCount() === 1) {
|
|
11763
|
+
if (dropList.itemCount() === 1 && p.clearInputWhen.includes('multi_select_single')) {
|
|
11710
11764
|
this._setInputText('');
|
|
11711
11765
|
}
|
|
11712
11766
|
|
|
@@ -11976,8 +12030,6 @@
|
|
|
11976
12030
|
|
|
11977
12031
|
p.filterTerm = p.input.value.trim();
|
|
11978
12032
|
(_p$dropList9 = p.dropList) === null || _p$dropList9 === void 0 || _p$dropList9.setSearchTerm(p.filterTerm, true);
|
|
11979
|
-
|
|
11980
|
-
this._trigger('search', { value: p.input.value });
|
|
11981
12033
|
}).
|
|
11982
12034
|
add(p.input, 'click.dropdown', () => {
|
|
11983
12035
|
if (p.disabled) return;
|