@danielgindi/selectbox 1.0.67 → 1.0.68
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 -22
- 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 +28 -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 +60 -22
- 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 +27 -3
- package/package.json +1 -1
package/lib/SelectBox.js
CHANGED
|
@@ -360,6 +360,7 @@ class SelectBox {
|
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
this.setItems(o.items);
|
|
363
|
+
delete o.items; // we do not need this in memory anymore
|
|
363
364
|
|
|
364
365
|
if (o.multi && Array.isArray(o.selectedValues)) {
|
|
365
366
|
this.setSelectedValues(o.selectedValues);
|
|
@@ -511,6 +512,8 @@ class SelectBox {
|
|
|
511
512
|
p.filteredItems = null;
|
|
512
513
|
p.itemsChanged = true;
|
|
513
514
|
|
|
515
|
+
this._updateItemByValueMap();
|
|
516
|
+
|
|
514
517
|
if (resetValues) {
|
|
515
518
|
this.setSelectedValues(this.getSelectedValues());
|
|
516
519
|
}
|
|
@@ -540,9 +543,9 @@ class SelectBox {
|
|
|
540
543
|
}
|
|
541
544
|
|
|
542
545
|
updateItemByValue(value, newItem) {
|
|
543
|
-
const p = this._p
|
|
546
|
+
const p = this._p;
|
|
544
547
|
|
|
545
|
-
let existingItem = p.
|
|
548
|
+
let existingItem = p.itemByValueMap.get(value);
|
|
546
549
|
if (existingItem)
|
|
547
550
|
Object.assign(existingItem, newItem);
|
|
548
551
|
|
|
@@ -1064,11 +1067,17 @@ class SelectBox {
|
|
|
1064
1067
|
*/
|
|
1065
1068
|
setValueProp(prop) {
|
|
1066
1069
|
const p = this._p;
|
|
1070
|
+
|
|
1071
|
+
if (p.valueProp === prop)
|
|
1072
|
+
return this;
|
|
1073
|
+
|
|
1067
1074
|
p.valueProp = prop;
|
|
1068
1075
|
|
|
1069
1076
|
if (p.dropList)
|
|
1070
1077
|
p.dropList.setValueProp(prop);
|
|
1071
1078
|
|
|
1079
|
+
this._updateItemByValueMap();
|
|
1080
|
+
|
|
1072
1081
|
return this;
|
|
1073
1082
|
}
|
|
1074
1083
|
|
|
@@ -1220,7 +1229,7 @@ class SelectBox {
|
|
|
1220
1229
|
|
|
1221
1230
|
selectedValues.push(value);
|
|
1222
1231
|
|
|
1223
|
-
let item = p.
|
|
1232
|
+
let item = p.itemByValueMap.get(value);
|
|
1224
1233
|
if (item !== undefined) {
|
|
1225
1234
|
selectedItems.push(item);
|
|
1226
1235
|
} else {
|
|
@@ -1441,6 +1450,21 @@ class SelectBox {
|
|
|
1441
1450
|
return this;
|
|
1442
1451
|
}
|
|
1443
1452
|
|
|
1453
|
+
/**
|
|
1454
|
+
* Prepare the mapping between values and items.
|
|
1455
|
+
* This reduces search time greatly (i.e when checking items), especially when Vue proxies are in place.
|
|
1456
|
+
* @private
|
|
1457
|
+
*/
|
|
1458
|
+
_updateItemByValueMap() {
|
|
1459
|
+
const p = this._p;
|
|
1460
|
+
|
|
1461
|
+
const itemByValueMap = p.itemByValueMap = new Map();
|
|
1462
|
+
const valueProp = p.valueProp;
|
|
1463
|
+
for (let item of p.items) {
|
|
1464
|
+
itemByValueMap.set(item[valueProp], item);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1444
1468
|
/** @private */
|
|
1445
1469
|
_renderBase() {
|
|
1446
1470
|
const p = this._p;
|
package/package.json
CHANGED