@danielgindi/selectbox 2.0.7 → 2.0.9
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 +60 -22
- 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/DropList.js +36 -14
- package/lib/SelectBox.js +23 -7
- package/package.json +1 -1
- package/vue/SelectBox.vue +3 -2
package/dist/lib.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.9
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
'hide': the drop list was hidden.
|
|
185
185
|
'hide:after': emitted after the hide css transition has ended, or immediately after 'hide'.
|
|
186
186
|
'check' {value, item, checked: boolean, isGroup: boolean, isCheckingGroup: boolean}: item was selected (in multi mode).
|
|
187
|
-
'groupcheck' {value, item,
|
|
187
|
+
'groupcheck' {value, item, affectedCount: number}: item was selected (in multi mode).
|
|
188
188
|
'blur' {event}: element lost focus
|
|
189
189
|
'show_subitems {value, item, el, droplist: DropList}': subitems dropdown will show.
|
|
190
190
|
'hide_subitems {value, item, el}': subitems dropdown did hide.
|
|
@@ -777,6 +777,10 @@
|
|
|
777
777
|
p.groupCount++;
|
|
778
778
|
}
|
|
779
779
|
|
|
780
|
+
if (typeof oitem._level === 'number') {
|
|
781
|
+
item._level = oitem._level;
|
|
782
|
+
}
|
|
783
|
+
|
|
780
784
|
if (oitem._child) {
|
|
781
785
|
// This is used for setting a child class,
|
|
782
786
|
// But can be used to determine that current item is not part of above group,
|
|
@@ -879,6 +883,10 @@
|
|
|
879
883
|
}
|
|
880
884
|
}
|
|
881
885
|
|
|
886
|
+
if (hasOwnProperty.call(newItem, '_level')) {
|
|
887
|
+
newItem._level = item._level;
|
|
888
|
+
}
|
|
889
|
+
|
|
882
890
|
if (hasOwnProperty.call(newItem, '_child'))
|
|
883
891
|
item._child = !!newItem._child;
|
|
884
892
|
|
|
@@ -1208,6 +1216,7 @@
|
|
|
1208
1216
|
_nointeraction: !!oitem._nointeraction,
|
|
1209
1217
|
_subitems: oitem._subitems,
|
|
1210
1218
|
_group: !!oitem._group,
|
|
1219
|
+
_level: !!oitem._level,
|
|
1211
1220
|
_checked: !!oitem._checked
|
|
1212
1221
|
};
|
|
1213
1222
|
}
|
|
@@ -1751,15 +1760,23 @@
|
|
|
1751
1760
|
let item = p.items[i];
|
|
1752
1761
|
let checked = !item._nocheck && values.indexOf(item.value) !== -1;
|
|
1753
1762
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1763
|
+
let itemIndex = i;
|
|
1764
|
+
if (p.filteredItems) {
|
|
1765
|
+
const item = p.items[itemIndex];
|
|
1766
|
+
itemIndex = p.filteredItems.indexOf(item);
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
if (item._group && itemIndex !== -1) {
|
|
1770
|
+
groupIndexes.push(itemIndex);
|
|
1756
1771
|
}
|
|
1757
1772
|
|
|
1758
1773
|
if (item._checked === checked) continue;
|
|
1759
1774
|
|
|
1760
1775
|
item._checked = checked;
|
|
1761
1776
|
|
|
1762
|
-
|
|
1777
|
+
if (itemIndex === -1) continue;
|
|
1778
|
+
|
|
1779
|
+
let li = p.virtualListHelper.getItemElementAt(itemIndex);
|
|
1763
1780
|
if (!li) continue;
|
|
1764
1781
|
|
|
1765
1782
|
DomCompat.toggleClass(li, `${p.baseClassName}__item_checked`, item._checked);
|
|
@@ -2060,7 +2077,7 @@
|
|
|
2060
2077
|
this.rushRefilter();
|
|
2061
2078
|
|
|
2062
2079
|
if (p.filteredItems) {
|
|
2063
|
-
const item = p.
|
|
2080
|
+
const item = p.filteredItems[itemIndex];
|
|
2064
2081
|
itemIndex = p.items.indexOf(item);
|
|
2065
2082
|
}
|
|
2066
2083
|
|
|
@@ -3014,17 +3031,19 @@
|
|
|
3014
3031
|
if (item._group) {
|
|
3015
3032
|
// Now loop through children below the group
|
|
3016
3033
|
|
|
3017
|
-
let
|
|
3034
|
+
let affectedCount = 0;
|
|
3018
3035
|
|
|
3019
3036
|
if (p.autoCheckGroupChildren) {
|
|
3020
3037
|
const items = p.filteredItems ?? p.items;
|
|
3021
3038
|
let groupIndex = items.indexOf(item);
|
|
3039
|
+
const groupLevel = item._level;
|
|
3022
3040
|
|
|
3023
3041
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3024
3042
|
let next = items[i];
|
|
3025
3043
|
|
|
3026
3044
|
// Hit the next group, break out
|
|
3027
|
-
if (
|
|
3045
|
+
if (!next._child && items[i - 1]._child || (
|
|
3046
|
+
groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3028
3047
|
break;
|
|
3029
3048
|
|
|
3030
3049
|
// No change, skip
|
|
@@ -3034,7 +3053,7 @@
|
|
|
3034
3053
|
// Update state
|
|
3035
3054
|
next._checked = item._checked;
|
|
3036
3055
|
|
|
3037
|
-
|
|
3056
|
+
affectedCount++;
|
|
3038
3057
|
|
|
3039
3058
|
// Update DOM
|
|
3040
3059
|
let nextEl = p.virtualListHelper.getItemElementAt(i);
|
|
@@ -3057,7 +3076,7 @@
|
|
|
3057
3076
|
this._trigger('groupcheck', {
|
|
3058
3077
|
value: item.value,
|
|
3059
3078
|
item: item[ItemSymbol] ?? item,
|
|
3060
|
-
|
|
3079
|
+
affectedCount: affectedCount
|
|
3061
3080
|
});
|
|
3062
3081
|
} else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
|
|
3063
3082
|
const items = p.filteredItems ?? p.items;
|
|
@@ -3091,18 +3110,21 @@
|
|
|
3091
3110
|
|
|
3092
3111
|
if (!groupItem || !groupItem._group) return this;
|
|
3093
3112
|
|
|
3094
|
-
let
|
|
3113
|
+
let next,hasChecked = false,hasUnchecked = false;
|
|
3114
|
+
|
|
3115
|
+
const groupLevel = groupItem._level;
|
|
3095
3116
|
|
|
3096
3117
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3097
|
-
|
|
3118
|
+
next = items[i];
|
|
3098
3119
|
|
|
3099
3120
|
// Hit the next group, break out
|
|
3100
|
-
if (
|
|
3121
|
+
if (!next._child && items[i - 1]._child || (
|
|
3122
|
+
groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3101
3123
|
break;
|
|
3102
3124
|
|
|
3103
|
-
if (
|
|
3125
|
+
if (next._checked) {
|
|
3104
3126
|
hasChecked = true;
|
|
3105
|
-
} else if (!
|
|
3127
|
+
} else if (!next._checked) {
|
|
3106
3128
|
hasUnchecked = true;
|
|
3107
3129
|
}
|
|
3108
3130
|
}
|
|
@@ -3459,11 +3481,12 @@
|
|
|
3459
3481
|
'open' { list: DropList }: the drop list is opening
|
|
3460
3482
|
'open:before' { list: DropList }: the drop list will open
|
|
3461
3483
|
'close': the drop list is closing
|
|
3462
|
-
'addsel:before' {value, item, cancel: false}: an item selection is about to be added (in multi mode). return false to abort.
|
|
3463
|
-
'removesel:before' {value, item, cancel: false}: an item selection is about to be removed (in multi mode). return false to abort.
|
|
3484
|
+
'addsel:before' {value, item, cancel: false, isCheckingGroup: bool}: an item selection is about to be added (in multi mode). return false to abort.
|
|
3485
|
+
'removesel:before' {value, item, cancel: false, isCheckingGroup: bool}: an item selection is about to be removed (in multi mode). return false to abort.
|
|
3486
|
+
'addsel' {value, item, isCheckingGroup: bool}: an item selection has been added (in multi mode)
|
|
3487
|
+
'removesel' {value, item, isCheckingGroup: bool}: an item selection has been removed (in multi mode)
|
|
3488
|
+
'groupcheck' {value, item, affectedCount: number}: an item selection has been removed (in multi mode)
|
|
3464
3489
|
'select:before' {value, item, cancel: false}: an item is about to be selected (in single mode). return false to abort.
|
|
3465
|
-
'addsel' {value, item}: an item selection has been added (in multi mode)
|
|
3466
|
-
'removesel' {value, item}: an item selection has been removed (in multi mode)
|
|
3467
3490
|
'select' {value, item}: an item has been selected (in single mode)
|
|
3468
3491
|
'search' {value}: input box value has changed
|
|
3469
3492
|
'search:focus': input box has gained focus
|
|
@@ -5141,7 +5164,12 @@
|
|
|
5141
5164
|
let checked = event.checked;
|
|
5142
5165
|
if (event.isGroup && !p.treatGroupSelectionAsItems) return; // Ignore groups
|
|
5143
5166
|
|
|
5144
|
-
let selEvt = {
|
|
5167
|
+
let selEvt = {
|
|
5168
|
+
value: value,
|
|
5169
|
+
item: item,
|
|
5170
|
+
cancel: false,
|
|
5171
|
+
isCheckingGroup: event.isCheckingGroup
|
|
5172
|
+
};
|
|
5145
5173
|
this._trigger((checked ? 'addsel' : 'removesel') + ':before', selEvt);
|
|
5146
5174
|
|
|
5147
5175
|
if (selEvt.cancel) {
|
|
@@ -5199,16 +5227,26 @@
|
|
|
5199
5227
|
this._scheduleSync('syncPlaceholder');
|
|
5200
5228
|
}
|
|
5201
5229
|
|
|
5202
|
-
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
5230
|
+
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
5231
|
+
value: value,
|
|
5232
|
+
item: item,
|
|
5233
|
+
isCheckingGroup: event.isCheckingGroup
|
|
5234
|
+
});
|
|
5203
5235
|
}
|
|
5204
5236
|
break;
|
|
5205
5237
|
|
|
5206
5238
|
case 'groupcheck':{
|
|
5207
5239
|
if (!p.multi) return;
|
|
5208
5240
|
|
|
5209
|
-
if (event.
|
|
5241
|
+
if (event.affectedCount) {
|
|
5210
5242
|
this._scheduleSync(p.sortSelectedItems ? 'full' : 'render_base');
|
|
5211
5243
|
}
|
|
5244
|
+
|
|
5245
|
+
this._trigger('groupcheck', {
|
|
5246
|
+
value: event.value,
|
|
5247
|
+
item: event.item,
|
|
5248
|
+
affectedCount: event.affectedCount
|
|
5249
|
+
});
|
|
5212
5250
|
}
|
|
5213
5251
|
break;
|
|
5214
5252
|
|