jqtree 1.6.3 → 1.7.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/.github/workflows/ci.yml +21 -19
- package/.tool-versions +1 -0
- 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 +3 -3
- package/docs/_config.yml +1 -1
- package/docs/_entries/10_changelog.md +9 -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/{96_getprevioussibling.md → 97_getprevioussibling.md} +0 -0
- package/docs/_entries/98_getpreviousvisiblenode.md +14 -0
- package/docs/_entries/{97_parent.md → 99_parent.md} +0 -0
- package/docs/package.json +7 -7
- package/docs/pnpm-lock.yaml +138 -108
- package/docs/static/bower.json +1 -1
- package/docs/static/bower_components/jquery/dist/jquery.js +209 -97
- package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -2
- package/docs/static/documentation.css +224 -84
- package/docs/static/example.css +0 -1
- package/docs/tree.jquery.js +2 -2
- package/lib/dataLoader.js +5 -31
- package/lib/dragAndDropHandler.js +19 -132
- package/lib/elementsRenderer.js +29 -59
- package/lib/keyHandler.js +8 -32
- package/lib/mouse.widget.js +13 -74
- package/lib/node.js +60 -125
- package/lib/nodeElement.js +5 -72
- 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 +12 -61
- package/lib/scrollHandler.js +17 -74
- package/lib/selectNodeHandler.js +5 -24
- package/lib/simple.widget.js +18 -53
- package/lib/test/jqTree/create.test.js +0 -4
- package/lib/test/jqTree/events.test.js +0 -7
- 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 +127 -72
- 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 +40 -39
- package/src/keyHandler.ts +3 -3
- package/src/node.ts +43 -12
- package/src/test/.eslintrc +3 -1
- package/src/test/node.test.ts +146 -54
- package/src/tree.jquery.ts +6 -5
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +202 -855
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +2 -2
- package/tree.jquery.js.map +1 -1
package/lib/test/node.test.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _givens = _interopRequireDefault(require("givens"));
|
|
4
|
-
|
|
5
4
|
var _node = require("../node");
|
|
6
|
-
|
|
7
5
|
var _exampleData = _interopRequireDefault(require("./support/exampleData"));
|
|
8
|
-
|
|
9
6
|
require("jest-extended");
|
|
10
|
-
|
|
11
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
8
|
var context = describe;
|
|
14
9
|
describe("addAfter", function () {
|
|
15
10
|
var given = (0, _givens["default"])();
|
|
@@ -378,8 +373,8 @@ describe("constructor", function () {
|
|
|
378
373
|
id: 123,
|
|
379
374
|
name: "n1",
|
|
380
375
|
url: "/"
|
|
381
|
-
});
|
|
382
|
-
|
|
376
|
+
});
|
|
377
|
+
// todo: match object?
|
|
383
378
|
expect(given.node).not.toHaveProperty("label");
|
|
384
379
|
expect(given.node.children).toHaveLength(0);
|
|
385
380
|
expect(given.node.parent).toBeNull();
|
|
@@ -520,50 +515,39 @@ describe("getNextNode", function () {
|
|
|
520
515
|
given("tree", function () {
|
|
521
516
|
return new _node.Node().loadFromData(_exampleData["default"]);
|
|
522
517
|
});
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
context("with includeChildren is true", function () {
|
|
527
|
-
given("includeChildren", function () {
|
|
528
|
-
return true;
|
|
518
|
+
context("with a parent node", function () {
|
|
519
|
+
given("fromNode", function () {
|
|
520
|
+
return given.tree.getNodeByNameMustExist("node1");
|
|
529
521
|
});
|
|
530
|
-
context("
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
context("when the parent node is closed", function () {
|
|
535
|
-
it("returns the next sibling", function () {
|
|
536
|
-
expect(given.nextNode).toMatchObject({
|
|
537
|
-
name: "node2"
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
context("when the parent node is open", function () {
|
|
542
|
-
beforeEach(function () {
|
|
543
|
-
given.fromNode.is_open = true;
|
|
544
|
-
});
|
|
545
|
-
it("returns the first child", function () {
|
|
546
|
-
expect(given.nextNode).toMatchObject({
|
|
547
|
-
name: "child1"
|
|
548
|
-
});
|
|
522
|
+
context("when the parent node is closed", function () {
|
|
523
|
+
it("returns the first child", function () {
|
|
524
|
+
expect(given.fromNode.getNextNode()).toMatchObject({
|
|
525
|
+
name: "child1"
|
|
549
526
|
});
|
|
550
527
|
});
|
|
551
528
|
});
|
|
552
|
-
context("
|
|
553
|
-
|
|
554
|
-
|
|
529
|
+
context("when the parent node is open", function () {
|
|
530
|
+
beforeEach(function () {
|
|
531
|
+
given.fromNode.is_open = true;
|
|
555
532
|
});
|
|
556
|
-
it("returns the
|
|
557
|
-
expect(given.
|
|
558
|
-
name: "
|
|
533
|
+
it("returns the first child", function () {
|
|
534
|
+
expect(given.fromNode.getNextNode()).toMatchObject({
|
|
535
|
+
name: "child1"
|
|
559
536
|
});
|
|
560
537
|
});
|
|
561
538
|
});
|
|
562
539
|
});
|
|
563
|
-
context("with
|
|
564
|
-
given("
|
|
565
|
-
return
|
|
540
|
+
context("with the node is the last child", function () {
|
|
541
|
+
given("fromNode", function () {
|
|
542
|
+
return given.tree.getNodeByNameMustExist("child2");
|
|
543
|
+
});
|
|
544
|
+
it("returns the next sibling of the parent", function () {
|
|
545
|
+
expect(given.fromNode.getNextNode()).toMatchObject({
|
|
546
|
+
name: "node2"
|
|
547
|
+
});
|
|
566
548
|
});
|
|
549
|
+
});
|
|
550
|
+
context("with includeChildren is false", function () {
|
|
567
551
|
context("with an open parent node", function () {
|
|
568
552
|
given("fromNode", function () {
|
|
569
553
|
return given.tree.getNodeByNameMustExist("node1");
|
|
@@ -572,11 +556,57 @@ describe("getNextNode", function () {
|
|
|
572
556
|
given.fromNode.is_open = true;
|
|
573
557
|
});
|
|
574
558
|
it("returns the next sibling", function () {
|
|
575
|
-
expect(given.
|
|
559
|
+
expect(given.fromNode.getNextNode(false)).toMatchObject({
|
|
560
|
+
name: "node2"
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
describe("getNextVisibleNode", function () {
|
|
567
|
+
var given = (0, _givens["default"])();
|
|
568
|
+
given("tree", function () {
|
|
569
|
+
return new _node.Node().loadFromData(_exampleData["default"]);
|
|
570
|
+
});
|
|
571
|
+
context("with a parent node", function () {
|
|
572
|
+
given("fromNode", function () {
|
|
573
|
+
return given.tree.getNodeByNameMustExist("node1");
|
|
574
|
+
});
|
|
575
|
+
context("when the parent node is closed", function () {
|
|
576
|
+
it("returns the next sibling", function () {
|
|
577
|
+
expect(given.fromNode.getNextVisibleNode()).toMatchObject({
|
|
576
578
|
name: "node2"
|
|
577
579
|
});
|
|
578
580
|
});
|
|
579
581
|
});
|
|
582
|
+
context("when the parent node is open", function () {
|
|
583
|
+
beforeEach(function () {
|
|
584
|
+
given.fromNode.is_open = true;
|
|
585
|
+
});
|
|
586
|
+
it("returns the first child", function () {
|
|
587
|
+
expect(given.fromNode.getNextVisibleNode()).toMatchObject({
|
|
588
|
+
name: "child1"
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
context("with the node is the last child", function () {
|
|
594
|
+
given("fromNode", function () {
|
|
595
|
+
return given.tree.getNodeByNameMustExist("child2");
|
|
596
|
+
});
|
|
597
|
+
it("returns the next sibling of the parent", function () {
|
|
598
|
+
expect(given.fromNode.getNextVisibleNode()).toMatchObject({
|
|
599
|
+
name: "node2"
|
|
600
|
+
});
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
context("with the tree node", function () {
|
|
604
|
+
given("fromNode", function () {
|
|
605
|
+
return given.tree;
|
|
606
|
+
});
|
|
607
|
+
it("returns null", function () {
|
|
608
|
+
expect(given.fromNode.getNextVisibleNode()).toBeNull();
|
|
609
|
+
});
|
|
580
610
|
});
|
|
581
611
|
});
|
|
582
612
|
describe("getNextSibling", function () {
|
|
@@ -699,44 +729,71 @@ describe("getParent", function () {
|
|
|
699
729
|
});
|
|
700
730
|
describe("getPreviousNode", function () {
|
|
701
731
|
var given = (0, _givens["default"])();
|
|
702
|
-
given("
|
|
703
|
-
return
|
|
732
|
+
given("tree", function () {
|
|
733
|
+
return new _node.Node().loadFromData(_exampleData["default"]);
|
|
734
|
+
});
|
|
735
|
+
it("returns null with a tree node", function () {
|
|
736
|
+
expect(given.tree.getPreviousNode()).toBeNull();
|
|
737
|
+
});
|
|
738
|
+
it("returns the last child of the previous sibling when the previous node is closed and has children", function () {
|
|
739
|
+
given.tree.getNodeByNameMustExist("node2").is_open = false;
|
|
740
|
+
var node2 = given.tree.getNodeByNameMustExist("node2");
|
|
741
|
+
expect(node2.getPreviousNode()).toMatchObject({
|
|
742
|
+
name: "child2"
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
it("returns the last child of the previous sibling when the previous node is open and has children", function () {
|
|
746
|
+
given.tree.getNodeByNameMustExist("node2").is_open = true;
|
|
747
|
+
var node2 = given.tree.getNodeByNameMustExist("node2");
|
|
748
|
+
expect(node2.getPreviousNode()).toMatchObject({
|
|
749
|
+
name: "child2"
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
it("returns the first child if a node is the second child", function () {
|
|
753
|
+
var child2 = given.tree.getNodeByNameMustExist("child2");
|
|
754
|
+
expect(child2.getPreviousNode()).toMatchObject({
|
|
755
|
+
name: "child1"
|
|
756
|
+
});
|
|
704
757
|
});
|
|
705
|
-
|
|
706
|
-
|
|
758
|
+
it("returns the parent with a node that is the first child", function () {
|
|
759
|
+
var node3 = given.tree.getNodeByNameMustExist("node3");
|
|
760
|
+
expect(node3.getPreviousNode()).toMatchObject({
|
|
761
|
+
name: "node2"
|
|
762
|
+
});
|
|
707
763
|
});
|
|
764
|
+
});
|
|
765
|
+
describe("getPreviousVisibleNode", function () {
|
|
766
|
+
var given = (0, _givens["default"])();
|
|
708
767
|
given("tree", function () {
|
|
709
768
|
return new _node.Node().loadFromData(_exampleData["default"]);
|
|
710
769
|
});
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
770
|
+
it("returns null with a tree node", function () {
|
|
771
|
+
expect(given.tree.getPreviousVisibleNode()).toBeNull();
|
|
772
|
+
});
|
|
773
|
+
it("returns the previous sibling when the previous sibling is closed and has children", function () {
|
|
774
|
+
given.tree.getNodeByNameMustExist("node2").is_open = false;
|
|
775
|
+
var node2 = given.tree.getNodeByNameMustExist("node2");
|
|
776
|
+
expect(node2.getPreviousVisibleNode()).toMatchObject({
|
|
777
|
+
name: "node1"
|
|
714
778
|
});
|
|
715
779
|
});
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
});
|
|
722
|
-
});
|
|
780
|
+
it("returns the last child of the previous sibling when the previous sibling is open and has children", function () {
|
|
781
|
+
given.tree.getNodeByNameMustExist("node1").is_open = true;
|
|
782
|
+
var node2 = given.tree.getNodeByNameMustExist("node2");
|
|
783
|
+
expect(node2.getPreviousVisibleNode()).toMatchObject({
|
|
784
|
+
name: "child2"
|
|
723
785
|
});
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
expect(given.node2.getPreviousNode()).toMatchObject({
|
|
730
|
-
name: "child2"
|
|
731
|
-
});
|
|
732
|
-
});
|
|
786
|
+
});
|
|
787
|
+
it("returns the first child if a node is the second child", function () {
|
|
788
|
+
var child2 = given.tree.getNodeByNameMustExist("child2");
|
|
789
|
+
expect(child2.getPreviousVisibleNode()).toMatchObject({
|
|
790
|
+
name: "child1"
|
|
733
791
|
});
|
|
734
792
|
});
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
});
|
|
793
|
+
it("returns the parent when a node is the first child", function () {
|
|
794
|
+
var node3 = given.tree.getNodeByNameMustExist("node3");
|
|
795
|
+
expect(node3.getPreviousVisibleNode()).toMatchObject({
|
|
796
|
+
name: "node2"
|
|
740
797
|
});
|
|
741
798
|
});
|
|
742
799
|
});
|
|
@@ -861,7 +918,6 @@ describe("iterate", function () {
|
|
|
861
918
|
given.visited.push([node.name, level]);
|
|
862
919
|
return true;
|
|
863
920
|
};
|
|
864
|
-
|
|
865
921
|
given("visitor", function () {
|
|
866
922
|
return visitAllNodes;
|
|
867
923
|
});
|
|
@@ -874,7 +930,6 @@ describe("iterate", function () {
|
|
|
874
930
|
given.visited.push([node.name, level]);
|
|
875
931
|
return false;
|
|
876
932
|
};
|
|
877
|
-
|
|
878
933
|
given("visitor", function () {
|
|
879
934
|
return visitNodes;
|
|
880
935
|
});
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _treeStructure = _interopRequireDefault(require("./treeStructure"));
|
|
4
|
-
|
|
5
4
|
var _testUtil = require("./testUtil");
|
|
6
|
-
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
-
|
|
9
6
|
var assertJqTreeFolder = function assertJqTreeFolder($el) {
|
|
10
7
|
/* istanbul ignore if */
|
|
11
8
|
if (!$el.hasClass("jqtree-folder")) {
|
|
12
9
|
throw new Error("Node is not a folder");
|
|
13
10
|
}
|
|
14
11
|
};
|
|
15
|
-
|
|
16
12
|
expect.extend({
|
|
17
13
|
toBeClosed: function toBeClosed(el) {
|
|
18
14
|
var $el = jQuery(el);
|
|
19
15
|
assertJqTreeFolder($el);
|
|
20
|
-
/* istanbul ignore next */
|
|
21
16
|
|
|
17
|
+
/* istanbul ignore next */
|
|
22
18
|
return {
|
|
23
19
|
message: function message() {
|
|
24
20
|
return "The node is open";
|
|
@@ -38,8 +34,8 @@ expect.extend({
|
|
|
38
34
|
toBeOpen: function toBeOpen(el) {
|
|
39
35
|
var $el = jQuery(el);
|
|
40
36
|
assertJqTreeFolder($el);
|
|
41
|
-
/* istanbul ignore next */
|
|
42
37
|
|
|
38
|
+
/* istanbul ignore next */
|
|
43
39
|
return {
|
|
44
40
|
message: function message() {
|
|
45
41
|
return "The node is closed";
|
|
@@ -49,8 +45,8 @@ expect.extend({
|
|
|
49
45
|
},
|
|
50
46
|
toBeSelected: function toBeSelected(el) {
|
|
51
47
|
var $el = jQuery(el);
|
|
52
|
-
/* istanbul ignore next */
|
|
53
48
|
|
|
49
|
+
/* istanbul ignore next */
|
|
54
50
|
return {
|
|
55
51
|
message: function message() {
|
|
56
52
|
return "The node is not selected";
|
|
@@ -60,11 +56,10 @@ expect.extend({
|
|
|
60
56
|
},
|
|
61
57
|
toHaveTreeStructure: function toHaveTreeStructure(el, expectedStructure) {
|
|
62
58
|
var _this = this;
|
|
63
|
-
|
|
64
59
|
var $el = jQuery(el);
|
|
65
60
|
var receivedStructure = (0, _treeStructure["default"])($el);
|
|
66
|
-
/* istanbul ignore next */
|
|
67
61
|
|
|
62
|
+
/* istanbul ignore next */
|
|
68
63
|
return {
|
|
69
64
|
message: function message() {
|
|
70
65
|
return _this.utils.printDiffOrStringify(expectedStructure, receivedStructure, "expected", "received", true);
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _jquery = _interopRequireDefault(require("jquery"));
|
|
4
|
-
|
|
5
4
|
require("./jqTreeMatchers");
|
|
6
|
-
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
-
|
|
9
6
|
window.$ = _jquery["default"]; // eslint-disable-line @typescript-eslint/no-unsafe-member-access
|
|
10
|
-
|
|
11
7
|
window.jQuery = _jquery["default"]; // eslint-disable-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -4,38 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.togglerLink = exports.titleSpan = exports.singleChild = void 0;
|
|
7
|
-
|
|
8
7
|
var singleChild = function singleChild($el, selector) {
|
|
9
8
|
var $result = $el.children(selector);
|
|
10
|
-
/* istanbul ignore if */
|
|
11
9
|
|
|
10
|
+
/* istanbul ignore if */
|
|
12
11
|
if ($result.length === 0) {
|
|
13
12
|
throw "No child found for selector '".concat(selector, "'");
|
|
14
13
|
}
|
|
15
|
-
/* istanbul ignore if */
|
|
16
|
-
|
|
17
14
|
|
|
15
|
+
/* istanbul ignore if */
|
|
18
16
|
if ($result.length > 1) {
|
|
19
17
|
throw "Multiple elements found for selector '".concat(selector, "'");
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
return $result;
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
exports.singleChild = singleChild;
|
|
26
|
-
|
|
27
22
|
var titleSpan = function titleSpan(liNode) {
|
|
28
23
|
return singleChild(nodeElement(liNode), "span.jqtree-title");
|
|
29
24
|
};
|
|
30
|
-
|
|
31
25
|
exports.titleSpan = titleSpan;
|
|
32
|
-
|
|
33
26
|
var togglerLink = function togglerLink(liNode) {
|
|
34
27
|
return singleChild(nodeElement(liNode), "a.jqtree-toggler");
|
|
35
28
|
};
|
|
36
|
-
|
|
37
29
|
exports.togglerLink = togglerLink;
|
|
38
|
-
|
|
39
30
|
var nodeElement = function nodeElement(liNode) {
|
|
40
31
|
return singleChild(jQuery(liNode), "div.jqtree-element ");
|
|
41
32
|
};
|
|
@@ -4,15 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _testUtil = require("./testUtil");
|
|
9
|
-
|
|
10
8
|
var getTreeNode = function getTreeNode($li) {
|
|
11
9
|
var $div = (0, _testUtil.singleChild)($li, "div.jqtree-element");
|
|
12
10
|
var $span = (0, _testUtil.singleChild)($div, "span.jqtree-title");
|
|
13
11
|
var name = $span.html();
|
|
14
12
|
var selected = $li.hasClass("jqtree-selected");
|
|
15
|
-
|
|
16
13
|
if ($li.hasClass("jqtree-folder")) {
|
|
17
14
|
var $ul = $li.children("ul.jqtree_common");
|
|
18
15
|
return {
|
|
@@ -30,16 +27,13 @@ var getTreeNode = function getTreeNode($li) {
|
|
|
30
27
|
};
|
|
31
28
|
}
|
|
32
29
|
};
|
|
33
|
-
|
|
34
30
|
var getChildren = function getChildren($ul) {
|
|
35
31
|
return $ul.children("li.jqtree_common").map(function (_, li) {
|
|
36
32
|
return getTreeNode(jQuery(li));
|
|
37
33
|
}).get();
|
|
38
34
|
};
|
|
39
|
-
|
|
40
35
|
var treeStructure = function treeStructure($el) {
|
|
41
36
|
return getChildren((0, _testUtil.singleChild)($el, "ul.jqtree-tree"));
|
|
42
37
|
};
|
|
43
|
-
|
|
44
38
|
var _default = treeStructure;
|
|
45
39
|
exports["default"] = _default;
|