@danielgindi/selectbox 2.0.9 → 2.0.11
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 +6753 -236
- 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 +36 -8
- 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 +11908 -5391
- 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 +6 -7
- package/lib/SelectBox.js +29 -0
- package/package.json +16 -16
- package/vue/DropList.vue +1 -1
- package/vue/SelectBox.vue +775 -775
package/lib/DropList.js
CHANGED
|
@@ -1169,7 +1169,10 @@ class DropList {
|
|
|
1169
1169
|
p.items.map(x => {
|
|
1170
1170
|
const y = x[ItemSymbol];
|
|
1171
1171
|
if (y !== undefined) {
|
|
1172
|
-
|
|
1172
|
+
// Seal it to avoid object finding issues when wrapped in proxies by Vue or other libs
|
|
1173
|
+
y[ItemSymbol] = Object.seal({
|
|
1174
|
+
[ItemSymbol]: x,
|
|
1175
|
+
});
|
|
1173
1176
|
return y;
|
|
1174
1177
|
}
|
|
1175
1178
|
|
|
@@ -1180,7 +1183,7 @@ class DropList {
|
|
|
1180
1183
|
if (Array.isArray(filteredItems)) {
|
|
1181
1184
|
// And back
|
|
1182
1185
|
filteredItems = filteredItems.map(oitem => {
|
|
1183
|
-
let our = oitem[ItemSymbol];
|
|
1186
|
+
let our = oitem[ItemSymbol]?.[ItemSymbol]; // double-unwrap sealed->item
|
|
1184
1187
|
if (!our) {
|
|
1185
1188
|
our = {
|
|
1186
1189
|
[ItemSymbol]: oitem,
|
|
@@ -1734,11 +1737,7 @@ class DropList {
|
|
|
1734
1737
|
let item = p.items[i];
|
|
1735
1738
|
let checked = !item._nocheck && values.indexOf(item.value) !== -1;
|
|
1736
1739
|
|
|
1737
|
-
let itemIndex = i;
|
|
1738
|
-
if (p.filteredItems) {
|
|
1739
|
-
const item = p.items[itemIndex];
|
|
1740
|
-
itemIndex = p.filteredItems.indexOf(item);
|
|
1741
|
-
}
|
|
1740
|
+
let itemIndex = p.filteredItems ? p.filteredItems.indexOf(item) : i;
|
|
1742
1741
|
|
|
1743
1742
|
if (item._group && itemIndex !== -1) {
|
|
1744
1743
|
groupIndexes.push(itemIndex);
|
package/lib/SelectBox.js
CHANGED
|
@@ -111,6 +111,7 @@ const inputBackbufferCssProps = [
|
|
|
111
111
|
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderNoResultsItem]
|
|
112
112
|
* @property {boolean} [searchable=false] is it searchable?
|
|
113
113
|
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
114
|
+
* @property {boolean} [autoSelectTextOnCheck=true] automatically select text in input when an item is checked (multi mode). Used to allow the user to quickly type multiple items.
|
|
114
115
|
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
115
116
|
* @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
|
|
116
117
|
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
@@ -138,6 +139,7 @@ const defaultOptions = {
|
|
|
138
139
|
multiPlaceholderFormatter: null,
|
|
139
140
|
searchable: true,
|
|
140
141
|
noResultsText: 'No matching results',
|
|
142
|
+
autoSelectTextOnCheck: true,
|
|
141
143
|
filterThrottleWindow: 300,
|
|
142
144
|
filterOnEmptyTerm: false,
|
|
143
145
|
labelProp: 'label',
|
|
@@ -232,6 +234,7 @@ class SelectBox {
|
|
|
232
234
|
multiPlaceholderFormatter: o.multiPlaceholderFormatter,
|
|
233
235
|
searchable: o.searchable,
|
|
234
236
|
noResultsText: o.noResultsText,
|
|
237
|
+
autoSelectTextOnCheck: o.autoSelectTextOnCheck,
|
|
235
238
|
|
|
236
239
|
labelProp: o.labelProp,
|
|
237
240
|
valueProp: o.valueProp,
|
|
@@ -1006,6 +1009,22 @@ class SelectBox {
|
|
|
1006
1009
|
return this._p.noResultsText;
|
|
1007
1010
|
}
|
|
1008
1011
|
|
|
1012
|
+
/**
|
|
1013
|
+
* @param {boolean} autoSelectTextOnCheck
|
|
1014
|
+
* @returns {SelectBox}
|
|
1015
|
+
*/
|
|
1016
|
+
setAutoSelectTextOnCheck(autoSelectTextOnCheck) {
|
|
1017
|
+
this._p.autoSelectTextOnCheck = autoSelectTextOnCheck;
|
|
1018
|
+
return this;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* @returns {boolean}
|
|
1023
|
+
*/
|
|
1024
|
+
getAutoSelectTextOnCheck() {
|
|
1025
|
+
return this._p.autoSelectTextOnCheck;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1009
1028
|
/**
|
|
1010
1029
|
* @param {number} window
|
|
1011
1030
|
* @returns {SelectBox}
|
|
@@ -1856,6 +1875,11 @@ class SelectBox {
|
|
|
1856
1875
|
case 'check': {
|
|
1857
1876
|
if (!p.multi) return;
|
|
1858
1877
|
|
|
1878
|
+
if (p.autoSelectTextOnCheck && p.input && document.activeElement === p.input) {
|
|
1879
|
+
// Select the text in the input, without causing any focus changes
|
|
1880
|
+
p.input.setSelectionRange(0, p.input.value.length);
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1859
1883
|
const item = /**@type DropList.Item*/event.item;
|
|
1860
1884
|
const value = event.value;
|
|
1861
1885
|
|
|
@@ -1936,6 +1960,11 @@ class SelectBox {
|
|
|
1936
1960
|
case 'groupcheck': {
|
|
1937
1961
|
if (!p.multi) return;
|
|
1938
1962
|
|
|
1963
|
+
if (p.autoSelectTextOnCheck && p.input && document.activeElement === p.input) {
|
|
1964
|
+
// Select the text in the input, without causing any focus changes
|
|
1965
|
+
p.input.setSelectionRange(0, p.input.value.length);
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1939
1968
|
if (event.affectedCount) {
|
|
1940
1969
|
this._scheduleSync(p.sortSelectedItems ? 'full' : 'render_base');
|
|
1941
1970
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielgindi/selectbox",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "A collection of dom utilities. So you can work natively with the dom without dom frameworks.",
|
|
5
5
|
"main": "dist/lib.cjs.min.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -30,29 +30,29 @@
|
|
|
30
30
|
"homepage": "https://github.com/danielgindi/selectbox#readme",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "^7.
|
|
34
|
-
"@babel/preset-env": "^7.
|
|
35
|
-
"@babel/runtime": "^7.
|
|
36
|
-
"@eslint/eslintrc": "^3.
|
|
37
|
-
"@eslint/js": "^9.
|
|
38
|
-
"@rollup/plugin-babel": "^6.0
|
|
39
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
40
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
33
|
+
"@babel/core": "^7.28.4",
|
|
34
|
+
"@babel/preset-env": "^7.28.3",
|
|
35
|
+
"@babel/runtime": "^7.28.4",
|
|
36
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
37
|
+
"@eslint/js": "^9.38.0",
|
|
38
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
39
|
+
"@rollup/plugin-commonjs": "^28.0.8",
|
|
40
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
41
41
|
"@rollup/plugin-terser": "^0.4.4",
|
|
42
|
-
"core-js": "^3.
|
|
43
|
-
"eslint": "^9.
|
|
42
|
+
"core-js": "^3.46.0",
|
|
43
|
+
"eslint": "^9.38.0",
|
|
44
44
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
45
45
|
"eslint-plugin-vue": "^9.32.0",
|
|
46
|
-
"fs-extra": "^11.3.
|
|
47
|
-
"globals": "^
|
|
46
|
+
"fs-extra": "^11.3.2",
|
|
47
|
+
"globals": "^16.4.0",
|
|
48
48
|
"husky": "^9.1.7",
|
|
49
49
|
"pinst": "^3.0.0",
|
|
50
|
-
"rollup": "^4.
|
|
51
|
-
"sass": "^1.
|
|
50
|
+
"rollup": "^4.52.5",
|
|
51
|
+
"sass": "^1.93.2"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@danielgindi/dom-utils": "^1.0.11",
|
|
55
|
-
"@danielgindi/virtual-list-helper": "^1.0.
|
|
55
|
+
"@danielgindi/virtual-list-helper": "^1.0.15",
|
|
56
56
|
"fast-deep-equal": "^3.1.3",
|
|
57
57
|
"keycode-js": "^3.1.0",
|
|
58
58
|
"mitt": "^3.0.1"
|
package/vue/DropList.vue
CHANGED