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