orgchart 6.0.0 → 7.0.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/publish.yml +11 -8
- package/README.md +47 -35
- package/README.zh-cn.md +73 -30
- package/README.zh-tw.md +73 -30
- package/demo/edit-chart.html +0 -4
- package/demo/edit-hybrid-chart.html +3 -4
- package/demo/index.html +5 -1
- package/demo/ondemand-loading-data.html +137 -80
- package/demo/options-compact-drag.html +82 -0
- package/demo/options-export-navigation.html +76 -0
- package/demo/options-horizontal-template.html +80 -0
- package/demo/options-hybrid-navigation.html +71 -0
- package/dist/css/orgchart.css +12 -1
- package/dist/css/orgchart.min.css +1 -1
- package/dist/js/orgchart.js +896 -523
- package/dist/js/orgchart.min.js +1 -1
- package/dist/js/orgchart.min.js.map +1 -1
- package/gulpfile.js +5 -1
- package/package.json +2 -1
- package/src/css/orgchart.css +12 -1
- package/src/js/orgchart.js +896 -523
- package/test/compatibility/README.md +123 -0
- package/test/compatibility/browser.tests.js +1279 -0
- package/test/compatibility/options.tests.js +628 -0
- package/test/cypress/e2e/demo-interactions.cy.js +3 -3
- package/test/cypress/e2e/demo-rendering.cy.js +62 -1
- package/test/cypress/e2e/drag-drop-hybrid-chart.cy.js +2 -1
- package/test/cypress/e2e/local-datasource.cy.js +16 -16
- package/test/cypress/e2e/ondemand-loading-data.cy.js +34 -10
- package/test/cypress/e2e/toggle-sibs-resp.cy.js +4 -4
- package/test/cypress/e2e/vertical-vevel.cy.js +5 -5
- package/test/integration/init-tests.js +30 -43
- package/test/integration/tests.js +21 -13
- package/test/unit/lifecycle-builders-export.tests.js +179 -118
- package/test/unit/tests.js +33 -34
package/test/unit/tests.js
CHANGED
|
@@ -237,7 +237,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
237
237
|
$container = document.getElementById('chart-container');
|
|
238
238
|
oc = new OrgChart({
|
|
239
239
|
chartContainer: '#chart-container',
|
|
240
|
-
'data': ds,
|
|
240
|
+
'data': JSON.parse(JSON.stringify(ds)),
|
|
241
241
|
'nodeContent': 'title'
|
|
242
242
|
}),
|
|
243
243
|
$laolao = document.getElementById('n1'),
|
|
@@ -276,12 +276,10 @@ describe('orgchart -- unit tests', function () {
|
|
|
276
276
|
id: 'root',
|
|
277
277
|
title: 'chief',
|
|
278
278
|
name: 'Root',
|
|
279
|
-
relationship: '001',
|
|
280
279
|
children: [
|
|
281
280
|
{
|
|
282
281
|
id: 'child',
|
|
283
|
-
name: 'Child'
|
|
284
|
-
relationship: '100'
|
|
282
|
+
name: 'Child'
|
|
285
283
|
}
|
|
286
284
|
]
|
|
287
285
|
});
|
|
@@ -682,6 +680,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
682
680
|
});
|
|
683
681
|
|
|
684
682
|
it('hideChildrenEnd() accepts direct animated and node payloads', function () {
|
|
683
|
+
$sumiao.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
685
684
|
const bottomEdgeEl = query('.bottomEdge', $sumiao);
|
|
686
685
|
const verticalSpy = sinon.spy(oc, 'switchVerticalArrow');
|
|
687
686
|
|
|
@@ -700,6 +699,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
700
699
|
});
|
|
701
700
|
|
|
702
701
|
it('hideChildrenEnd() accepts wrapped native animated and node payloads', function () {
|
|
702
|
+
$sumiao.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
703
703
|
const bottomEdgeEl = query('.bottomEdge', $sumiao);
|
|
704
704
|
const verticalSpy = sinon.spy(oc, 'switchVerticalArrow');
|
|
705
705
|
|
|
@@ -777,6 +777,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
777
777
|
});
|
|
778
778
|
|
|
779
779
|
it('showSiblingsEnd() accepts direct visible and node payloads', function () {
|
|
780
|
+
$heihei.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
780
781
|
const topEdgeEl = query('.topEdge', $heihei);
|
|
781
782
|
const switchSpy = sinon.spy(oc, 'switchHorizontalArrow');
|
|
782
783
|
|
|
@@ -799,6 +800,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
799
800
|
});
|
|
800
801
|
|
|
801
802
|
it('showSiblingsEnd() accepts wrapped native visible and node payloads', function () {
|
|
803
|
+
$heihei.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
802
804
|
const topEdgeEl = query('.topEdge', $heihei);
|
|
803
805
|
const switchSpy = sinon.spy(oc, 'switchHorizontalArrow');
|
|
804
806
|
|
|
@@ -1006,6 +1008,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
1006
1008
|
});
|
|
1007
1009
|
|
|
1008
1010
|
it('accepts direct node, container, and animated payloads', function () {
|
|
1011
|
+
$heihei.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1009
1012
|
const horizontalSpy = sinon.spy(oc, 'switchHorizontalArrow');
|
|
1010
1013
|
const nodeContainerEl = closestElement($heihei, '.hierarchy');
|
|
1011
1014
|
|
|
@@ -1029,6 +1032,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
1029
1032
|
});
|
|
1030
1033
|
|
|
1031
1034
|
it('accepts wrapped native node, container, and animated payloads', function () {
|
|
1035
|
+
$heihei.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1032
1036
|
const horizontalSpy = sinon.spy(oc, 'switchHorizontalArrow');
|
|
1033
1037
|
const nodeContainerEl = closestElement($heihei, '.hierarchy');
|
|
1034
1038
|
|
|
@@ -1061,26 +1065,15 @@ describe('orgchart -- unit tests', function () {
|
|
|
1061
1065
|
spy.should.have.been.calledWith($sumiao);
|
|
1062
1066
|
});
|
|
1063
1067
|
|
|
1064
|
-
it('nodeEnterLeaveHandler() removes
|
|
1068
|
+
it('nodeEnterLeaveHandler() removes controls from a native node payload on mouseleave', function () {
|
|
1065
1069
|
const nodeEl = $sumiao;
|
|
1066
1070
|
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
oc.options.icons.expandToUp,
|
|
1070
|
-
oc.options.icons.collapseToDown,
|
|
1071
|
-
oc.options.icons.collapseToLeft,
|
|
1072
|
-
oc.options.icons.expandToRight
|
|
1073
|
-
);
|
|
1074
|
-
});
|
|
1071
|
+
nodeEl.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1072
|
+
nodeEl.querySelectorAll('.edge').length.should.equal(4);
|
|
1075
1073
|
|
|
1076
1074
|
oc.nodeEnterLeaveHandler({ type: 'mouseleave', node: nodeEl });
|
|
1077
1075
|
|
|
1078
|
-
|
|
1079
|
-
edgeEl.classList.contains(oc.options.icons.expandToUp).should.equal(false);
|
|
1080
|
-
edgeEl.classList.contains(oc.options.icons.collapseToDown).should.equal(false);
|
|
1081
|
-
edgeEl.classList.contains(oc.options.icons.collapseToLeft).should.equal(false);
|
|
1082
|
-
edgeEl.classList.contains(oc.options.icons.expandToRight).should.equal(false);
|
|
1083
|
-
});
|
|
1076
|
+
nodeEl.querySelectorAll('.edge').length.should.equal(0);
|
|
1084
1077
|
});
|
|
1085
1078
|
|
|
1086
1079
|
it('nodeEnterLeaveHandler() accepts wrapped native node payloads', function () {
|
|
@@ -1098,6 +1091,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
1098
1091
|
});
|
|
1099
1092
|
|
|
1100
1093
|
it('HideFirstParentEnd() accepts a native top edge payload', function () {
|
|
1094
|
+
$heihei.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1101
1095
|
const topEdgeEl = query('.topEdge', $heihei);
|
|
1102
1096
|
const verticalSpy = sinon.spy(oc, 'switchVerticalArrow');
|
|
1103
1097
|
const horizontalSpy = sinon.spy(oc, 'switchHorizontalArrow');
|
|
@@ -1113,6 +1107,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
1113
1107
|
});
|
|
1114
1108
|
|
|
1115
1109
|
it('HideFirstParentEnd() accepts a wrapped native top edge payload', function () {
|
|
1110
|
+
$heihei.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1116
1111
|
const topEdgeEl = query('.topEdge', $heihei);
|
|
1117
1112
|
const verticalSpy = sinon.spy(oc, 'switchVerticalArrow');
|
|
1118
1113
|
const horizontalSpy = sinon.spy(oc, 'switchHorizontalArrow');
|
|
@@ -1304,6 +1299,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
1304
1299
|
});
|
|
1305
1300
|
|
|
1306
1301
|
it('startLoading() and endLoading() accept a native edge node', function () {
|
|
1302
|
+
$sumiao.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1307
1303
|
const edgeEl = query('.bottomEdge', $sumiao);
|
|
1308
1304
|
|
|
1309
1305
|
oc.startLoading(edgeEl).should.be.true;
|
|
@@ -1318,6 +1314,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
1318
1314
|
});
|
|
1319
1315
|
|
|
1320
1316
|
it('startLoading() and endLoading() toggle native export buttons', function () {
|
|
1317
|
+
$sumiao.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1321
1318
|
const edgeEl = query('.bottomEdge', $sumiao);
|
|
1322
1319
|
const exportButtonEl = document.createElement('button');
|
|
1323
1320
|
|
|
@@ -1909,20 +1906,22 @@ describe('orgchart -- unit tests', function () {
|
|
|
1909
1906
|
levels[3].map(function (nodeEl) { return nodeEl.id; }).should.deep.equal(['n8', 'n9', 'n10']);
|
|
1910
1907
|
});
|
|
1911
1908
|
|
|
1912
|
-
it('isInAction()
|
|
1909
|
+
it('isInAction() tracks node interaction independently of arrow classes', function () {
|
|
1913
1910
|
const nodeEl = $sumiao;
|
|
1914
|
-
const topEdgeEl = nodeEl.querySelector('.topEdge');
|
|
1915
1911
|
|
|
1916
|
-
should.
|
|
1917
|
-
|
|
1912
|
+
oc.isInAction(nodeEl).should.equal(false);
|
|
1913
|
+
nodeEl.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1918
1914
|
oc.isInAction(nodeEl).should.equal(true);
|
|
1919
1915
|
|
|
1920
|
-
|
|
1916
|
+
nodeEl.querySelector('.topEdge').className = 'edge topEdge';
|
|
1917
|
+
oc.isInAction(nodeEl).should.equal(true);
|
|
1918
|
+
nodeEl.dispatchEvent(new window.MouseEvent('mouseleave'));
|
|
1921
1919
|
oc.isInAction(nodeEl).should.equal(false);
|
|
1922
1920
|
});
|
|
1923
1921
|
|
|
1924
1922
|
it('switchHorizontalArrow() accepts a native node and toggles edge classes from native siblings', function () {
|
|
1925
1923
|
const nodeEl = $sumiao;
|
|
1924
|
+
nodeEl.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1926
1925
|
const leftEdgeEl = nodeEl.querySelector('.leftEdge');
|
|
1927
1926
|
const rightEdgeEl = nodeEl.querySelector('.rightEdge');
|
|
1928
1927
|
|
|
@@ -1944,6 +1943,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
1944
1943
|
});
|
|
1945
1944
|
|
|
1946
1945
|
it('switchVerticalArrow() accepts a native edge element and toggles vertical arrow classes', function () {
|
|
1946
|
+
$sumiao.dispatchEvent(new window.MouseEvent('mouseenter'));
|
|
1947
1947
|
const bottomEdgeEl = $sumiao.querySelector('.bottomEdge');
|
|
1948
1948
|
|
|
1949
1949
|
should.exist(bottomEdgeEl);
|
|
@@ -2135,7 +2135,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
2135
2135
|
const pinchCenterStub = sinon.stub(oc, 'getPinchCenter').returns({ x: 24, y: 36 });
|
|
2136
2136
|
|
|
2137
2137
|
setState(oc.chart, 'pinching', true);
|
|
2138
|
-
oc.zoomingHandler({ orgChart: oc });
|
|
2138
|
+
oc.zoomingHandler({ orgChart: oc, touches: [{ clientX: 0, clientY: 0 }, { clientX: 3, clientY: 4 }] });
|
|
2139
2139
|
|
|
2140
2140
|
getState(oc.chart, 'pinchDistEnd').should.equal(18);
|
|
2141
2141
|
getState(oc.chart, 'pinchCenterEnd').should.deep.equal({ x: 24, y: 36 });
|
|
@@ -2279,7 +2279,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
2279
2279
|
});
|
|
2280
2280
|
const spy = sinon.spy(draggableChart, 'bindDragDrop');
|
|
2281
2281
|
|
|
2282
|
-
draggableChart.createNode({ id: 'n11', name: 'Li Xin',
|
|
2282
|
+
draggableChart.createNode({ id: 'n11', name: 'Li Xin', level: 0 });
|
|
2283
2283
|
|
|
2284
2284
|
spy.should.have.been.called;
|
|
2285
2285
|
spy.firstCall.args[0].nodeType.should.equal(1);
|
|
@@ -2297,12 +2297,12 @@ describe('orgchart -- unit tests', function () {
|
|
|
2297
2297
|
let verticalNodesEl;
|
|
2298
2298
|
|
|
2299
2299
|
hierarchyEl.className = 'hierarchy';
|
|
2300
|
-
nodeEl = verticalChart.createNode({ id: 'n11', name: 'Parent',
|
|
2300
|
+
nodeEl = verticalChart.createNode({ id: 'n11', name: 'Parent', level: 1 });
|
|
2301
2301
|
hierarchyEl.appendChild(nodeEl);
|
|
2302
2302
|
|
|
2303
2303
|
verticalChart.buildInferiorNodes(hierarchyEl, nodeEl, {
|
|
2304
2304
|
collapsed: true,
|
|
2305
|
-
children: [{ id: 'n12', name: 'Child'
|
|
2305
|
+
children: [{ id: 'n12', name: 'Child' }]
|
|
2306
2306
|
}, 1);
|
|
2307
2307
|
|
|
2308
2308
|
verticalNodesEl = Array.from(hierarchyEl.children).find(function (childEl) {
|
|
@@ -2317,14 +2317,14 @@ describe('orgchart -- unit tests', function () {
|
|
|
2317
2317
|
|
|
2318
2318
|
it('buildInferiorNodes() keeps compact descendants on the native node element', function () {
|
|
2319
2319
|
const hierarchyEl = document.createElement('li');
|
|
2320
|
-
const nodeEl = oc.createNode({ id: 'n11', name: 'Parent',
|
|
2320
|
+
const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', level: 0 });
|
|
2321
2321
|
|
|
2322
2322
|
hierarchyEl.className = 'hierarchy';
|
|
2323
2323
|
hierarchyEl.appendChild(nodeEl);
|
|
2324
2324
|
|
|
2325
2325
|
oc.buildInferiorNodes(hierarchyEl, nodeEl, {
|
|
2326
2326
|
compact: true,
|
|
2327
|
-
children: [{ id: 'n12', name: 'Child'
|
|
2327
|
+
children: [{ id: 'n12', name: 'Child' }]
|
|
2328
2328
|
}, 0);
|
|
2329
2329
|
|
|
2330
2330
|
nodeEl.classList.contains('compact').should.equal(true);
|
|
@@ -2339,13 +2339,12 @@ describe('orgchart -- unit tests', function () {
|
|
|
2339
2339
|
hierarchyEl.className = 'hierarchy';
|
|
2340
2340
|
|
|
2341
2341
|
oc.buildHierarchy(hierarchyEl, [[
|
|
2342
|
-
{ id: 'n11', name: 'Spouse A',
|
|
2342
|
+
{ id: 'n11', name: 'Spouse A', outsider: false },
|
|
2343
2343
|
{
|
|
2344
2344
|
id: 'n12',
|
|
2345
2345
|
name: 'Spouse B',
|
|
2346
|
-
relationship: '001',
|
|
2347
2346
|
outsider: true,
|
|
2348
|
-
children: [[{ id: 'n13', name: 'Child'
|
|
2347
|
+
children: [[{ id: 'n13', name: 'Child' }]]
|
|
2349
2348
|
}
|
|
2350
2349
|
]]);
|
|
2351
2350
|
|
|
@@ -2364,7 +2363,7 @@ describe('orgchart -- unit tests', function () {
|
|
|
2364
2363
|
let ancestorNodeEl;
|
|
2365
2364
|
let originalRootNodeEl;
|
|
2366
2365
|
|
|
2367
|
-
oc.addAncestors({ id: 'n0', name: 'Lao Ye'
|
|
2366
|
+
oc.addAncestors({ id: 'n0', name: 'Lao Ye' }, 'n0');
|
|
2368
2367
|
|
|
2369
2368
|
ancestorNodeEl = document.getElementById('n0');
|
|
2370
2369
|
originalRootNodeEl = document.getElementById('n1');
|