@danielgindi/selectbox 2.0.6 → 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 +57 -19
- 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 +57 -19
- 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 +57 -19
- 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 +33 -11
- 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
|
|
|
@@ -1188,7 +1196,15 @@ class DropList {
|
|
|
1188
1196
|
if (typeof fn === 'function') {
|
|
1189
1197
|
// Send the original items to the filter function
|
|
1190
1198
|
filteredItems = p.filterFn(
|
|
1191
|
-
p.items.map((x) =>
|
|
1199
|
+
p.items.map((x) => {
|
|
1200
|
+
const y = x[ItemSymbol];
|
|
1201
|
+
if (y !== undefined) {
|
|
1202
|
+
y[ItemSymbol] = x;
|
|
1203
|
+
return y;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
return x;
|
|
1207
|
+
}),
|
|
1192
1208
|
term);
|
|
1193
1209
|
|
|
1194
1210
|
if (Array.isArray(filteredItems)) {
|
|
@@ -1204,6 +1220,7 @@ class DropList {
|
|
|
1204
1220
|
_nointeraction: !!oitem._nointeraction,
|
|
1205
1221
|
_subitems: oitem._subitems,
|
|
1206
1222
|
_group: !!oitem._group,
|
|
1223
|
+
_level: !!oitem._level,
|
|
1207
1224
|
_checked: !!oitem._checked
|
|
1208
1225
|
};
|
|
1209
1226
|
}
|
|
@@ -3010,17 +3027,19 @@ class DropList {
|
|
|
3010
3027
|
if (item._group) {
|
|
3011
3028
|
// Now loop through children below the group
|
|
3012
3029
|
|
|
3013
|
-
let
|
|
3030
|
+
let affectedCount = 0;
|
|
3014
3031
|
|
|
3015
3032
|
if (p.autoCheckGroupChildren) {
|
|
3016
3033
|
const items = p.filteredItems ?? p.items;
|
|
3017
3034
|
let groupIndex = items.indexOf(item);
|
|
3035
|
+
const groupLevel = item._level;
|
|
3018
3036
|
|
|
3019
3037
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3020
3038
|
let next = items[i];
|
|
3021
3039
|
|
|
3022
3040
|
// Hit the next group, break out
|
|
3023
|
-
if (
|
|
3041
|
+
if (!next._child && items[i - 1]._child || (
|
|
3042
|
+
groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3024
3043
|
break;
|
|
3025
3044
|
|
|
3026
3045
|
// No change, skip
|
|
@@ -3030,7 +3049,7 @@ class DropList {
|
|
|
3030
3049
|
// Update state
|
|
3031
3050
|
next._checked = item._checked;
|
|
3032
3051
|
|
|
3033
|
-
|
|
3052
|
+
affectedCount++;
|
|
3034
3053
|
|
|
3035
3054
|
// Update DOM
|
|
3036
3055
|
let nextEl = p.virtualListHelper.getItemElementAt(i);
|
|
@@ -3053,7 +3072,7 @@ class DropList {
|
|
|
3053
3072
|
this._trigger('groupcheck', {
|
|
3054
3073
|
value: item.value,
|
|
3055
3074
|
item: item[ItemSymbol] ?? item,
|
|
3056
|
-
|
|
3075
|
+
affectedCount: affectedCount
|
|
3057
3076
|
});
|
|
3058
3077
|
} else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
|
|
3059
3078
|
const items = p.filteredItems ?? p.items;
|
|
@@ -3087,18 +3106,21 @@ class DropList {
|
|
|
3087
3106
|
|
|
3088
3107
|
if (!groupItem || !groupItem._group) return this;
|
|
3089
3108
|
|
|
3090
|
-
let
|
|
3109
|
+
let next,hasChecked = false,hasUnchecked = false;
|
|
3110
|
+
|
|
3111
|
+
const groupLevel = groupItem._level;
|
|
3091
3112
|
|
|
3092
3113
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3093
|
-
|
|
3114
|
+
next = items[i];
|
|
3094
3115
|
|
|
3095
3116
|
// Hit the next group, break out
|
|
3096
|
-
if (
|
|
3117
|
+
if (!next._child && items[i - 1]._child || (
|
|
3118
|
+
groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3097
3119
|
break;
|
|
3098
3120
|
|
|
3099
|
-
if (
|
|
3121
|
+
if (next._checked) {
|
|
3100
3122
|
hasChecked = true;
|
|
3101
|
-
} else if (!
|
|
3123
|
+
} else if (!next._checked) {
|
|
3102
3124
|
hasUnchecked = true;
|
|
3103
3125
|
}
|
|
3104
3126
|
}
|
|
@@ -3455,11 +3477,12 @@ Emits the following events:
|
|
|
3455
3477
|
'open' { list: DropList }: the drop list is opening
|
|
3456
3478
|
'open:before' { list: DropList }: the drop list will open
|
|
3457
3479
|
'close': the drop list is closing
|
|
3458
|
-
'addsel:before' {value, item, cancel: false}: an item selection is about to be added (in multi mode). return false to abort.
|
|
3459
|
-
'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)
|
|
3460
3485
|
'select:before' {value, item, cancel: false}: an item is about to be selected (in single mode). return false to abort.
|
|
3461
|
-
'addsel' {value, item}: an item selection has been added (in multi mode)
|
|
3462
|
-
'removesel' {value, item}: an item selection has been removed (in multi mode)
|
|
3463
3486
|
'select' {value, item}: an item has been selected (in single mode)
|
|
3464
3487
|
'search' {value}: input box value has changed
|
|
3465
3488
|
'search:focus': input box has gained focus
|
|
@@ -5137,7 +5160,12 @@ class SelectBox {
|
|
|
5137
5160
|
let checked = event.checked;
|
|
5138
5161
|
if (event.isGroup && !p.treatGroupSelectionAsItems) return; // Ignore groups
|
|
5139
5162
|
|
|
5140
|
-
let selEvt = {
|
|
5163
|
+
let selEvt = {
|
|
5164
|
+
value: value,
|
|
5165
|
+
item: item,
|
|
5166
|
+
cancel: false,
|
|
5167
|
+
isCheckingGroup: event.isCheckingGroup
|
|
5168
|
+
};
|
|
5141
5169
|
this._trigger((checked ? 'addsel' : 'removesel') + ':before', selEvt);
|
|
5142
5170
|
|
|
5143
5171
|
if (selEvt.cancel) {
|
|
@@ -5195,16 +5223,26 @@ class SelectBox {
|
|
|
5195
5223
|
this._scheduleSync('syncPlaceholder');
|
|
5196
5224
|
}
|
|
5197
5225
|
|
|
5198
|
-
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
5226
|
+
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
5227
|
+
value: value,
|
|
5228
|
+
item: item,
|
|
5229
|
+
isCheckingGroup: event.isCheckingGroup
|
|
5230
|
+
});
|
|
5199
5231
|
}
|
|
5200
5232
|
break;
|
|
5201
5233
|
|
|
5202
5234
|
case 'groupcheck':{
|
|
5203
5235
|
if (!p.multi) return;
|
|
5204
5236
|
|
|
5205
|
-
if (event.
|
|
5237
|
+
if (event.affectedCount) {
|
|
5206
5238
|
this._scheduleSync(p.sortSelectedItems ? 'full' : 'render_base');
|
|
5207
5239
|
}
|
|
5240
|
+
|
|
5241
|
+
this._trigger('groupcheck', {
|
|
5242
|
+
value: event.value,
|
|
5243
|
+
item: event.item,
|
|
5244
|
+
affectedCount: event.affectedCount
|
|
5245
|
+
});
|
|
5208
5246
|
}
|
|
5209
5247
|
break;
|
|
5210
5248
|
|