@danielgindi/selectbox 1.0.137 → 1.0.139
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 +194 -2643
- 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 +47 -19
- 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 +5949 -8398
- 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/eslint.config.mjs +143 -0
- package/lib/DropList.js +7 -6
- package/lib/SelectBox.js +39 -12
- package/package.json +14 -11
- package/vue/DropList.vue +1 -1
- package/vue/SelectBox.vue +4 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import js from "@eslint/js";
|
|
5
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const compat = new FlatCompat({
|
|
10
|
+
baseDirectory: __dirname,
|
|
11
|
+
recommendedConfig: js.configs.recommended,
|
|
12
|
+
allConfig: js.configs.all,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default [
|
|
16
|
+
{
|
|
17
|
+
ignores: [
|
|
18
|
+
"tests/**/*",
|
|
19
|
+
"test/**/*",
|
|
20
|
+
"!tests/**/*tests.js",
|
|
21
|
+
"!test/**/*tests.js",
|
|
22
|
+
"!tests/**/*_test.js",
|
|
23
|
+
"!test/**/*_test.js",
|
|
24
|
+
"!tests/**/*_helpers.js",
|
|
25
|
+
"!test/**/*_helpers.js",
|
|
26
|
+
"dist/**/*",
|
|
27
|
+
"example/**/*",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
...compat.extends("eslint:recommended", "plugin:vue/recommended"),
|
|
31
|
+
{
|
|
32
|
+
languageOptions: {
|
|
33
|
+
globals: {
|
|
34
|
+
...Object.fromEntries(Object.entries(globals.node).map(([key]) => [key, "off"])),
|
|
35
|
+
...globals.browser,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
ecmaVersion: 2020,
|
|
39
|
+
sourceType: "module",
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
rules: {
|
|
43
|
+
semi: ["warn", "always"],
|
|
44
|
+
"comma-dangle": ["warn", "always-multiline"],
|
|
45
|
+
"comma-style": ["warn", "last"],
|
|
46
|
+
"no-var": ["warn"],
|
|
47
|
+
|
|
48
|
+
"arrow-spacing": ["warn", {
|
|
49
|
+
before: true,
|
|
50
|
+
after: true,
|
|
51
|
+
}],
|
|
52
|
+
|
|
53
|
+
"space-infix-ops": ["warn", {
|
|
54
|
+
int32Hint: true,
|
|
55
|
+
}],
|
|
56
|
+
|
|
57
|
+
"keyword-spacing": ["warn", {
|
|
58
|
+
before: true,
|
|
59
|
+
after: true,
|
|
60
|
+
}],
|
|
61
|
+
|
|
62
|
+
"space-unary-ops": ["warn", {
|
|
63
|
+
words: true,
|
|
64
|
+
nonwords: false,
|
|
65
|
+
}],
|
|
66
|
+
|
|
67
|
+
"comma-spacing": ["warn", {
|
|
68
|
+
before: false,
|
|
69
|
+
after: true,
|
|
70
|
+
}],
|
|
71
|
+
|
|
72
|
+
"object-curly-spacing": ["warn", "always"],
|
|
73
|
+
|
|
74
|
+
"no-unused-vars": ["warn", {
|
|
75
|
+
vars: "all",
|
|
76
|
+
args: "after-used",
|
|
77
|
+
varsIgnorePattern: "[iIgnored]|^_",
|
|
78
|
+
ignoreRestSiblings: false,
|
|
79
|
+
argsIgnorePattern: "^_",
|
|
80
|
+
caughtErrors: "all",
|
|
81
|
+
caughtErrorsIgnorePattern: "^ignore",
|
|
82
|
+
}],
|
|
83
|
+
|
|
84
|
+
"no-console": "warn",
|
|
85
|
+
"no-extra-semi": "warn",
|
|
86
|
+
"no-unreachable": "warn",
|
|
87
|
+
|
|
88
|
+
"no-fallthrough": ["error", {
|
|
89
|
+
commentPattern: "break[\\s\\w]*omitted|fallthrough",
|
|
90
|
+
}],
|
|
91
|
+
|
|
92
|
+
"no-useless-escape": "warn",
|
|
93
|
+
"no-constant-condition": "warn",
|
|
94
|
+
"no-return-await": "warn",
|
|
95
|
+
"no-async-promise-executor": "warn",
|
|
96
|
+
|
|
97
|
+
"vue/no-unused-vars": ["warn", {
|
|
98
|
+
ignorePattern: "^_",
|
|
99
|
+
}],
|
|
100
|
+
|
|
101
|
+
"vue/require-default-prop": ["off"],
|
|
102
|
+
"vue/no-v-html": ["off"],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
files: [
|
|
107
|
+
"tests/**/*tests.js",
|
|
108
|
+
"test/**/*tests.js",
|
|
109
|
+
"tests/**/*_test.js",
|
|
110
|
+
"test/**/*_test.js",
|
|
111
|
+
],
|
|
112
|
+
|
|
113
|
+
languageOptions: {
|
|
114
|
+
globals: {
|
|
115
|
+
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])),
|
|
116
|
+
...globals.node,
|
|
117
|
+
...globals.mocha,
|
|
118
|
+
...globals.jest,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
rules: {
|
|
123
|
+
"no-console": "off",
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
files: ["*db*/**/migrations/**/*.js"],
|
|
128
|
+
|
|
129
|
+
rules: {
|
|
130
|
+
"no-console": "off",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
files: ["scripts/**/*.js", "**/eslint.config.mjs"],
|
|
135
|
+
|
|
136
|
+
languageOptions: {
|
|
137
|
+
globals: {
|
|
138
|
+
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])),
|
|
139
|
+
...globals.node,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
];
|
package/lib/DropList.js
CHANGED
|
@@ -1578,7 +1578,7 @@ class DropList {
|
|
|
1578
1578
|
let itemPos, previousPos = -1;
|
|
1579
1579
|
let maxIterations = 30; // Some zoom/scroll issues can make it so that it takes almost forever
|
|
1580
1580
|
|
|
1581
|
-
|
|
1581
|
+
|
|
1582
1582
|
while (maxIterations-- > 0) {
|
|
1583
1583
|
itemPos = p.virtualListHelper.getItemPosition(itemIndex);
|
|
1584
1584
|
|
|
@@ -1820,11 +1820,12 @@ class DropList {
|
|
|
1820
1820
|
setTimeout(() => {
|
|
1821
1821
|
if (this[DestroyedSymbol]) return;
|
|
1822
1822
|
|
|
1823
|
-
if (
|
|
1824
|
-
|
|
1825
|
-
this._delayBlurItemOnBlur();
|
|
1826
|
-
this._trigger('blur', event);
|
|
1823
|
+
if (document.activeElement && this.elContains(document.activeElement, true)) {
|
|
1824
|
+
return;
|
|
1827
1825
|
}
|
|
1826
|
+
|
|
1827
|
+
this._delayBlurItemOnBlur();
|
|
1828
|
+
this._trigger('blur', event);
|
|
1828
1829
|
});
|
|
1829
1830
|
});
|
|
1830
1831
|
}
|
|
@@ -2116,7 +2117,7 @@ class DropList {
|
|
|
2116
2117
|
let base = getElementOffset(p.focusItemEl).top;
|
|
2117
2118
|
let height = getElementHeight(p.el, true);
|
|
2118
2119
|
|
|
2119
|
-
while (true) {
|
|
2120
|
+
while (true) {
|
|
2120
2121
|
next = p.focusItemEl.nextElementSibling;
|
|
2121
2122
|
if (!next) return;
|
|
2122
2123
|
if (next.tagName !== 'LI') continue;
|
package/lib/SelectBox.js
CHANGED
|
@@ -462,6 +462,20 @@ class SelectBox {
|
|
|
462
462
|
return this._p.el;
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
get droplistInstance() {
|
|
466
|
+
return this._p.dropList;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Returns true if other is an inclusive descendant of droplist node, false otherwise, and undefined if the droplist is not initiated.
|
|
471
|
+
* @param {Node} other
|
|
472
|
+
* @param {boolean} [considerSubmenus=true]
|
|
473
|
+
* @returns {boolean|undefined}
|
|
474
|
+
*/
|
|
475
|
+
droplistElContains(other, considerSubmenus = true) {
|
|
476
|
+
return this._p.dropList?.elContains(other, considerSubmenus);
|
|
477
|
+
}
|
|
478
|
+
|
|
465
479
|
/**
|
|
466
480
|
* Enables the control
|
|
467
481
|
* @param {boolean=true} enabled Should the control be enabled?
|
|
@@ -1956,6 +1970,9 @@ class SelectBox {
|
|
|
1956
1970
|
}
|
|
1957
1971
|
}
|
|
1958
1972
|
break;
|
|
1973
|
+
|
|
1974
|
+
case 'blur':
|
|
1975
|
+
this._handleOnBlur();
|
|
1959
1976
|
}
|
|
1960
1977
|
},
|
|
1961
1978
|
});
|
|
@@ -1970,6 +1987,27 @@ class SelectBox {
|
|
|
1970
1987
|
this._registerDropdownEvents();
|
|
1971
1988
|
}
|
|
1972
1989
|
|
|
1990
|
+
_handleOnBlur() {
|
|
1991
|
+
const p = this._p;
|
|
1992
|
+
|
|
1993
|
+
setTimeout(() => {
|
|
1994
|
+
if (p.disabled) return;
|
|
1995
|
+
|
|
1996
|
+
this._trigger('search:blur');
|
|
1997
|
+
|
|
1998
|
+
if (this[DestroyedSymbol]) return; // destroyed by event handler
|
|
1999
|
+
|
|
2000
|
+
if (document.activeElement &&
|
|
2001
|
+
(p.input && p.input.contains(document.activeElement) ||
|
|
2002
|
+
p.dropList && this.droplistElContains(document.activeElement, true))) {
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
if (p.throttledUpdateListItems)
|
|
2006
|
+
p.throttledUpdateListItems.cancel();
|
|
2007
|
+
this.closeList();
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
|
|
1973
2011
|
_unregisterDropdownEvents() {
|
|
1974
2012
|
const p = this._p;
|
|
1975
2013
|
|
|
@@ -2139,18 +2177,7 @@ class SelectBox {
|
|
|
2139
2177
|
avoidToggleFromClick = true;
|
|
2140
2178
|
setTimeout(() => { avoidToggleFromClick = false; }, 10);
|
|
2141
2179
|
})
|
|
2142
|
-
.add(p.input, 'blur.dropdown', () =>
|
|
2143
|
-
if (p.disabled) return;
|
|
2144
|
-
|
|
2145
|
-
this._trigger('search:blur');
|
|
2146
|
-
|
|
2147
|
-
if (this[DestroyedSymbol]) return; // destroyed by event handler
|
|
2148
|
-
|
|
2149
|
-
if (p.throttledUpdateListItems)
|
|
2150
|
-
p.throttledUpdateListItems.cancel();
|
|
2151
|
-
|
|
2152
|
-
this.closeList();
|
|
2153
|
-
});
|
|
2180
|
+
.add(p.input, 'blur.dropdown', () => this._handleOnBlur());
|
|
2154
2181
|
}
|
|
2155
2182
|
|
|
2156
2183
|
p.sink
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielgindi/selectbox",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.139",
|
|
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",
|
|
@@ -31,22 +31,25 @@
|
|
|
31
31
|
"homepage": "https://github.com/danielgindi/selectbox#readme",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@babel/core": "^7.
|
|
35
|
-
"@babel/preset-env": "^7.
|
|
36
|
-
"@babel/runtime": "^7.
|
|
34
|
+
"@babel/core": "^7.25.2",
|
|
35
|
+
"@babel/preset-env": "^7.25.3",
|
|
36
|
+
"@babel/runtime": "^7.25.0",
|
|
37
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
38
|
+
"@eslint/js": "^9.8.0",
|
|
37
39
|
"@rollup/plugin-babel": "^6.0.4",
|
|
38
|
-
"@rollup/plugin-commonjs": "^
|
|
40
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
39
41
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
40
42
|
"@rollup/plugin-terser": "^0.4.4",
|
|
41
|
-
"core-js": "^3.
|
|
42
|
-
"eslint": "^8.
|
|
43
|
+
"core-js": "^3.38.0",
|
|
44
|
+
"eslint": "^9.8.0",
|
|
43
45
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
44
|
-
"eslint-plugin-vue": "^9.
|
|
46
|
+
"eslint-plugin-vue": "^9.27.0",
|
|
45
47
|
"fs-extra": "^11.2.0",
|
|
46
|
-
"
|
|
48
|
+
"globals": "^15.9.0",
|
|
49
|
+
"husky": "^9.1.4",
|
|
47
50
|
"pinst": "^3.0.0",
|
|
48
|
-
"rollup": "^4.
|
|
49
|
-
"sass": "^1.
|
|
51
|
+
"rollup": "^4.20.0",
|
|
52
|
+
"sass": "^1.77.8"
|
|
50
53
|
},
|
|
51
54
|
"dependencies": {
|
|
52
55
|
"@danielgindi/dom-utils": "^1.0.8",
|
package/vue/DropList.vue
CHANGED
package/vue/SelectBox.vue
CHANGED