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.
Files changed (35) hide show
  1. package/.github/workflows/publish.yml +11 -8
  2. package/README.md +47 -35
  3. package/README.zh-cn.md +73 -30
  4. package/README.zh-tw.md +73 -30
  5. package/demo/edit-chart.html +0 -4
  6. package/demo/edit-hybrid-chart.html +3 -4
  7. package/demo/index.html +5 -1
  8. package/demo/ondemand-loading-data.html +137 -80
  9. package/demo/options-compact-drag.html +82 -0
  10. package/demo/options-export-navigation.html +76 -0
  11. package/demo/options-horizontal-template.html +80 -0
  12. package/demo/options-hybrid-navigation.html +71 -0
  13. package/dist/css/orgchart.css +12 -1
  14. package/dist/css/orgchart.min.css +1 -1
  15. package/dist/js/orgchart.js +896 -523
  16. package/dist/js/orgchart.min.js +1 -1
  17. package/dist/js/orgchart.min.js.map +1 -1
  18. package/gulpfile.js +5 -1
  19. package/package.json +2 -1
  20. package/src/css/orgchart.css +12 -1
  21. package/src/js/orgchart.js +896 -523
  22. package/test/compatibility/README.md +123 -0
  23. package/test/compatibility/browser.tests.js +1279 -0
  24. package/test/compatibility/options.tests.js +628 -0
  25. package/test/cypress/e2e/demo-interactions.cy.js +3 -3
  26. package/test/cypress/e2e/demo-rendering.cy.js +62 -1
  27. package/test/cypress/e2e/drag-drop-hybrid-chart.cy.js +2 -1
  28. package/test/cypress/e2e/local-datasource.cy.js +16 -16
  29. package/test/cypress/e2e/ondemand-loading-data.cy.js +34 -10
  30. package/test/cypress/e2e/toggle-sibs-resp.cy.js +4 -4
  31. package/test/cypress/e2e/vertical-vevel.cy.js +5 -5
  32. package/test/integration/init-tests.js +30 -43
  33. package/test/integration/tests.js +21 -13
  34. package/test/unit/lifecycle-builders-export.tests.js +179 -118
  35. package/test/unit/tests.js +33 -34
