@danielgindi/selectbox 1.0.73 → 1.0.74
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 +211 -169
- 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 -32
- 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 +211 -169
- 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 -31
- package/package.json +1 -1
package/dist/lib.es6.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 1.0.
|
|
2
|
+
* @danielgindi/selectbox 1.0.74
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
|
|
@@ -2585,7 +2585,7 @@ class SelectBox {
|
|
|
2585
2585
|
this.setValue(o.value);
|
|
2586
2586
|
}
|
|
2587
2587
|
|
|
2588
|
-
this._scheduleSync();
|
|
2588
|
+
this._scheduleSync('full');
|
|
2589
2589
|
|
|
2590
2590
|
this.silenceEvents = false;
|
|
2591
2591
|
|
|
@@ -2790,7 +2790,7 @@ class SelectBox {
|
|
|
2790
2790
|
return this;
|
|
2791
2791
|
|
|
2792
2792
|
this._p.clearable = !!clearable;
|
|
2793
|
-
this._scheduleSync();
|
|
2793
|
+
this._scheduleSync('render_clear');
|
|
2794
2794
|
return this;
|
|
2795
2795
|
}
|
|
2796
2796
|
|
|
@@ -2812,7 +2812,7 @@ class SelectBox {
|
|
|
2812
2812
|
return this;
|
|
2813
2813
|
|
|
2814
2814
|
this._p.hasOpenIndicator = enabled;
|
|
2815
|
-
this._scheduleSync();
|
|
2815
|
+
this._scheduleSync('render_base');
|
|
2816
2816
|
return this;
|
|
2817
2817
|
}
|
|
2818
2818
|
|
|
@@ -2829,7 +2829,7 @@ class SelectBox {
|
|
|
2829
2829
|
*/
|
|
2830
2830
|
setPlaceholder(placeholder) {
|
|
2831
2831
|
this._p.placeholder = placeholder == null ? '' : String(placeholder);
|
|
2832
|
-
this._scheduleSync();
|
|
2832
|
+
this._scheduleSync('render_base');
|
|
2833
2833
|
return this;
|
|
2834
2834
|
}
|
|
2835
2835
|
|
|
@@ -2897,7 +2897,7 @@ class SelectBox {
|
|
|
2897
2897
|
return this;
|
|
2898
2898
|
|
|
2899
2899
|
p.sortSelectedItems = sortSelectedItems;
|
|
2900
|
-
this._scheduleSync('
|
|
2900
|
+
this._scheduleSync('render_items');
|
|
2901
2901
|
return this;
|
|
2902
2902
|
}
|
|
2903
2903
|
|
|
@@ -2921,7 +2921,7 @@ class SelectBox {
|
|
|
2921
2921
|
p.sortListItems = sortListItems;
|
|
2922
2922
|
p.filteredItems = null;
|
|
2923
2923
|
p.itemsChanged = true;
|
|
2924
|
-
this._scheduleSync();
|
|
2924
|
+
this._scheduleSync('render_list');
|
|
2925
2925
|
return this;
|
|
2926
2926
|
}
|
|
2927
2927
|
|
|
@@ -2944,7 +2944,7 @@ class SelectBox {
|
|
|
2944
2944
|
|
|
2945
2945
|
p.sortCheckedFirst = sortListCheckedFirst;
|
|
2946
2946
|
p.itemsChanged = true;
|
|
2947
|
-
this._scheduleSync();
|
|
2947
|
+
this._scheduleSync('render_list');
|
|
2948
2948
|
return this;
|
|
2949
2949
|
}
|
|
2950
2950
|
|
|
@@ -2964,7 +2964,7 @@ class SelectBox {
|
|
|
2964
2964
|
|
|
2965
2965
|
p.stickyValues = Array.isArray(values) ? new Set(values) : null;
|
|
2966
2966
|
p.itemsChanged = true;
|
|
2967
|
-
this._scheduleSync();
|
|
2967
|
+
this._scheduleSync('render_list');
|
|
2968
2968
|
return this;
|
|
2969
2969
|
}
|
|
2970
2970
|
|
|
@@ -2986,7 +2986,7 @@ class SelectBox {
|
|
|
2986
2986
|
|
|
2987
2987
|
p.sortItemComparator = comparator;
|
|
2988
2988
|
p.itemsChanged = true;
|
|
2989
|
-
this._scheduleSync();
|
|
2989
|
+
this._scheduleSync('render_list');
|
|
2990
2990
|
return this;
|
|
2991
2991
|
}
|
|
2992
2992
|
|
|
@@ -3009,7 +3009,7 @@ class SelectBox {
|
|
|
3009
3009
|
|
|
3010
3010
|
p.treatGroupSelectionAsItems = treatGroupSelectionAsItems;
|
|
3011
3011
|
p.itemsChanged = true;
|
|
3012
|
-
this._scheduleSync();
|
|
3012
|
+
this._scheduleSync('render_list');
|
|
3013
3013
|
return this;
|
|
3014
3014
|
}
|
|
3015
3015
|
|
|
@@ -3032,7 +3032,7 @@ class SelectBox {
|
|
|
3032
3032
|
|
|
3033
3033
|
p.splitListCheckedGroups = splitListCheckedGroups;
|
|
3034
3034
|
p.itemsChanged = true;
|
|
3035
|
-
this._scheduleSync();
|
|
3035
|
+
this._scheduleSync('render_list');
|
|
3036
3036
|
return this;
|
|
3037
3037
|
}
|
|
3038
3038
|
|
|
@@ -3054,7 +3054,7 @@ class SelectBox {
|
|
|
3054
3054
|
return this;
|
|
3055
3055
|
|
|
3056
3056
|
p.showSelection = showSelection;
|
|
3057
|
-
this._scheduleSync('
|
|
3057
|
+
this._scheduleSync('render_items');
|
|
3058
3058
|
return this;
|
|
3059
3059
|
}
|
|
3060
3060
|
|
|
@@ -3076,7 +3076,7 @@ class SelectBox {
|
|
|
3076
3076
|
return this;
|
|
3077
3077
|
|
|
3078
3078
|
p.showPlaceholderInTooltip = showPlaceholderInTooltip;
|
|
3079
|
-
this._scheduleSync('
|
|
3079
|
+
this._scheduleSync('render_base');
|
|
3080
3080
|
return this;
|
|
3081
3081
|
}
|
|
3082
3082
|
|
|
@@ -3098,7 +3098,7 @@ class SelectBox {
|
|
|
3098
3098
|
return this;
|
|
3099
3099
|
|
|
3100
3100
|
p.multiPlaceholderFormatter = formatter;
|
|
3101
|
-
this._scheduleSync('
|
|
3101
|
+
this._scheduleSync('render_base');
|
|
3102
3102
|
return this;
|
|
3103
3103
|
}
|
|
3104
3104
|
|
|
@@ -3181,7 +3181,7 @@ class SelectBox {
|
|
|
3181
3181
|
*/
|
|
3182
3182
|
setNoResultsText(noResultsText) {
|
|
3183
3183
|
this._p.noResultsText = noResultsText;
|
|
3184
|
-
this._scheduleSync('
|
|
3184
|
+
this._scheduleSync('render_list');
|
|
3185
3185
|
return this;
|
|
3186
3186
|
}
|
|
3187
3187
|
|
|
@@ -4000,7 +4000,7 @@ class SelectBox {
|
|
|
4000
4000
|
|
|
4001
4001
|
if (!p.multi) {
|
|
4002
4002
|
this._setInputText('');
|
|
4003
|
-
this._scheduleSync();
|
|
4003
|
+
this._scheduleSync('render_base');
|
|
4004
4004
|
}
|
|
4005
4005
|
|
|
4006
4006
|
this._trigger('close');
|
|
@@ -4062,7 +4062,7 @@ class SelectBox {
|
|
|
4062
4062
|
}
|
|
4063
4063
|
|
|
4064
4064
|
if (!hasGroupSync)
|
|
4065
|
-
this._scheduleSync();
|
|
4065
|
+
this._scheduleSync('render_base');
|
|
4066
4066
|
}
|
|
4067
4067
|
} else {
|
|
4068
4068
|
if (p.maxMultiItems != null &&
|
|
@@ -4073,7 +4073,7 @@ class SelectBox {
|
|
|
4073
4073
|
}
|
|
4074
4074
|
|
|
4075
4075
|
if (!hasGroupSync)
|
|
4076
|
-
this._scheduleSync();
|
|
4076
|
+
this._scheduleSync('render_base');
|
|
4077
4077
|
}
|
|
4078
4078
|
}
|
|
4079
4079
|
|
|
@@ -4085,7 +4085,7 @@ class SelectBox {
|
|
|
4085
4085
|
if (!p.multi) return;
|
|
4086
4086
|
|
|
4087
4087
|
if (event.affectedItems) {
|
|
4088
|
-
this._scheduleSync(p.sortSelectedItems ? 'full' :
|
|
4088
|
+
this._scheduleSync(p.sortSelectedItems ? 'full' : 'render_base');
|
|
4089
4089
|
}
|
|
4090
4090
|
}
|
|
4091
4091
|
break;
|
|
@@ -4611,10 +4611,11 @@ class SelectBox {
|
|
|
4611
4611
|
if (!p.syncQueue)
|
|
4612
4612
|
p.syncQueue = [];
|
|
4613
4613
|
|
|
4614
|
-
if (mode === 'full')
|
|
4614
|
+
if (mode === 'full' || ('render_items' === mode && !p.syncQueue.some(x => x.mode === 'full')))
|
|
4615
4615
|
p.syncQueue.length = 0;
|
|
4616
4616
|
|
|
4617
|
-
if (p.syncQueue.length === 0 ||
|
|
4617
|
+
if (p.syncQueue.length === 0 ||
|
|
4618
|
+
(!['full', 'render_items'].includes(mode)))
|
|
4618
4619
|
p.syncQueue.push({ mode: mode, data: data });
|
|
4619
4620
|
|
|
4620
4621
|
if (p.syncTimeout)
|
|
@@ -4638,7 +4639,24 @@ class SelectBox {
|
|
|
4638
4639
|
for (let op of queue) {
|
|
4639
4640
|
switch (op.mode) {
|
|
4640
4641
|
case 'full':
|
|
4641
|
-
this._syncFull(true);
|
|
4642
|
+
this._syncFull(true, true);
|
|
4643
|
+
break;
|
|
4644
|
+
|
|
4645
|
+
case 'render_base':
|
|
4646
|
+
this._syncFull(false, false);
|
|
4647
|
+
break;
|
|
4648
|
+
|
|
4649
|
+
case 'render_items':
|
|
4650
|
+
this._syncFull(true, false);
|
|
4651
|
+
break;
|
|
4652
|
+
|
|
4653
|
+
case 'render_list':
|
|
4654
|
+
this._syncFull(false, true);
|
|
4655
|
+
break;
|
|
4656
|
+
|
|
4657
|
+
case 'render_clear':
|
|
4658
|
+
this._syncClearButton();
|
|
4659
|
+
this._resizeInput();
|
|
4642
4660
|
break;
|
|
4643
4661
|
|
|
4644
4662
|
case 'singleItem':
|
|
@@ -4695,10 +4713,6 @@ class SelectBox {
|
|
|
4695
4713
|
this._resizeInput();
|
|
4696
4714
|
}
|
|
4697
4715
|
break;
|
|
4698
|
-
|
|
4699
|
-
default:
|
|
4700
|
-
this._syncFull(false);
|
|
4701
|
-
break;
|
|
4702
4716
|
}
|
|
4703
4717
|
}
|
|
4704
4718
|
}
|
|
@@ -4908,9 +4922,10 @@ class SelectBox {
|
|
|
4908
4922
|
/**
|
|
4909
4923
|
* Syncs render state, selected items, and position
|
|
4910
4924
|
* @param {boolean=false} fullItemsRender Should re-render all items?
|
|
4925
|
+
* @param {boolean=false} updateListItems Should call updateListItems?
|
|
4911
4926
|
* @returns {SelectBox}
|
|
4912
4927
|
*/
|
|
4913
|
-
_syncFull(fullItemsRender) {
|
|
4928
|
+
_syncFull(fullItemsRender, updateListItems) {
|
|
4914
4929
|
const p = this._p,
|
|
4915
4930
|
multiItemLabelProp = p.multiItemLabelProp;
|
|
4916
4931
|
|
|
@@ -5003,8 +5018,9 @@ class SelectBox {
|
|
|
5003
5018
|
// Update input size
|
|
5004
5019
|
this._resizeInput();
|
|
5005
5020
|
|
|
5006
|
-
|
|
5007
|
-
|
|
5021
|
+
if (updateListItems) {
|
|
5022
|
+
this._updateListItems();
|
|
5023
|
+
}
|
|
5008
5024
|
|
|
5009
5025
|
return this;
|
|
5010
5026
|
}
|
|
@@ -5095,6 +5111,7 @@ class SelectBox {
|
|
|
5095
5111
|
}
|
|
5096
5112
|
|
|
5097
5113
|
if (itemsToRemove.length > 0) {
|
|
5114
|
+
// remove the "rest" element, we'll add that back later if necessary
|
|
5098
5115
|
this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
|
|
5099
5116
|
|
|
5100
5117
|
for (let item of itemsToRemove) {
|
|
@@ -5111,12 +5128,13 @@ class SelectBox {
|
|
|
5111
5128
|
}
|
|
5112
5129
|
}
|
|
5113
5130
|
|
|
5131
|
+
// we have not removed the whole "rest", then add the "rest" element back
|
|
5114
5132
|
if (items.length > itemsToRemove.length) {
|
|
5115
5133
|
this._addMultiItemRestElement();
|
|
5116
5134
|
}
|
|
5117
5135
|
|
|
5118
5136
|
if (itemsToRemove.length > 0) {
|
|
5119
|
-
this._scheduleSync();
|
|
5137
|
+
this._scheduleSync('render_list');
|
|
5120
5138
|
}
|
|
5121
5139
|
} else {
|
|
5122
5140
|
let removeselEvt = { value: value, item: item, cancel: false };
|
|
@@ -5184,7 +5202,7 @@ class SelectBox {
|
|
|
5184
5202
|
}
|
|
5185
5203
|
|
|
5186
5204
|
// sync
|
|
5187
|
-
this._scheduleSync();
|
|
5205
|
+
this._scheduleSync('render_list');
|
|
5188
5206
|
}
|
|
5189
5207
|
|
|
5190
5208
|
/**
|