@danielgindi/selectbox 2.0.48 → 2.0.50
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 +50 -4
- 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 +50 -4
- 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 +50 -4
- 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/SelectBox.js +49 -3
- 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.50
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
@@ -9989,6 +9989,42 @@ const defaultMultiPlaceholderFormatter = (items, labelProp) => {
|
|
|
9989
9989
|
return title;
|
|
9990
9990
|
};
|
|
9991
9991
|
|
|
9992
|
+
|
|
9993
|
+
function getFocusState(element) {
|
|
9994
|
+
if (!element)
|
|
9995
|
+
return null;
|
|
9996
|
+
|
|
9997
|
+
const state = { element };
|
|
9998
|
+
|
|
9999
|
+
if (typeof element.selectionStart === 'number' &&
|
|
10000
|
+
typeof element.selectionEnd === 'number') {
|
|
10001
|
+
state.selectionStart = element.selectionStart;
|
|
10002
|
+
state.selectionEnd = element.selectionEnd;
|
|
10003
|
+
state.selectionDirection = element.selectionDirection;
|
|
10004
|
+
}
|
|
10005
|
+
|
|
10006
|
+
return state;
|
|
10007
|
+
}
|
|
10008
|
+
|
|
10009
|
+
function restoreFocusState(state) {
|
|
10010
|
+
if (!(state !== null && state !== void 0 && state.element) || !document.body.contains(state.element))
|
|
10011
|
+
return false;
|
|
10012
|
+
|
|
10013
|
+
state.element.focus();
|
|
10014
|
+
|
|
10015
|
+
if (typeof state.selectionStart === 'number' &&
|
|
10016
|
+
typeof state.selectionEnd === 'number' &&
|
|
10017
|
+
typeof state.element.setSelectionRange === 'function') {var _state$selectionDirec;
|
|
10018
|
+
state.element.setSelectionRange(
|
|
10019
|
+
state.selectionStart,
|
|
10020
|
+
state.selectionEnd, (_state$selectionDirec =
|
|
10021
|
+
state.selectionDirection) !== null && _state$selectionDirec !== void 0 ? _state$selectionDirec : 'none'
|
|
10022
|
+
);
|
|
10023
|
+
}
|
|
10024
|
+
|
|
10025
|
+
return true;
|
|
10026
|
+
}
|
|
10027
|
+
|
|
9992
10028
|
/*
|
|
9993
10029
|
Emits the following events:
|
|
9994
10030
|
---------------------------
|
|
@@ -11253,6 +11289,9 @@ class SelectBox {
|
|
|
11253
11289
|
|
|
11254
11290
|
this._trigger('open:before', { list: p.dropList });
|
|
11255
11291
|
|
|
11292
|
+
if (document.activeElement !== p.input)
|
|
11293
|
+
p.lastActiveElement = document.activeElement === document.body ? null : getFocusState(document.activeElement);
|
|
11294
|
+
|
|
11256
11295
|
// Propagate direction to droplist
|
|
11257
11296
|
p.dropList.setDirection(getComputedStyle(p.el).direction);
|
|
11258
11297
|
|
|
@@ -11287,6 +11326,12 @@ class SelectBox {
|
|
|
11287
11326
|
|
|
11288
11327
|
p.dropList.hide();
|
|
11289
11328
|
|
|
11329
|
+
if (p.lastActiveElement) {
|
|
11330
|
+
if (!p.multi && !p.searchable)
|
|
11331
|
+
restoreFocusState(p.lastActiveElement);
|
|
11332
|
+
p.lastActiveElement = null;
|
|
11333
|
+
}
|
|
11334
|
+
|
|
11290
11335
|
return this;
|
|
11291
11336
|
}
|
|
11292
11337
|
|
|
@@ -11879,9 +11924,10 @@ class SelectBox {
|
|
|
11879
11924
|
|
|
11880
11925
|
this.closeList();
|
|
11881
11926
|
|
|
11882
|
-
if (p.blurOnSingleSelection === 'touch' && hasTouchCapability ||
|
|
11883
|
-
p.blurOnSingleSelection !== 'touch' && p.blurOnSingleSelection)
|
|
11884
|
-
|
|
11927
|
+
if ((p.blurOnSingleSelection === 'touch' && hasTouchCapability ||
|
|
11928
|
+
p.blurOnSingleSelection !== 'touch' && p.blurOnSingleSelection) &&
|
|
11929
|
+
p.input && document.activeElement === p.input) {
|
|
11930
|
+
p.input.blur();
|
|
11885
11931
|
}
|
|
11886
11932
|
}
|
|
11887
11933
|
break;
|