@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/lib/DropList.js
CHANGED
|
@@ -158,7 +158,7 @@ Emits the following events:
|
|
|
158
158
|
'hide': the drop list was hidden.
|
|
159
159
|
'hide:after': emitted after the hide css transition has ended, or immediately after 'hide'.
|
|
160
160
|
'check' {value, item, checked: boolean, isGroup: boolean, isCheckingGroup: boolean}: item was selected (in multi mode).
|
|
161
|
-
'groupcheck' {value, item,
|
|
161
|
+
'groupcheck' {value, item, affectedCount: number}: item was selected (in multi mode).
|
|
162
162
|
'blur' {event}: element lost focus
|
|
163
163
|
'show_subitems {value, item, el, droplist: DropList}': subitems dropdown will show.
|
|
164
164
|
'hide_subitems {value, item, el}': subitems dropdown did hide.
|
|
@@ -751,6 +751,10 @@ class DropList {
|
|
|
751
751
|
p.groupCount++;
|
|
752
752
|
}
|
|
753
753
|
|
|
754
|
+
if (typeof oitem._level === 'number') {
|
|
755
|
+
item._level = oitem._level;
|
|
756
|
+
}
|
|
757
|
+
|
|
754
758
|
if (oitem._child) {
|
|
755
759
|
// This is used for setting a child class,
|
|
756
760
|
// But can be used to determine that current item is not part of above group,
|
|
@@ -853,6 +857,10 @@ class DropList {
|
|
|
853
857
|
}
|
|
854
858
|
}
|
|
855
859
|
|
|
860
|
+
if (hasOwnProperty.call(newItem, '_level')) {
|
|
861
|
+
newItem._level = item._level;
|
|
862
|
+
}
|
|
863
|
+
|
|
856
864
|
if (hasOwnProperty.call(newItem, '_child'))
|
|
857
865
|
item._child = !!newItem._child;
|
|
858
866
|
|
|
@@ -1182,6 +1190,7 @@ class DropList {
|
|
|
1182
1190
|
_nointeraction: !!oitem._nointeraction,
|
|
1183
1191
|
_subitems: oitem._subitems,
|
|
1184
1192
|
_group: !!oitem._group,
|
|
1193
|
+
_level: !!oitem._level,
|
|
1185
1194
|
_checked: !!oitem._checked,
|
|
1186
1195
|
};
|
|
1187
1196
|
}
|
|
@@ -1725,15 +1734,23 @@ class DropList {
|
|
|
1725
1734
|
let item = p.items[i];
|
|
1726
1735
|
let checked = !item._nocheck && values.indexOf(item.value) !== -1;
|
|
1727
1736
|
|
|
1728
|
-
|
|
1729
|
-
|
|
1737
|
+
let itemIndex = i;
|
|
1738
|
+
if (p.filteredItems) {
|
|
1739
|
+
const item = p.items[itemIndex];
|
|
1740
|
+
itemIndex = p.filteredItems.indexOf(item);
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
if (item._group && itemIndex !== -1) {
|
|
1744
|
+
groupIndexes.push(itemIndex);
|
|
1730
1745
|
}
|
|
1731
1746
|
|
|
1732
1747
|
if (item._checked === checked) continue;
|
|
1733
1748
|
|
|
1734
1749
|
item._checked = checked;
|
|
1735
1750
|
|
|
1736
|
-
|
|
1751
|
+
if (itemIndex === -1) continue;
|
|
1752
|
+
|
|
1753
|
+
let li = p.virtualListHelper.getItemElementAt(itemIndex);
|
|
1737
1754
|
if (!li) continue;
|
|
1738
1755
|
|
|
1739
1756
|
toggleClass(li, `${p.baseClassName}__item_checked`, item._checked);
|
|
@@ -2034,7 +2051,7 @@ class DropList {
|
|
|
2034
2051
|
this.rushRefilter();
|
|
2035
2052
|
|
|
2036
2053
|
if (p.filteredItems) {
|
|
2037
|
-
const item = p.
|
|
2054
|
+
const item = p.filteredItems[itemIndex];
|
|
2038
2055
|
itemIndex = p.items.indexOf(item);
|
|
2039
2056
|
}
|
|
2040
2057
|
|
|
@@ -2988,17 +3005,19 @@ class DropList {
|
|
|
2988
3005
|
if (item._group) {
|
|
2989
3006
|
// Now loop through children below the group
|
|
2990
3007
|
|
|
2991
|
-
let
|
|
3008
|
+
let affectedCount = 0;
|
|
2992
3009
|
|
|
2993
3010
|
if (p.autoCheckGroupChildren) {
|
|
2994
3011
|
const items = p.filteredItems ?? p.items;
|
|
2995
3012
|
let groupIndex = items.indexOf(item);
|
|
3013
|
+
const groupLevel = item._level;
|
|
2996
3014
|
|
|
2997
3015
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
2998
3016
|
let next = items[i];
|
|
2999
3017
|
|
|
3000
3018
|
// Hit the next group, break out
|
|
3001
|
-
if (
|
|
3019
|
+
if ((!next._child && items[i - 1]._child) ||
|
|
3020
|
+
(groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3002
3021
|
break;
|
|
3003
3022
|
|
|
3004
3023
|
// No change, skip
|
|
@@ -3008,7 +3027,7 @@ class DropList {
|
|
|
3008
3027
|
// Update state
|
|
3009
3028
|
next._checked = item._checked;
|
|
3010
3029
|
|
|
3011
|
-
|
|
3030
|
+
affectedCount++;
|
|
3012
3031
|
|
|
3013
3032
|
// Update DOM
|
|
3014
3033
|
let nextEl = p.virtualListHelper.getItemElementAt(i);
|
|
@@ -3031,7 +3050,7 @@ class DropList {
|
|
|
3031
3050
|
this._trigger('groupcheck', {
|
|
3032
3051
|
value: item.value,
|
|
3033
3052
|
item: item[ItemSymbol] ?? item,
|
|
3034
|
-
|
|
3053
|
+
affectedCount: affectedCount,
|
|
3035
3054
|
});
|
|
3036
3055
|
} else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
|
|
3037
3056
|
const items = p.filteredItems ?? p.items;
|
|
@@ -3065,18 +3084,21 @@ class DropList {
|
|
|
3065
3084
|
|
|
3066
3085
|
if (!groupItem || !groupItem._group) return this;
|
|
3067
3086
|
|
|
3068
|
-
let
|
|
3087
|
+
let next, hasChecked = false, hasUnchecked = false;
|
|
3088
|
+
|
|
3089
|
+
const groupLevel = groupItem._level;
|
|
3069
3090
|
|
|
3070
3091
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3071
|
-
|
|
3092
|
+
next = items[i];
|
|
3072
3093
|
|
|
3073
3094
|
// Hit the next group, break out
|
|
3074
|
-
if (
|
|
3095
|
+
if ((!next._child && items[i - 1]._child) ||
|
|
3096
|
+
(groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3075
3097
|
break;
|
|
3076
3098
|
|
|
3077
|
-
if (
|
|
3099
|
+
if (next._checked) {
|
|
3078
3100
|
hasChecked = true;
|
|
3079
|
-
} else if (!
|
|
3101
|
+
} else if (!next._checked) {
|
|
3080
3102
|
hasUnchecked = true;
|
|
3081
3103
|
}
|
|
3082
3104
|
}
|
package/lib/SelectBox.js
CHANGED
|
@@ -179,11 +179,12 @@ Emits the following events:
|
|
|
179
179
|
'open' { list: DropList }: the drop list is opening
|
|
180
180
|
'open:before' { list: DropList }: the drop list will open
|
|
181
181
|
'close': the drop list is closing
|
|
182
|
-
'addsel:before' {value, item, cancel: false}: an item selection is about to be added (in multi mode). return false to abort.
|
|
183
|
-
'removesel:before' {value, item, cancel: false}: an item selection is about to be removed (in multi mode). return false to abort.
|
|
182
|
+
'addsel:before' {value, item, cancel: false, isCheckingGroup: bool}: an item selection is about to be added (in multi mode). return false to abort.
|
|
183
|
+
'removesel:before' {value, item, cancel: false, isCheckingGroup: bool}: an item selection is about to be removed (in multi mode). return false to abort.
|
|
184
|
+
'addsel' {value, item, isCheckingGroup: bool}: an item selection has been added (in multi mode)
|
|
185
|
+
'removesel' {value, item, isCheckingGroup: bool}: an item selection has been removed (in multi mode)
|
|
186
|
+
'groupcheck' {value, item, affectedCount: number}: an item selection has been removed (in multi mode)
|
|
184
187
|
'select:before' {value, item, cancel: false}: an item is about to be selected (in single mode). return false to abort.
|
|
185
|
-
'addsel' {value, item}: an item selection has been added (in multi mode)
|
|
186
|
-
'removesel' {value, item}: an item selection has been removed (in multi mode)
|
|
187
188
|
'select' {value, item}: an item has been selected (in single mode)
|
|
188
189
|
'search' {value}: input box value has changed
|
|
189
190
|
'search:focus': input box has gained focus
|
|
@@ -1861,7 +1862,12 @@ class SelectBox {
|
|
|
1861
1862
|
let checked = event.checked;
|
|
1862
1863
|
if (event.isGroup && !p.treatGroupSelectionAsItems) return; // Ignore groups
|
|
1863
1864
|
|
|
1864
|
-
let selEvt = {
|
|
1865
|
+
let selEvt = {
|
|
1866
|
+
value: value,
|
|
1867
|
+
item: item,
|
|
1868
|
+
cancel: false,
|
|
1869
|
+
isCheckingGroup: event.isCheckingGroup,
|
|
1870
|
+
};
|
|
1865
1871
|
this._trigger((checked ? 'addsel' : 'removesel') + ':before', selEvt);
|
|
1866
1872
|
|
|
1867
1873
|
if (selEvt.cancel) {
|
|
@@ -1919,16 +1925,26 @@ class SelectBox {
|
|
|
1919
1925
|
this._scheduleSync('syncPlaceholder');
|
|
1920
1926
|
}
|
|
1921
1927
|
|
|
1922
|
-
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
1928
|
+
this._trigger(checked ? 'addsel' : 'removesel', {
|
|
1929
|
+
value: value,
|
|
1930
|
+
item: item,
|
|
1931
|
+
isCheckingGroup: event.isCheckingGroup,
|
|
1932
|
+
});
|
|
1923
1933
|
}
|
|
1924
1934
|
break;
|
|
1925
1935
|
|
|
1926
1936
|
case 'groupcheck': {
|
|
1927
1937
|
if (!p.multi) return;
|
|
1928
1938
|
|
|
1929
|
-
if (event.
|
|
1939
|
+
if (event.affectedCount) {
|
|
1930
1940
|
this._scheduleSync(p.sortSelectedItems ? 'full' : 'render_base');
|
|
1931
1941
|
}
|
|
1942
|
+
|
|
1943
|
+
this._trigger('groupcheck', {
|
|
1944
|
+
value: event.value,
|
|
1945
|
+
item: event.item,
|
|
1946
|
+
affectedCount: event.affectedCount,
|
|
1947
|
+
});
|
|
1932
1948
|
}
|
|
1933
1949
|
break;
|
|
1934
1950
|
|
package/package.json
CHANGED
package/vue/SelectBox.vue
CHANGED
|
@@ -724,8 +724,9 @@
|
|
|
724
724
|
|
|
725
725
|
if (event === 'select' ||
|
|
726
726
|
event === 'clear' ||
|
|
727
|
-
event === '
|
|
728
|
-
event === '
|
|
727
|
+
event === 'groupcheck' ||
|
|
728
|
+
(event === 'addsel' && !event.isCheckingGroup) ||
|
|
729
|
+
(event === 'removesel' && !event.isCheckingGroup)) {
|
|
729
730
|
let value = event === 'select' ? data.value : this.nonReactive.instance.getValue();
|
|
730
731
|
if (value === undefined && event !== 'select' && this.emitNullForEmptyValue)
|
|
731
732
|
value = null;
|