@danielgindi/selectbox 2.0.9 → 2.0.11
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 +6753 -236
- 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 +36 -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 +11908 -5391
- 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 +6 -7
- package/lib/SelectBox.js +29 -0
- package/package.json +16 -16
- package/vue/DropList.vue +1 -1
- package/vue/SelectBox.vue +775 -775
package/dist/lib.es6.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.11
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
|
|
@@ -1197,7 +1197,10 @@ class DropList {
|
|
|
1197
1197
|
p.items.map(x => {
|
|
1198
1198
|
const y = x[ItemSymbol];
|
|
1199
1199
|
if (y !== undefined) {
|
|
1200
|
-
|
|
1200
|
+
// Seal it to avoid object finding issues when wrapped in proxies by Vue or other libs
|
|
1201
|
+
y[ItemSymbol] = Object.seal({
|
|
1202
|
+
[ItemSymbol]: x,
|
|
1203
|
+
});
|
|
1201
1204
|
return y;
|
|
1202
1205
|
}
|
|
1203
1206
|
|
|
@@ -1208,7 +1211,7 @@ class DropList {
|
|
|
1208
1211
|
if (Array.isArray(filteredItems)) {
|
|
1209
1212
|
// And back
|
|
1210
1213
|
filteredItems = filteredItems.map(oitem => {
|
|
1211
|
-
let our = oitem[ItemSymbol];
|
|
1214
|
+
let our = oitem[ItemSymbol]?.[ItemSymbol]; // double-unwrap sealed->item
|
|
1212
1215
|
if (!our) {
|
|
1213
1216
|
our = {
|
|
1214
1217
|
[ItemSymbol]: oitem,
|
|
@@ -1762,11 +1765,7 @@ class DropList {
|
|
|
1762
1765
|
let item = p.items[i];
|
|
1763
1766
|
let checked = !item._nocheck && values.indexOf(item.value) !== -1;
|
|
1764
1767
|
|
|
1765
|
-
let itemIndex = i;
|
|
1766
|
-
if (p.filteredItems) {
|
|
1767
|
-
const item = p.items[itemIndex];
|
|
1768
|
-
itemIndex = p.filteredItems.indexOf(item);
|
|
1769
|
-
}
|
|
1768
|
+
let itemIndex = p.filteredItems ? p.filteredItems.indexOf(item) : i;
|
|
1770
1769
|
|
|
1771
1770
|
if (item._group && itemIndex !== -1) {
|
|
1772
1771
|
groupIndexes.push(itemIndex);
|
|
@@ -3415,6 +3414,7 @@ const inputBackbufferCssProps = [
|
|
|
3415
3414
|
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderNoResultsItem]
|
|
3416
3415
|
* @property {boolean} [searchable=false] is it searchable?
|
|
3417
3416
|
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
3417
|
+
* @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.
|
|
3418
3418
|
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
3419
3419
|
* @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
|
|
3420
3420
|
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
@@ -3442,6 +3442,7 @@ const defaultOptions = {
|
|
|
3442
3442
|
multiPlaceholderFormatter: null,
|
|
3443
3443
|
searchable: true,
|
|
3444
3444
|
noResultsText: 'No matching results',
|
|
3445
|
+
autoSelectTextOnCheck: true,
|
|
3445
3446
|
filterThrottleWindow: 300,
|
|
3446
3447
|
filterOnEmptyTerm: false,
|
|
3447
3448
|
labelProp: 'label',
|
|
@@ -3536,6 +3537,7 @@ class SelectBox {
|
|
|
3536
3537
|
multiPlaceholderFormatter: o.multiPlaceholderFormatter,
|
|
3537
3538
|
searchable: o.searchable,
|
|
3538
3539
|
noResultsText: o.noResultsText,
|
|
3540
|
+
autoSelectTextOnCheck: o.autoSelectTextOnCheck,
|
|
3539
3541
|
|
|
3540
3542
|
labelProp: o.labelProp,
|
|
3541
3543
|
valueProp: o.valueProp,
|
|
@@ -4310,6 +4312,22 @@ class SelectBox {
|
|
|
4310
4312
|
return this._p.noResultsText;
|
|
4311
4313
|
}
|
|
4312
4314
|
|
|
4315
|
+
/**
|
|
4316
|
+
* @param {boolean} autoSelectTextOnCheck
|
|
4317
|
+
* @returns {SelectBox}
|
|
4318
|
+
*/
|
|
4319
|
+
setAutoSelectTextOnCheck(autoSelectTextOnCheck) {
|
|
4320
|
+
this._p.autoSelectTextOnCheck = autoSelectTextOnCheck;
|
|
4321
|
+
return this;
|
|
4322
|
+
}
|
|
4323
|
+
|
|
4324
|
+
/**
|
|
4325
|
+
* @returns {boolean}
|
|
4326
|
+
*/
|
|
4327
|
+
getAutoSelectTextOnCheck() {
|
|
4328
|
+
return this._p.autoSelectTextOnCheck;
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4313
4331
|
/**
|
|
4314
4332
|
* @param {number} window
|
|
4315
4333
|
* @returns {SelectBox}
|
|
@@ -5160,6 +5178,11 @@ class SelectBox {
|
|
|
5160
5178
|
case 'check': {
|
|
5161
5179
|
if (!p.multi) return;
|
|
5162
5180
|
|
|
5181
|
+
if (p.autoSelectTextOnCheck && p.input && document.activeElement === p.input) {
|
|
5182
|
+
// Select the text in the input, without causing any focus changes
|
|
5183
|
+
p.input.setSelectionRange(0, p.input.value.length);
|
|
5184
|
+
}
|
|
5185
|
+
|
|
5163
5186
|
const item = /**@type DropList.Item*/event.item;
|
|
5164
5187
|
const value = event.value;
|
|
5165
5188
|
|
|
@@ -5240,6 +5263,11 @@ class SelectBox {
|
|
|
5240
5263
|
case 'groupcheck': {
|
|
5241
5264
|
if (!p.multi) return;
|
|
5242
5265
|
|
|
5266
|
+
if (p.autoSelectTextOnCheck && p.input && document.activeElement === p.input) {
|
|
5267
|
+
// Select the text in the input, without causing any focus changes
|
|
5268
|
+
p.input.setSelectionRange(0, p.input.value.length);
|
|
5269
|
+
}
|
|
5270
|
+
|
|
5243
5271
|
if (event.affectedCount) {
|
|
5244
5272
|
this._scheduleSync(p.sortSelectedItems ? 'full' : 'render_base');
|
|
5245
5273
|
}
|