@danielgindi/selectbox 2.0.66 → 3.0.0
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 +150 -130
- package/css/droplist.css +1 -1
- package/css/droplist.css.map +1 -1
- package/css/selectbox.css +1 -1
- package/css/selectbox.css.map +1 -1
- package/dist/lib.cjs.js +50 -40
- 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 +51 -40
- 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 +50 -40
- 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.map +1 -1
- package/dist/types/SelectBox.d.ts.map +1 -1
- package/eslint.config.mjs +153 -151
- package/package.json +23 -13
- package/scss/droplist.scss +62 -71
- package/scss/selectbox.scss +126 -210
- package/vite.config.mjs +29 -0
- package/vue/DropList.vue +20 -20
- package/vue/SelectBox.vue +15 -20
- package/vue/component-types.d.ts +223 -221
- package/vue/utils/slots.js +17 -64
- package/vite.config.js +0 -9
package/dist/lib.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox
|
|
2
|
+
* @danielgindi/selectbox 3.0.0
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
(function(global, factory) {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.SelectBox = {}, global.domUtilsDom, global.domUtilsDomCompat, global.domUtilsCss, global.domUtilsDomEventsSink, global.VirtualListHelper, global.keyCode, global.mitt));
|
|
16
16
|
})(this, function(exports, _danielgindi_dom_utils_lib_Dom, _danielgindi_dom_utils_lib_DomCompat, _danielgindi_dom_utils_lib_Css, _danielgindi_dom_utils_lib_DomEventsSink, _danielgindi_virtual_list_helper, keycode_js, mitt) {
|
|
17
17
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
|
|
18
|
+
// \0rolldown/runtime.js
|
|
19
19
|
var __create = Object.create;
|
|
20
20
|
var __defProp = Object.defineProperty;
|
|
21
21
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -36,15 +36,13 @@
|
|
|
36
36
|
value: mod,
|
|
37
37
|
enumerable: true
|
|
38
38
|
}) : target, mod));
|
|
39
|
-
//#endregion
|
|
40
39
|
_danielgindi_dom_utils_lib_DomEventsSink = __toESM(_danielgindi_dom_utils_lib_DomEventsSink);
|
|
41
40
|
_danielgindi_virtual_list_helper = __toESM(_danielgindi_virtual_list_helper);
|
|
42
41
|
mitt = __toESM(mitt);
|
|
43
|
-
|
|
42
|
+
// src/lib/utils/escapeRegex.ts
|
|
44
43
|
/** @internal */
|
|
45
44
|
var escapeRegex = (value) => value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
46
|
-
|
|
47
|
-
//#region src/lib/utils/throttle.ts
|
|
45
|
+
// src/lib/utils/throttle.ts
|
|
48
46
|
/** @internal */
|
|
49
47
|
var throttle = (func, wait, options = {}) => {
|
|
50
48
|
let timeout;
|
|
@@ -85,8 +83,7 @@
|
|
|
85
83
|
};
|
|
86
84
|
return throttled;
|
|
87
85
|
};
|
|
88
|
-
|
|
89
|
-
//#region src/lib/utils/reportError.ts
|
|
86
|
+
// src/lib/utils/reportError.ts
|
|
90
87
|
/**
|
|
91
88
|
* Routes an error/warning to `handler` if supplied, falling back to the
|
|
92
89
|
* console (matching the previous hardcoded behaviour) if there is no
|
|
@@ -103,8 +100,7 @@
|
|
|
103
100
|
if (context.level === "warn") console.warn(error);
|
|
104
101
|
else console.error(error);
|
|
105
102
|
};
|
|
106
|
-
|
|
107
|
-
//#region src/lib/DropList.ts
|
|
103
|
+
// src/lib/DropList.ts
|
|
108
104
|
var ItemSymbol = Symbol("item");
|
|
109
105
|
var DestroyedSymbol$1 = Symbol("destroyed");
|
|
110
106
|
var GhostSymbol = Symbol("ghost");
|
|
@@ -593,7 +589,7 @@
|
|
|
593
589
|
const p = this._p;
|
|
594
590
|
let itemIndex = this.itemIndexByValue(value);
|
|
595
591
|
if (itemIndex === -1) return this;
|
|
596
|
-
let item =
|
|
592
|
+
let item = p.items[itemIndex];
|
|
597
593
|
item[ItemSymbol] = newItem;
|
|
598
594
|
if (hasOwnProperty.call(newItem, p.labelProp)) item.label = newItem[p.labelProp];
|
|
599
595
|
if (hasOwnProperty.call(newItem, p.valueProp)) item.value = newItem[p.valueProp];
|
|
@@ -613,10 +609,7 @@
|
|
|
613
609
|
if (hasOwnProperty.call(newItem, "_level")) item._level = newItem._level;
|
|
614
610
|
if (hasOwnProperty.call(newItem, "_child")) item._child = !!newItem._child;
|
|
615
611
|
let virtualItemIndex = itemIndex;
|
|
616
|
-
if (p.filteredItems)
|
|
617
|
-
virtualItemIndex = p.filteredItems.indexOf(item);
|
|
618
|
-
if (virtualItemIndex !== -1) p.filteredItems.splice(virtualItemIndex, 1);
|
|
619
|
-
}
|
|
612
|
+
if (p.filteredItems) virtualItemIndex = p.filteredItems.indexOf(item);
|
|
620
613
|
if (virtualItemIndex !== -1 && p.virtualListHelper.isItemRendered(virtualItemIndex)) p.virtualListHelper.refreshItemAt(virtualItemIndex).render();
|
|
621
614
|
return this;
|
|
622
615
|
}
|
|
@@ -634,7 +627,7 @@
|
|
|
634
627
|
if (virtualItemIndex !== -1) {
|
|
635
628
|
p.hasNoResultsItem = (p.filteredItems ?? p.items).length === 0 && !!p.noResultsText;
|
|
636
629
|
if (p.hasNoResultsItem) p.virtualListHelper.setCount(1).render();
|
|
637
|
-
else p.virtualListHelper.removeItemsAt(
|
|
630
|
+
else p.virtualListHelper.removeItemsAt(1, virtualItemIndex).render();
|
|
638
631
|
}
|
|
639
632
|
return this;
|
|
640
633
|
}
|
|
@@ -2056,14 +2049,16 @@
|
|
|
2056
2049
|
} else if (p.focusItemEl) {
|
|
2057
2050
|
let base = (0, _danielgindi_dom_utils_lib_Css.getElementOffset)(p.focusItemEl).top;
|
|
2058
2051
|
let height = (0, _danielgindi_dom_utils_lib_Css.getElementHeight)(p.el, true);
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
if (
|
|
2052
|
+
let candidate = p.focusItemEl;
|
|
2053
|
+
next = null;
|
|
2054
|
+
while (candidate = direction === "prev_page" ? candidate.previousElementSibling : candidate.nextElementSibling) {
|
|
2055
|
+
if (candidate.tagName !== "LI") continue;
|
|
2056
|
+
next = candidate;
|
|
2063
2057
|
if (direction === "prev_page") {
|
|
2064
2058
|
if ((0, _danielgindi_dom_utils_lib_Css.getElementOffset)(next).top - base + height <= 0) break;
|
|
2065
2059
|
} else if ((0, _danielgindi_dom_utils_lib_Css.getElementOffset)(next).top - base - height >= 0) break;
|
|
2066
2060
|
}
|
|
2061
|
+
if (!next) return;
|
|
2067
2062
|
if (next) {
|
|
2068
2063
|
nextIndex = p.virtualListHelper.getItemIndexFromElement(next);
|
|
2069
2064
|
if (nextIndex === void 0) nextIndex = -1;
|
|
@@ -2282,8 +2277,7 @@
|
|
|
2282
2277
|
return newOuterWidth;
|
|
2283
2278
|
}
|
|
2284
2279
|
};
|
|
2285
|
-
|
|
2286
|
-
//#region src/lib/SelectBox.ts
|
|
2280
|
+
// src/lib/SelectBox.ts
|
|
2287
2281
|
var DestroyedSymbol = Symbol("destroyed");
|
|
2288
2282
|
var RestMultiItemsSymbol = Symbol("rest_multi_items");
|
|
2289
2283
|
var hasTouchCapability = !!("ontouchstart" in window || window.DocumentTouch && window.document instanceof window.DocumentTouch || window.navigator.maxTouchPoints);
|
|
@@ -2531,9 +2525,12 @@
|
|
|
2531
2525
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.list);
|
|
2532
2526
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.singleWrapper);
|
|
2533
2527
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.input);
|
|
2528
|
+
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.inputWrapper);
|
|
2534
2529
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.inputBackBuffer);
|
|
2535
2530
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.clearButtonWrapper);
|
|
2536
2531
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.openIndicator);
|
|
2532
|
+
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.spinner);
|
|
2533
|
+
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.controls);
|
|
2537
2534
|
if (!p.ownsEl) {
|
|
2538
2535
|
for (let name of Array.from(p.el.classList)) if (name.startsWith(p.baseClassName)) p.el.classList.remove(name);
|
|
2539
2536
|
p.el.removeAttribute("role");
|
|
@@ -2619,6 +2616,7 @@
|
|
|
2619
2616
|
p.itemsChanged = true;
|
|
2620
2617
|
this._refreshItemByValueMap();
|
|
2621
2618
|
if (resetValues) this.setSelectedValues(this.getSelectedValues());
|
|
2619
|
+
else this._scheduleSync("render_list");
|
|
2622
2620
|
this._trigger("itemschanged", {
|
|
2623
2621
|
term: null,
|
|
2624
2622
|
mutated: true,
|
|
@@ -3274,6 +3272,10 @@
|
|
|
3274
3272
|
top: "-9999px",
|
|
3275
3273
|
whiteSpace: "pre"
|
|
3276
3274
|
} });
|
|
3275
|
+
if (!p.controls) {
|
|
3276
|
+
p.controls = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__controls` });
|
|
3277
|
+
p.el.appendChild(p.controls);
|
|
3278
|
+
}
|
|
3277
3279
|
if (!p.input) p.inputWrapper = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__search_wrapper` }, p.input = (0, _danielgindi_dom_utils_lib_Dom.createElement)("input", {
|
|
3278
3280
|
class: `${p.baseClassName}__search_field`,
|
|
3279
3281
|
type: "search",
|
|
@@ -3295,7 +3297,7 @@
|
|
|
3295
3297
|
this._unregisterDropdownEvents();
|
|
3296
3298
|
const lastActiveElement = document.activeElement;
|
|
3297
3299
|
p.list = (0, _danielgindi_dom_utils_lib_Dom.createElement)("ul", { class: `${p.baseClassName}__list` });
|
|
3298
|
-
p.el.
|
|
3300
|
+
p.el.insertBefore(p.list, p.controls);
|
|
3299
3301
|
p.list.appendChild(p.inputWrapper);
|
|
3300
3302
|
p.el.classList.remove(`${p.baseClassName}__single`);
|
|
3301
3303
|
p.el.classList.add(`${p.baseClassName}__multi`);
|
|
@@ -3324,8 +3326,8 @@
|
|
|
3324
3326
|
this._unregisterDropdownEvents();
|
|
3325
3327
|
const lastActiveElement = document.activeElement;
|
|
3326
3328
|
p.singleWrapper = (0, _danielgindi_dom_utils_lib_Dom.createElement)("div", { class: `${p.baseClassName}__single_wrapper` });
|
|
3327
|
-
p.el.
|
|
3328
|
-
p.el.
|
|
3329
|
+
p.el.insertBefore(p.singleWrapper, p.controls);
|
|
3330
|
+
p.el.insertBefore(p.inputWrapper, p.controls);
|
|
3329
3331
|
p.el.classList.remove(`${p.baseClassName}__multi`);
|
|
3330
3332
|
p.el.classList.add(`${p.baseClassName}__single`);
|
|
3331
3333
|
if (lastActiveElement === p.input) p.input.focus();
|
|
@@ -3335,7 +3337,7 @@
|
|
|
3335
3337
|
if (p.hasOpenIndicator !== !!p.openIndicator) {
|
|
3336
3338
|
if (p.hasOpenIndicator) {
|
|
3337
3339
|
p.openIndicator = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__open_indicator` });
|
|
3338
|
-
|
|
3340
|
+
this._insertControl(p.openIndicator);
|
|
3339
3341
|
p.el.classList.add(`${p.baseClassName}__has_open_indicator`);
|
|
3340
3342
|
} else {
|
|
3341
3343
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.openIndicator);
|
|
@@ -3346,7 +3348,7 @@
|
|
|
3346
3348
|
if (p.isLoadingMode !== !!p.spinner) {
|
|
3347
3349
|
if (p.isLoadingMode) {
|
|
3348
3350
|
p.spinner = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__spinner` });
|
|
3349
|
-
|
|
3351
|
+
this._insertControl(p.spinner);
|
|
3350
3352
|
p.el.classList.add(`${p.baseClassName}__has_spinner`);
|
|
3351
3353
|
} else {
|
|
3352
3354
|
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.spinner);
|
|
@@ -3356,6 +3358,21 @@
|
|
|
3356
3358
|
}
|
|
3357
3359
|
}
|
|
3358
3360
|
/**
|
|
3361
|
+
* Inserts a control into the controls group, keeping the order: spinner, clear button, open indicator
|
|
3362
|
+
* @private
|
|
3363
|
+
* @internal
|
|
3364
|
+
*/
|
|
3365
|
+
_insertControl(control) {
|
|
3366
|
+
const p = this._p;
|
|
3367
|
+
const order = [
|
|
3368
|
+
p.spinner,
|
|
3369
|
+
p.clearButtonWrapper,
|
|
3370
|
+
p.openIndicator
|
|
3371
|
+
];
|
|
3372
|
+
const next = order.slice(order.indexOf(control) + 1).find((x) => x && x.parentNode === p.controls);
|
|
3373
|
+
p.controls.insertBefore(control, next ?? null);
|
|
3374
|
+
}
|
|
3375
|
+
/**
|
|
3359
3376
|
* @private
|
|
3360
3377
|
* @internal
|
|
3361
3378
|
*/
|
|
@@ -3375,7 +3392,10 @@
|
|
|
3375
3392
|
if (p.searchable || p.multi) classes.push(`${p.baseClassName}__searchable`);
|
|
3376
3393
|
if (p.direction === "ltr" || p.direction === "rtl") classes.push(`${p.baseClassName}__` + p.direction);
|
|
3377
3394
|
if (p.additionalClasses) classes = classes.concat(p.additionalClasses);
|
|
3378
|
-
|
|
3395
|
+
classes = classes.join(" ").split(/\s+/).filter(Boolean);
|
|
3396
|
+
const previousClasses = p.appliedClasses ?? [];
|
|
3397
|
+
el.className = Array.from(el.classList).filter((name) => !name.startsWith(p.baseClassName) && !previousClasses.includes(name)).concat(classes).join(" ");
|
|
3398
|
+
p.appliedClasses = classes;
|
|
3379
3399
|
}
|
|
3380
3400
|
/** @private */
|
|
3381
3401
|
/** @internal */
|
|
@@ -3892,9 +3912,8 @@
|
|
|
3892
3912
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
3893
3913
|
if (p.selectedItems.length > 0 && p.selectedItems.some((x) => x[multiItemLabelProp] !== false) && p.clearable && p.showSelection) {
|
|
3894
3914
|
if (!p.clearButtonWrapper) {
|
|
3895
|
-
p.clearButtonWrapper = (0, _danielgindi_dom_utils_lib_Dom.createElement)(
|
|
3896
|
-
|
|
3897
|
-
else (0, _danielgindi_dom_utils_lib_DomCompat.append)(p.el, p.clearButtonWrapper);
|
|
3915
|
+
p.clearButtonWrapper = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__clear` }, p.clearButton = (0, _danielgindi_dom_utils_lib_Dom.createElement)("button"));
|
|
3916
|
+
this._insertControl(p.clearButtonWrapper);
|
|
3898
3917
|
p.el.classList.add(`${p.baseClassName}__has_clear`);
|
|
3899
3918
|
p.sink.add(p.clearButton, "click", () => {
|
|
3900
3919
|
if (this.isDisabled() || this.isReadOnly()) return;
|
|
@@ -4141,14 +4160,6 @@
|
|
|
4141
4160
|
let hasResize = false;
|
|
4142
4161
|
if (p.multi && p.multiItemEls.length === 0 && p.showSelection) {
|
|
4143
4162
|
input.style.width = "";
|
|
4144
|
-
let beforeWidth = 0, afterWidth = 0;
|
|
4145
|
-
let beforeStyle = getComputedStyle(p.list || el, "::before");
|
|
4146
|
-
if (beforeStyle.content && beforeStyle.content !== "none" && beforeStyle.position !== "absolute" && beforeStyle.float !== "none") beforeWidth = (0, _danielgindi_dom_utils_lib_Css.getPseudoElementWidth)(p.list || el, "::before", true, true, true);
|
|
4147
|
-
let afterStyle = getComputedStyle(p.list || el, "::after");
|
|
4148
|
-
if (afterStyle.content && afterStyle.content !== "none" && afterStyle.position !== "absolute" && afterStyle.float !== "none") afterWidth = (0, _danielgindi_dom_utils_lib_Css.getPseudoElementWidth)(p.list || el, "::after", true, true, true);
|
|
4149
|
-
let contentWidth = (0, _danielgindi_dom_utils_lib_Css.getElementWidth)(p.list || el);
|
|
4150
|
-
contentWidth -= beforeWidth + afterWidth;
|
|
4151
|
-
input.style.width = `${contentWidth}px`;
|
|
4152
4163
|
hasResize = true;
|
|
4153
4164
|
} else {
|
|
4154
4165
|
(0, _danielgindi_dom_utils_lib_Css.setCssProps)(backBufferEl, (0, _danielgindi_dom_utils_lib_Css.getCssProps)(input, inputBackbufferCssProps));
|
|
@@ -4433,7 +4444,6 @@
|
|
|
4433
4444
|
return joined;
|
|
4434
4445
|
}
|
|
4435
4446
|
};
|
|
4436
|
-
//#endregion
|
|
4437
4447
|
exports.DropList = DropList;
|
|
4438
4448
|
exports.DropListDefaultOptions = DefaultOptions;
|
|
4439
4449
|
exports.ItemSymbol = ItemSymbol;
|