jqtree 1.8.11 → 1.9.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/bower.json +1 -1
- package/eslint.config.mjs +21 -7
- package/package.json +40 -46
- package/pnpm-workspace.yaml +4 -0
- package/src/animation.ts +48 -0
- package/src/dataLoader.ts +38 -48
- package/src/dragAndDropHandler/dragElement.ts +11 -11
- package/src/dragAndDropHandler/generateHitAreas.ts +4 -3
- package/src/dragAndDropHandler/index.ts +119 -120
- package/src/dragAndDropHandler/iterateVisibleNodes.ts +1 -1
- package/src/dragAndDropHandler/types.ts +1 -1
- package/src/elementsRenderer.ts +71 -78
- package/src/jqtreeMethodTypes.ts +2 -2
- package/src/jqtreeOptions.ts +3 -2
- package/src/keyHandler.ts +34 -34
- package/src/mouseHandler.ts +118 -119
- package/src/node.ts +22 -22
- package/src/nodeElement/borderDropHint.ts +6 -6
- package/src/nodeElement/folderElement.ts +30 -22
- package/src/nodeElement/ghostDropHint.ts +24 -24
- package/src/nodeElement/index.ts +13 -12
- package/src/positionUtils.ts +18 -0
- package/src/saveStateHandler.ts +56 -55
- package/src/scrollHandler/containerScrollParent.ts +17 -15
- package/src/scrollHandler/documentScrollParent.ts +23 -22
- package/src/scrollHandler.ts +23 -22
- package/src/selectNodeHandler.ts +28 -28
- package/src/tree.jquery.ts +251 -269
- package/src/util.ts +0 -14
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +873 -734
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +2 -2
- package/tree.jquery.js.map +1 -1
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type {
|
|
3
2
|
HorizontalScrollDirection,
|
|
4
|
-
ScrollParent,
|
|
5
3
|
VerticalScrollDirection,
|
|
6
4
|
} from "./scrollParent";
|
|
7
5
|
|
|
6
|
+
import { getOffsetTop } from "../positionUtils";
|
|
7
|
+
import { ScrollParent } from "./scrollParent";
|
|
8
|
+
|
|
8
9
|
interface Params {
|
|
9
10
|
refreshHitAreas: () => void;
|
|
10
11
|
treeElement: HTMLElement;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export default class DocumentScrollParent extends ScrollParent {
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
15
|
+
private _documentScrollHeight?: number;
|
|
16
|
+
private _documentScrollWidth?: number;
|
|
17
|
+
private _treeElement: HTMLElement;
|
|
17
18
|
|
|
18
19
|
constructor({ refreshHitAreas, treeElement }: Params) {
|
|
19
20
|
super({ container: document.documentElement, refreshHitAreas });
|
|
20
21
|
|
|
21
|
-
this.
|
|
22
|
+
this._treeElement = treeElement;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
public scrollToY(top: number): void {
|
|
25
|
-
const treeTop = getOffsetTop(this.
|
|
26
|
+
const treeTop = getOffsetTop(this._treeElement);
|
|
26
27
|
|
|
27
28
|
super.scrollToY(top + treeTop);
|
|
28
29
|
}
|
|
@@ -30,8 +31,8 @@ export default class DocumentScrollParent extends ScrollParent {
|
|
|
30
31
|
public stopScrolling() {
|
|
31
32
|
super.stopScrolling();
|
|
32
33
|
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
34
|
+
this._documentScrollHeight = undefined;
|
|
35
|
+
this._documentScrollWidth = undefined;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
protected getNewHorizontalScrollDirection(
|
|
@@ -43,7 +44,7 @@ export default class DocumentScrollParent extends ScrollParent {
|
|
|
43
44
|
const isNearRightEdge = pageX > windowWidth - 20;
|
|
44
45
|
const isNearLeftEdge = pageX - scrollLeft < 20;
|
|
45
46
|
|
|
46
|
-
if (isNearRightEdge && this.
|
|
47
|
+
if (isNearRightEdge && this._canScrollRight()) {
|
|
47
48
|
return "right";
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -66,38 +67,38 @@ export default class DocumentScrollParent extends ScrollParent {
|
|
|
66
67
|
|
|
67
68
|
const windowHeight = window.innerHeight;
|
|
68
69
|
|
|
69
|
-
if (windowHeight - (pageY - scrollTop) < 20 && this.
|
|
70
|
+
if (windowHeight - (pageY - scrollTop) < 20 && this._canScrollDown()) {
|
|
70
71
|
return "bottom";
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
return undefined;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
private
|
|
77
|
+
private _canScrollDown() {
|
|
77
78
|
return (
|
|
78
79
|
this.container.scrollTop + this.container.clientHeight <
|
|
79
|
-
this.
|
|
80
|
+
this._getDocumentScrollHeight()
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
private
|
|
84
|
+
private _canScrollRight() {
|
|
84
85
|
return (
|
|
85
86
|
this.container.scrollLeft + this.container.clientWidth <
|
|
86
|
-
this.
|
|
87
|
+
this._getDocumentScrollWidth()
|
|
87
88
|
);
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
private
|
|
91
|
+
private _getDocumentScrollHeight() {
|
|
91
92
|
// Store the original scroll height because the scroll height can increase when the drag element is moved beyond the scroll height.
|
|
92
|
-
this.
|
|
93
|
+
this._documentScrollHeight ??= this.container.scrollHeight;
|
|
93
94
|
|
|
94
|
-
return this.
|
|
95
|
+
return this._documentScrollHeight;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
private
|
|
98
|
+
private _getDocumentScrollWidth() {
|
|
98
99
|
// Store the original scroll width because the scroll width can increase when the drag element is moved beyond the scroll width.
|
|
99
|
-
this.
|
|
100
|
+
this._documentScrollWidth ??= this.container.scrollWidth;
|
|
100
101
|
|
|
101
|
-
return this.
|
|
102
|
+
return this._documentScrollWidth;
|
|
102
103
|
}
|
|
103
104
|
}
|
package/src/scrollHandler.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { PositionInfo } from "./mouseUtils";
|
|
1
|
+
import type { PositionInfo } from "./mouseUtils";
|
|
2
|
+
import type { ScrollParent } from "./scrollHandler/scrollParent";
|
|
3
|
+
|
|
2
4
|
import createScrollParent from "./scrollHandler/createScrollParent";
|
|
3
|
-
import { ScrollParent } from "./scrollHandler/scrollParent";
|
|
4
5
|
|
|
5
6
|
interface ScrollHandlerParams {
|
|
6
7
|
refreshHitAreas: () => void;
|
|
@@ -8,47 +9,47 @@ interface ScrollHandlerParams {
|
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export default class ScrollHandler {
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
12
|
+
private _refreshHitAreas: () => void;
|
|
13
|
+
private _scrollParent?: ScrollParent;
|
|
14
|
+
private _treeElement: HTMLElement;
|
|
14
15
|
|
|
15
16
|
constructor({ refreshHitAreas, treeElement }: ScrollHandlerParams) {
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
17
|
+
this._refreshHitAreas = refreshHitAreas;
|
|
18
|
+
this._scrollParent = undefined;
|
|
19
|
+
this._treeElement = treeElement;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
public checkScrolling(positionInfo: PositionInfo): void {
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
23
|
+
this._checkVerticalScrolling(positionInfo);
|
|
24
|
+
this._checkHorizontalScrolling(positionInfo);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
public getScrollLeft(): number {
|
|
27
|
-
return this.
|
|
28
|
+
return this._getScrollParent().getScrollLeft();
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
public scrollToY(top: number): void {
|
|
31
|
-
this.
|
|
32
|
+
this._getScrollParent().scrollToY(top);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
public stopScrolling() {
|
|
35
|
-
this.
|
|
36
|
+
this._getScrollParent().stopScrolling();
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
private
|
|
39
|
-
this.
|
|
39
|
+
private _checkHorizontalScrolling(positionInfo: PositionInfo): void {
|
|
40
|
+
this._getScrollParent().checkHorizontalScrolling(positionInfo.pageX);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
private
|
|
43
|
-
this.
|
|
43
|
+
private _checkVerticalScrolling(positionInfo: PositionInfo): void {
|
|
44
|
+
this._getScrollParent().checkVerticalScrolling(positionInfo.pageY);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
private
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
47
|
+
private _getScrollParent(): ScrollParent {
|
|
48
|
+
this._scrollParent ??= createScrollParent(
|
|
49
|
+
this._treeElement,
|
|
50
|
+
this._refreshHitAreas,
|
|
50
51
|
);
|
|
51
52
|
|
|
52
|
-
return this.
|
|
53
|
+
return this._scrollParent;
|
|
53
54
|
}
|
|
54
55
|
}
|
package/src/selectNodeHandler.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { GetNodeById } from "./jqtreeMethodTypes";
|
|
2
|
-
import { Node } from "./node";
|
|
1
|
+
import type { GetNodeById } from "./jqtreeMethodTypes";
|
|
2
|
+
import type { Node } from "./node";
|
|
3
3
|
|
|
4
4
|
interface SelectNodeHandlerParameters {
|
|
5
5
|
getNodeById: GetNodeById;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export default class SelectNodeHandler {
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
-
private
|
|
9
|
+
private _getNodeById: GetNodeById;
|
|
10
|
+
private _selectedNodes: Set<NodeId>;
|
|
11
|
+
private _selectedSingleNode: Node | null;
|
|
12
12
|
|
|
13
13
|
constructor({ getNodeById }: SelectNodeHandlerParameters) {
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
14
|
+
this._getNodeById = getNodeById;
|
|
15
|
+
this._selectedNodes = new Set<NodeId>();
|
|
16
16
|
this.clear();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
public addToSelection(node: Node): void {
|
|
20
20
|
if (node.id != null) {
|
|
21
|
-
this.
|
|
21
|
+
this._selectedNodes.add(node.id);
|
|
22
22
|
} else {
|
|
23
|
-
this.
|
|
23
|
+
this._selectedSingleNode = node;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
public clear(): void {
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
28
|
+
this._selectedNodes.clear();
|
|
29
|
+
this._selectedSingleNode = null;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
public getSelectedNode(): false | Node {
|
|
@@ -40,13 +40,13 @@ export default class SelectNodeHandler {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
public getSelectedNodes(): Node[] {
|
|
43
|
-
if (this.
|
|
44
|
-
return [this.
|
|
43
|
+
if (this._selectedSingleNode) {
|
|
44
|
+
return [this._selectedSingleNode];
|
|
45
45
|
} else {
|
|
46
46
|
const selectedNodes: Node[] = [];
|
|
47
47
|
|
|
48
|
-
this.
|
|
49
|
-
const node = this.
|
|
48
|
+
this._selectedNodes.forEach((id) => {
|
|
49
|
+
const node = this._getNodeById(id);
|
|
50
50
|
if (node) {
|
|
51
51
|
selectedNodes.push(node);
|
|
52
52
|
}
|
|
@@ -57,17 +57,17 @@ export default class SelectNodeHandler {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
public getSelectedNodesUnder(parent: Node): Node[] {
|
|
60
|
-
if (this.
|
|
61
|
-
if (parent.isParentOf(this.
|
|
62
|
-
return [this.
|
|
60
|
+
if (this._selectedSingleNode) {
|
|
61
|
+
if (parent.isParentOf(this._selectedSingleNode)) {
|
|
62
|
+
return [this._selectedSingleNode];
|
|
63
63
|
} else {
|
|
64
64
|
return [];
|
|
65
65
|
}
|
|
66
66
|
} else {
|
|
67
67
|
const selectedNodes: Node[] = [];
|
|
68
68
|
|
|
69
|
-
this.
|
|
70
|
-
const node = this.
|
|
69
|
+
this._selectedNodes.forEach((id) => {
|
|
70
|
+
const node = this._getNodeById(id);
|
|
71
71
|
if (node && parent.isParentOf(node)) {
|
|
72
72
|
selectedNodes.push(node);
|
|
73
73
|
}
|
|
@@ -79,9 +79,9 @@ export default class SelectNodeHandler {
|
|
|
79
79
|
|
|
80
80
|
public isNodeSelected(node: Node): boolean {
|
|
81
81
|
if (node.id != null) {
|
|
82
|
-
return this.
|
|
83
|
-
} else if (this.
|
|
84
|
-
return this.
|
|
82
|
+
return this._selectedNodes.has(node.id);
|
|
83
|
+
} else if (this._selectedSingleNode) {
|
|
84
|
+
return this._selectedSingleNode.element === node.element;
|
|
85
85
|
} else {
|
|
86
86
|
return false;
|
|
87
87
|
}
|
|
@@ -90,18 +90,18 @@ export default class SelectNodeHandler {
|
|
|
90
90
|
public removeFromSelection(node: Node, includeChildren = false): void {
|
|
91
91
|
if (node.id == null) {
|
|
92
92
|
if (
|
|
93
|
-
this.
|
|
94
|
-
node.element === this.
|
|
93
|
+
this._selectedSingleNode &&
|
|
94
|
+
node.element === this._selectedSingleNode.element
|
|
95
95
|
) {
|
|
96
|
-
this.
|
|
96
|
+
this._selectedSingleNode = null;
|
|
97
97
|
}
|
|
98
98
|
} else {
|
|
99
|
-
this.
|
|
99
|
+
this._selectedNodes.delete(node.id);
|
|
100
100
|
|
|
101
101
|
if (includeChildren) {
|
|
102
102
|
node.iterate(() => {
|
|
103
103
|
if (node.id != null) {
|
|
104
|
-
this.
|
|
104
|
+
this._selectedNodes.delete(node.id);
|
|
105
105
|
}
|
|
106
106
|
return true;
|
|
107
107
|
});
|