jqtree 1.6.3 → 1.7.1
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/.github/workflows/ci.yml +15 -21
- package/.github/workflows/codeql-analysis.yml +2 -2
- package/README.md +1 -1
- package/bower.json +10 -3
- package/config/production +2 -2
- package/config/{rollup.config.js → rollup.config.mjs} +3 -8
- package/docs/Gemfile.lock +34 -37
- package/docs/_config.yml +1 -1
- package/docs/_entries/10_changelog.md +13 -0
- package/docs/_entries/93_getnextnode.md +4 -1
- package/docs/_entries/{95_getpreviousnode.md → 95_getnextvisiblenode.md} +1 -1
- package/docs/_entries/96_getpreviousnode.md +0 -0
- package/docs/_entries/98_getpreviousvisiblenode.md +14 -0
- package/docs/package.json +7 -7
- package/docs/pnpm-lock.yaml +413 -265
- package/docs/static/bower.json +2 -2
- package/docs/static/bower_components/fontawesome/css/all.min.css +6 -2
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
- package/docs/static/bower_components/jquery/dist/jquery.js +944 -1121
- package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -2
- package/docs/static/documentation.css +181 -159
- package/docs/static/example.css +0 -1
- package/docs/tree.jquery.js +3 -3
- package/lib/dataLoader.js +5 -31
- package/lib/dragAndDropHandler.js +40 -142
- package/lib/elementsRenderer.js +52 -72
- package/lib/keyHandler.js +8 -32
- package/lib/mouse.widget.js +24 -74
- package/lib/node.js +72 -134
- package/lib/nodeElement.js +24 -84
- package/lib/playwright/coverage.js +58 -97
- package/lib/playwright/playwright.test.js +148 -210
- package/lib/playwright/testUtils.js +116 -182
- package/lib/saveStateHandler.js +13 -62
- package/lib/scrollHandler.js +24 -77
- package/lib/selectNodeHandler.js +6 -25
- package/lib/simple.widget.js +20 -53
- package/lib/test/jqTree/accessibility.test.js +37 -0
- package/lib/test/jqTree/create.test.js +0 -4
- package/lib/test/jqTree/events.test.js +73 -84
- package/lib/test/jqTree/keyboard.test.js +0 -6
- package/lib/test/jqTree/loadOnDemand.test.js +84 -121
- package/lib/test/jqTree/methods.test.js +107 -150
- package/lib/test/jqTree/options.test.js +32 -54
- package/lib/test/node.test.js +134 -76
- package/lib/test/nodeUtil.test.js +0 -1
- package/lib/test/support/jqTreeMatchers.js +4 -9
- package/lib/test/support/setupTests.js +0 -4
- package/lib/test/support/testUtil.js +2 -11
- package/lib/test/support/treeStructure.js +0 -6
- package/lib/test/util.test.js +0 -1
- package/lib/tree.jquery.js +28 -239
- package/lib/util.js +0 -6
- package/lib/version.js +1 -1
- package/package.json +44 -47
- package/src/dragAndDropHandler.ts +24 -10
- package/src/elementsRenderer.ts +49 -42
- package/src/jqtreeOptions.ts +3 -3
- package/src/keyHandler.ts +3 -3
- package/src/mouse.widget.ts +12 -0
- package/src/node.ts +52 -16
- package/src/nodeElement.ts +27 -21
- package/src/saveStateHandler.ts +1 -1
- package/src/scrollHandler.ts +6 -2
- package/src/selectNodeHandler.ts +1 -1
- package/src/simple.widget.ts +2 -0
- package/src/test/.eslintrc +3 -1
- package/src/test/jqTree/accessibility.test.ts +25 -0
- package/src/test/jqTree/events.test.ts +79 -93
- package/src/test/jqTree/methods.test.ts +1 -1
- package/src/test/node.test.ts +152 -58
- package/src/test/nodeUtil.test.ts +1 -1
- package/src/tree.jquery.ts +7 -6
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +297 -904
- 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/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.svg +0 -3717
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.svg +0 -801
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.svg +0 -5028
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
- /package/docs/_entries/{96_getprevioussibling.md → 97_getprevioussibling.md} +0 -0
- /package/docs/_entries/{97_parent.md → 99_parent.md} +0 -0
package/src/test/node.test.ts
CHANGED
|
@@ -164,7 +164,7 @@ describe("addChild", () => {
|
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
it("sets the parent of the child", () => {
|
|
167
|
-
expect(given.node.children[0]
|
|
167
|
+
expect(given.node.children[0]?.parent).toEqual(given.node);
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
|
|
@@ -538,14 +538,16 @@ describe("getLastChild", () => {
|
|
|
538
538
|
context("when its last child is open and has children", () => {
|
|
539
539
|
beforeEach(() => {
|
|
540
540
|
const child2 = given.node.children[1];
|
|
541
|
-
child2
|
|
542
|
-
child2
|
|
541
|
+
child2?.append("child2a");
|
|
542
|
+
child2?.append("child2b");
|
|
543
543
|
});
|
|
544
544
|
|
|
545
545
|
context("and the last child is open", () => {
|
|
546
546
|
beforeEach(() => {
|
|
547
547
|
const child2 = given.node.children[1];
|
|
548
|
-
child2
|
|
548
|
+
if (child2) {
|
|
549
|
+
child2.is_open = true;
|
|
550
|
+
}
|
|
549
551
|
});
|
|
550
552
|
|
|
551
553
|
it("returns the last child of that child", () => {
|
|
@@ -568,52 +570,47 @@ describe("getLastChild", () => {
|
|
|
568
570
|
|
|
569
571
|
describe("getNextNode", () => {
|
|
570
572
|
interface Vars {
|
|
571
|
-
includeChildren: boolean;
|
|
572
573
|
fromNode: Node;
|
|
573
|
-
nextNode: Node | null;
|
|
574
574
|
tree: Node;
|
|
575
575
|
}
|
|
576
576
|
const given = getGiven<Vars>();
|
|
577
577
|
given("tree", () => new Node().loadFromData(exampleData));
|
|
578
|
-
given("nextNode", () => given.fromNode.getNextNode(given.includeChildren));
|
|
579
578
|
|
|
580
|
-
context("with
|
|
581
|
-
given("
|
|
579
|
+
context("with a parent node", () => {
|
|
580
|
+
given("fromNode", () => given.tree.getNodeByNameMustExist("node1"));
|
|
582
581
|
|
|
583
|
-
context("
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
it("returns the next sibling", () => {
|
|
588
|
-
expect(given.nextNode).toMatchObject({ name: "node2" });
|
|
582
|
+
context("when the parent node is closed", () => {
|
|
583
|
+
it("returns the first child", () => {
|
|
584
|
+
expect(given.fromNode.getNextNode()).toMatchObject({
|
|
585
|
+
name: "child1",
|
|
589
586
|
});
|
|
590
587
|
});
|
|
588
|
+
});
|
|
591
589
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
590
|
+
context("when the parent node is open", () => {
|
|
591
|
+
beforeEach(() => {
|
|
592
|
+
given.fromNode.is_open = true;
|
|
593
|
+
});
|
|
596
594
|
|
|
597
|
-
|
|
598
|
-
|
|
595
|
+
it("returns the first child", () => {
|
|
596
|
+
expect(given.fromNode.getNextNode()).toMatchObject({
|
|
597
|
+
name: "child1",
|
|
599
598
|
});
|
|
600
599
|
});
|
|
601
600
|
});
|
|
601
|
+
});
|
|
602
602
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
given.tree.getNodeByNameMustExist("child2")
|
|
606
|
-
);
|
|
603
|
+
context("with the node is the last child", () => {
|
|
604
|
+
given("fromNode", () => given.tree.getNodeByNameMustExist("child2"));
|
|
607
605
|
|
|
608
|
-
|
|
609
|
-
|
|
606
|
+
it("returns the next sibling of the parent", () => {
|
|
607
|
+
expect(given.fromNode.getNextNode()).toMatchObject({
|
|
608
|
+
name: "node2",
|
|
610
609
|
});
|
|
611
610
|
});
|
|
612
611
|
});
|
|
613
612
|
|
|
614
613
|
context("with includeChildren is false", () => {
|
|
615
|
-
given("includeChildren", () => false);
|
|
616
|
-
|
|
617
614
|
context("with an open parent node", () => {
|
|
618
615
|
given("fromNode", () => given.tree.getNodeByNameMustExist("node1"));
|
|
619
616
|
|
|
@@ -622,10 +619,63 @@ describe("getNextNode", () => {
|
|
|
622
619
|
});
|
|
623
620
|
|
|
624
621
|
it("returns the next sibling", () => {
|
|
625
|
-
expect(given.
|
|
622
|
+
expect(given.fromNode.getNextNode(false)).toMatchObject({
|
|
623
|
+
name: "node2",
|
|
624
|
+
});
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
describe("getNextVisibleNode", () => {
|
|
631
|
+
interface Vars {
|
|
632
|
+
fromNode: Node;
|
|
633
|
+
tree: Node;
|
|
634
|
+
}
|
|
635
|
+
const given = getGiven<Vars>();
|
|
636
|
+
given("tree", () => new Node().loadFromData(exampleData));
|
|
637
|
+
|
|
638
|
+
context("with a parent node", () => {
|
|
639
|
+
given("fromNode", () => given.tree.getNodeByNameMustExist("node1"));
|
|
640
|
+
|
|
641
|
+
context("when the parent node is closed", () => {
|
|
642
|
+
it("returns the next sibling", () => {
|
|
643
|
+
expect(given.fromNode.getNextVisibleNode()).toMatchObject({
|
|
644
|
+
name: "node2",
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
context("when the parent node is open", () => {
|
|
650
|
+
beforeEach(() => {
|
|
651
|
+
given.fromNode.is_open = true;
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
it("returns the first child", () => {
|
|
655
|
+
expect(given.fromNode.getNextVisibleNode()).toMatchObject({
|
|
656
|
+
name: "child1",
|
|
657
|
+
});
|
|
626
658
|
});
|
|
627
659
|
});
|
|
628
660
|
});
|
|
661
|
+
|
|
662
|
+
context("with the node is the last child", () => {
|
|
663
|
+
given("fromNode", () => given.tree.getNodeByNameMustExist("child2"));
|
|
664
|
+
|
|
665
|
+
it("returns the next sibling of the parent", () => {
|
|
666
|
+
expect(given.fromNode.getNextVisibleNode()).toMatchObject({
|
|
667
|
+
name: "node2",
|
|
668
|
+
});
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
context("with the tree node", () => {
|
|
673
|
+
given("fromNode", () => given.tree);
|
|
674
|
+
|
|
675
|
+
it("returns null", () => {
|
|
676
|
+
expect(given.fromNode.getNextVisibleNode()).toBeNull();
|
|
677
|
+
});
|
|
678
|
+
});
|
|
629
679
|
});
|
|
630
680
|
|
|
631
681
|
describe("getNextSibling", () => {
|
|
@@ -766,48 +816,92 @@ describe("getParent", () => {
|
|
|
766
816
|
|
|
767
817
|
describe("getPreviousNode", () => {
|
|
768
818
|
interface Vars {
|
|
769
|
-
node2: Node;
|
|
770
|
-
node3: Node;
|
|
771
819
|
tree: Node;
|
|
772
820
|
}
|
|
773
821
|
const given = getGiven<Vars>();
|
|
774
|
-
given("node2", () => given.tree.getNodeByNameMustExist("node2"));
|
|
775
|
-
given("node3", () => given.tree.getNodeByNameMustExist("node3"));
|
|
776
822
|
given("tree", () => new Node().loadFromData(exampleData));
|
|
777
823
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
824
|
+
it("returns null with a tree node", () => {
|
|
825
|
+
expect(given.tree.getPreviousNode()).toBeNull();
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
it("returns the last child of the previous sibling when the previous node is closed and has children", () => {
|
|
829
|
+
given.tree.getNodeByNameMustExist("node2").is_open = false;
|
|
830
|
+
const node2 = given.tree.getNodeByNameMustExist("node2");
|
|
831
|
+
|
|
832
|
+
expect(node2.getPreviousNode()).toMatchObject({
|
|
833
|
+
name: "child2",
|
|
781
834
|
});
|
|
782
835
|
});
|
|
783
836
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
});
|
|
837
|
+
it("returns the last child of the previous sibling when the previous node is open and has children", () => {
|
|
838
|
+
given.tree.getNodeByNameMustExist("node2").is_open = true;
|
|
839
|
+
const node2 = given.tree.getNodeByNameMustExist("node2");
|
|
840
|
+
|
|
841
|
+
expect(node2.getPreviousNode()).toMatchObject({
|
|
842
|
+
name: "child2",
|
|
791
843
|
});
|
|
844
|
+
});
|
|
792
845
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
given.tree.getNodeByNameMustExist("node1").is_open = true;
|
|
796
|
-
});
|
|
846
|
+
it("returns the first child if a node is the second child", () => {
|
|
847
|
+
const child2 = given.tree.getNodeByNameMustExist("child2");
|
|
797
848
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
name: "child2",
|
|
801
|
-
});
|
|
802
|
-
});
|
|
849
|
+
expect(child2.getPreviousNode()).toMatchObject({
|
|
850
|
+
name: "child1",
|
|
803
851
|
});
|
|
804
852
|
});
|
|
805
853
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
854
|
+
it("returns the parent with a node that is the first child", () => {
|
|
855
|
+
const node3 = given.tree.getNodeByNameMustExist("node3");
|
|
856
|
+
|
|
857
|
+
expect(node3.getPreviousNode()).toMatchObject({
|
|
858
|
+
name: "node2",
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
describe("getPreviousVisibleNode", () => {
|
|
864
|
+
interface Vars {
|
|
865
|
+
tree: Node;
|
|
866
|
+
}
|
|
867
|
+
const given = getGiven<Vars>();
|
|
868
|
+
given("tree", () => new Node().loadFromData(exampleData));
|
|
869
|
+
|
|
870
|
+
it("returns null with a tree node", () => {
|
|
871
|
+
expect(given.tree.getPreviousVisibleNode()).toBeNull();
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
it("returns the previous sibling when the previous sibling is closed and has children", () => {
|
|
875
|
+
given.tree.getNodeByNameMustExist("node2").is_open = false;
|
|
876
|
+
const node2 = given.tree.getNodeByNameMustExist("node2");
|
|
877
|
+
|
|
878
|
+
expect(node2.getPreviousVisibleNode()).toMatchObject({
|
|
879
|
+
name: "node1",
|
|
880
|
+
});
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
it("returns the last child of the previous sibling when the previous sibling is open and has children", () => {
|
|
884
|
+
given.tree.getNodeByNameMustExist("node1").is_open = true;
|
|
885
|
+
const node2 = given.tree.getNodeByNameMustExist("node2");
|
|
886
|
+
|
|
887
|
+
expect(node2.getPreviousVisibleNode()).toMatchObject({
|
|
888
|
+
name: "child2",
|
|
889
|
+
});
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
it("returns the first child if a node is the second child", () => {
|
|
893
|
+
const child2 = given.tree.getNodeByNameMustExist("child2");
|
|
894
|
+
|
|
895
|
+
expect(child2.getPreviousVisibleNode()).toMatchObject({
|
|
896
|
+
name: "child1",
|
|
897
|
+
});
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
it("returns the parent when a node is the first child", () => {
|
|
901
|
+
const node3 = given.tree.getNodeByNameMustExist("node3");
|
|
902
|
+
|
|
903
|
+
expect(node3.getPreviousVisibleNode()).toMatchObject({
|
|
904
|
+
name: "node2",
|
|
811
905
|
});
|
|
812
906
|
});
|
|
813
907
|
});
|
package/src/tree.jquery.ts
CHANGED
|
@@ -777,7 +777,7 @@ export class JqTreeWidget extends MouseWidget<JQTreeOptions> {
|
|
|
777
777
|
// Set initial state, either by restoring the state or auto-opening nodes
|
|
778
778
|
// result: must load nodes on demand?
|
|
779
779
|
private setInitialState(): boolean {
|
|
780
|
-
const restoreState = (): boolean
|
|
780
|
+
const restoreState = (): [boolean, boolean] => {
|
|
781
781
|
// result: is state restored, must load on demand?
|
|
782
782
|
if (!this.options.saveState) {
|
|
783
783
|
return [false, false];
|
|
@@ -1118,11 +1118,7 @@ export class JqTreeWidget extends MouseWidget<JQTreeOptions> {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
|
|
1120
1120
|
private doLoadData(data: NodeData[] | null, parentNode: Node | null): void {
|
|
1121
|
-
if (
|
|
1122
|
-
return;
|
|
1123
|
-
} else {
|
|
1124
|
-
this._triggerEvent("tree.load_data", { tree_data: data });
|
|
1125
|
-
|
|
1121
|
+
if (data) {
|
|
1126
1122
|
if (parentNode) {
|
|
1127
1123
|
this.deselectNodes(parentNode);
|
|
1128
1124
|
this.loadSubtree(data, parentNode);
|
|
@@ -1134,6 +1130,11 @@ export class JqTreeWidget extends MouseWidget<JQTreeOptions> {
|
|
|
1134
1130
|
this.dndHandler.refresh();
|
|
1135
1131
|
}
|
|
1136
1132
|
}
|
|
1133
|
+
|
|
1134
|
+
this._triggerEvent("tree.load_data", {
|
|
1135
|
+
tree_data: data,
|
|
1136
|
+
parent_node: parentNode,
|
|
1137
|
+
});
|
|
1137
1138
|
}
|
|
1138
1139
|
|
|
1139
1140
|
private deselectNodes(parentNode: Node): void {
|
package/src/version.ts
CHANGED