@danielgindi/selectbox 1.0.65 → 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 +91 -35
- 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 +56 -14
- 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 +91 -35
- 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 +55 -13
- package/package.json +1 -1
package/dist/lib.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 1.0.
|
|
2
|
+
* @danielgindi/selectbox 1.0.68
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
@@ -8820,7 +8820,7 @@ var checkCorrectnessOfIteration = checkCorrectnessOfIteration$2;
|
|
|
8820
8820
|
var setToStringTag = setToStringTag$4;
|
|
8821
8821
|
var inheritIfRequired = inheritIfRequired$2;
|
|
8822
8822
|
|
|
8823
|
-
var collection$
|
|
8823
|
+
var collection$2 = function (CONSTRUCTOR_NAME, wrapper, common) {
|
|
8824
8824
|
var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
|
|
8825
8825
|
var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
|
|
8826
8826
|
var ADDER = IS_MAP ? 'set' : 'add';
|
|
@@ -8933,7 +8933,7 @@ var InternalStateModule = internalState;
|
|
|
8933
8933
|
var setInternalState = InternalStateModule.set;
|
|
8934
8934
|
var internalStateGetterFor = InternalStateModule.getterFor;
|
|
8935
8935
|
|
|
8936
|
-
var collectionStrong$
|
|
8936
|
+
var collectionStrong$2 = {
|
|
8937
8937
|
getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
|
|
8938
8938
|
var Constructor = wrapper(function (that, iterable) {
|
|
8939
8939
|
anInstance(that, Prototype);
|
|
@@ -9123,14 +9123,14 @@ var collectionStrong$1 = {
|
|
|
9123
9123
|
};
|
|
9124
9124
|
|
|
9125
9125
|
'use strict';
|
|
9126
|
-
var collection = collection$
|
|
9127
|
-
var collectionStrong = collectionStrong$
|
|
9126
|
+
var collection$1 = collection$2;
|
|
9127
|
+
var collectionStrong$1 = collectionStrong$2;
|
|
9128
9128
|
|
|
9129
9129
|
// `Set` constructor
|
|
9130
9130
|
// https://tc39.es/ecma262/#sec-set-objects
|
|
9131
|
-
collection('Set', function (init) {
|
|
9131
|
+
collection$1('Set', function (init) {
|
|
9132
9132
|
return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
|
|
9133
|
-
}, collectionStrong);
|
|
9133
|
+
}, collectionStrong$1);
|
|
9134
9134
|
|
|
9135
9135
|
var web_domCollections_iterator = {};
|
|
9136
9136
|
|
|
@@ -9370,6 +9370,20 @@ $$2({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
|
|
|
9370
9370
|
}
|
|
9371
9371
|
});
|
|
9372
9372
|
|
|
9373
|
+
var es_map = {};
|
|
9374
|
+
|
|
9375
|
+
var es_map_constructor = {};
|
|
9376
|
+
|
|
9377
|
+
'use strict';
|
|
9378
|
+
var collection = collection$2;
|
|
9379
|
+
var collectionStrong = collectionStrong$2;
|
|
9380
|
+
|
|
9381
|
+
// `Map` constructor
|
|
9382
|
+
// https://tc39.es/ecma262/#sec-map-objects
|
|
9383
|
+
collection('Map', function (init) {
|
|
9384
|
+
return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
|
|
9385
|
+
}, collectionStrong);
|
|
9386
|
+
|
|
9373
9387
|
var es_array_findIndex = {};
|
|
9374
9388
|
|
|
9375
9389
|
'use strict';
|
|
@@ -9935,6 +9949,7 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
9935
9949
|
}
|
|
9936
9950
|
|
|
9937
9951
|
this.setItems(o.items);
|
|
9952
|
+
delete o.items; // we do not need this in memory anymore
|
|
9938
9953
|
|
|
9939
9954
|
if (o.multi && Array.isArray(o.selectedValues)) {
|
|
9940
9955
|
this.setSelectedValues(o.selectedValues);
|
|
@@ -10086,6 +10101,8 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
10086
10101
|
p.filteredItems = null;
|
|
10087
10102
|
p.itemsChanged = true;
|
|
10088
10103
|
|
|
10104
|
+
this._updateItemByValueMap();
|
|
10105
|
+
|
|
10089
10106
|
if (resetValues) {
|
|
10090
10107
|
this.setSelectedValues(this.getSelectedValues());
|
|
10091
10108
|
}
|
|
@@ -10115,9 +10132,9 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
10115
10132
|
} }, { key: "updateItemByValue", value:
|
|
10116
10133
|
|
|
10117
10134
|
function updateItemByValue(value, newItem) {
|
|
10118
|
-
var p = this._p
|
|
10135
|
+
var p = this._p;
|
|
10119
10136
|
|
|
10120
|
-
var existingItem = p.
|
|
10137
|
+
var existingItem = p.itemByValueMap.get(value);
|
|
10121
10138
|
if (existingItem)
|
|
10122
10139
|
Object.assign(existingItem, newItem);
|
|
10123
10140
|
|
|
@@ -10639,11 +10656,17 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
10639
10656
|
*/ }, { key: "setValueProp", value:
|
|
10640
10657
|
function setValueProp(prop) {
|
|
10641
10658
|
var p = this._p;
|
|
10659
|
+
|
|
10660
|
+
if (p.valueProp === prop)
|
|
10661
|
+
return this;
|
|
10662
|
+
|
|
10642
10663
|
p.valueProp = prop;
|
|
10643
10664
|
|
|
10644
10665
|
if (p.dropList)
|
|
10645
10666
|
p.dropList.setValueProp(prop);
|
|
10646
10667
|
|
|
10668
|
+
this._updateItemByValueMap();
|
|
10669
|
+
|
|
10647
10670
|
return this;
|
|
10648
10671
|
}
|
|
10649
10672
|
|
|
@@ -10788,19 +10811,19 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
10788
10811
|
var selectedValues = [];
|
|
10789
10812
|
var selectedItems = [];var _iterator2 = _createForOfIteratorHelper(
|
|
10790
10813
|
|
|
10791
|
-
values),_step2;try {
|
|
10814
|
+
values),_step2;try {for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {var value = _step2.value;
|
|
10792
10815
|
if (set.has(value))
|
|
10793
|
-
|
|
10816
|
+
continue;
|
|
10794
10817
|
set.add(value);
|
|
10795
10818
|
|
|
10796
10819
|
selectedValues.push(value);
|
|
10797
10820
|
|
|
10798
|
-
var item = p.
|
|
10821
|
+
var item = p.itemByValueMap.get(value);
|
|
10799
10822
|
if (item !== undefined) {
|
|
10800
10823
|
selectedItems.push(item);
|
|
10801
10824
|
} else {
|
|
10802
10825
|
selectedItems.push(_defineProperty({}, p.valueProp, value));
|
|
10803
|
-
}
|
|
10826
|
+
}
|
|
10804
10827
|
}} catch (err) {_iterator2.e(err);} finally {_iterator2.f();}
|
|
10805
10828
|
|
|
10806
10829
|
p.selectedValues = selectedValues;
|
|
@@ -11016,6 +11039,21 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
11016
11039
|
return this;
|
|
11017
11040
|
}
|
|
11018
11041
|
|
|
11042
|
+
/**
|
|
11043
|
+
* Prepare the mapping between values and items.
|
|
11044
|
+
* This reduces search time greatly (i.e when checking items), especially when Vue proxies are in place.
|
|
11045
|
+
* @private
|
|
11046
|
+
*/ }, { key: "_updateItemByValueMap", value:
|
|
11047
|
+
function _updateItemByValueMap() {
|
|
11048
|
+
var p = this._p;
|
|
11049
|
+
|
|
11050
|
+
var itemByValueMap = p.itemByValueMap = new Map();
|
|
11051
|
+
var valueProp = p.valueProp;var _iterator3 = _createForOfIteratorHelper(
|
|
11052
|
+
p.items),_step3;try {for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {var item = _step3.value;
|
|
11053
|
+
itemByValueMap.set(item[valueProp], item);
|
|
11054
|
+
}} catch (err) {_iterator3.e(err);} finally {_iterator3.f();}
|
|
11055
|
+
}
|
|
11056
|
+
|
|
11019
11057
|
/** @private */ }, { key: "_renderBase", value:
|
|
11020
11058
|
function _renderBase() {var _this4 = this;
|
|
11021
11059
|
var p = this._p;
|
|
@@ -11926,9 +11964,9 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
11926
11964
|
var p = this._p;
|
|
11927
11965
|
|
|
11928
11966
|
if (this[DestroyedSymbol])
|
|
11929
|
-
return;var
|
|
11967
|
+
return;var _iterator4 = _createForOfIteratorHelper(
|
|
11930
11968
|
|
|
11931
|
-
queue),
|
|
11969
|
+
queue),_step4;try {for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {var op = _step4.value;
|
|
11932
11970
|
switch (op.mode) {
|
|
11933
11971
|
case 'full':
|
|
11934
11972
|
this._syncFull(true);
|
|
@@ -11993,7 +12031,7 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
11993
12031
|
this._syncFull(false);
|
|
11994
12032
|
break;}
|
|
11995
12033
|
|
|
11996
|
-
}} catch (err) {
|
|
12034
|
+
}} catch (err) {_iterator4.e(err);} finally {_iterator4.f();}
|
|
11997
12035
|
} }, { key: "_cleanupSingleWrapper", value:
|
|
11998
12036
|
|
|
11999
12037
|
function _cleanupSingleWrapper() {
|
|
@@ -12086,15 +12124,18 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12086
12124
|
|
|
12087
12125
|
/**
|
|
12088
12126
|
* @param {DropList.ItemBase} item
|
|
12127
|
+
* @returns {boolean} true if rendered, false if not
|
|
12089
12128
|
* @private
|
|
12090
12129
|
*/ }, { key: "_addMultiItemElement", value:
|
|
12091
12130
|
function _addMultiItemElement(item) {
|
|
12092
12131
|
var p = this._p;
|
|
12093
12132
|
var itemEl = this._renderMultiItem(item);
|
|
12094
|
-
if (!itemEl) return;
|
|
12133
|
+
if (!itemEl) return false;
|
|
12095
12134
|
|
|
12096
12135
|
DomCompat.before(p.inputWrapper, itemEl);
|
|
12097
12136
|
p.multiItemEls.push(itemEl);
|
|
12137
|
+
|
|
12138
|
+
return true;
|
|
12098
12139
|
}
|
|
12099
12140
|
|
|
12100
12141
|
/** @private */ }, { key: "_addMultiItemRestElement", value:
|
|
@@ -12116,10 +12157,13 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12116
12157
|
|
|
12117
12158
|
/** @private */ }, { key: "_syncClearButton", value:
|
|
12118
12159
|
function _syncClearButton() {var _this9 = this;
|
|
12119
|
-
var p = this._p
|
|
12160
|
+
var p = this._p,
|
|
12161
|
+
multiItemLabelProp = p.multiItemLabelProp;
|
|
12120
12162
|
|
|
12121
12163
|
// Set clear button
|
|
12122
|
-
if (p.selectedItems.length > 0 &&
|
|
12164
|
+
if (p.selectedItems.length > 0 &&
|
|
12165
|
+
p.selectedItems.some(function (x) {return x[multiItemLabelProp] !== false;}) &&
|
|
12166
|
+
p.clearable && p.showSelection) {
|
|
12123
12167
|
if (!p.clearButtonWrapper) {
|
|
12124
12168
|
p.clearButtonWrapper = Dom.createElement(
|
|
12125
12169
|
p.multi ? 'li' : 'span',
|
|
@@ -12149,7 +12193,8 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12149
12193
|
|
|
12150
12194
|
/** @private */ }, { key: "_syncPlaceholder", value:
|
|
12151
12195
|
function _syncPlaceholder() {
|
|
12152
|
-
var p = this._p
|
|
12196
|
+
var p = this._p,
|
|
12197
|
+
multiItemLabelProp = p.multiItemLabelProp;
|
|
12153
12198
|
|
|
12154
12199
|
var placeholder = '';
|
|
12155
12200
|
|
|
@@ -12159,7 +12204,9 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12159
12204
|
} else {
|
|
12160
12205
|
placeholder = defaultMultiPlaceholderFormatter(p.selectedItems, p.labelProp);
|
|
12161
12206
|
}
|
|
12162
|
-
} else if (p.selectedItems.length === 0 ||
|
|
12207
|
+
} else if (p.selectedItems.length === 0 ||
|
|
12208
|
+
!p.showSelection ||
|
|
12209
|
+
p.selectedItems.every(function (x) {return x[multiItemLabelProp] === false;})) {
|
|
12163
12210
|
placeholder = p.placeholder == null ? '' : p.placeholder + '';
|
|
12164
12211
|
}
|
|
12165
12212
|
|
|
@@ -12188,13 +12235,16 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12188
12235
|
* @returns {SelectBox}
|
|
12189
12236
|
*/ }, { key: "_syncFull", value:
|
|
12190
12237
|
function _syncFull(fullItemsRender) {
|
|
12191
|
-
var p = this._p
|
|
12238
|
+
var p = this._p,
|
|
12239
|
+
multiItemLabelProp = p.multiItemLabelProp;
|
|
12192
12240
|
|
|
12193
12241
|
this._renderBase();
|
|
12194
12242
|
this._syncClearButton();
|
|
12195
12243
|
this._syncPlaceholder();
|
|
12196
12244
|
|
|
12197
|
-
fullItemsRender = p.multi &&
|
|
12245
|
+
fullItemsRender = p.multi &&
|
|
12246
|
+
p.showSelection && (
|
|
12247
|
+
fullItemsRender || p.selectedItems.filter(function (x) {return x[multiItemLabelProp] !== false;}).length !== p.multiItemEls.length);
|
|
12198
12248
|
|
|
12199
12249
|
if (fullItemsRender || !p.showSelection || !p.multi) {
|
|
12200
12250
|
// Remove all item elements
|
|
@@ -12212,7 +12262,7 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12212
12262
|
// Sort these
|
|
12213
12263
|
if (p.sortSelectedItems) {
|
|
12214
12264
|
var labelProp = p.labelProp,
|
|
12215
|
-
|
|
12265
|
+
_multiItemLabelProp = p.multiItemLabelProp,
|
|
12216
12266
|
valueProp = p.valueProp,
|
|
12217
12267
|
stickyValues = p.stickyValues;
|
|
12218
12268
|
|
|
@@ -12224,8 +12274,8 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12224
12274
|
if (!sa && sb) return 1;
|
|
12225
12275
|
}
|
|
12226
12276
|
|
|
12227
|
-
var aLabel = a[
|
|
12228
|
-
var bLabel = b[
|
|
12277
|
+
var aLabel = a[_multiItemLabelProp] || a[labelProp];
|
|
12278
|
+
var bLabel = b[_multiItemLabelProp] || b[labelProp];
|
|
12229
12279
|
return aLabel < bLabel ? -1 : aLabel > bLabel ? 1 : 0;
|
|
12230
12280
|
};
|
|
12231
12281
|
|
|
@@ -12247,8 +12297,9 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12247
12297
|
break;
|
|
12248
12298
|
}
|
|
12249
12299
|
|
|
12250
|
-
|
|
12251
|
-
|
|
12300
|
+
if (this._addMultiItemElement(items[i])) {
|
|
12301
|
+
actualItemCount++;
|
|
12302
|
+
}
|
|
12252
12303
|
}
|
|
12253
12304
|
|
|
12254
12305
|
if (addRestItem) {
|
|
@@ -12355,19 +12406,19 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12355
12406
|
if (value === RestMultiItemsSymbol) {
|
|
12356
12407
|
var items = (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter(function (x) {return !x._group;})).
|
|
12357
12408
|
slice(p.maxMultiItems);
|
|
12358
|
-
var itemsToRemove = [];var
|
|
12409
|
+
var itemsToRemove = [];var _iterator5 = _createForOfIteratorHelper(
|
|
12359
12410
|
|
|
12360
|
-
items),
|
|
12411
|
+
items),_step5;try {for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {var _item3 = _step5.value;
|
|
12361
12412
|
var removeselEvt = { value: value, item: _item3, cancel: false };
|
|
12362
12413
|
this._trigger('removesel:before', removeselEvt);
|
|
12363
12414
|
if (!removeselEvt.cancel)
|
|
12364
12415
|
itemsToRemove.push(_item3);
|
|
12365
|
-
}} catch (err) {
|
|
12416
|
+
}} catch (err) {_iterator5.e(err);} finally {_iterator5.f();}
|
|
12366
12417
|
|
|
12367
12418
|
if (itemsToRemove.length > 0) {
|
|
12368
|
-
this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);var
|
|
12419
|
+
this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);var _iterator6 = _createForOfIteratorHelper(
|
|
12369
12420
|
|
|
12370
|
-
itemsToRemove),
|
|
12421
|
+
itemsToRemove),_step6;try {for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {var _item2 = _step6.value;
|
|
12371
12422
|
// sync selection
|
|
12372
12423
|
var idx = p.selectedItems.indexOf(_item2);
|
|
12373
12424
|
if (idx === -1)
|
|
@@ -12378,7 +12429,7 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12378
12429
|
p.selectionChanged = true;
|
|
12379
12430
|
p.resortBySelectionNeeded = true;
|
|
12380
12431
|
}
|
|
12381
|
-
}} catch (err) {
|
|
12432
|
+
}} catch (err) {_iterator6.e(err);} finally {_iterator6.f();}
|
|
12382
12433
|
}
|
|
12383
12434
|
|
|
12384
12435
|
if (items.length > itemsToRemove.length) {
|
|
@@ -12777,6 +12828,11 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12777
12828
|
stickyGroup = groups[0].filter(function (x) {return stickyValues.has(x[valueProp]);});
|
|
12778
12829
|
if (stickyGroup.length > 0) {
|
|
12779
12830
|
groups[0] = groups[0].filter(function (x) {return !stickyValues.has(x[valueProp]);});
|
|
12831
|
+
|
|
12832
|
+
if (groups[0].length === 0)
|
|
12833
|
+
groups.shift();
|
|
12834
|
+
} else {
|
|
12835
|
+
stickyGroup = null;
|
|
12780
12836
|
}
|
|
12781
12837
|
}
|
|
12782
12838
|
|
|
@@ -12801,7 +12857,7 @@ var SelectBox = /*#__PURE__*/function () {
|
|
|
12801
12857
|
});
|
|
12802
12858
|
}
|
|
12803
12859
|
|
|
12804
|
-
if (stickyGroup
|
|
12860
|
+
if (stickyGroup) {
|
|
12805
12861
|
groups.unshift(stickyGroup);
|
|
12806
12862
|
}
|
|
12807
12863
|
|