jqtree 1.8.9 → 1.8.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/bower.json +3 -10
- package/eslint.config.mjs +27 -3
- package/package.json +50 -47
- package/src/elementsRenderer.ts +1 -1
- package/src/mouseHandler.ts +10 -7
- package/src/node.ts +1 -5
- package/src/nodeElement/index.ts +1 -3
- package/src/scrollHandler/containerScrollParent.ts +19 -118
- package/src/scrollHandler/createScrollParent.ts +1 -1
- package/src/scrollHandler/documentScrollParent.ts +35 -118
- package/src/scrollHandler/scrollParent.ts +117 -0
- package/src/scrollHandler.ts +5 -7
- package/src/simple.widget.ts +1 -3
- package/src/tree.jquery.ts +5 -13
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +232 -354
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +3 -3
- package/tree.jquery.js.map +1 -1
- package/.tool-versions +0 -2
- package/src/scrollHandler/types.ts +0 -7
|
@@ -1,128 +1,43 @@
|
|
|
1
|
-
import type { ScrollParent } from "./types";
|
|
2
|
-
|
|
3
1
|
import { getOffsetTop } from "../util";
|
|
2
|
+
import {
|
|
3
|
+
HorizontalScrollDirection,
|
|
4
|
+
ScrollParent,
|
|
5
|
+
VerticalScrollDirection,
|
|
6
|
+
} from "./scrollParent";
|
|
4
7
|
|
|
5
|
-
type HorizontalScrollDirection = "left" | "right";
|
|
6
8
|
interface Params {
|
|
7
9
|
refreshHitAreas: () => void;
|
|
8
10
|
treeElement: HTMLElement;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export default class DocumentScrollParent implements ScrollParent {
|
|
13
|
+
export default class DocumentScrollParent extends ScrollParent {
|
|
14
14
|
private documentScrollHeight?: number;
|
|
15
15
|
private documentScrollWidth?: number;
|
|
16
|
-
private horizontalScrollDirection?: HorizontalScrollDirection;
|
|
17
|
-
private horizontalScrollTimeout?: number;
|
|
18
|
-
private refreshHitAreas: () => void;
|
|
19
16
|
private treeElement: HTMLElement;
|
|
20
|
-
private verticalScrollDirection?: VerticalScrollDirection;
|
|
21
|
-
private verticalScrollTimeout?: number;
|
|
22
17
|
|
|
23
18
|
constructor({ refreshHitAreas, treeElement }: Params) {
|
|
24
|
-
|
|
25
|
-
this.treeElement = treeElement;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public checkHorizontalScrolling(pageX: number): void {
|
|
29
|
-
const newHorizontalScrollDirection =
|
|
30
|
-
this.getNewHorizontalScrollDirection(pageX);
|
|
19
|
+
super({ container: document.documentElement, refreshHitAreas });
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
this.horizontalScrollDirection = newHorizontalScrollDirection;
|
|
34
|
-
|
|
35
|
-
if (this.horizontalScrollTimeout != null) {
|
|
36
|
-
window.clearTimeout(this.horizontalScrollTimeout);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (newHorizontalScrollDirection) {
|
|
40
|
-
this.horizontalScrollTimeout = window.setTimeout(
|
|
41
|
-
this.scrollHorizontally.bind(this),
|
|
42
|
-
40,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public checkVerticalScrolling(pageY: number) {
|
|
49
|
-
const newVerticalScrollDirection =
|
|
50
|
-
this.getNewVerticalScrollDirection(pageY);
|
|
51
|
-
|
|
52
|
-
if (this.verticalScrollDirection !== newVerticalScrollDirection) {
|
|
53
|
-
this.verticalScrollDirection = newVerticalScrollDirection;
|
|
54
|
-
|
|
55
|
-
if (this.verticalScrollTimeout != null) {
|
|
56
|
-
window.clearTimeout(this.verticalScrollTimeout);
|
|
57
|
-
this.verticalScrollTimeout = undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (newVerticalScrollDirection) {
|
|
61
|
-
this.verticalScrollTimeout = window.setTimeout(
|
|
62
|
-
this.scrollVertically.bind(this),
|
|
63
|
-
40,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public getScrollLeft(): number {
|
|
70
|
-
return document.documentElement.scrollLeft;
|
|
21
|
+
this.treeElement = treeElement;
|
|
71
22
|
}
|
|
72
23
|
|
|
73
24
|
public scrollToY(top: number): void {
|
|
74
25
|
const treeTop = getOffsetTop(this.treeElement);
|
|
75
26
|
|
|
76
|
-
|
|
27
|
+
super.scrollToY(top + treeTop);
|
|
77
28
|
}
|
|
78
29
|
|
|
79
30
|
public stopScrolling() {
|
|
80
|
-
|
|
81
|
-
|
|
31
|
+
super.stopScrolling();
|
|
32
|
+
|
|
82
33
|
this.documentScrollHeight = undefined;
|
|
83
34
|
this.documentScrollWidth = undefined;
|
|
84
35
|
}
|
|
85
36
|
|
|
86
|
-
|
|
87
|
-
const documentElement = document.documentElement;
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
documentElement.scrollTop + documentElement.clientHeight <
|
|
91
|
-
this.getDocumentScrollHeight()
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private canScrollRight() {
|
|
96
|
-
const documentElement = document.documentElement;
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
documentElement.scrollLeft + documentElement.clientWidth <
|
|
100
|
-
this.getDocumentScrollWidth()
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private getDocumentScrollHeight() {
|
|
105
|
-
// Store the original scroll height because the scroll height can increase when the drag element is moved beyond the scroll height.
|
|
106
|
-
if (this.documentScrollHeight == null) {
|
|
107
|
-
this.documentScrollHeight = document.documentElement.scrollHeight;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return this.documentScrollHeight;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
private getDocumentScrollWidth() {
|
|
114
|
-
// Store the original scroll width because the scroll width can increase when the drag element is moved beyond the scroll width.
|
|
115
|
-
if (this.documentScrollWidth == null) {
|
|
116
|
-
this.documentScrollWidth = document.documentElement.scrollWidth;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this.documentScrollWidth;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private getNewHorizontalScrollDirection(
|
|
37
|
+
protected getNewHorizontalScrollDirection(
|
|
123
38
|
pageX: number,
|
|
124
39
|
): HorizontalScrollDirection | undefined {
|
|
125
|
-
const scrollLeft =
|
|
40
|
+
const scrollLeft = this.container.scrollLeft;
|
|
126
41
|
const windowWidth = window.innerWidth;
|
|
127
42
|
|
|
128
43
|
const isNearRightEdge = pageX > windowWidth - 20;
|
|
@@ -139,10 +54,10 @@ export default class DocumentScrollParent implements ScrollParent {
|
|
|
139
54
|
return undefined;
|
|
140
55
|
}
|
|
141
56
|
|
|
142
|
-
|
|
57
|
+
protected getNewVerticalScrollDirection(
|
|
143
58
|
pageY: number,
|
|
144
59
|
): undefined | VerticalScrollDirection {
|
|
145
|
-
const scrollTop =
|
|
60
|
+
const scrollTop = this.container.scrollTop;
|
|
146
61
|
const distanceTop = pageY - scrollTop;
|
|
147
62
|
|
|
148
63
|
if (distanceTop < 20) {
|
|
@@ -158,29 +73,31 @@ export default class DocumentScrollParent implements ScrollParent {
|
|
|
158
73
|
return undefined;
|
|
159
74
|
}
|
|
160
75
|
|
|
161
|
-
private
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
window.scrollBy({ behavior: "instant", left: distance, top: 0 });
|
|
168
|
-
|
|
169
|
-
this.refreshHitAreas();
|
|
76
|
+
private canScrollDown() {
|
|
77
|
+
return (
|
|
78
|
+
this.container.scrollTop + this.container.clientHeight <
|
|
79
|
+
this.getDocumentScrollHeight()
|
|
80
|
+
);
|
|
81
|
+
}
|
|
170
82
|
|
|
171
|
-
|
|
83
|
+
private canScrollRight() {
|
|
84
|
+
return (
|
|
85
|
+
this.container.scrollLeft + this.container.clientWidth <
|
|
86
|
+
this.getDocumentScrollWidth()
|
|
87
|
+
);
|
|
172
88
|
}
|
|
173
89
|
|
|
174
|
-
private
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
90
|
+
private getDocumentScrollHeight() {
|
|
91
|
+
// Store the original scroll height because the scroll height can increase when the drag element is moved beyond the scroll height.
|
|
92
|
+
this.documentScrollHeight ??= this.container.scrollHeight;
|
|
178
93
|
|
|
179
|
-
|
|
180
|
-
|
|
94
|
+
return this.documentScrollHeight;
|
|
95
|
+
}
|
|
181
96
|
|
|
182
|
-
|
|
97
|
+
private getDocumentScrollWidth() {
|
|
98
|
+
// Store the original scroll width because the scroll width can increase when the drag element is moved beyond the scroll width.
|
|
99
|
+
this.documentScrollWidth ??= this.container.scrollWidth;
|
|
183
100
|
|
|
184
|
-
|
|
101
|
+
return this.documentScrollWidth;
|
|
185
102
|
}
|
|
186
103
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export type HorizontalScrollDirection = "left" | "right";
|
|
2
|
+
export type VerticalScrollDirection = "bottom" | "top";
|
|
3
|
+
|
|
4
|
+
interface ConstructorParams {
|
|
5
|
+
container: HTMLElement;
|
|
6
|
+
refreshHitAreas: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export abstract class ScrollParent {
|
|
10
|
+
protected container: HTMLElement;
|
|
11
|
+
protected horizontalScrollDirection?: HorizontalScrollDirection;
|
|
12
|
+
protected horizontalScrollTimeout?: number;
|
|
13
|
+
|
|
14
|
+
protected refreshHitAreas: () => void;
|
|
15
|
+
protected verticalScrollDirection?: VerticalScrollDirection;
|
|
16
|
+
protected verticalScrollTimeout?: number;
|
|
17
|
+
|
|
18
|
+
constructor({ container, refreshHitAreas }: ConstructorParams) {
|
|
19
|
+
this.container = container;
|
|
20
|
+
this.refreshHitAreas = refreshHitAreas;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public checkHorizontalScrolling(pageX: number): void {
|
|
24
|
+
const newHorizontalScrollDirection =
|
|
25
|
+
this.getNewHorizontalScrollDirection(pageX);
|
|
26
|
+
|
|
27
|
+
if (this.horizontalScrollDirection !== newHorizontalScrollDirection) {
|
|
28
|
+
this.horizontalScrollDirection = newHorizontalScrollDirection;
|
|
29
|
+
|
|
30
|
+
if (this.horizontalScrollTimeout != null) {
|
|
31
|
+
window.clearTimeout(this.horizontalScrollTimeout);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (newHorizontalScrollDirection) {
|
|
35
|
+
this.horizontalScrollTimeout = window.setTimeout(
|
|
36
|
+
this.scrollHorizontally.bind(this),
|
|
37
|
+
40,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public checkVerticalScrolling(pageY: number) {
|
|
44
|
+
const newVerticalScrollDirection =
|
|
45
|
+
this.getNewVerticalScrollDirection(pageY);
|
|
46
|
+
|
|
47
|
+
if (this.verticalScrollDirection !== newVerticalScrollDirection) {
|
|
48
|
+
this.verticalScrollDirection = newVerticalScrollDirection;
|
|
49
|
+
|
|
50
|
+
if (this.verticalScrollTimeout != null) {
|
|
51
|
+
window.clearTimeout(this.verticalScrollTimeout);
|
|
52
|
+
this.verticalScrollTimeout = undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (newVerticalScrollDirection) {
|
|
56
|
+
this.verticalScrollTimeout = window.setTimeout(
|
|
57
|
+
this.scrollVertically.bind(this),
|
|
58
|
+
40,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public getScrollLeft(): number {
|
|
65
|
+
return this.container.scrollLeft;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public scrollToY(top: number): void {
|
|
69
|
+
this.container.scrollTop = top;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public stopScrolling() {
|
|
73
|
+
this.horizontalScrollDirection = undefined;
|
|
74
|
+
this.verticalScrollDirection = undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected abstract getNewHorizontalScrollDirection(
|
|
78
|
+
pageX: number,
|
|
79
|
+
): HorizontalScrollDirection | undefined;
|
|
80
|
+
protected abstract getNewVerticalScrollDirection(
|
|
81
|
+
pageY: number,
|
|
82
|
+
): undefined | VerticalScrollDirection;
|
|
83
|
+
|
|
84
|
+
protected scrollHorizontally() {
|
|
85
|
+
if (!this.horizontalScrollDirection) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const distance = this.horizontalScrollDirection === "left" ? -20 : 20;
|
|
90
|
+
this.container.scrollBy({
|
|
91
|
+
behavior: "instant",
|
|
92
|
+
left: distance,
|
|
93
|
+
top: 0,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
this.refreshHitAreas();
|
|
97
|
+
|
|
98
|
+
setTimeout(this.scrollHorizontally.bind(this), 40);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected scrollVertically() {
|
|
102
|
+
if (!this.verticalScrollDirection) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const distance = this.verticalScrollDirection === "top" ? -20 : 20;
|
|
107
|
+
this.container.scrollBy({
|
|
108
|
+
behavior: "instant",
|
|
109
|
+
left: 0,
|
|
110
|
+
top: distance,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
this.refreshHitAreas();
|
|
114
|
+
|
|
115
|
+
setTimeout(this.scrollVertically.bind(this), 40);
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/scrollHandler.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PositionInfo } from "./mouseUtils";
|
|
2
2
|
import createScrollParent from "./scrollHandler/createScrollParent";
|
|
3
|
-
import { ScrollParent } from "./scrollHandler/
|
|
3
|
+
import { ScrollParent } from "./scrollHandler/scrollParent";
|
|
4
4
|
|
|
5
5
|
interface ScrollHandlerParams {
|
|
6
6
|
refreshHitAreas: () => void;
|
|
@@ -44,12 +44,10 @@ export default class ScrollHandler {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
private getScrollParent(): ScrollParent {
|
|
47
|
-
|
|
48
|
-
this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
}
|
|
47
|
+
this.scrollParent ??= createScrollParent(
|
|
48
|
+
this.treeElement,
|
|
49
|
+
this.refreshHitAreas,
|
|
50
|
+
);
|
|
53
51
|
|
|
54
52
|
return this.scrollParent;
|
|
55
53
|
}
|
package/src/simple.widget.ts
CHANGED
|
@@ -87,11 +87,9 @@ const register = (widgetClass: unknown, widgetName: string): void => {
|
|
|
87
87
|
} else if (typeof argument1 === "string" && argument1[0] !== "_") {
|
|
88
88
|
const functionName = argument1;
|
|
89
89
|
|
|
90
|
-
if (
|
|
90
|
+
if (argument1 === "destroy") {
|
|
91
91
|
destroyWidget(this);
|
|
92
92
|
return undefined;
|
|
93
|
-
} else if (functionName === "get_widget_class") {
|
|
94
|
-
return widgetClass;
|
|
95
93
|
} else {
|
|
96
94
|
return callFunction(this, functionName, args);
|
|
97
95
|
}
|
package/src/tree.jquery.ts
CHANGED
|
@@ -190,7 +190,7 @@ export class JqTreeWidget extends SimpleWidget<JQTreeOptions> {
|
|
|
190
190
|
const element =
|
|
191
191
|
inputElement instanceof HTMLElement
|
|
192
192
|
? inputElement
|
|
193
|
-
: inputElement
|
|
193
|
+
: inputElement.get(0);
|
|
194
194
|
|
|
195
195
|
if (!element) {
|
|
196
196
|
return null;
|
|
@@ -247,9 +247,7 @@ export class JqTreeWidget extends SimpleWidget<JQTreeOptions> {
|
|
|
247
247
|
|
|
248
248
|
this.options.rtl = this.getRtlOption();
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
this.options.closedIcon = this.getDefaultClosedIcon();
|
|
252
|
-
}
|
|
250
|
+
this.options.closedIcon ??= this.getDefaultClosedIcon();
|
|
253
251
|
|
|
254
252
|
this.connectHandlers();
|
|
255
253
|
|
|
@@ -373,9 +371,7 @@ export class JqTreeWidget extends SimpleWidget<JQTreeOptions> {
|
|
|
373
371
|
onFinished = param2 as OnFinishOpenNode;
|
|
374
372
|
}
|
|
375
373
|
|
|
376
|
-
|
|
377
|
-
slide = this.options.slide;
|
|
378
|
-
}
|
|
374
|
+
slide ??= this.options.slide;
|
|
379
375
|
|
|
380
376
|
return [slide, onFinished];
|
|
381
377
|
};
|
|
@@ -703,7 +699,7 @@ export class JqTreeWidget extends SimpleWidget<JQTreeOptions> {
|
|
|
703
699
|
private containsElement(element: HTMLElement): boolean {
|
|
704
700
|
const node = this.getNode(element);
|
|
705
701
|
|
|
706
|
-
return node
|
|
702
|
+
return node?.tree === this.tree;
|
|
707
703
|
}
|
|
708
704
|
|
|
709
705
|
private createFolderElement(node: Node) {
|
|
@@ -1005,11 +1001,7 @@ export class JqTreeWidget extends SimpleWidget<JQTreeOptions> {
|
|
|
1005
1001
|
private isFocusOnTree(): boolean {
|
|
1006
1002
|
const activeElement = document.activeElement;
|
|
1007
1003
|
|
|
1008
|
-
return
|
|
1009
|
-
activeElement &&
|
|
1010
|
-
activeElement.tagName === "SPAN" &&
|
|
1011
|
-
this.containsElement(activeElement as HTMLElement),
|
|
1012
|
-
);
|
|
1004
|
+
return activeElement?.tagName === "SPAN" && this.containsElement(activeElement as HTMLElement);
|
|
1013
1005
|
}
|
|
1014
1006
|
|
|
1015
1007
|
private isSelectedNodeInSubtree(subtree: Node): boolean {
|
package/src/version.ts
CHANGED