@danielgindi/selectbox 2.0.7 → 2.0.8
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 +48 -18
- 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 +48 -18
- 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 +48 -18
- 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 +24 -10
- 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.8
|
|
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
|
}
|
|
@@ -3018,17 +3027,19 @@ class DropList {
|
|
|
3018
3027
|
if (item._group) {
|
|
3019
3028
|
// Now loop through children below the group
|
|
3020
3029
|
|
|
3021
|
-
let
|
|
3030
|
+
let affectedCount = 0;
|
|
3022
3031
|
|
|
3023
3032
|
if (p.autoCheckGroupChildren) {
|
|
3024
3033
|
const items = p.filteredItems ?? p.items;
|
|
3025
3034
|
let groupIndex = items.indexOf(item);
|
|
3035
|
+
const groupLevel = item._level;
|
|
3026
3036
|
|
|
3027
3037
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3028
3038
|
let next = items[i];
|
|
3029
3039
|
|
|
3030
3040
|
// Hit the next group, break out
|
|
3031
|
-
if (
|
|
3041
|
+
if (!next._child && items[i - 1]._child || (
|
|
3042
|
+
groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3032
3043
|
break;
|
|
3033
3044
|
|
|
3034
3045
|
// No change, skip
|
|
@@ -3038,7 +3049,7 @@ class DropList {
|
|
|
3038
3049
|
// Update state
|
|
3039
3050
|
next._checked = item._checked;
|
|
3040
3051
|
|
|
3041
|
-
|
|
3052
|
+
affectedCount++;
|
|
3042
3053
|
|
|
3043
3054
|
// Update DOM
|
|
3044
3055
|
let nextEl = p.virtualListHelper.getItemElementAt(i);
|
|
@@ -3061,7 +3072,7 @@ class DropList {
|
|
|
3061
3072
|
this._trigger('groupcheck', {
|
|
3062
3073
|
value: item.value,
|
|
3063
3074
|
item: item[ItemSymbol] ?? item,
|
|
3064
|
-
|
|
3075
|
+
affectedCount: affectedCount
|
|
3065
3076
|
});
|
|
3066
3077
|
} else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
|
|
3067
3078
|
const items = p.filteredItems ?? p.items;
|
|
@@ -3095,18 +3106,21 @@ class DropList {
|
|
|
3095
3106
|
|
|
3096
3107
|
if (!groupItem || !groupItem._group) return this;
|
|
3097
3108
|
|
|
3098
|
-
let
|
|
3109
|
+
let next,hasChecked = false,hasUnchecked = false;
|
|
3110
|
+
|
|
3111
|
+
const groupLevel = groupItem._level;
|
|
3099
3112
|
|
|
3100
3113
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3101
|
-
|
|
3114
|
+
next = items[i];
|
|
3102
3115
|
|
|
3103
3116
|
// Hit the next group, break out
|
|
3104
|
-
if (
|
|
3117
|
+
if (!next._child && items[i - 1]._child || (
|
|
3118
|
+
groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3105
3119
|
break;
|
|
3106
3120
|
|
|
3107
|
-
if (
|
|
3121
|
+
if (next._checked) {
|
|
3108
3122
|
hasChecked = true;
|
|
3109
|
-
} else if (!
|
|
3123
|
+
} else if (!next._checked) {
|
|
3110
3124
|
hasUnchecked = true;
|
|
3111
3125
|
}
|
|
3112
3126
|
}
|
|
@@ -3463,11 +3477,12 @@ Emits the following events:
|
|
|
3463
3477
|
'open' { list: DropList }: the drop list is opening
|
|
3464
3478
|
'open:before' { list: DropList }: the drop list will open
|
|
3465
3479
|
'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.
|
|
3480
|
+
'addsel:before' {value, item, cancel: false, isCheckingGroup: bool}: an item selection is about to be added (in multi mode). return false to abort.
|
|
3481
|
+
'removesel:before' {value, item, cancel: false, isCheckingGroup: bool}: an item selection is about to be removed (in multi mode). return false to abort.
|
|
3482
|
+
'addsel' {value, item, isCheckingGroup: bool}: an item selection has been added (in multi mode)
|
|
3483
|
+
'removesel' {value, item, isCheckingGroup: bool}: an item selection has been removed (in multi mode)
|
|
3484
|
+
'groupcheck' {value, item, affectedCount: number}: an item selection has been removed (in multi mode)
|
|
3468
3485
|
'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
3486
|
'select' {value, item}: an item has been selected (in single mode)
|
|
3472
3487
|
'search' {value}: input box value has changed
|
|
3473
3488
|
'search:focus': input box has gained focus
|
|
@@ -5145,7 +5160,12 @@ class SelectBox {
|
|
|
5145
5160
|
let checked = event.checked;
|
|
5146
5161
|
if (event.isGroup && !p.treatGroupSelectionAsItems) return; // Ignore groups
|
|
5147
5162
|
|
|
5148
|
-
let selEvt = {
|
|
5163
|
+
let selEvt = {
|
|
5164
|
+
value: value,
|
|
5165
|
+
item: item,
|
|
5166
|
+
cancel: false,
|
|
5167
|
+
isCheckingGroup: event.isCheckingGroup
|
|
5168
|
+
};
|
|
5149
5169
|
this._trigger((checked ? 'addsel' : 'removesel') + ':before', selEvt);
|
|
5150
5170
|
|
|
5151
5171
|
if (selEvt.cancel) {
|
|
@@ -5203,16 +5223,26 @@ class SelectBox {
|
|
|
5203
5223
|
this._scheduleSync('syncPlaceholder');
|
|
5204
5224
|
}
|
|
5205
5225
|
|
|
5206
|
-
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
5226
|
+
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
5227
|
+
value: value,
|
|
5228
|
+
item: item,
|
|
5229
|
+
isCheckingGroup: event.isCheckingGroup
|
|
5230
|
+
});
|
|
5207
5231
|
}
|
|
5208
5232
|
break;
|
|
5209
5233
|
|
|
5210
5234
|
case 'groupcheck':{
|
|
5211
5235
|
if (!p.multi) return;
|
|
5212
5236
|
|
|
5213
|
-
if (event.
|
|
5237
|
+
if (event.affectedCount) {
|
|
5214
5238
|
this._scheduleSync(p.sortSelectedItems ? 'full' : 'render_base');
|
|
5215
5239
|
}
|
|
5240
|
+
|
|
5241
|
+
this._trigger('groupcheck', {
|
|
5242
|
+
value: event.value,
|
|
5243
|
+
item: event.item,
|
|
5244
|
+
affectedCount: event.affectedCount
|
|
5245
|
+
});
|
|
5216
5246
|
}
|
|
5217
5247
|
break;
|
|
5218
5248
|
|