@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/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
|
}
|
|
@@ -2988,17 +2997,19 @@ class DropList {
|
|
|
2988
2997
|
if (item._group) {
|
|
2989
2998
|
// Now loop through children below the group
|
|
2990
2999
|
|
|
2991
|
-
let
|
|
3000
|
+
let affectedCount = 0;
|
|
2992
3001
|
|
|
2993
3002
|
if (p.autoCheckGroupChildren) {
|
|
2994
3003
|
const items = p.filteredItems ?? p.items;
|
|
2995
3004
|
let groupIndex = items.indexOf(item);
|
|
3005
|
+
const groupLevel = item._level;
|
|
2996
3006
|
|
|
2997
3007
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
2998
3008
|
let next = items[i];
|
|
2999
3009
|
|
|
3000
3010
|
// Hit the next group, break out
|
|
3001
|
-
if (
|
|
3011
|
+
if ((!next._child && items[i - 1]._child) ||
|
|
3012
|
+
(groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3002
3013
|
break;
|
|
3003
3014
|
|
|
3004
3015
|
// No change, skip
|
|
@@ -3008,7 +3019,7 @@ class DropList {
|
|
|
3008
3019
|
// Update state
|
|
3009
3020
|
next._checked = item._checked;
|
|
3010
3021
|
|
|
3011
|
-
|
|
3022
|
+
affectedCount++;
|
|
3012
3023
|
|
|
3013
3024
|
// Update DOM
|
|
3014
3025
|
let nextEl = p.virtualListHelper.getItemElementAt(i);
|
|
@@ -3031,7 +3042,7 @@ class DropList {
|
|
|
3031
3042
|
this._trigger('groupcheck', {
|
|
3032
3043
|
value: item.value,
|
|
3033
3044
|
item: item[ItemSymbol] ?? item,
|
|
3034
|
-
|
|
3045
|
+
affectedCount: affectedCount,
|
|
3035
3046
|
});
|
|
3036
3047
|
} else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
|
|
3037
3048
|
const items = p.filteredItems ?? p.items;
|
|
@@ -3065,18 +3076,21 @@ class DropList {
|
|
|
3065
3076
|
|
|
3066
3077
|
if (!groupItem || !groupItem._group) return this;
|
|
3067
3078
|
|
|
3068
|
-
let
|
|
3079
|
+
let next, hasChecked = false, hasUnchecked = false;
|
|
3080
|
+
|
|
3081
|
+
const groupLevel = groupItem._level;
|
|
3069
3082
|
|
|
3070
3083
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
3071
|
-
|
|
3084
|
+
next = items[i];
|
|
3072
3085
|
|
|
3073
3086
|
// Hit the next group, break out
|
|
3074
|
-
if (
|
|
3087
|
+
if ((!next._child && items[i - 1]._child) ||
|
|
3088
|
+
(groupLevel === undefined ? next._group || next._level !== undefined : next._level <= groupLevel))
|
|
3075
3089
|
break;
|
|
3076
3090
|
|
|
3077
|
-
if (
|
|
3091
|
+
if (next._checked) {
|
|
3078
3092
|
hasChecked = true;
|
|
3079
|
-
} else if (!
|
|
3093
|
+
} else if (!next._checked) {
|
|
3080
3094
|
hasUnchecked = true;
|
|
3081
3095
|
}
|
|
3082
3096
|
}
|
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;
|