@danielgindi/selectbox 2.0.64 → 2.0.66
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/README.md +130 -103
- package/dist/lib.cjs.js +195 -91
- 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 +195 -91
- 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 +195 -91
- 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/dist/types/DropList.d.ts +13 -1
- package/dist/types/DropList.d.ts.map +1 -1
- package/dist/types/SelectBox.d.ts +7 -1
- package/dist/types/SelectBox.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +35 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +11 -11
- package/vue/DropList.vue +19 -5
- package/vue/SelectBox.vue +19 -5
- package/vue/component-types.d.ts +4 -0
package/dist/lib.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.66
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
(function(global, factory) {
|
|
@@ -127,6 +127,7 @@
|
|
|
127
127
|
labelProp: "label",
|
|
128
128
|
valueProp: "value",
|
|
129
129
|
on: null,
|
|
130
|
+
zIndex: null,
|
|
130
131
|
isHeaderVisible: false,
|
|
131
132
|
isFooterVisible: false,
|
|
132
133
|
searchable: false,
|
|
@@ -171,6 +172,9 @@
|
|
|
171
172
|
unrenderNoResultsItem: o.unrenderNoResultsItem,
|
|
172
173
|
on: o.on || null,
|
|
173
174
|
positionOptionsProvider: o.positionOptionsProvider ?? null,
|
|
175
|
+
zIndex: o.zIndex ?? null,
|
|
176
|
+
appliedZIndex: null,
|
|
177
|
+
ownerSelectBox: null,
|
|
174
178
|
onError: o.onError,
|
|
175
179
|
searchable: o.searchable,
|
|
176
180
|
searchPlaceholder: o.searchPlaceholder,
|
|
@@ -271,12 +275,13 @@
|
|
|
271
275
|
itemEl.className = `${p.baseClassName}__item`;
|
|
272
276
|
const classList = itemEl.classList;
|
|
273
277
|
if (item) {
|
|
274
|
-
if (p.multi)
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
if (p.multi) {
|
|
279
|
+
if (item._nocheck) classList.add(`${p.baseClassName}__item_multi_nocheck`);
|
|
280
|
+
else {
|
|
281
|
+
classList.add(`${p.baseClassName}__item_multi`);
|
|
282
|
+
if (item._checked) classList.add(`${p.baseClassName}__item_checked`);
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
280
285
|
classList.add(`${p.baseClassName}__item_single`);
|
|
281
286
|
if (p.singleSelectedValue !== void 0 && item.value === p.singleSelectedValue) {
|
|
282
287
|
classList.add(`${p.baseClassName}__item_selected`);
|
|
@@ -741,6 +746,70 @@
|
|
|
741
746
|
return this._p.positionOptionsProvider;
|
|
742
747
|
}
|
|
743
748
|
/**
|
|
749
|
+
* Sets the z-index: a fixed value, a resolver function, or `null` to use the CSS z-index.
|
|
750
|
+
* Applied immediately if the DropList is visible.
|
|
751
|
+
*/
|
|
752
|
+
setZIndex(zIndex) {
|
|
753
|
+
const p = this._p;
|
|
754
|
+
zIndex = zIndex ?? null;
|
|
755
|
+
if (p.zIndex === zIndex) return this;
|
|
756
|
+
p.zIndex = zIndex;
|
|
757
|
+
this.updateZIndex();
|
|
758
|
+
return this;
|
|
759
|
+
}
|
|
760
|
+
getZIndex() {
|
|
761
|
+
return this._p.zIndex;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Re-resolves the z-index (re-invoking a resolver function) and applies it.
|
|
765
|
+
* The z-index is resolved automatically on `show()`, so call this only when the stacking
|
|
766
|
+
* order around the owner changes while the DropList is open. Does nothing while hidden.
|
|
767
|
+
*/
|
|
768
|
+
updateZIndex() {
|
|
769
|
+
const p = this._p;
|
|
770
|
+
if (!this.isVisible()) return this;
|
|
771
|
+
this._applyZIndex(p.positionOptionsProvider?.() ?? p.lastPositionOptions ?? null);
|
|
772
|
+
return this;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Marks this DropList as owned by a SelectBox, for `DropListZIndexContext`.
|
|
776
|
+
* @internal
|
|
777
|
+
*/
|
|
778
|
+
_setOwnerSelectBox(selectBox) {
|
|
779
|
+
this._p.ownerSelectBox = selectBox;
|
|
780
|
+
}
|
|
781
|
+
/** @internal */
|
|
782
|
+
_resolveZIndex(positionOptions) {
|
|
783
|
+
const p = this._p;
|
|
784
|
+
const option = p.zIndex;
|
|
785
|
+
let zIndex;
|
|
786
|
+
if (typeof option === "function") {
|
|
787
|
+
const context = {
|
|
788
|
+
dropList: this,
|
|
789
|
+
owner: p.ownerSelectBox?.el ?? positionOptions?.target ?? null,
|
|
790
|
+
selectBox: p.ownerSelectBox,
|
|
791
|
+
positionOptions
|
|
792
|
+
};
|
|
793
|
+
try {
|
|
794
|
+
zIndex = option(context);
|
|
795
|
+
} catch (err) {
|
|
796
|
+
reportError(p.onError, err, { source: "zIndex" });
|
|
797
|
+
zIndex = null;
|
|
798
|
+
}
|
|
799
|
+
} else zIndex = option;
|
|
800
|
+
if (zIndex == null || zIndex === "") return null;
|
|
801
|
+
return String(zIndex);
|
|
802
|
+
}
|
|
803
|
+
/** @internal */
|
|
804
|
+
_applyZIndex(positionOptions) {
|
|
805
|
+
const p = this._p;
|
|
806
|
+
const zIndex = this._resolveZIndex(positionOptions);
|
|
807
|
+
if (zIndex !== null) p.el.style.zIndex = zIndex;
|
|
808
|
+
else if (p.appliedZIndex !== null) p.el.style.zIndex = "";
|
|
809
|
+
p.appliedZIndex = zIndex;
|
|
810
|
+
p.currentSubDropList?.droplist?.updateZIndex();
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
744
813
|
* Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderItem`/`unrenderItem`)
|
|
745
814
|
* instead of the default `console.error`/`console.warn`.
|
|
746
815
|
*/
|
|
@@ -809,13 +878,15 @@
|
|
|
809
878
|
return our;
|
|
810
879
|
});
|
|
811
880
|
}
|
|
812
|
-
if (!Array.isArray(filteredItems))
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
881
|
+
if (!Array.isArray(filteredItems)) {
|
|
882
|
+
if (term) {
|
|
883
|
+
const matcher = new RegExp(escapeRegex(term), "i");
|
|
884
|
+
filteredItems = p.items.filter((x) => {
|
|
885
|
+
if (!filterGroups && x._group) return true;
|
|
886
|
+
return matcher.test(x.label);
|
|
887
|
+
});
|
|
888
|
+
} else filteredItems = null;
|
|
889
|
+
}
|
|
819
890
|
p.filteredItems = filteredItems;
|
|
820
891
|
if (filteredItems && filterEmptyGroups) {
|
|
821
892
|
let lastGroup = -1;
|
|
@@ -1026,8 +1097,10 @@
|
|
|
1026
1097
|
};
|
|
1027
1098
|
viewCss.left += anchor.left - position.left;
|
|
1028
1099
|
if (positionOptions.offset) {
|
|
1029
|
-
if (positionOptions.offset.y)
|
|
1030
|
-
|
|
1100
|
+
if (positionOptions.offset.y) {
|
|
1101
|
+
if (invertYPos) viewCss.top -= positionOptions.offset.y;
|
|
1102
|
+
else viewCss.top += positionOptions.offset.y;
|
|
1103
|
+
}
|
|
1031
1104
|
if (positionOptions.offset.x) {
|
|
1032
1105
|
let rtl = elComputedStyle.direction === "rtl";
|
|
1033
1106
|
viewCss.left += rtl ? -positionOptions.offset.x : positionOptions.offset.x;
|
|
@@ -1157,6 +1230,7 @@
|
|
|
1157
1230
|
p.lastPositionOptions = null;
|
|
1158
1231
|
if (positionOptions === void 0) positionOptions = p.positionOptionsProvider?.() ?? p.lastPositionOptions;
|
|
1159
1232
|
else p.lastPositionOptions = positionOptions;
|
|
1233
|
+
this._applyZIndex(positionOptions ?? null);
|
|
1160
1234
|
if (positionOptions) {
|
|
1161
1235
|
const elComputedStyle = getComputedStyle(el);
|
|
1162
1236
|
const originalMaxHeight = el.style.maxHeight;
|
|
@@ -1358,7 +1432,8 @@
|
|
|
1358
1432
|
valueProp: p.valueProp,
|
|
1359
1433
|
renderItem: p.renderItem,
|
|
1360
1434
|
unrenderItem: p.unrenderItem,
|
|
1361
|
-
positionOptionsProvider: () => p.currentSubDropList.showOptions
|
|
1435
|
+
positionOptionsProvider: () => p.currentSubDropList.showOptions,
|
|
1436
|
+
zIndex: () => this._p?.appliedZIndex ?? null
|
|
1362
1437
|
});
|
|
1363
1438
|
let onBlur = (event) => {
|
|
1364
1439
|
if (this[DestroyedSymbol$1]) return;
|
|
@@ -2181,14 +2256,18 @@
|
|
|
2181
2256
|
_updateWidth(positionOptions) {
|
|
2182
2257
|
const p = this._p, el = p.el;
|
|
2183
2258
|
let targetWidth = 0;
|
|
2184
|
-
if (positionOptions)
|
|
2185
|
-
|
|
2186
|
-
|
|
2259
|
+
if (positionOptions) {
|
|
2260
|
+
if (typeof positionOptions.updateWidth === "number") targetWidth = positionOptions.updateWidth;
|
|
2261
|
+
else if (positionOptions.targetWidth != null) targetWidth = positionOptions.targetWidth;
|
|
2262
|
+
else targetWidth = (0, _danielgindi_dom_utils_lib_Css.getElementWidth)(positionOptions.target, true, true);
|
|
2263
|
+
}
|
|
2187
2264
|
let autoWidth = 0;
|
|
2188
|
-
if (!p.useExactTargetWidth || !targetWidth)
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2265
|
+
if (!p.useExactTargetWidth || !targetWidth) {
|
|
2266
|
+
if (p.estimateWidth || p.virtualListHelper.isVirtual()) autoWidth = p.lastMeasureItemWidth;
|
|
2267
|
+
else {
|
|
2268
|
+
el.style.width = "";
|
|
2269
|
+
autoWidth = (0, _danielgindi_dom_utils_lib_Css.getElementWidth)(el, true, true);
|
|
2270
|
+
}
|
|
2192
2271
|
}
|
|
2193
2272
|
let newOuterWidth = Math.max(autoWidth, targetWidth);
|
|
2194
2273
|
(0, _danielgindi_dom_utils_lib_Css.setElementWidth)(el, newOuterWidth, true, true);
|
|
@@ -2817,6 +2896,22 @@
|
|
|
2817
2896
|
this._setupDropdownMenu();
|
|
2818
2897
|
return this;
|
|
2819
2898
|
}
|
|
2899
|
+
/**
|
|
2900
|
+
* Sets `listOptions.zIndex` without recreating the DropList.
|
|
2901
|
+
* `undefined` falls back to `DropListDefaultOptions.zIndex`.
|
|
2902
|
+
*/
|
|
2903
|
+
setListZIndex(zIndex) {
|
|
2904
|
+
const p = this._p;
|
|
2905
|
+
p.listOptions = {
|
|
2906
|
+
...p.listOptions,
|
|
2907
|
+
zIndex
|
|
2908
|
+
};
|
|
2909
|
+
p.dropList?.setZIndex(zIndex === void 0 ? DefaultOptions.zIndex : zIndex);
|
|
2910
|
+
return this;
|
|
2911
|
+
}
|
|
2912
|
+
getListZIndex() {
|
|
2913
|
+
return this._p.listOptions?.zIndex;
|
|
2914
|
+
}
|
|
2820
2915
|
setRenderSingleItem(render, unrender) {
|
|
2821
2916
|
const p = this._p;
|
|
2822
2917
|
p.renderSingleItem = render;
|
|
@@ -3237,23 +3332,27 @@
|
|
|
3237
3332
|
this._registerDropdownEvents();
|
|
3238
3333
|
}
|
|
3239
3334
|
}
|
|
3240
|
-
if (p.hasOpenIndicator !== !!p.openIndicator)
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3335
|
+
if (p.hasOpenIndicator !== !!p.openIndicator) {
|
|
3336
|
+
if (p.hasOpenIndicator) {
|
|
3337
|
+
p.openIndicator = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__open_indicator` });
|
|
3338
|
+
p.el.appendChild(p.openIndicator);
|
|
3339
|
+
p.el.classList.add(`${p.baseClassName}__has_open_indicator`);
|
|
3340
|
+
} else {
|
|
3341
|
+
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.openIndicator);
|
|
3342
|
+
delete p.openIndicator;
|
|
3343
|
+
p.el.classList.remove(`${p.baseClassName}__has_open_indicator`);
|
|
3344
|
+
}
|
|
3248
3345
|
}
|
|
3249
|
-
if (p.isLoadingMode !== !!p.spinner)
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3346
|
+
if (p.isLoadingMode !== !!p.spinner) {
|
|
3347
|
+
if (p.isLoadingMode) {
|
|
3348
|
+
p.spinner = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__spinner` });
|
|
3349
|
+
p.el.appendChild(p.spinner);
|
|
3350
|
+
p.el.classList.add(`${p.baseClassName}__has_spinner`);
|
|
3351
|
+
} else {
|
|
3352
|
+
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.spinner);
|
|
3353
|
+
delete p.spinner;
|
|
3354
|
+
p.el.classList.remove(`${p.baseClassName}__has_spinner`);
|
|
3355
|
+
}
|
|
3257
3356
|
}
|
|
3258
3357
|
}
|
|
3259
3358
|
/**
|
|
@@ -3380,21 +3479,22 @@
|
|
|
3380
3479
|
p.selectionChanged = true;
|
|
3381
3480
|
p.resortBySelectionNeeded = true;
|
|
3382
3481
|
const hasGroupSync = !!event.isCheckingGroup;
|
|
3383
|
-
if (p.showSelection)
|
|
3384
|
-
if (
|
|
3385
|
-
|
|
3386
|
-
if (
|
|
3482
|
+
if (p.showSelection) {
|
|
3483
|
+
if (checked) {
|
|
3484
|
+
if (dropList.itemCount() === 1 && p.clearInputWhen.includes("multi_select_single")) this._setInputText("");
|
|
3485
|
+
if (p.sortSelectedItems) {
|
|
3486
|
+
if (!hasGroupSync) this._scheduleSync("full");
|
|
3487
|
+
} else {
|
|
3488
|
+
if (p.maxMultiItems != null && (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).length > p.maxMultiItems) this._scheduleSync("addOrUpdateMultiItemRestElement");
|
|
3489
|
+
else this._scheduleSync("addMultiItemElement", item);
|
|
3490
|
+
if (!hasGroupSync) this._scheduleSync("render_base");
|
|
3491
|
+
}
|
|
3387
3492
|
} else {
|
|
3388
|
-
if (p.maxMultiItems != null && (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).length
|
|
3389
|
-
else this._scheduleSync("
|
|
3493
|
+
if (p.maxMultiItems != null && (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).length === p.maxMultiItems) this._scheduleSync("removeMultiItemRestElement");
|
|
3494
|
+
else this._scheduleSync("removeMultiItemElement", item);
|
|
3390
3495
|
if (!hasGroupSync) this._scheduleSync("render_base");
|
|
3391
3496
|
}
|
|
3392
|
-
} else
|
|
3393
|
-
if (p.maxMultiItems != null && (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).length === p.maxMultiItems) this._scheduleSync("removeMultiItemRestElement");
|
|
3394
|
-
else this._scheduleSync("removeMultiItemElement", item);
|
|
3395
|
-
if (!hasGroupSync) this._scheduleSync("render_base");
|
|
3396
|
-
}
|
|
3397
|
-
else if (p.multi) this._scheduleSync("syncPlaceholder");
|
|
3497
|
+
} else if (p.multi) this._scheduleSync("syncPlaceholder");
|
|
3398
3498
|
this._trigger(checked ? "addsel" : "removesel", {
|
|
3399
3499
|
value,
|
|
3400
3500
|
item,
|
|
@@ -3440,6 +3540,7 @@
|
|
|
3440
3540
|
}
|
|
3441
3541
|
}
|
|
3442
3542
|
});
|
|
3543
|
+
dropList._setOwnerSelectBox(this);
|
|
3443
3544
|
p.sink.add(dropList.el, "mousedown", preventDropListMouseDownBlur);
|
|
3444
3545
|
this._registerDropdownEvents();
|
|
3445
3546
|
}
|
|
@@ -3555,7 +3656,7 @@
|
|
|
3555
3656
|
let selectedItems = this.getSelectedItems();
|
|
3556
3657
|
let finalItemCount = p.dropList.getFilteredItemCount();
|
|
3557
3658
|
if (finalItemCount + (p.clearable ? 1 : 0) > 1) {
|
|
3558
|
-
let nextIndex = selectedItems.length > 0 ? p.dropList.
|
|
3659
|
+
let nextIndex = selectedItems.length > 0 ? p.dropList.filteredItemIndexByValue(selectedItems[0][p.valueProp]) - 1 : finalItemCount - 1;
|
|
3559
3660
|
if (nextIndex === -1 && !p.clearable) nextIndex = finalItemCount - 1;
|
|
3560
3661
|
let item = nextIndex === -1 ? null : p.dropList.filteredItemAtIndex(nextIndex);
|
|
3561
3662
|
if (item) this._performSelectWithEvent(item, item[p.valueProp]);
|
|
@@ -3569,7 +3670,7 @@
|
|
|
3569
3670
|
let selectedItems = this.getSelectedItems();
|
|
3570
3671
|
let finalItemCount = p.dropList.getFilteredItemCount();
|
|
3571
3672
|
if (finalItemCount + (p.clearable ? 1 : 0) > 1) {
|
|
3572
|
-
let nextIndex = selectedItems.length > 0 ? p.dropList.
|
|
3673
|
+
let nextIndex = selectedItems.length > 0 ? p.dropList.filteredItemIndexByValue(selectedItems[0][p.valueProp]) + 1 : 0;
|
|
3573
3674
|
if (nextIndex === finalItemCount) nextIndex = p.clearable ? -1 : 0;
|
|
3574
3675
|
let item = nextIndex === -1 ? null : p.dropList.filteredItemAtIndex(nextIndex);
|
|
3575
3676
|
if (item) this._performSelectWithEvent(item, item[p.valueProp]);
|
|
@@ -3813,9 +3914,10 @@
|
|
|
3813
3914
|
_syncPlaceholder() {
|
|
3814
3915
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
3815
3916
|
let placeholder = "";
|
|
3816
|
-
if (p.multi && !p.showSelection)
|
|
3817
|
-
|
|
3818
|
-
|
|
3917
|
+
if (p.multi && !p.showSelection) {
|
|
3918
|
+
if (typeof p.multiPlaceholderFormatter === "function") placeholder = p.multiPlaceholderFormatter(p.selectedItems);
|
|
3919
|
+
else placeholder = p.selectedItems.length === 0 ? p.placeholder || "" : defaultMultiPlaceholderFormatter(p.selectedItems, p.labelProp);
|
|
3920
|
+
} else if (p.selectedItems.length === 0 || !p.showSelection || p.selectedItems.every((x) => x[multiItemLabelProp] === false)) placeholder = p.placeholder == null ? "" : p.placeholder + "";
|
|
3819
3921
|
p.input.setAttribute("placeholder", placeholder);
|
|
3820
3922
|
if (p.showPlaceholderInTooltip) p.input.setAttribute("title", placeholder);
|
|
3821
3923
|
else p.input.removeAttribute("title");
|
|
@@ -3939,46 +4041,48 @@
|
|
|
3939
4041
|
else if (kEvent.key === keycode_js.VALUE_BACK_SPACE) nextFocus = (0, _danielgindi_dom_utils_lib_Dom.prev)(itemEl, `.${p.baseClassName}__item,.${p.baseClassName}__search_wrapper`);
|
|
3940
4042
|
} else if (/click|mouse|touch/.test(originatingEvent.type)) nextFocus = (0, _danielgindi_dom_utils_lib_Dom.next)(itemEl, `.${p.baseClassName}__item,.${p.baseClassName}__search_wrapper`);
|
|
3941
4043
|
const item = itemEl[ItemSymbol], value = item[p.valueProp];
|
|
3942
|
-
if (item !== void 0)
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
4044
|
+
if (item !== void 0) {
|
|
4045
|
+
if (value === RestMultiItemsSymbol) {
|
|
4046
|
+
let items = (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).slice(p.maxMultiItems);
|
|
4047
|
+
let itemsToRemove = [];
|
|
4048
|
+
for (let item of items) {
|
|
4049
|
+
let removeselEvt = {
|
|
4050
|
+
value: item[p.valueProp],
|
|
4051
|
+
item,
|
|
4052
|
+
cancel: false
|
|
4053
|
+
};
|
|
4054
|
+
this._trigger("removesel:before", removeselEvt);
|
|
4055
|
+
if (!removeselEvt.cancel) itemsToRemove.push(item);
|
|
4056
|
+
}
|
|
4057
|
+
if (itemsToRemove.length > 0) {
|
|
4058
|
+
this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
|
|
4059
|
+
for (let item of itemsToRemove) {
|
|
4060
|
+
let idx = p.selectedItems.indexOf(item);
|
|
4061
|
+
if (idx === -1) idx = p.selectedValues.indexOf(item[p.valueProp]);
|
|
4062
|
+
if (idx !== -1) {
|
|
4063
|
+
p.selectedItems.splice(idx, 1);
|
|
4064
|
+
p.selectedValues.splice(idx, 1);
|
|
4065
|
+
p.selectionChanged = true;
|
|
4066
|
+
p.resortBySelectionNeeded = true;
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
if (items.length > itemsToRemove.length) this._addMultiItemRestElement();
|
|
4071
|
+
if (itemsToRemove.length > 0) this._scheduleSync("render_list");
|
|
4072
|
+
} else {
|
|
3946
4073
|
let removeselEvt = {
|
|
3947
|
-
value
|
|
4074
|
+
value,
|
|
3948
4075
|
item,
|
|
3949
4076
|
cancel: false
|
|
3950
4077
|
};
|
|
3951
4078
|
this._trigger("removesel:before", removeselEvt);
|
|
3952
|
-
if (
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
if (idx === -1) idx = p.selectedValues.indexOf(item[p.valueProp]);
|
|
3959
|
-
if (idx !== -1) {
|
|
3960
|
-
p.selectedItems.splice(idx, 1);
|
|
3961
|
-
p.selectedValues.splice(idx, 1);
|
|
3962
|
-
p.selectionChanged = true;
|
|
3963
|
-
p.resortBySelectionNeeded = true;
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
4079
|
+
if (removeselEvt.cancel) return this;
|
|
4080
|
+
this._removeMultiItem(item);
|
|
4081
|
+
this._trigger("removesel", {
|
|
4082
|
+
value,
|
|
4083
|
+
item
|
|
4084
|
+
});
|
|
3966
4085
|
}
|
|
3967
|
-
if (items.length > itemsToRemove.length) this._addMultiItemRestElement();
|
|
3968
|
-
if (itemsToRemove.length > 0) this._scheduleSync("render_list");
|
|
3969
|
-
} else {
|
|
3970
|
-
let removeselEvt = {
|
|
3971
|
-
value,
|
|
3972
|
-
item,
|
|
3973
|
-
cancel: false
|
|
3974
|
-
};
|
|
3975
|
-
this._trigger("removesel:before", removeselEvt);
|
|
3976
|
-
if (removeselEvt.cancel) return this;
|
|
3977
|
-
this._removeMultiItem(item);
|
|
3978
|
-
this._trigger("removesel", {
|
|
3979
|
-
value,
|
|
3980
|
-
item
|
|
3981
|
-
});
|
|
3982
4086
|
}
|
|
3983
4087
|
if (!nextFocus) nextFocus = p.el.querySelector(`.${p.baseClassName}__item, .${p.baseClassName}__search_field`);
|
|
3984
4088
|
if (hasClass(nextFocus, `${p.baseClassName}__search_wrapper`)) nextFocus = nextFocus.querySelector("input");
|