jqtree 1.5.2 → 1.6.2
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/.eslintrc +1 -0
- package/.github/workflows/ci.yml +54 -0
- package/.github/workflows/codeql-analysis.yml +28 -0
- package/README.md +1 -1
- package/_config.yml +1 -1
- package/_entries/10_changelog.md +20 -0
- package/_entries/{36_showemptynode.md → 36_showemptyfolder.md} +5 -5
- package/_entries/38_start_dnd_delay.md +13 -0
- package/_entries/{38_tabindex.md → 39_tabindex.md} +0 -0
- package/_entries/{39_usecontextmenu.md → 40_usecontextmenu.md} +0 -0
- package/_entries/{40_functions.md → 41_functions.md} +0 -0
- package/_entries/{41_addparentnode.md → 42_addparentnode.md} +0 -0
- package/_entries/{42_addnodeafter.md → 43_addnodeafter.md} +0 -0
- package/_entries/{43_addnodebefore.md → 44_addnodebefore.md} +0 -0
- package/_entries/{44_appendnode.md → 45_appendnode.md} +0 -0
- package/_entries/{45_closenode.md → 46_closenode.md} +0 -0
- package/_entries/{46_destroy.md → 47_destroy.md} +0 -0
- package/_entries/{47_getnodebycallback.md → 48_getnodebycallback.md} +0 -0
- package/_entries/{48_getnodebyid.md → 49_getnodebyid.md} +0 -0
- package/_entries/{49_getnodebyhtmlelement.md → 50_getnodebyhtmlelement.md} +0 -0
- package/_entries/{50_getselectednode.md → 51_getselectednode.md} +0 -0
- package/_entries/{51_getstate.md → 52_getstate.md} +0 -0
- package/_entries/{52_gettree.md → 53_gettree.md} +0 -0
- package/_entries/{53_isdragging.md → 54_isdragging.md} +0 -0
- package/_entries/{54_loaddata.md → 55_loaddata.md} +0 -0
- package/_entries/{55_loaddatafromurl.md → 56_loaddatafromurl.md} +0 -0
- package/_entries/{56_movedown.md → 57_movedown.md} +0 -0
- package/_entries/{57_movenode.md → 58_movenode.md} +0 -0
- package/_entries/{58_moveup.md → 59_moveup.md} +0 -0
- package/_entries/{59_opennode.md → 60_opennode.md} +0 -0
- package/_entries/{60_prependnode.md → 61_prependnode.md} +0 -0
- package/_entries/62_refresh.md +12 -0
- package/_entries/{61_reload.md → 63_reload.md} +0 -0
- package/_entries/{62_removenode.md → 64_removenode.md} +0 -0
- package/_entries/{63_selectnode.md → 65_selectnode.md} +0 -0
- package/_entries/{64_scrolltonode.md → 66_scrolltonode.md} +0 -0
- package/_entries/{65_setoption.md → 67_setoption.md} +0 -0
- package/_entries/{66_setstate.md → 68_setstate.md} +0 -0
- package/_entries/{67_toggle.md → 69_toggle.md} +0 -0
- package/_entries/{68_tojson.md → 70_tojson.md} +0 -0
- package/_entries/{69_updatenode.md → 71_updatenode.md} +0 -0
- package/_entries/{70_events.md → 72_events.md} +0 -0
- package/_entries/{71_tree-click.md → 73_tree-click.md} +0 -0
- package/_entries/{72_tree-close.md → 74_tree-close.md} +0 -0
- package/_entries/{73_tree-contextmenu.md → 75_tree-contextmenu.md} +0 -0
- package/_entries/{74_tree-dblclick.md → 76_tree-dblclick.md} +0 -0
- package/_entries/{75_tree-init.md → 77_tree-init.md} +0 -0
- package/_entries/{76_tree-load-data.md → 78_tree-load-data.md} +0 -0
- package/_entries/{77_tree-loading-data.md → 79_tree-loading-data.md} +0 -0
- package/_entries/{78_tree-move.md → 80_tree-move.md} +0 -0
- package/_entries/{79_tree-refresh.md → 81_tree-refresh.md} +0 -0
- package/_entries/{80_tree-open.md → 82_tree-open.md} +0 -0
- package/_entries/{81_tree-select.md → 83_tree-select.md} +0 -0
- package/_entries/{82_multiple-selection.md → 84_multiple-selection.md} +0 -0
- package/_entries/{83_add-to-selection.md → 85_add-to-selection.md} +0 -0
- package/_entries/{84_get-selected-nodes.md → 86_get-selected-nodes.md} +0 -0
- package/_entries/{85_is-node-selected.md → 87_is-node-selected.md} +0 -0
- package/_entries/{86_remove-from-selection.md → 88_remove-from-selection.md} +0 -0
- package/_entries/{87_node-functions.md → 89_node-functions.md} +0 -0
- package/_entries/{88_children.md → 90_children.md} +0 -0
- package/_entries/{89_getdata.md → 91_getdata.md} +0 -0
- package/_entries/{90_getlevel.md → 92_getlevel.md} +0 -0
- package/_entries/{91_getnextnode.md → 93_getnextnode.md} +0 -0
- package/_entries/{92_getnextsibling.md → 94_getnextsibling.md} +0 -0
- package/_entries/{93_getpreviousnode.md → 95_getpreviousnode.md} +0 -0
- package/_entries/{94_getprevioussibling.md → 96_getprevioussibling.md} +0 -0
- package/_entries/{95_parent.md → 97_parent.md} +0 -0
- package/_examples/13_drag_outside.html +2 -1
- package/_examples/14_filter.html +113 -0
- package/_layouts/base.html +1 -23
- package/babel.config.json +11 -0
- package/babel.coverage.config.json +4 -0
- package/bower.json +1 -1
- package/jest-browser.config.js +0 -3
- package/jest-jsdom.config.js +1 -2
- package/jqtree.css +4 -1
- package/jqtree.postcss +3 -0
- package/lib/dataLoader.js +146 -98
- package/lib/dragAndDropHandler.js +668 -470
- package/lib/elementsRenderer.js +282 -197
- package/lib/jqtreeOptions.js +1 -2
- package/lib/keyHandler.js +134 -87
- package/lib/mouse.widget.js +288 -165
- package/lib/node.js +693 -505
- package/lib/nodeElement.js +329 -205
- package/lib/playwright/playwright.test.js +216 -189
- package/lib/playwright/testUtil.js +437 -192
- package/lib/playwright/visualRegression.js +183 -117
- package/lib/saveStateHandler.js +311 -204
- package/lib/scrollHandler.js +293 -199
- package/lib/selectNodeHandler.js +140 -105
- package/lib/simple.widget.js +184 -109
- package/lib/test/global.d.js +3 -0
- package/lib/test/jqTree/create.test.js +44 -40
- package/lib/test/jqTree/events.test.js +185 -138
- package/lib/test/jqTree/keyboard.test.js +216 -199
- package/lib/test/jqTree/loadOnDemand.test.js +233 -157
- package/lib/test/jqTree/methods.test.js +1269 -1000
- package/lib/test/jqTree/options.test.js +467 -398
- package/lib/test/node.test.js +1036 -873
- package/lib/test/nodeUtil.test.js +21 -20
- package/lib/test/support/exampleData.js +35 -23
- package/lib/test/support/jqTreeMatchers.js +72 -54
- package/lib/test/support/matchers.d.js +1 -0
- package/lib/test/support/setupTests.js +9 -3
- package/lib/test/support/testUtil.js +38 -15
- package/lib/test/support/treeStructure.js +41 -32
- package/lib/test/util.test.js +21 -20
- package/lib/tree.jquery.d.js +1 -0
- package/lib/tree.jquery.js +1264 -883
- package/lib/types.js +1 -2
- package/lib/typings.d.js +2 -0
- package/lib/util.js +21 -7
- package/lib/version.js +8 -3
- package/package.json +43 -36
- package/production +4 -4
- package/rollup.config.js +16 -11
- package/src/dataLoader.ts +6 -6
- package/src/dragAndDropHandler.ts +0 -4
- package/src/elementsRenderer.ts +4 -0
- package/src/jqtreeOptions.ts +33 -32
- package/src/mouse.widget.ts +58 -29
- package/src/node.ts +32 -46
- package/src/nodeElement.ts +17 -9
- package/src/playwright/.eslintrc +5 -0
- package/src/playwright/playwright.test.ts +30 -30
- package/src/playwright/testUtil.ts +36 -37
- package/src/saveStateHandler.ts +11 -6
- package/src/selectNodeHandler.ts +14 -21
- package/src/simple.widget.ts +1 -1
- package/src/test/.eslintrc +4 -0
- package/src/test/jqTree/create.test.ts +0 -1
- package/src/test/jqTree/events.test.ts +12 -13
- package/src/test/jqTree/keyboard.test.ts +0 -1
- package/src/test/jqTree/loadOnDemand.test.ts +46 -1
- package/src/test/jqTree/methods.test.ts +67 -18
- package/src/test/jqTree/options.test.ts +5 -6
- package/src/test/node.test.ts +2 -2
- package/src/test/support/jqTreeMatchers.ts +8 -9
- package/src/test/support/matchers.d.ts +2 -4
- package/src/test/support/setupTests.ts +2 -1
- package/src/tree.jquery.d.ts +19 -13
- package/src/tree.jquery.ts +63 -57
- package/src/version.ts +1 -1
- package/static/bower.json +3 -3
- package/static/bower_components/fontawesome/css/all.min.css +2 -2
- package/static/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-brands-400.svg +774 -627
- package/static/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-regular-400.svg +93 -95
- package/static/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-solid-900.svg +1164 -1074
- package/static/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/static/bower_components/jquery/dist/jquery.js +118 -109
- package/static/bower_components/jquery/dist/jquery.min.js +2 -2
- package/static/bower_components/jquery-mockjax/dist/jquery.mockjax.js +15 -9
- package/static/example.css +13 -0
- package/static/example.postcss +13 -0
- package/static/example_data.js +33 -36
- package/static/examples/filter.js +63 -0
- package/tree.jquery.debug.js +4809 -3305
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +3 -3
- package/tree.jquery.js.map +1 -1
- package/tsconfig.json +1 -0
- package/.travis.yml +0 -18
package/lib/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
1
|
+
"use strict";
|
package/lib/typings.d.js
ADDED
package/lib/util.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isInt = exports.isFunction = exports.getBoolString = void 0;
|
|
7
|
+
|
|
8
|
+
var isInt = function isInt(n) {
|
|
9
|
+
return typeof n === "number" && n % 1 === 0;
|
|
6
10
|
};
|
|
7
|
-
|
|
8
|
-
exports.
|
|
9
|
-
|
|
11
|
+
|
|
12
|
+
exports.isInt = isInt;
|
|
13
|
+
|
|
14
|
+
var isFunction = function isFunction(v) {
|
|
15
|
+
return typeof v === "function";
|
|
10
16
|
};
|
|
17
|
+
|
|
18
|
+
exports.isFunction = isFunction;
|
|
19
|
+
|
|
20
|
+
var getBoolString = function getBoolString(value) {
|
|
21
|
+
return value ? "true" : "false";
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.getBoolString = getBoolString;
|
package/lib/version.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var version = "1.6.2";
|
|
8
|
+
var _default = version;
|
|
9
|
+
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jqtree",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Tree widget for jQuery",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jquery-plugin",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"url": "https://github.com/mbraak/jqtree"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"
|
|
17
|
+
"ci": "pnpm run lint && yarn run tsc && pnpm run test",
|
|
18
|
+
"test": "start-server-and-test 'yarn devserver-with-coverage' http://localhost:8080 'jest --runInBand --coverage --no-cache --verbose'",
|
|
18
19
|
"test-with-server": "jest --runInBand --coverage",
|
|
19
20
|
"test-watch": "jest --watch",
|
|
20
21
|
"lint": "eslint src/ --ext .ts,.tsx",
|
|
@@ -31,45 +32,51 @@
|
|
|
31
32
|
"print-coverage": "nyc report"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"jquery": "
|
|
35
|
+
"jquery": "^3.6.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"eslint": "^7.
|
|
48
|
-
"eslint
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
38
|
+
"@babel/cli": "^7.16.0",
|
|
39
|
+
"@babel/core": "^7.16.5",
|
|
40
|
+
"@babel/preset-env": "^7.16.5",
|
|
41
|
+
"@babel/preset-typescript": "^7.16.5",
|
|
42
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
43
|
+
"@rollup/plugin-node-resolve": "^13.1.1",
|
|
44
|
+
"@testing-library/dom": "^8.11.1",
|
|
45
|
+
"@types/jest": "^27.0.3",
|
|
46
|
+
"@types/jquery": "^3.5.10",
|
|
47
|
+
"@types/pngjs": "^6.0.1",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.7.0",
|
|
49
|
+
"@typescript-eslint/parser": "^5.7.0",
|
|
50
|
+
"autoprefixer": "^10.4.0",
|
|
51
|
+
"babel-jest": "^27.4.5",
|
|
52
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
53
|
+
"coveralls": "^3.1.1",
|
|
54
|
+
"eslint": "^8.4.1",
|
|
55
|
+
"eslint-plugin-import": "^2.25.3",
|
|
56
|
+
"eslint-plugin-jest": "^25.3.0",
|
|
57
|
+
"eslint-plugin-playwright": "^0.6.0",
|
|
58
|
+
"eslint-plugin-testing-library": "^5.0.1",
|
|
59
|
+
"expect-playwright": "^0.8.0",
|
|
60
|
+
"givens": "^1.3.9",
|
|
61
|
+
"jest": "^27.4.5",
|
|
62
|
+
"jest-extended": "^1.2.0",
|
|
63
|
+
"jest-playwright-preset": "^1.7.0",
|
|
64
|
+
"jsonfile": "^6.1.0",
|
|
56
65
|
"lodash.template": "^4.5.0",
|
|
57
|
-
"msw": "^0.
|
|
66
|
+
"msw": "^0.36.3",
|
|
58
67
|
"pixelmatch": "^5.2.1",
|
|
59
|
-
"playwright": "^1.
|
|
68
|
+
"playwright": "^1.17.1",
|
|
60
69
|
"pngjs": "^6.0.0",
|
|
61
|
-
"postcss": "^8.
|
|
62
|
-
"postcss-cli": "^
|
|
63
|
-
"postcss-load-config": "^3.
|
|
64
|
-
"postcss-nested": "^5.0.
|
|
65
|
-
"prettier": "^2.
|
|
66
|
-
"rollup": "^2.
|
|
67
|
-
"rollup-plugin-
|
|
68
|
-
"rollup-plugin-serve": "^1.0.4",
|
|
70
|
+
"postcss": "^8.4.5",
|
|
71
|
+
"postcss-cli": "^9.1.0",
|
|
72
|
+
"postcss-load-config": "^3.1.0",
|
|
73
|
+
"postcss-nested": "^5.0.6",
|
|
74
|
+
"prettier": "^2.5.1",
|
|
75
|
+
"rollup": "^2.61.1",
|
|
76
|
+
"rollup-plugin-serve": "^1.1.0",
|
|
69
77
|
"rollup-plugin-terser": "^7.0.2",
|
|
70
|
-
"start-server-and-test": "^1.
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"typescript": "^4.0.2"
|
|
78
|
+
"start-server-and-test": "^1.14.0",
|
|
79
|
+
"tslib": "^2.3.1",
|
|
80
|
+
"typescript": "^4.5.4"
|
|
74
81
|
}
|
|
75
82
|
}
|
package/production
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
rollup -c rollup.config.js
|
|
2
|
-
DEBUG_BUILD=true rollup -c rollup.config.js
|
|
3
|
-
|
|
4
|
-
postcss -o jqtree.css jqtree.postcss
|
|
1
|
+
rollup -c rollup.config.js &&
|
|
2
|
+
DEBUG_BUILD=true rollup -c rollup.config.js &&
|
|
3
|
+
babel src --out-dir lib --extensions .ts &&
|
|
4
|
+
postcss -o jqtree.css jqtree.postcss &&
|
|
5
5
|
postcss -o static/example.css static/example.postcss
|
package/rollup.config.js
CHANGED
|
@@ -2,10 +2,10 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import jsonfile from "jsonfile";
|
|
4
4
|
import template from "lodash.template";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import { babel } from "@rollup/plugin-babel";
|
|
6
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
7
7
|
import serve from "rollup-plugin-serve";
|
|
8
|
-
import
|
|
8
|
+
import { terser } from "rollup-plugin-terser";
|
|
9
9
|
|
|
10
10
|
const getBanner = () => {
|
|
11
11
|
const headerTemplate = fs.readFileSync("./src/header.txt", "utf8");
|
|
@@ -24,7 +24,19 @@ const debugBuild = Boolean(process.env.DEBUG_BUILD);
|
|
|
24
24
|
const devServer = Boolean(process.env.SERVE);
|
|
25
25
|
const includeCoverage = Boolean(process.env.COVERAGE);
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const resolvePlugin = resolve({ extensions: [".ts"] });
|
|
28
|
+
|
|
29
|
+
const babelConfigFile = includeCoverage
|
|
30
|
+
? "babel.coverage.config.json"
|
|
31
|
+
: "babel.config.json";
|
|
32
|
+
|
|
33
|
+
const babelPlugin = babel({
|
|
34
|
+
babelHelpers: "bundled",
|
|
35
|
+
configFile: path.resolve(__dirname, babelConfigFile),
|
|
36
|
+
extensions: [".ts"],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const plugins = [resolvePlugin, babelPlugin];
|
|
28
40
|
|
|
29
41
|
if (!debugBuild) {
|
|
30
42
|
const terserPlugin = terser({
|
|
@@ -35,13 +47,6 @@ if (!debugBuild) {
|
|
|
35
47
|
plugins.push(terserPlugin);
|
|
36
48
|
}
|
|
37
49
|
|
|
38
|
-
if (includeCoverage) {
|
|
39
|
-
const coveragePlugin = coverage({
|
|
40
|
-
esModules: true,
|
|
41
|
-
});
|
|
42
|
-
plugins.push(coveragePlugin);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
50
|
if (devServer) {
|
|
46
51
|
const servePlugin = serve({
|
|
47
52
|
contentBase: [
|
package/src/dataLoader.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Node } from "./node";
|
|
2
2
|
import { JqTreeWidget } from "./tree.jquery";
|
|
3
3
|
|
|
4
4
|
export type HandleFinishedLoading = () => void;
|
|
@@ -28,7 +28,7 @@ export default class DataLoader {
|
|
|
28
28
|
this.notifyLoading(false, parentNode, $el);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const handleSuccess = (data:
|
|
31
|
+
const handleSuccess = (data: string | NodeData[]): void => {
|
|
32
32
|
stopLoading();
|
|
33
33
|
this.treeWidget.loadData(this.parseData(data), parentNode);
|
|
34
34
|
|
|
@@ -108,12 +108,12 @@ export default class DataLoader {
|
|
|
108
108
|
void jQuery.ajax(ajaxSettings);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
private parseData(data: NodeData): NodeData[] {
|
|
111
|
+
private parseData(data: string | NodeData[]): NodeData[] {
|
|
112
112
|
const { dataFilter } = this.treeWidget.options;
|
|
113
113
|
|
|
114
|
-
const getParsedData = ()
|
|
114
|
+
const getParsedData = () => {
|
|
115
115
|
if (typeof data === "string") {
|
|
116
|
-
return JSON.parse(data) as
|
|
116
|
+
return JSON.parse(data) as NodeData[];
|
|
117
117
|
} else {
|
|
118
118
|
return data;
|
|
119
119
|
}
|
|
@@ -124,7 +124,7 @@ export default class DataLoader {
|
|
|
124
124
|
if (dataFilter) {
|
|
125
125
|
return dataFilter(parsedData);
|
|
126
126
|
} else {
|
|
127
|
-
return parsedData
|
|
127
|
+
return parsedData;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import * as jQueryProxy from "jquery";
|
|
2
1
|
import { getPositionName, Node, Position } from "./node";
|
|
3
2
|
import { DropHint, HitArea, PositionInfo } from "./types";
|
|
4
3
|
import { NodeElement } from "./nodeElement";
|
|
5
4
|
import { JqTreeWidget } from "./tree.jquery";
|
|
6
5
|
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
8
|
-
const jQuery: JQueryStatic = (<any>jQueryProxy).default || jQueryProxy;
|
|
9
|
-
|
|
10
6
|
interface Dimensions {
|
|
11
7
|
left: number;
|
|
12
8
|
top: number;
|
package/src/elementsRenderer.ts
CHANGED
|
@@ -248,6 +248,10 @@ export default class ElementsRenderer {
|
|
|
248
248
|
classes += " jqtree-title-folder";
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
classes += ` jqtree-title-button-${
|
|
252
|
+
this.treeWidget.options.buttonLeft ? "left" : "right"
|
|
253
|
+
}`;
|
|
254
|
+
|
|
251
255
|
titleSpan.className = classes;
|
|
252
256
|
|
|
253
257
|
titleSpan.setAttribute("role", "treeitem");
|
package/src/jqtreeOptions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node
|
|
1
|
+
import { Node } from "./node";
|
|
2
2
|
|
|
3
3
|
type CanMoveNodeTo = (
|
|
4
4
|
node: Node,
|
|
@@ -17,35 +17,36 @@ type HandleLoadingMethod = (
|
|
|
17
17
|
) => void;
|
|
18
18
|
|
|
19
19
|
export interface JQTreeOptions {
|
|
20
|
-
animationSpeed
|
|
21
|
-
autoEscape
|
|
22
|
-
autoOpen
|
|
23
|
-
buttonLeft
|
|
24
|
-
closedIcon
|
|
25
|
-
data
|
|
26
|
-
dataFilter
|
|
27
|
-
dataUrl
|
|
28
|
-
dragAndDrop
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
onCanMove
|
|
32
|
-
onCanMoveTo
|
|
33
|
-
onCanSelectNode
|
|
34
|
-
onCreateLi
|
|
35
|
-
onDragMove
|
|
36
|
-
onDragStop
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
onSetStateFromStorage
|
|
42
|
-
openedIcon
|
|
43
|
-
openFolderDelay
|
|
44
|
-
rtl
|
|
45
|
-
selectable
|
|
46
|
-
saveState
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
20
|
+
animationSpeed: string | number;
|
|
21
|
+
autoEscape: boolean;
|
|
22
|
+
autoOpen: boolean | number;
|
|
23
|
+
buttonLeft: boolean;
|
|
24
|
+
closedIcon: string | Element | undefined;
|
|
25
|
+
data: NodeData[] | undefined;
|
|
26
|
+
dataFilter: DataFilter | undefined;
|
|
27
|
+
dataUrl: DataUrl | undefined;
|
|
28
|
+
dragAndDrop: boolean;
|
|
29
|
+
keyboardSupport: boolean;
|
|
30
|
+
nodeClass: typeof Node;
|
|
31
|
+
onCanMove: ((node: Node) => boolean) | undefined;
|
|
32
|
+
onCanMoveTo: CanMoveNodeTo | undefined;
|
|
33
|
+
onCanSelectNode: ((node: Node) => boolean) | undefined;
|
|
34
|
+
onCreateLi: CreateLi | undefined;
|
|
35
|
+
onDragMove: DragMethod | undefined;
|
|
36
|
+
onDragStop: DragMethod | undefined;
|
|
37
|
+
onGetStateFromStorage: (() => string) | undefined;
|
|
38
|
+
onIsMoveHandle: ((el: JQuery) => boolean) | undefined;
|
|
39
|
+
onLoadFailed: ((response: JQuery.jqXHR) => void) | undefined;
|
|
40
|
+
onLoading: HandleLoadingMethod | undefined;
|
|
41
|
+
onSetStateFromStorage: ((data: string) => void) | undefined;
|
|
42
|
+
openedIcon: string | Element;
|
|
43
|
+
openFolderDelay: number;
|
|
44
|
+
rtl: boolean | undefined;
|
|
45
|
+
selectable: boolean;
|
|
46
|
+
saveState: boolean | string;
|
|
47
|
+
showEmptyFolder: boolean;
|
|
48
|
+
slide: boolean;
|
|
49
|
+
startDndDelay: number;
|
|
50
|
+
tabIndex: number;
|
|
51
|
+
useContextMenu: boolean;
|
|
51
52
|
}
|
package/src/mouse.widget.ts
CHANGED
|
@@ -22,28 +22,24 @@ const getPositionInfoFromTouch = (
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
abstract class MouseWidget<WidgetOptions> extends SimpleWidget<WidgetOptions> {
|
|
25
|
-
public $el: JQuery<HTMLElement>;
|
|
26
25
|
protected isMouseStarted: boolean;
|
|
27
|
-
protected mouseDelay: number;
|
|
28
26
|
protected mouseDownInfo: PositionInfo | null;
|
|
29
27
|
private mouseDelayTimer: number | null;
|
|
30
28
|
private isMouseDelayMet: boolean;
|
|
31
29
|
|
|
32
|
-
public setMouseDelay(mouseDelay: number): void {
|
|
33
|
-
this.mouseDelay = mouseDelay;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
30
|
public init(): void {
|
|
37
31
|
const element = this.$el.get(0);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
|
|
33
|
+
if (element) {
|
|
34
|
+
element.addEventListener("mousedown", this.mouseDown, {
|
|
35
|
+
passive: false,
|
|
36
|
+
});
|
|
37
|
+
element.addEventListener("touchstart", this.touchStart, {
|
|
38
|
+
passive: false,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
44
41
|
|
|
45
42
|
this.isMouseStarted = false;
|
|
46
|
-
this.mouseDelay = 0;
|
|
47
43
|
this.mouseDelayTimer = null;
|
|
48
44
|
this.isMouseDelayMet = false;
|
|
49
45
|
this.mouseDownInfo = null;
|
|
@@ -51,13 +47,20 @@ abstract class MouseWidget<WidgetOptions> extends SimpleWidget<WidgetOptions> {
|
|
|
51
47
|
|
|
52
48
|
public deinit(): void {
|
|
53
49
|
const el = this.$el.get(0);
|
|
54
|
-
el.removeEventListener("mousedown", this.mouseDown);
|
|
55
|
-
el.removeEventListener("touchstart", this.touchStart);
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
if (el) {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
53
|
+
(el as any).removeEventListener("mousedown", this.mouseDown, {
|
|
54
|
+
passive: false,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
58
|
+
(el as any).removeEventListener("touchstart", this.touchStart, {
|
|
59
|
+
passive: false,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.removeMouseMoveEventListeners();
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
protected abstract mouseCapture(positionInfo: PositionInfo): boolean | null;
|
|
@@ -68,6 +71,8 @@ abstract class MouseWidget<WidgetOptions> extends SimpleWidget<WidgetOptions> {
|
|
|
68
71
|
|
|
69
72
|
protected abstract mouseStop(positionInfo: PositionInfo): void;
|
|
70
73
|
|
|
74
|
+
protected abstract getMouseDelay(): number;
|
|
75
|
+
|
|
71
76
|
private mouseDown = (e: MouseEvent): void => {
|
|
72
77
|
// Left mouse button?
|
|
73
78
|
if (e.button !== 0) {
|
|
@@ -110,19 +115,25 @@ abstract class MouseWidget<WidgetOptions> extends SimpleWidget<WidgetOptions> {
|
|
|
110
115
|
passive: false,
|
|
111
116
|
});
|
|
112
117
|
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
const mouseDelay = this.getMouseDelay();
|
|
119
|
+
|
|
120
|
+
if (mouseDelay) {
|
|
121
|
+
this.startMouseDelayTimer(mouseDelay);
|
|
122
|
+
} else {
|
|
123
|
+
this.isMouseDelayMet = true;
|
|
115
124
|
}
|
|
116
125
|
}
|
|
117
126
|
|
|
118
|
-
private startMouseDelayTimer(): void {
|
|
127
|
+
private startMouseDelayTimer(mouseDelay: number): void {
|
|
119
128
|
if (this.mouseDelayTimer) {
|
|
120
129
|
clearTimeout(this.mouseDelayTimer);
|
|
121
130
|
}
|
|
122
131
|
|
|
123
132
|
this.mouseDelayTimer = window.setTimeout(() => {
|
|
124
|
-
this.
|
|
125
|
-
|
|
133
|
+
if (this.mouseDownInfo) {
|
|
134
|
+
this.isMouseDelayMet = true;
|
|
135
|
+
}
|
|
136
|
+
}, mouseDelay);
|
|
126
137
|
|
|
127
138
|
this.isMouseDelayMet = false;
|
|
128
139
|
}
|
|
@@ -144,7 +155,7 @@ abstract class MouseWidget<WidgetOptions> extends SimpleWidget<WidgetOptions> {
|
|
|
144
155
|
return;
|
|
145
156
|
}
|
|
146
157
|
|
|
147
|
-
if (
|
|
158
|
+
if (!this.isMouseDelayMet) {
|
|
148
159
|
return;
|
|
149
160
|
}
|
|
150
161
|
|
|
@@ -168,10 +179,9 @@ abstract class MouseWidget<WidgetOptions> extends SimpleWidget<WidgetOptions> {
|
|
|
168
179
|
};
|
|
169
180
|
|
|
170
181
|
private handleMouseUp(positionInfo: PositionInfo): void {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
document.removeEventListener("touchend", this.touchEnd);
|
|
182
|
+
this.removeMouseMoveEventListeners();
|
|
183
|
+
this.isMouseDelayMet = false;
|
|
184
|
+
this.mouseDownInfo = null;
|
|
175
185
|
|
|
176
186
|
if (this.isMouseStarted) {
|
|
177
187
|
this.isMouseStarted = false;
|
|
@@ -179,6 +189,25 @@ abstract class MouseWidget<WidgetOptions> extends SimpleWidget<WidgetOptions> {
|
|
|
179
189
|
}
|
|
180
190
|
}
|
|
181
191
|
|
|
192
|
+
private removeMouseMoveEventListeners() {
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
194
|
+
(document as any).removeEventListener("mousemove", this.mouseMove, {
|
|
195
|
+
passive: false,
|
|
196
|
+
});
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
198
|
+
(document as any).removeEventListener("touchmove", this.touchMove, {
|
|
199
|
+
passive: false,
|
|
200
|
+
});
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
202
|
+
(document as any).removeEventListener("mouseup", this.mouseUp, {
|
|
203
|
+
passive: false,
|
|
204
|
+
});
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
206
|
+
(document as any).removeEventListener("touchend", this.touchEnd, {
|
|
207
|
+
passive: false,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
182
211
|
private touchStart = (e: TouchEvent): void => {
|
|
183
212
|
if (!e) {
|
|
184
213
|
return;
|