@@ -155,8 +155,8 @@ describe('orgchart -- init and builder unit tests', function () {
155
155
  chart = new OrgChart({
156
156
  chartContainer: '#chart-container',
157
157
  data: [[
158
- { id: 'n1', name: 'Lao Lao', relationship: '001' },
159
- { id: 'n2', name: 'Bo Miao', relationship: '001' }
158
+ { id: 'n1', name: 'Lao Lao' },
159
+ { id: 'n2', name: 'Bo Miao' }
160
160
  ]]
161
161
  });
162
162
 
@@ -196,38 +196,24 @@ describe('orgchart -- init and builder unit tests', function () {
196
196
  ulElement.remove();
197
197
  });
198
198
 
199
- it('routes plain object data through attachRel() before building', function () {
200
- const attachRelSpy = sinon.spy(oc, 'attachRel');
199
+ it('initializes without generated relationship metadata or attachRel()', function () {
200
+ const data = {
201
+ id: 'r1',
202
+ name: 'Root',
203
+ children: [{ id: 'c1', name: 'Child' }]
204
+ };
201
205
 
202
- oc.init({
203
- data: {
204
- id: 'r1',
205
- name: 'Root',
206
- children: [{ id: 'c1', name: 'Child' }]
207
- }
208
- });
206
+ oc.init({ data: data });
209
207
 
210
- attachRelSpy.should.have.been.called;
211
- attachRelSpy.firstCall.args[1].should.equal('00');
212
- attachRelSpy.restore();
208
+ data.should.not.have.property('relationship');
209
+ data.children[0].should.not.have.property('relationship');
210
+ should.equal(oc.attachRel, undefined);
211
+ should.exist(query('#r1', oc.chart));
212
+ should.exist(query('#c1', oc.chart));
213
213
  });
214
214
 
215
- it('keeps explicit relationship data untouched during init()', function () {
216
- const attachRelSpy = sinon.spy(oc, 'attachRel');
217
-
218
- oc.init({
219
- data: {
220
- id: 'r1',
221
- name: 'Root',
222
- relationship: '001',
223
- children: [{ id: 'c1', name: 'Child', relationship: '100' }]
224
- }
225
- });
226
-
227
- attachRelSpy.should.not.have.been.called;
228
- attachRelSpy.restore();
229
- query('#r1', oc.chart).should.not.equal(null);
230
- query('#c1', oc.chart).should.not.equal(null);
215
+ it('does not create interaction controls during init()', function () {
216
+ queryAll('.edge, .toggleBtn, .backToCompactSymbol, .backToLooseSymbol', oc.chart).length.should.equal(0);
231
217
  });
232
218
 
233
219
  it('calls attachExportButton() only when exportButton is enabled', function () {
@@ -301,7 +287,7 @@ describe('orgchart -- init and builder unit tests', function () {
301
287
  initSpy.firstCall.args[0].should.have.property('data');
302
288
  initSpy.firstCall.args[0].data.id.should.equal('x1');
303
289
  initSpy.firstCall.args[0].data.name.should.equal('Reloaded Root');
304
- initSpy.firstCall.args[0].data.relationship.should.equal('000');
290
+ initSpy.firstCall.args[0].data.should.not.have.property('relationship');
305
291
  initSpy.firstCall.args[0].data.level.should.equal(1);
306
292
  initSpy.restore();
307
293
  });
@@ -337,8 +323,8 @@ describe('orgchart -- init and builder unit tests', function () {
337
323
  });
338
324
  });
339
325
 
340
- describe('attachRel()', function () {
341
- it('assigns root and child relationship flags recursively', function () {
326
+ describe('layout inheritance', function () {
327
+ it('builds parent and sibling relations without generating metadata', function () {
342
328
  const tree = {
343
329
  id: 'n1',
344
330
  name: 'Root',
@@ -348,12 +334,12 @@ describe('orgchart -- init and builder unit tests', function () {
348
334
  ]
349
335
  };
350
336
 
351
- oc.attachRel(tree, '00');
337
+ oc.init({ data: tree });
352
338
 
353
- tree.relationship.should.equal('001');
354
- tree.children[0].relationship.should.equal('110');
355
- tree.children[1].relationship.should.equal('111');
356
- tree.children[1].children[0].relationship.should.equal('100');
339
+ oc.getParent(query('#n2', oc.chart)).id.should.equal('n1');
340
+ oc.getSiblings(query('#n2', oc.chart)).map(function (node) { return node.id; }).should.deep.equal(['n3']);
341
+ tree.should.not.have.property('relationship');
342
+ tree.children[1].children[0].should.not.have.property('relationship');
357
343
  });
358
344
 
359
345
  it('marks compact nodes when the compact option predicate returns true', function () {
@@ -377,7 +363,7 @@ describe('orgchart -- init and builder unit tests', function () {
377
363
  ]
378
364
  };
379
365
 
380
- chart.attachRel(tree, '00');
366
+ chart.init({ data: tree });
381
367
 
382
368
  should.equal(tree.compact, undefined);
383
369
  tree.children[1].compact.should.equal(true);
@@ -398,7 +384,7 @@ describe('orgchart -- init and builder unit tests', function () {
398
384
  ]
399
385
  };
400
386
 
401
- oc.attachRel(tree, '00');
387
+ oc.init({ data: tree });
402
388
 
403
389
  tree.children[0].vertical.should.equal(true);
404
390
  tree.children[0].children[0].vertical.should.equal(true);
@@ -419,39 +405,37 @@ describe('orgchart -- init and builder unit tests', function () {
419
405
  ]
420
406
  };
421
407
 
422
- oc.attachRel(tree, '00');
408
+ oc.init({ data: tree });
423
409
 
424
410
  tree.children[0].compact.should.equal(true);
425
411
  tree.children[1].associatedCompact.should.equal(true);
426
412
  tree.children[0].children[0].associatedCompact.should.equal(true);
427
413
  });
428
414
 
429
- it('returns the same data object after mutating relationships', function () {
415
+ it('retains the datasource object without synthetic relation flags', function () {
430
416
  const tree = { id: 'n1', name: 'Root' };
431
417
 
432
- oc.attachRel(tree, '00').should.equal(tree);
433
- tree.relationship.should.equal('000');
418
+ oc.init({ data: tree });
419
+ oc.options.data.should.equal(tree);
420
+ tree.should.not.have.property('relationship');
434
421
  });
435
422
  });
436
423
 
437
424
  describe('createNode()', function () {
438
- it('renders the standard title, content, and edges from relationship flags', function () {
425
+ it('renders title and content without prebuilt interaction controls', function () {
439
426
  const nodeEl = oc.createNode({
440
427
  id: 'n11',
441
428
  name: 'Li Xin',
442
429
  title: 'architect',
443
- relationship: '111',
444
- level: 1
430
+ level: 1,
431
+ children: [{ id: 'child', name: 'Child' }]
445
432
  });
446
433
 
447
434
  nodeEl.classList.contains('node').should.equal(true);
448
435
  nodeEl.id.should.equal('n11');
449
436
  query('.title', nodeEl).textContent.trim().should.equal('Li Xin');
450
437
  query('.content', nodeEl).textContent.should.equal('architect');
451
- should.exist(query('.topEdge', nodeEl));
452
- should.exist(query('.leftEdge', nodeEl));
453
- should.exist(query('.rightEdge', nodeEl));
454
- should.exist(query('.bottomEdge', nodeEl));
438
+ queryAll('.edge, .toggleBtn, .backToCompactSymbol, .backToLooseSymbol', nodeEl).length.should.equal(0);
455
439
  should.exist(query('.parentNodeSymbol', nodeEl));
456
440
  });
457
441
 
@@ -459,7 +443,6 @@ describe('orgchart -- init and builder unit tests', function () {
459
443
  const data = {
460
444
  id: 'n11',
461
445
  name: 'Li Xin',
462
- relationship: '001',
463
446
  level: 0,
464
447
  children: [{ id: 'n12', name: 'Child' }]
465
448
  };
@@ -473,7 +456,6 @@ describe('orgchart -- init and builder unit tests', function () {
473
456
  const nodeEl = oc.createNode({
474
457
  id: 'n11',
475
458
  name: 'Li Xin',
476
- relationship: '001',
477
459
  level: 0,
478
460
  children: [{ id: 'n12', name: 'Child' }]
479
461
  });
@@ -493,7 +475,6 @@ describe('orgchart -- init and builder unit tests', function () {
493
475
  const nodeEl = chart.createNode({
494
476
  id: 'n11',
495
477
  name: 'Li Xin',
496
- relationship: '000',
497
478
  level: 2
498
479
  });
499
480
 
@@ -504,7 +485,6 @@ describe('orgchart -- init and builder unit tests', function () {
504
485
  const nodeEl = oc.createNode({
505
486
  id: 'n11',
506
487
  name: 'Li Xin',
507
- relationship: '000',
508
488
  level: 0,
509
489
  className: 'custom-node',
510
490
  outsider: true
@@ -525,7 +505,6 @@ describe('orgchart -- init and builder unit tests', function () {
525
505
  const nodeEl = chart.createNode({
526
506
  id: 'n11',
527
507
  name: 'Li Xin',
528
- relationship: '001',
529
508
  level: 0
530
509
  });
531
510
 
@@ -542,7 +521,6 @@ describe('orgchart -- init and builder unit tests', function () {
542
521
  const nodeEl = chart.createNode({
543
522
  id: 'n11',
544
523
  name: 'Li Xin',
545
- relationship: '001',
546
524
  level: 0,
547
525
  title: 'architect'
548
526
  });
@@ -550,53 +528,54 @@ describe('orgchart -- init and builder unit tests', function () {
550
528
  should.equal(query('.content', nodeEl), null);
551
529
  });
552
530
 
553
- it('renders a vertical toggle button at or beyond verticalLevel', function () {
531
+ it('renders a vertical toggle button on hover at or beyond verticalLevel', function () {
554
532
  const chart = new OrgChart({
555
533
  chartContainer: '#chart-container',
556
- data: JSON.parse(JSON.stringify(ds)),
534
+ data: { id: 'root', name: 'Root', children: [{ id: 'n11', name: 'Parent', children: [{ id: 'child', name: 'Child' }] }] },
557
535
  verticalLevel: 2
558
536
  });
559
- const nodeEl = chart.createNode({
560
- id: 'n11',
561
- name: 'Li Xin',
562
- relationship: '001',
563
- level: 2
564
- });
537
+ const nodeEl = query('#n11', chart.chart);
538
+
539
+ should.equal(query('.toggleBtn', nodeEl), null);
540
+ nodeEl.dispatchEvent(new window.MouseEvent('mouseenter'));
565
541
 
566
542
  should.exist(query('.toggleBtn', nodeEl));
567
543
  should.equal(query('.bottomEdge', nodeEl), null);
568
544
  });
569
545
 
570
- it('renders a toggle button for explicitly vertical nodes', function () {
571
- const nodeEl = oc.createNode({
546
+ it('renders a toggle button on hover for explicitly vertical nodes', function () {
547
+ oc.init({ data: {
572
548
  id: 'n11',
573
549
  name: 'Li Xin',
574
- relationship: '001',
575
- level: 0,
576
- vertical: true
577
- });
550
+ vertical: true,
551
+ children: [{ id: 'child', name: 'Child' }]
552
+ } });
553
+ const nodeEl = query('#n11', oc.chart);
554
+
555
+ nodeEl.dispatchEvent(new window.MouseEvent('mouseenter'));
578
556
 
579
557
  should.exist(query('.toggleBtn', nodeEl));
580
558
  });
581
559
 
582
- it('renders a bottom edge for hybrid nodes with children', function () {
583
- const nodeEl = oc.createNode({
560
+ it('renders a bottom edge on hover for hybrid nodes with children', function () {
561
+ oc.init({ data: {
584
562
  id: 'n11',
585
563
  name: 'Li Xin',
586
- relationship: '001',
587
- level: 0,
588
- hybrid: true
589
- });
564
+ hybrid: true,
565
+ children: [{ id: 'child', name: 'Child' }]
566
+ } });
567
+ const nodeEl = query('#n11', oc.chart);
568
+
569
+ nodeEl.dispatchEvent(new window.MouseEvent('mouseenter'));
590
570
 
591
571
  should.exist(query('.bottomEdge', nodeEl));
592
572
  should.equal(query('.toggleBtn', nodeEl), null);
593
573
  });
594
574
 
595
- it('renders compact mode controls and grid columns for compact nodes', function () {
596
- const nodeEl = oc.createNode({
575
+ it('renders compact controls on hover while keeping grid columns stable', function () {
576
+ oc.init({ data: {
597
577
  id: 'n11',
598
578
  name: 'Li Xin',
599
- relationship: '001',
600
579
  level: 0,
601
580
  compact: true,
602
581
  children: [
@@ -604,7 +583,11 @@ describe('orgchart -- init and builder unit tests', function () {
604
583
  { id: 'n13', name: 'B' },
605
584
  { id: 'n14', name: 'C' }
606
585
  ]
607
- });
586
+ } });
587
+ const nodeEl = query('#n11', oc.chart);
588
+
589
+ should.equal(query('.backToLooseSymbol', nodeEl), null);
590
+ nodeEl.dispatchEvent(new window.MouseEvent('mouseenter'));
608
591
 
609
592
  should.exist(query('.backToCompactSymbol', nodeEl));
610
593
  should.exist(query('.backToLooseSymbol', nodeEl));
@@ -615,7 +598,6 @@ describe('orgchart -- init and builder unit tests', function () {
615
598
  const nodeEl = oc.createNode({
616
599
  id: 'n11',
617
600
  name: 'Li Xin',
618
- relationship: '111',
619
601
  level: 1,
620
602
  associatedCompact: true
621
603
  });
@@ -636,7 +618,6 @@ describe('orgchart -- init and builder unit tests', function () {
636
618
  const nodeEl = chart.createNode({
637
619
  id: 'n11',
638
620
  name: 'Li Xin',
639
- relationship: '001',
640
621
  level: 0
641
622
  });
642
623
 
@@ -659,7 +640,6 @@ describe('orgchart -- init and builder unit tests', function () {
659
640
  const nodeData = {
660
641
  id: 'n11',
661
642
  name: 'Li Xin',
662
- relationship: '001',
663
643
  level: 0
664
644
  };
665
645
 
@@ -672,6 +652,89 @@ describe('orgchart -- init and builder unit tests', function () {
672
652
  });
673
653
  });
674
654
 
655
+ describe('lazy node controls', function () {
656
+ it('creates only the hovered node controls and removes them on leave', function () {
657
+ const node = query('#n3', oc.chart);
658
+ node.dispatchEvent(new window.MouseEvent('mouseenter'));
659
+
660
+ queryAll('.edge', oc.chart).length.should.equal(4);
661
+ node.dispatchEvent(new window.MouseEvent('mouseleave'));
662
+ queryAll('.edge', oc.chart).length.should.equal(0);
663
+ });
664
+
665
+ it('keeps controls while focused and releases them after blur', function () {
666
+ const node = query('#n3', oc.chart);
667
+ node.focus();
668
+ should.exist(query('.bottomEdge', node));
669
+ node.dispatchEvent(new window.MouseEvent('mouseleave'));
670
+ should.exist(query('.bottomEdge', node));
671
+ node.blur();
672
+ should.equal(query('.edge', node), null);
673
+ });
674
+
675
+ it('supports keyboard activation of a lazily created control', function () {
676
+ const node = query('#n3', oc.chart);
677
+ node.focus();
678
+ const control = query('.bottomEdge', node);
679
+ control.getAttribute('role').should.equal('button');
680
+ control.getAttribute('aria-label').should.equal('Toggle child nodes');
681
+ control.focus();
682
+ control.dispatchEvent(new window.KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
683
+ query('#n5', oc.chart).classList.contains('slide-up').should.equal(true);
684
+ });
685
+
686
+ it('updates active controls from the current structure after add and remove', function () {
687
+ const node = query('#n2', oc.chart);
688
+ node.dispatchEvent(new window.MouseEvent('mouseenter'));
689
+ should.equal(query('.bottomEdge', node), null);
690
+ oc.addChildren(node, [{ id: 'added', name: 'Added' }]);
691
+ should.exist(query('.bottomEdge', node));
692
+ queryAll('.edge', query('#added', oc.chart)).length.should.equal(0);
693
+ oc.removeNodes(query('#added', oc.chart));
694
+ should.equal(query('.bottomEdge', node), null);
695
+ should.equal(query('.parentNodeSymbol', node), null);
696
+ });
697
+
698
+ it('does not create controls for inactive nodes during mutations', function () {
699
+ oc.addChildren(query('#n2', oc.chart), [{ id: 'added', name: 'Added' }]);
700
+ oc.addParent(query('#n1', oc.chart), { id: 'ancestor', name: 'Ancestor' });
701
+ queryAll('.edge, .toggleBtn, .backToCompactSymbol, .backToLooseSymbol', oc.chart).length.should.equal(0);
702
+ });
703
+
704
+ it('preserves the loading control until completion after mouseleave', function () {
705
+ const node = query('#n3', oc.chart);
706
+ node.dispatchEvent(new window.MouseEvent('mouseenter'));
707
+ const control = query('.bottomEdge', node);
708
+ oc.startLoading(control).should.equal(true);
709
+ node.dispatchEvent(new window.MouseEvent('mouseleave'));
710
+ control.parentElement.should.equal(node);
711
+ oc.endLoading(control);
712
+ queryAll('.edge, .spinner', node).length.should.equal(0);
713
+ });
714
+
715
+ it('keeps demo-owned request buttons separate from library controls', function () {
716
+ const node = query('#n3', oc.chart);
717
+ const requestButton = document.createElement('button');
718
+ requestButton.className = 'request-control';
719
+ node.appendChild(requestButton);
720
+ node.dispatchEvent(new window.MouseEvent('mouseenter'));
721
+ node.dispatchEvent(new window.MouseEvent('mouseleave'));
722
+ requestButton.parentElement.should.equal(node);
723
+ queryAll('.edge', node).length.should.equal(0);
724
+ });
725
+
726
+ it('does not refresh minimap for transient controls', async function () {
727
+ oc.setOptions('minimap', true);
728
+ const refresh = sinon.spy(oc, 'updateMinimap');
729
+ query('#n3', oc.chart).dispatchEvent(new window.MouseEvent('mouseenter'));
730
+ query('#n3', oc.chart).dispatchEvent(new window.MouseEvent('mouseleave'));
731
+ await Promise.resolve();
732
+ refresh.should.not.have.been.called;
733
+ refresh.restore();
734
+ oc.detachMinimap();
735
+ });
736
+ });
737
+
675
738
  describe('buildInferiorNodes()', function () {
676
739
  it('creates a hidden vertical nodes layer at the vertical cutoff', function () {
677
740
  const chart = new OrgChart({
@@ -681,13 +744,13 @@ describe('orgchart -- init and builder unit tests', function () {
681
744
  visibleLevel: 1
682
745
  });
683
746
  const hierarchyEl = document.createElement('li');
684
- const nodeEl = chart.createNode({ id: 'n11', name: 'Parent', relationship: '001', level: 1 });
747
+ const nodeEl = chart.createNode({ id: 'n11', name: 'Parent', level: 1 });
685
748
 
686
749
  hierarchyEl.className = 'hierarchy';
687
750
  hierarchyEl.appendChild(nodeEl);
688
751
  chart.buildInferiorNodes(hierarchyEl, nodeEl, {
689
752
  collapsed: true,
690
- children: [{ id: 'n12', name: 'Child', relationship: '000' }]
753
+ children: [{ id: 'n12', name: 'Child' }]
691
754
  }, 1);
692
755
 
693
756
  should.exist(query(':scope > .nodes.vertical.hidden', hierarchyEl));
@@ -696,13 +759,13 @@ describe('orgchart -- init and builder unit tests', function () {
696
759
 
697
760
  it('creates a vertical layer for hybrid nodes outside an existing vertical context', function () {
698
761
  const hierarchyEl = document.createElement('li');
699
- const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', relationship: '001', level: 0 });
762
+ const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', level: 0 });
700
763
 
701
764
  hierarchyEl.className = 'hierarchy';
702
765
  hierarchyEl.appendChild(nodeEl);
703
766
  oc.buildInferiorNodes(hierarchyEl, nodeEl, {
704
767
  hybrid: true,
705
- children: [{ id: 'n12', name: 'Child', relationship: '000' }]
768
+ children: [{ id: 'n12', name: 'Child' }]
706
769
  }, 0);
707
770
 
708
771
  should.exist(query(':scope > .nodes.vertical', hierarchyEl));
@@ -712,7 +775,7 @@ describe('orgchart -- init and builder unit tests', function () {
712
775
  it('does not add a second vertical class when already inside a vertical branch', function () {
713
776
  const verticalWrapper = document.createElement('ul');
714
777
  const hierarchyEl = document.createElement('li');
715
- const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', relationship: '001', level: 1 });
778
+ const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', level: 1 });
716
779
  let nodesEl;
717
780
 
718
781
  verticalWrapper.className = 'nodes vertical';
@@ -723,7 +786,7 @@ describe('orgchart -- init and builder unit tests', function () {
723
786
 
724
787
  oc.buildInferiorNodes(hierarchyEl, nodeEl, {
725
788
  hybrid: true,
726
- children: [{ id: 'n12', name: 'Child', relationship: '000' }]
789
+ children: [{ id: 'n12', name: 'Child' }]
727
790
  }, 1);
728
791
  nodesEl = query(':scope > .nodes', hierarchyEl);
729
792
 
@@ -737,12 +800,12 @@ describe('orgchart -- init and builder unit tests', function () {
737
800
  visibleLevel: 0
738
801
  });
739
802
  const hierarchyEl = document.createElement('li');
740
- const nodeEl = chart.createNode({ id: 'n11', name: 'Parent', relationship: '001', level: 0 });
803
+ const nodeEl = chart.createNode({ id: 'n11', name: 'Parent', level: 0 });
741
804
 
742
805
  hierarchyEl.className = 'hierarchy';
743
806
  hierarchyEl.appendChild(nodeEl);
744
807
  chart.buildInferiorNodes(hierarchyEl, nodeEl, {
745
- children: [{ id: 'n12', name: 'Child', relationship: '000' }]
808
+ children: [{ id: 'n12', name: 'Child' }]
746
809
  }, 0);
747
810
 
748
811
  hierarchyEl.classList.contains('isChildrenCollapsed').should.equal(true);
@@ -751,13 +814,13 @@ describe('orgchart -- init and builder unit tests', function () {
751
814
 
752
815
  it('keeps compact descendants inside the compact node element', function () {
753
816
  const hierarchyEl = document.createElement('li');
754
- const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', relationship: '001', level: 0 });
817
+ const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', level: 0 });
755
818
 
756
819
  hierarchyEl.className = 'hierarchy';
757
820
  hierarchyEl.appendChild(nodeEl);
758
821
  oc.buildInferiorNodes(hierarchyEl, nodeEl, {
759
822
  compact: true,
760
- children: [{ id: 'n12', name: 'Child', relationship: '000' }]
823
+ children: [{ id: 'n12', name: 'Child' }]
761
824
  }, 0);
762
825
 
763
826
  nodeEl.classList.contains('compact').should.equal(true);
@@ -767,19 +830,18 @@ describe('orgchart -- init and builder unit tests', function () {
767
830
 
768
831
  it('handles grouped family-tree children arrays', function () {
769
832
  const hierarchyEl = document.createElement('li');
770
- const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', relationship: '001', level: 0 });
833
+ const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', level: 0 });
771
834
 
772
835
  hierarchyEl.className = 'hierarchy';
773
836
  hierarchyEl.appendChild(nodeEl);
774
837
  oc.buildInferiorNodes(hierarchyEl, nodeEl, {
775
838
  children: [[
776
- { id: 'n12', name: 'Spouse A', relationship: '001' },
839
+ { id: 'n12', name: 'Spouse A' },
777
840
  {
778
841
  id: 'n13',
779
842
  name: 'Spouse B',
780
- relationship: '001',
781
843
  outsider: true,
782
- children: [[{ id: 'n14', name: 'Child', relationship: '000' }]]
844
+ children: [[{ id: 'n14', name: 'Child' }]]
783
845
  }
784
846
  ]]
785
847
  }, 0);
@@ -803,8 +865,7 @@ describe('orgchart -- init and builder unit tests', function () {
803
865
  oc.buildHierarchy(hierarchyEl, {
804
866
  id: 'n11',
805
867
  name: 'Parent',
806
- relationship: '001',
807
- children: [{ id: 'n12', name: 'Child', relationship: '000' }]
868
+ children: [{ id: 'n12', name: 'Child' }]
808
869
  });
809
870
 
810
871
  should.exist(query('#n11', hierarchyEl));
@@ -818,7 +879,7 @@ describe('orgchart -- init and builder unit tests', function () {
818
879
  const outerHierarchyEl = document.createElement('li');
819
880
  const innerNodesEl = document.createElement('ul');
820
881
  const hierarchyEl = document.createElement('li');
821
- const data = { id: 'n11', name: 'Parent', relationship: '000' };
882
+ const data = { id: 'n11', name: 'Parent' };
822
883
 
823
884
  chartEl.className = 'orgchart';
824
885
  outerNodesEl.className = 'nodes';
@@ -839,7 +900,7 @@ describe('orgchart -- init and builder unit tests', function () {
839
900
 
840
901
  it('preserves an explicit data.level value', function () {
841
902
  const hierarchyEl = document.createElement('li');
842
- const data = { id: 'n11', name: 'Parent', relationship: '000', level: 7 };
903
+ const data = { id: 'n11', name: 'Parent', level: 7 };
843
904
 
844
905
  hierarchyEl.className = 'hierarchy';
845
906
  oc.buildHierarchy(hierarchyEl, data);
@@ -847,18 +908,18 @@ describe('orgchart -- init and builder unit tests', function () {
847
908
  data.level.should.equal(7);
848
909
  });
849
910
 
850
- it('propagates a derived level into grouped family-tree arrays', function () {
911
+ it('propagates a one-based level into grouped family-tree arrays', function () {
851
912
  const hierarchyEl = document.createElement('li');
852
913
  const familyData = [[
853
- { id: 'n11', name: 'Spouse A', relationship: '001' },
854
- { id: 'n12', name: 'Spouse B', relationship: '001', outsider: true }
914
+ { id: 'n11', name: 'Spouse A' },
915
+ { id: 'n12', name: 'Spouse B', outsider: true }
855
916
  ]];
856
917
 
857
918
  hierarchyEl.className = 'hierarchy';
858
919
  oc.buildHierarchy(hierarchyEl, familyData);
859
920
 
860
- familyData[0][0].level.should.equal(0);
861
- familyData[0][1].level.should.equal(0);
921
+ familyData[0][0].level.should.equal(1);
922
+ familyData[0][1].level.should.equal(1);
862
923
  });
863
924
 
864
925
  it('creates spouse, couple, and insider wrappers for family trees', function () {
@@ -866,9 +927,9 @@ describe('orgchart -- init and builder unit tests', function () {
866
927
 
867
928
  hierarchyEl.className = 'hierarchy';
868
929
  oc.buildHierarchy(hierarchyEl, [[
869
- { id: 'n11', name: 'Spouse A', relationship: '001', outsider: false },
870
- { id: 'n12', name: 'Spouse B', relationship: '001', outsider: true },
871
- { id: 'n13', name: 'Spouse C', relationship: '001', outsider: true }
930
+ { id: 'n11', name: 'Spouse A', outsider: false },
931
+ { id: 'n12', name: 'Spouse B', outsider: true },
932
+ { id: 'n13', name: 'Spouse C', outsider: true }
872
933
  ]]);
873
934
 
874
935
  queryAll(':scope > .spouse', hierarchyEl).length.should.equal(3);
@@ -883,8 +944,8 @@ describe('orgchart -- init and builder unit tests', function () {
883
944
 
884
945
  hierarchyEl.className = 'hierarchy';
885
946
  oc.buildHierarchy(hierarchyEl, [[
886
- { id: 'n11', name: 'Spouse A', relationship: '001', outsider: false },
887
- { id: 'n12', name: 'Spouse B', relationship: '001', outsider: true }
947
+ { id: 'n11', name: 'Spouse A', outsider: false },
948
+ { id: 'n12', name: 'Spouse B', outsider: true }
888
949
  ]]);
889
950
 
890
951
  queryAll('.node', hierarchyEl).map(function (nodeEl) {
@@ -897,7 +958,7 @@ describe('orgchart -- init and builder unit tests', function () {
897
958
 
898
959
  hierarchyEl.className = 'hierarchy';
899
960
  oc.buildHierarchy(hierarchyEl, {
900
- children: [{ id: 'n12', name: 'Child', relationship: '000' }]
961
+ children: [{ id: 'n12', name: 'Child' }]
901
962
  });
902
963
 
903
964
  should.equal(query('.node', hierarchyEl).id, 'n12');
@@ -930,7 +991,7 @@ describe('orgchart -- init and builder unit tests', function () {
930
991
 
931
992
  it('appends new child hierarchies into an existing child nodes container', function () {
932
993
  const hierarchyEl = document.createElement('li');
933
- const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', relationship: '001', level: 0 });
994
+ const nodeEl = oc.createNode({ id: 'n11', name: 'Parent', level: 0 });
934
995
  const nodesEl = document.createElement('ul');
935
996
 
936
997
  hierarchyEl.className = 'hierarchy';
@@ -938,8 +999,8 @@ describe('orgchart -- init and builder unit tests', function () {
938
999
  hierarchyEl.appendChild(nodeEl);
939
1000
  hierarchyEl.appendChild(nodesEl);
940
1001
  oc.buildChildNode(hierarchyEl, [
941
- { id: 'n12', name: 'Child A', relationship: '000' },
942
- { id: 'n13', name: 'Child B', relationship: '000' }
1002
+ { id: 'n12', name: 'Child A' },
1003
+ { id: 'n13', name: 'Child B' }
943
1004
  ]);
944
1005
 
945
1006
  queryAll(':scope > .hierarchy', nodesEl).length.should.equal(2);
@@ -963,12 +1024,12 @@ describe('orgchart -- init and builder unit tests', function () {
963
1024
  query(':scope > .nodes > .hierarchy > #n0', oc.chart).should.not.equal(null);
964
1025
  });
965
1026
 
966
- it('defaults the new parent relationship to 001 when absent', function () {
1027
+ it('does not generate relation metadata for a new parent', function () {
967
1028
  const currentRootEl = query('#n1', oc.chart);
968
1029
 
969
1030
  oc.buildParentNode(currentRootEl, { id: 'n0', name: 'Ancestor' });
970
1031
 
971
- getState(query('#n0', oc.chart), 'nodeData').relationship.should.equal('001');
1032
+ getState(query('#n0', oc.chart), 'nodeData').should.not.have.property('relationship');
972
1033
  });
973
1034
  });
974
1035