@danielgindi/selectbox 2.0.4 → 2.0.6

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/lib/DropList.js CHANGED
@@ -1186,11 +1186,10 @@ class DropList {
1186
1186
  if (!Array.isArray(filteredItems)) {
1187
1187
  if (term) {
1188
1188
  const matcher = new RegExp(escapeRegex(term), 'i');
1189
- const labelProp = p.labelProp;
1190
1189
 
1191
1190
  filteredItems = p.items.filter(x => {
1192
1191
  if (!filterGroups && x._group) return true;
1193
- return matcher.test(x[labelProp]);
1192
+ return matcher.test(x.label);
1194
1193
  });
1195
1194
  } else {
1196
1195
  filteredItems = null;
@@ -1464,6 +1463,8 @@ class DropList {
1464
1463
 
1465
1464
  // Calculate virtual viewport size
1466
1465
  if (p.virtualListHelper.isVirtual()) {
1466
+ // Avoid extremely high size which will cause laying out the whole list
1467
+ menuEl.style.height = Math.min(el.clientHeight, document.body.clientHeight) + 'px';
1467
1468
  p.virtualListHelper.render();
1468
1469
  }
1469
1470
 
package/lib/SelectBox.js CHANGED
@@ -380,8 +380,7 @@ class SelectBox {
380
380
  p.resizeObserver.observe(p.el);
381
381
  }
382
382
 
383
- if (o.filterFn)
384
- this.setFilterFn(o.filterFn);
383
+ this.setFilterFn(o.filterFn);
385
384
 
386
385
  this.setItems(o.items);
387
386
  delete o.items; // we do not need this in memory anymore
@@ -1174,6 +1173,10 @@ class SelectBox {
1174
1173
  const p = this._p;
1175
1174
  if (p.filterFn === fn)
1176
1175
  return this;
1176
+
1177
+ // Do not keep this reference, as far as the user is concerned - he/she did not set a custom filter.
1178
+ p.filterFn = fn;
1179
+
1177
1180
  if (!fn) {
1178
1181
  // Add search by multi-item label
1179
1182
  fn = (items, term) => {
@@ -1187,7 +1190,8 @@ class SelectBox {
1187
1190
  });
1188
1191
  };
1189
1192
  }
1190
- p.filterFn = fn;
1193
+
1194
+ p.actualFilterFn = fn;
1191
1195
  p.dropList?.setFilterFn(fn);
1192
1196
  return this;
1193
1197
  }
@@ -1791,8 +1795,8 @@ class SelectBox {
1791
1795
  filterThrottleWindow: p.filterThrottleWindow,
1792
1796
  filterOnEmptyTerm: p.filterOnEmptyTerm,
1793
1797
  filterGroups: p.treatGroupSelectionAsItems,
1794
- filterEmptyGroups: p.treatGroupSelectionAsItems,
1795
- filterFn: p.filterFn,
1798
+ filterEmptyGroups: !p.treatGroupSelectionAsItems,
1799
+ filterFn: p.actualFilterFn,
1796
1800
 
1797
1801
  positionOptionsProvider: () => this._getDropListPositionOptions(),
1798
1802
 
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
- {
2
- "name": "@danielgindi/selectbox",
3
- "version": "2.0.4",
4
- "description": "A collection of dom utilities. So you can work natively with the dom without dom frameworks.",
5
- "main": "dist/lib.cjs.min.js",
6
- "module": "lib/index.js",
7
- "broswer": "dist/lib.umd.min.js",
8
- "author": {
9
- "name": "Daniel Cohen Gindi",
10
- "email": "danielgindi@gmail.com"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git://github.com/danielgindi/selectbox.git"
15
- },
16
- "directories": {
17
- "dist": "dist",
18
- "lib": "lib"
19
- },
20
- "scripts": {
21
- "build": "npm run lint && node ./scripts/build.js",
22
- "lint": "eslint -f codeframe ./",
23
- "lint-fix": "eslint -f codeframe --fix ./",
24
- "prepublishOnly": "npm run build",
25
- "prepare": "husky"
26
- },
27
- "bugs": {
28
- "url": "https://github.com/danielgindi/selectbox/issues"
29
- },
30
- "homepage": "https://github.com/danielgindi/selectbox#readme",
31
- "license": "MIT",
32
- "devDependencies": {
33
- "@babel/core": "^7.26.9",
34
- "@babel/preset-env": "^7.26.9",
35
- "@babel/runtime": "^7.26.9",
36
- "@eslint/eslintrc": "^3.2.0",
37
- "@eslint/js": "^9.20.0",
38
- "@rollup/plugin-babel": "^6.0.4",
39
- "@rollup/plugin-commonjs": "^28.0.2",
40
- "@rollup/plugin-node-resolve": "^16.0.0",
41
- "@rollup/plugin-terser": "^0.4.4",
42
- "core-js": "^3.40.0",
43
- "eslint": "^9.20.1",
44
- "eslint-formatter-codeframe": "^7.32.1",
45
- "eslint-plugin-vue": "^9.32.0",
46
- "fs-extra": "^11.3.0",
47
- "globals": "^15.15.0",
48
- "husky": "^9.1.7",
49
- "pinst": "^3.0.0",
50
- "rollup": "^4.34.8",
51
- "sass": "^1.85.0"
52
- },
53
- "dependencies": {
54
- "@danielgindi/dom-utils": "^1.0.11",
55
- "@danielgindi/virtual-list-helper": "^1.0.13",
56
- "fast-deep-equal": "^3.1.3",
57
- "keycode-js": "^3.1.0",
58
- "mitt": "^3.0.1"
59
- },
60
- "peerDependencies": {
61
- "vue": "^2.* || ^3.*"
62
- }
63
- }
1
+ {
2
+ "name": "@danielgindi/selectbox",
3
+ "version": "2.0.6",
4
+ "description": "A collection of dom utilities. So you can work natively with the dom without dom frameworks.",
5
+ "main": "dist/lib.cjs.min.js",
6
+ "module": "lib/index.js",
7
+ "broswer": "dist/lib.umd.min.js",
8
+ "author": {
9
+ "name": "Daniel Cohen Gindi",
10
+ "email": "danielgindi@gmail.com"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git://github.com/danielgindi/selectbox.git"
15
+ },
16
+ "directories": {
17
+ "dist": "dist",
18
+ "lib": "lib"
19
+ },
20
+ "scripts": {
21
+ "build": "npm run lint && node ./scripts/build.js",
22
+ "lint": "eslint -f codeframe ./",
23
+ "lint-fix": "eslint -f codeframe --fix ./",
24
+ "prepublishOnly": "npm run build",
25
+ "prepare": "husky"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/danielgindi/selectbox/issues"
29
+ },
30
+ "homepage": "https://github.com/danielgindi/selectbox#readme",
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "@babel/core": "^7.26.9",
34
+ "@babel/preset-env": "^7.26.9",
35
+ "@babel/runtime": "^7.26.9",
36
+ "@eslint/eslintrc": "^3.2.0",
37
+ "@eslint/js": "^9.20.0",
38
+ "@rollup/plugin-babel": "^6.0.4",
39
+ "@rollup/plugin-commonjs": "^28.0.2",
40
+ "@rollup/plugin-node-resolve": "^16.0.0",
41
+ "@rollup/plugin-terser": "^0.4.4",
42
+ "core-js": "^3.40.0",
43
+ "eslint": "^9.20.1",
44
+ "eslint-formatter-codeframe": "^7.32.1",
45
+ "eslint-plugin-vue": "^9.32.0",
46
+ "fs-extra": "^11.3.0",
47
+ "globals": "^15.15.0",
48
+ "husky": "^9.1.7",
49
+ "pinst": "^3.0.0",
50
+ "rollup": "^4.34.8",
51
+ "sass": "^1.85.0"
52
+ },
53
+ "dependencies": {
54
+ "@danielgindi/dom-utils": "^1.0.11",
55
+ "@danielgindi/virtual-list-helper": "^1.0.13",
56
+ "fast-deep-equal": "^3.1.3",
57
+ "keycode-js": "^3.1.0",
58
+ "mitt": "^3.0.1"
59
+ },
60
+ "peerDependencies": {
61
+ "vue": "^2.* || ^3.*"
62
+ }
63
+ }