@danielgindi/selectbox 2.0.51 → 2.0.53
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/benchmarks/selectbox-value-lookup.mjs +311 -0
- package/css/droplist.css +1 -1
- package/css/droplist.css.map +1 -1
- package/dist/lib.cjs.js +118 -15
- 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 +151 -48
- 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 +118 -15
- 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/eslint.config.mjs +1 -1
- package/lib/DropList.js +90 -41
- package/lib/SelectBox.js +61 -7
- package/package.json +2 -1
- package/scss/droplist.scss +11 -8
- package/vue/DropList.vue +51 -31
package/dist/lib.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.53
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -6318,7 +6318,8 @@
|
|
|
6318
6318
|
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderNoResultsItem]
|
|
6319
6319
|
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderNoResultsItem]
|
|
6320
6320
|
* @property {function(name: string, data: *)} [on]
|
|
6321
|
-
* @property {boolean} [isHeaderVisible=false] show header element
|
|
6321
|
+
* @property {boolean} [isHeaderVisible=false] show header element
|
|
6322
|
+
* @property {boolean} [isFooterVisible=false] show footer element
|
|
6322
6323
|
* @property {boolean} [searchable=false] include inline search box
|
|
6323
6324
|
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
6324
6325
|
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
@@ -6392,6 +6393,7 @@
|
|
|
6392
6393
|
on: null,
|
|
6393
6394
|
|
|
6394
6395
|
isHeaderVisible: false,
|
|
6396
|
+
isFooterVisible: false,
|
|
6395
6397
|
searchable: false,
|
|
6396
6398
|
noResultsText: 'No matching results',
|
|
6397
6399
|
filterThrottleWindow: 300,
|
|
@@ -6465,6 +6467,7 @@
|
|
|
6465
6467
|
|
|
6466
6468
|
searchable: o.searchable,
|
|
6467
6469
|
isHeaderVisible: o.isHeaderVisible,
|
|
6470
|
+
isFooterVisible: o.isFooterVisible,
|
|
6468
6471
|
|
|
6469
6472
|
silenceEvents: true,
|
|
6470
6473
|
mitt: mitt(),
|
|
@@ -6522,6 +6525,10 @@
|
|
|
6522
6525
|
class: p.baseClassName + '_header'
|
|
6523
6526
|
});
|
|
6524
6527
|
|
|
6528
|
+
p.footerEl = Dom.createElement('div', {
|
|
6529
|
+
class: p.baseClassName + '_footer'
|
|
6530
|
+
});
|
|
6531
|
+
|
|
6525
6532
|
if (o.searchable) {
|
|
6526
6533
|
this.setSearchable(true);
|
|
6527
6534
|
}
|
|
@@ -6531,6 +6538,9 @@
|
|
|
6531
6538
|
|
|
6532
6539
|
wrapperEl.appendChild(menuEl);
|
|
6533
6540
|
|
|
6541
|
+
if (o.isFooterVisible)
|
|
6542
|
+
this.setFooterVisible(o.isFooterVisible);
|
|
6543
|
+
|
|
6534
6544
|
p.items = [];
|
|
6535
6545
|
p.groupCount = 0; // This will keep state of how many `group` items we have
|
|
6536
6546
|
p.mouseHandled = false;
|
|
@@ -7787,12 +7797,18 @@
|
|
|
7787
7797
|
headerHeight = Css.getElementHeight(p.headerEl, true, true);
|
|
7788
7798
|
}
|
|
7789
7799
|
|
|
7800
|
+
let footerHeight = 0;
|
|
7801
|
+
if (p.footerEl) {
|
|
7802
|
+
footerHeight = Css.getElementHeight(p.footerEl, true, true);
|
|
7803
|
+
}
|
|
7804
|
+
|
|
7790
7805
|
if (p.virtualListHelper.isVirtual()) {
|
|
7791
7806
|
maxViewHeight =
|
|
7792
7807
|
p.virtualListHelper.estimateFullHeight() +
|
|
7793
7808
|
verticalPadding +
|
|
7794
7809
|
verticalBorderWidth +
|
|
7795
|
-
headerHeight
|
|
7810
|
+
headerHeight +
|
|
7811
|
+
footerHeight;
|
|
7796
7812
|
} else {
|
|
7797
7813
|
// Another method to calculate height is measuring the whole thing at once.
|
|
7798
7814
|
// This causes relayout of course.
|
|
@@ -7936,7 +7952,7 @@
|
|
|
7936
7952
|
Css.setElementHeight(el, viewSize.height, true, true);
|
|
7937
7953
|
|
|
7938
7954
|
if (menuEl !== el) {
|
|
7939
|
-
let menuHeight = viewSize.height - headerHeight - verticalBorderWidth - verticalPadding;
|
|
7955
|
+
let menuHeight = viewSize.height - headerHeight - footerHeight - verticalBorderWidth - verticalPadding;
|
|
7940
7956
|
Css.setElementHeight(menuEl, menuHeight, true, true);
|
|
7941
7957
|
}
|
|
7942
7958
|
|
|
@@ -8272,9 +8288,42 @@
|
|
|
8272
8288
|
return this._p.headerEl;
|
|
8273
8289
|
}
|
|
8274
8290
|
|
|
8275
|
-
/**
|
|
8276
|
-
*
|
|
8277
|
-
* You should probably call `relayout()` after this.
|
|
8291
|
+
/**
|
|
8292
|
+
* Change visibility of the footer element
|
|
8293
|
+
* You should probably call `relayout()` after this.
|
|
8294
|
+
* @param {boolean} visible
|
|
8295
|
+
*/
|
|
8296
|
+
setFooterVisible(visible) {
|
|
8297
|
+
let isVisible = this.isFooterVisible();
|
|
8298
|
+
if (isVisible === !!visible)
|
|
8299
|
+
return;
|
|
8300
|
+
|
|
8301
|
+
if (visible) {
|
|
8302
|
+
this._p.el.appendChild(this._p.footerEl);
|
|
8303
|
+
} else {
|
|
8304
|
+
this._p.footerEl.remove();
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
|
|
8308
|
+
/**
|
|
8309
|
+
* Is the footer element visible?
|
|
8310
|
+
* @returns {boolean}
|
|
8311
|
+
*/
|
|
8312
|
+
isFooterVisible() {
|
|
8313
|
+
return !!this._p.footerEl.parentNode;
|
|
8314
|
+
}
|
|
8315
|
+
|
|
8316
|
+
/**
|
|
8317
|
+
* Get a reference to the footer element in order to add custom content.
|
|
8318
|
+
* @returns {Element}
|
|
8319
|
+
*/
|
|
8320
|
+
getFooterElement() {
|
|
8321
|
+
return this._p.footerEl;
|
|
8322
|
+
}
|
|
8323
|
+
|
|
8324
|
+
/**
|
|
8325
|
+
* Set inline search visibility
|
|
8326
|
+
* You should probably call `relayout()` after this.
|
|
8278
8327
|
* @param {boolean} searchable
|
|
8279
8328
|
*/
|
|
8280
8329
|
setSearchable(searchable) {
|
|
@@ -10430,7 +10479,7 @@
|
|
|
10430
10479
|
p.items = items.slice(0);
|
|
10431
10480
|
p.itemsChanged = true;
|
|
10432
10481
|
|
|
10433
|
-
this.
|
|
10482
|
+
this._refreshItemByValueMap();
|
|
10434
10483
|
|
|
10435
10484
|
if (resetValues) {
|
|
10436
10485
|
this.setSelectedValues(this.getSelectedValues());
|
|
@@ -10461,9 +10510,16 @@
|
|
|
10461
10510
|
updateItemByValue(value, newItem) {
|
|
10462
10511
|
const p = this._p;
|
|
10463
10512
|
|
|
10464
|
-
let existingItem =
|
|
10465
|
-
if (existingItem)
|
|
10466
|
-
|
|
10513
|
+
let existingItem = this._getItemByValue(value);
|
|
10514
|
+
if (existingItem) {var _p$itemByValueMap;
|
|
10515
|
+
const valueProp = existingItem[p.valueProp];
|
|
10516
|
+
if ((_p$itemByValueMap = p.itemByValueMap) !== null && _p$itemByValueMap !== void 0 && _p$itemByValueMap.has(valueProp))
|
|
10517
|
+
p.itemByValueMap.delete(valueProp);
|
|
10518
|
+
|
|
10519
|
+
Object.assign(existingItem, newItem);
|
|
10520
|
+
|
|
10521
|
+
p.itemByValueMap.set(existingItem[p.valueProp], existingItem);
|
|
10522
|
+
}
|
|
10467
10523
|
|
|
10468
10524
|
if (p.dropList) {
|
|
10469
10525
|
p.dropList.updateItemByValue(value, newItem);
|
|
@@ -11034,7 +11090,7 @@
|
|
|
11034
11090
|
if (p.dropList)
|
|
11035
11091
|
p.dropList.setValueProp(prop);
|
|
11036
11092
|
|
|
11037
|
-
this.
|
|
11093
|
+
this._refreshItemByValueMap();
|
|
11038
11094
|
|
|
11039
11095
|
return this;
|
|
11040
11096
|
}
|
|
@@ -11220,7 +11276,7 @@
|
|
|
11220
11276
|
|
|
11221
11277
|
selectedValues.push(value);
|
|
11222
11278
|
|
|
11223
|
-
let item =
|
|
11279
|
+
let item = this._getItemByValue(value);
|
|
11224
11280
|
if (item !== undefined) {
|
|
11225
11281
|
selectedItems.push(item);
|
|
11226
11282
|
} else {
|
|
@@ -11515,7 +11571,7 @@
|
|
|
11515
11571
|
* This reduces search time greatly (i.e when checking items), especially when Vue proxies are in place.
|
|
11516
11572
|
* @private
|
|
11517
11573
|
*/
|
|
11518
|
-
|
|
11574
|
+
_refreshItemByValueMap() {
|
|
11519
11575
|
const p = this._p;
|
|
11520
11576
|
|
|
11521
11577
|
const itemByValueMap = p.itemByValueMap = new Map();
|
|
@@ -11523,6 +11579,52 @@
|
|
|
11523
11579
|
for (let item of p.items) {
|
|
11524
11580
|
itemByValueMap.set(item[valueProp], item);
|
|
11525
11581
|
}
|
|
11582
|
+
|
|
11583
|
+
p.subitemByValueMap = null;
|
|
11584
|
+
}
|
|
11585
|
+
|
|
11586
|
+
/**
|
|
11587
|
+
* @param {*} value
|
|
11588
|
+
* @returns {DropList.ItemBase|undefined}
|
|
11589
|
+
* @private
|
|
11590
|
+
*/
|
|
11591
|
+
_getItemByValue(value) {
|
|
11592
|
+
const p = this._p;
|
|
11593
|
+
let item = p.itemByValueMap.get(value);
|
|
11594
|
+
if (item !== undefined)
|
|
11595
|
+
return item;
|
|
11596
|
+
|
|
11597
|
+
if (!p.subitemByValueMap)
|
|
11598
|
+
this._refreshSubitemByValueMap();
|
|
11599
|
+
|
|
11600
|
+
return p.subitemByValueMap.get(value);
|
|
11601
|
+
}
|
|
11602
|
+
|
|
11603
|
+
/** @private */
|
|
11604
|
+
_refreshSubitemByValueMap() {
|
|
11605
|
+
const p = this._p;
|
|
11606
|
+
const subitemByValueMap = p.subitemByValueMap = new Map();
|
|
11607
|
+
this._addSubitemsToValueMap(p.items, subitemByValueMap, p.valueProp);
|
|
11608
|
+
}
|
|
11609
|
+
|
|
11610
|
+
/**
|
|
11611
|
+
* @param {DropList.ItemBase[]} items
|
|
11612
|
+
* @param {Map<*, DropList.ItemBase>} itemByValueMap
|
|
11613
|
+
* @param {string} valueProp
|
|
11614
|
+
* @private
|
|
11615
|
+
*/
|
|
11616
|
+
_addSubitemsToValueMap(items, itemByValueMap, valueProp) {
|
|
11617
|
+
for (let item of items) {var _item$_subitems;
|
|
11618
|
+
if (!((_item$_subitems = item._subitems) !== null && _item$_subitems !== void 0 && _item$_subitems.length))
|
|
11619
|
+
continue;
|
|
11620
|
+
|
|
11621
|
+
for (let subitem of item._subitems) {
|
|
11622
|
+
if (!itemByValueMap.has(subitem[valueProp]))
|
|
11623
|
+
itemByValueMap.set(subitem[valueProp], subitem);
|
|
11624
|
+
}
|
|
11625
|
+
|
|
11626
|
+
this._addSubitemsToValueMap(item._subitems, itemByValueMap, valueProp);
|
|
11627
|
+
}
|
|
11526
11628
|
}
|
|
11527
11629
|
|
|
11528
11630
|
/** @private */
|
|
@@ -11907,7 +12009,8 @@
|
|
|
11907
12009
|
}
|
|
11908
12010
|
break;
|
|
11909
12011
|
|
|
11910
|
-
case 'select':
|
|
12012
|
+
case 'select':
|
|
12013
|
+
case 'subitems:select':{
|
|
11911
12014
|
if (p.multi) return;
|
|
11912
12015
|
|
|
11913
12016
|
const item = event.item;
|