@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.cjs.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
|
'use strict';
|
|
@@ -188,7 +188,7 @@ Emits the following events:
|
|
|
188
188
|
'hide': the drop list was hidden.
|
|
189
189
|
'hide:after': emitted after the hide css transition has ended, or immediately after 'hide'.
|
|
190
190
|
'check' {value, item, checked: boolean, isGroup: boolean, isCheckingGroup: boolean}: item was selected (in multi mode).
|
|
191
|
-
'groupcheck' {value, item,
|
|
191
|
+
'groupcheck' {value, item, affectedCount: number}: item was selected (in multi mode).
|
|
192
192
|
'blur' {event}: element lost focus
|
|
193
193
|
'show_subitems {value, item, el, droplist: DropList}': subitems dropdown will show.
|
|
194
194
|
'hide_subitems {value, item, el}': subitems dropdown did hide.
|
|
@@ -781,6 +781,10 @@ class DropList {
|
|
|
781
781
|
p.groupCount++;
|
|
782
782
|
}
|
|
783
783
|
|
|
784
|
+
if (typeof oitem._level === 'number') {
|
|
785
|
+
item._level = oitem._level;
|
|
786
|
+
}
|
|
787
|
+
|
|
784
788
|
if (oitem._child) {
|
|
785
789
|
// This is used for setting a child class,
|
|
786
790
|
// But can be used to determine that current item is not part of above group,
|
|
@@ -883,6 +887,10 @@ class DropList {
|
|
|
883
887
|
}
|
|
884
888
|
}
|
|
885
889
|
|
|
890
|
+
if (hasOwnProperty.call(newItem, '_level')) {
|
|
891
|
+
newItem._level = item._level;
|
|
892
|
+
}
|
|
893
|
+
|
|
886
894
|
if (hasOwnProperty.call(newItem, '_child'))
|
|
887
895
|
item._child = !!newItem._child;
|
|
888
896
|
|
|
@@ -1212,6 +1220,7 @@ class DropList {
|
|
|
1212
1220
|
_nointeraction: !!oitem._nointeraction,
|
|
1213
1221
|
_subitems: oitem._subitems,
|
|
1214
1222
|
_group: !!oitem._group,
|
|
1223
|
+
_level: !!oitem._level,
|
|
1215
1224
|
_checked: !!oitem._checked
|
|
1216
1225
|
};
|
|
1217
1226
|
}
|
|
@@ -1755,15 +1764,23 @@ class DropList {
|
|
|
1755
1764
|
let item = p.items[i];
|
|
1756
1765
|
let checked = !item._nocheck && values.indexOf(item.value) !== -1;
|
|
1757
1766
|
|
|
1758
|
-
|
|
1759
|
-
|
|
1767
|
+
let itemIndex = i;
|
|
1768
|
+
if (p.filteredItems) {
|
|
1769
|
+
const item = p.items[itemIndex];
|
|
1770
|
+
itemIndex = p.filteredItems.indexOf(item);
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
if (item._group && itemIndex !== -1) {
|
|
1774
|
+
groupIndexes.push(itemIndex);
|
|
1760
1775
|
}
|
|
1761
1776
|
|
|
1762
1777
|
if (item._checked === checked) continue;
|
|
1763
1778
|
|
|
1764
1779
|
item._checked = checked;
|
|
1765
1780
|
|
|
1766
|
-
|
|
1781
|
+
if (itemIndex === -1) continue;
|
|
1782
|
+
|
|
1783
|
+
let li = p.virtualListHelper.getItemElementAt(itemIndex);
|
|
1767
1784
|
if (!li) continue;
|
|
1768
1785
|
|
|
1769
1786
|
DomCompat.toggleClass(li, `${p.baseClassName}__item_checked`, item._checked);
|
|
@@ -2064,7 +2081,7 @@ class DropList {
|
|
|
2064
2081
|
this.rushRefilter();
|
|
2065
2082
|
|
|
2066
2083
|
if (p.filteredItems) {
|
|
2067
|
-
const item = p.
|
|
2084
|
+
const item = p.filteredItems[itemIndex];
|
|
2068
2085
|
itemIndex = p.items.indexOf(item);
|
|
2069
2086
|
}
|
|
2070
2087
|
|
|
@@ -3018,17 +3035,19 @@ class DropList {
|
|
|
3018
3035
|
if (item._group) {
|
|
3019
3036
|
// Now loop through children below the group
|
|
3020
3037
|
|
|
3021
|
-
let
|
|
3038
|
+
let affectedCount = 0;
|
|
3022
3039
|
|
|
3023
3040
|
if (p.autoCheckGroupChildren) {
|
|
3024
3041
|
const items = p.filteredItems ?? p.items;
|
|
3025
3042
|
let groupIndex = items.indexOf(item);
|
|
3043
|
+
const groupLevel = item._level;
|
|
3026
3044
|
|
|
3027
3045
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3028
3046
|
let next = items[i];
|
|
3029
3047
|
|
|
3030
3048
|
// Hit the next group, break out
|
|
3031
|
-
if (
|
|
3049
|
+
if (!next._child && items[i - 1]._child || (
|
|
3050
|
+
groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3032
3051
|
break;
|
|
3033
3052
|
|
|
3034
3053
|
// No change, skip
|
|
@@ -3038,7 +3057,7 @@ class DropList {
|
|
|
3038
3057
|
// Update state
|
|
3039
3058
|
next._checked = item._checked;
|
|
3040
3059
|
|
|
3041
|
-
|
|
3060
|
+
affectedCount++;
|
|
3042
3061
|
|
|
3043
3062
|
// Update DOM
|
|
3044
3063
|
let nextEl = p.virtualListHelper.getItemElementAt(i);
|
|
@@ -3061,7 +3080,7 @@ class DropList {
|
|
|
3061
3080
|
this._trigger('groupcheck', {
|
|
3062
3081
|
value: item.value,
|
|
3063
3082
|
item: item[ItemSymbol] ?? item,
|
|
3064
|
-
|
|
3083
|
+
affectedCount: affectedCount
|
|
3065
3084
|
});
|
|
3066
3085
|
} else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
|
|
3067
3086
|
const items = p.filteredItems ?? p.items;
|
|
@@ -3095,18 +3114,21 @@ class DropList {
|
|
|
3095
3114
|
|
|
3096
3115
|
if (!groupItem || !groupItem._group) return this;
|
|
3097
3116
|
|
|
3098
|
-
let
|
|
3117
|
+
let next,hasChecked = false,hasUnchecked = false;
|
|
3118
|
+
|
|
3119
|
+
const groupLevel = groupItem._level;
|
|
3099
3120
|
|
|
3100
3121
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3101
|
-
|
|
3122
|
+
next = items[i];
|
|
3102
3123
|
|
|
3103
3124
|
// Hit the next group, break out
|
|
3104
|
-
if (
|
|
3125
|
+
if (!next._child && items[i - 1]._child || (
|
|
3126
|
+
groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3105
3127
|
break;
|
|
3106
3128
|
|
|
3107
|
-
if (
|
|
3129
|
+
if (next._checked) {
|
|
3108
3130
|
hasChecked = true;
|
|
3109
|
-
} else if (!
|
|
3131
|
+
} else if (!next._checked) {
|
|
3110
3132
|
hasUnchecked = true;
|
|
3111
3133
|
}
|
|
3112
3134
|
}
|
|
@@ -3463,11 +3485,12 @@ Emits the following events:
|
|
|
3463
3485
|
'open' { list: DropList }: the drop list is opening
|
|
3464
3486
|
'open:before' { list: DropList }: the drop list will open
|
|
3465
3487
|
'close': the drop list is closing
|
|
3466
|
-
'addsel:before' {value, item, cancel: false}: an item selection is about to be added (in multi mode). return false to abort.
|
|
3467
|
-
'removesel:before' {value, item, cancel: false}: an item selection is about to be removed (in multi mode). return false to abort.
|
|
3488
|
+
'addsel:before' {value, item, cancel: false, isCheckingGroup: bool}: an item selection is about to be added (in multi mode). return false to abort.
|
|
3489
|
+
'removesel:before' {value, item, cancel: false, isCheckingGroup: bool}: an item selection is about to be removed (in multi mode). return false to abort.
|
|
3490
|
+
'addsel' {value, item, isCheckingGroup: bool}: an item selection has been added (in multi mode)
|
|
3491
|
+
'removesel' {value, item, isCheckingGroup: bool}: an item selection has been removed (in multi mode)
|
|
3492
|
+
'groupcheck' {value, item, affectedCount: number}: an item selection has been removed (in multi mode)
|
|
3468
3493
|
'select:before' {value, item, cancel: false}: an item is about to be selected (in single mode). return false to abort.
|
|
3469
|
-
'addsel' {value, item}: an item selection has been added (in multi mode)
|
|
3470
|
-
'removesel' {value, item}: an item selection has been removed (in multi mode)
|
|
3471
3494
|
'select' {value, item}: an item has been selected (in single mode)
|
|
3472
3495
|
'search' {value}: input box value has changed
|
|
3473
3496
|
'search:focus': input box has gained focus
|
|
@@ -5145,7 +5168,12 @@ class SelectBox {
|
|
|
5145
5168
|
let checked = event.checked;
|
|
5146
5169
|
if (event.isGroup && !p.treatGroupSelectionAsItems) return; // Ignore groups
|
|
5147
5170
|
|
|
5148
|
-
let selEvt = {
|
|
5171
|
+
let selEvt = {
|
|
5172
|
+
value: value,
|
|
5173
|
+
item: item,
|
|
5174
|
+
cancel: false,
|
|
5175
|
+
isCheckingGroup: event.isCheckingGroup
|
|
5176
|
+
};
|
|
5149
5177
|
this._trigger((checked ? 'addsel' : 'removesel') + ':before', selEvt);
|
|
5150
5178
|
|
|
5151
5179
|
if (selEvt.cancel) {
|
|
@@ -5203,16 +5231,26 @@ class SelectBox {
|
|
|
5203
5231
|
this._scheduleSync('syncPlaceholder');
|
|
5204
5232
|
}
|
|
5205
5233
|
|
|
5206
|
-
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
5234
|
+
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
5235
|
+
value: value,
|
|
5236
|
+
item: item,
|
|
5237
|
+
isCheckingGroup: event.isCheckingGroup
|
|
5238
|
+
});
|
|
5207
5239
|
}
|
|
5208
5240
|
break;
|
|
5209
5241
|
|
|
5210
5242
|
case 'groupcheck':{
|
|
5211
5243
|
if (!p.multi) return;
|
|
5212
5244
|
|
|
5213
|
-
if (event.
|
|
5245
|
+
if (event.affectedCount) {
|
|
5214
5246
|
this._scheduleSync(p.sortSelectedItems ? 'full' : 'render_base');
|
|
5215
5247
|
}
|
|
5248
|
+
|
|
5249
|
+
this._trigger('groupcheck', {
|
|
5250
|
+
value: event.value,
|
|
5251
|
+
item: event.item,
|
|
5252
|
+
affectedCount: event.affectedCount
|
|
5253
|
+
});
|
|
5216
5254
|
}
|
|
5217
5255
|
break;
|
|
5218
5256
|
|