@worktile/gantt 12.1.0-next.0 → 12.1.3

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 (54) hide show
  1. package/bundles/worktile-gantt.umd.js +821 -907
  2. package/bundles/worktile-gantt.umd.js.map +1 -1
  3. package/class/event.d.ts +4 -0
  4. package/class/item.d.ts +4 -5
  5. package/components/calendar/{grid/calendar-grid.component.d.ts → calendar.component.d.ts} +10 -8
  6. package/components/links/links.component.d.ts +3 -2
  7. package/components/main/gantt-main.component.d.ts +4 -4
  8. package/components/table/gantt-table.component.d.ts +42 -0
  9. package/esm2015/class/event.js +3 -1
  10. package/esm2015/class/item.js +1 -1
  11. package/esm2015/components/bar/bar-drag.js +6 -1
  12. package/esm2015/components/calendar/calendar.component.js +86 -0
  13. package/esm2015/components/links/links.component.js +42 -19
  14. package/esm2015/components/main/gantt-main.component.js +5 -5
  15. package/esm2015/components/table/gantt-table.component.js +163 -0
  16. package/esm2015/gantt-dom.service.js +2 -5
  17. package/esm2015/gantt-drag-container.js +2 -1
  18. package/esm2015/gantt-item-upper.js +4 -5
  19. package/esm2015/gantt-print.service.js +2 -2
  20. package/esm2015/gantt-upper.js +110 -35
  21. package/esm2015/gantt.component.js +34 -169
  22. package/esm2015/gantt.config.js +13 -0
  23. package/esm2015/gantt.module.js +22 -18
  24. package/esm2015/public-api.js +2 -1
  25. package/esm2015/root.component.js +7 -8
  26. package/esm2015/table/gantt-table.component.js +9 -3
  27. package/esm2015/utils/helpers.js +10 -9
  28. package/esm2015/views/day.js +2 -2
  29. package/esm2015/views/month.js +3 -3
  30. package/esm2015/views/quarter.js +3 -3
  31. package/esm2015/views/view.js +4 -2
  32. package/esm2015/views/week.js +3 -3
  33. package/esm2015/views/year.js +2 -2
  34. package/fesm2015/worktile-gantt.js +794 -874
  35. package/fesm2015/worktile-gantt.js.map +1 -1
  36. package/gantt-dom.service.d.ts +0 -1
  37. package/gantt-drag-container.d.ts +1 -0
  38. package/gantt-upper.d.ts +23 -5
  39. package/gantt.component.d.ts +8 -27
  40. package/gantt.config.d.ts +23 -0
  41. package/gantt.module.d.ts +13 -16
  42. package/main.bundle.scss +206 -233
  43. package/package.json +1 -1
  44. package/public-api.d.ts +1 -0
  45. package/table/gantt-table.component.d.ts +4 -2
  46. package/utils/helpers.d.ts +3 -5
  47. package/views/view.d.ts +2 -0
  48. package/components/calendar/header/calendar-header.component.d.ts +0 -21
  49. package/components/table/body/gantt-table-body.component.d.ts +0 -24
  50. package/components/table/header/gantt-table-header.component.d.ts +0 -29
  51. package/esm2015/components/calendar/grid/calendar-grid.component.js +0 -76
  52. package/esm2015/components/calendar/header/calendar-header.component.js +0 -70
  53. package/esm2015/components/table/body/gantt-table-body.component.js +0 -68
  54. package/esm2015/components/table/header/gantt-table-header.component.js +0 -126
@@ -1,15 +1,14 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Directive, Input, Output, ContentChild, HostBinding, InjectionToken, Component, Inject, Injectable, ViewChild, Pipe, forwardRef, ChangeDetectionStrategy, Optional, ContentChildren, NgModule } from '@angular/core';
3
- import * as i1 from '@angular/common';
2
+ import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Pipe, ViewChild, Injectable, Optional, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
+ import * as i2 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import { take, skip, takeUntil, startWith, map, pairwise, auditTime, finalize } from 'rxjs/operators';
6
6
  import { BehaviorSubject, Subject, merge, fromEvent } from 'rxjs';
7
7
  import { fromUnixTime, getWeek, getDaysInMonth, differenceInCalendarDays, setDate, addSeconds, addMinutes, addHours, addDays, addWeeks, addMonths, addQuarters, addYears, startOfDay, startOfWeek, startOfMonth, startOfQuarter, startOfYear, endOfDay, endOfWeek, endOfMonth, endOfQuarter, endOfYear, getUnixTime, format, isWeekend, isToday, differenceInDays, differenceInCalendarQuarters, eachMonthOfInterval, eachYearOfInterval, eachWeekOfInterval, eachDayOfInterval, differenceInCalendarYears } from 'date-fns';
8
8
  export { addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarQuarters, differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, endOfDay, endOfMonth, endOfQuarter, endOfWeek, endOfYear, format, fromUnixTime, getDaysInMonth, getUnixTime, getWeek, isToday, isWeekend, setDate, startOfDay, startOfMonth, startOfQuarter, startOfWeek, startOfYear } from 'date-fns';
9
- import { coerceCssPixelValue } from '@angular/cdk/coercion';
10
- import * as i6 from '@angular/cdk/scrolling';
11
- import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
12
- import * as i1$1 from '@angular/cdk/drag-drop';
9
+ import { SelectionModel } from '@angular/cdk/collections';
10
+ import { coerceBooleanProperty, coerceCssPixelValue } from '@angular/cdk/coercion';
11
+ import * as i1 from '@angular/cdk/drag-drop';
13
12
  import { DragDropModule } from '@angular/cdk/drag-drop';
14
13
  import html2canvas from 'html2canvas';
15
14
 
@@ -35,6 +34,8 @@ class GanttLineClickEvent {
35
34
  }
36
35
  class GanttBarClickEvent {
37
36
  }
37
+ class GanttSelectedEvent {
38
+ }
38
39
 
39
40
  class GanttDate {
40
41
  constructor(date) {
@@ -295,11 +296,24 @@ class GanttGroupInternal {
295
296
  }
296
297
  }
297
298
 
299
+ const defaultConfig = {
300
+ dateFormat: {
301
+ week: '第w周',
302
+ month: 'M月',
303
+ quarter: 'QQQ',
304
+ year: 'yyyy年',
305
+ yearMonth: 'yyyy年MM月',
306
+ yearQuarter: 'yyyy年QQQ',
307
+ }
308
+ };
309
+ const GANTT_GLOBAL_CONFIG = new InjectionToken('GANTT_GLOBAL_CONFIG');
310
+
298
311
  const primaryDatePointTop = 18;
299
312
  const secondaryDatePointTop = 36;
300
313
  const viewOptions$5 = {
301
314
  min: new GanttDate().addYears(-1).startOfYear(),
302
- max: new GanttDate().addYears(1).endOfYear()
315
+ max: new GanttDate().addYears(1).endOfYear(),
316
+ dateFormat: defaultConfig.dateFormat
303
317
  };
304
318
  class GanttView {
305
319
  constructor(start, end, options) {
@@ -442,7 +456,7 @@ class GanttViewMonth extends GanttView {
442
456
  const points = [];
443
457
  for (let i = 0; i < quarters; i++) {
444
458
  const start = this.start.addQuarters(i);
445
- const point = new GanttDatePoint(start, start.format('yyyy年QQQ'), (this.getCellWidth() * 3) / 2 + i * (this.getCellWidth() * 3), primaryDatePointTop);
459
+ const point = new GanttDatePoint(start, start.format(this.options.dateFormat.yearQuarter), (this.getCellWidth() * 3) / 2 + i * (this.getCellWidth() * 3), primaryDatePointTop);
446
460
  points.push(point);
447
461
  }
448
462
  return points;
@@ -452,7 +466,7 @@ class GanttViewMonth extends GanttView {
452
466
  const points = [];
453
467
  for (let i = 0; i < months.length; i++) {
454
468
  const start = new GanttDate(months[i]);
455
- const point = new GanttDatePoint(start, `${start.getMonth() + 1}月`, i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
469
+ const point = new GanttDatePoint(start, start.format(this.options.dateFormat.month), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
456
470
  points.push(point);
457
471
  }
458
472
  return points;
@@ -489,7 +503,7 @@ class GanttViewQuarter extends GanttView {
489
503
  const points = [];
490
504
  for (let i = 0; i < years.length; i++) {
491
505
  const start = new GanttDate(years[i]);
492
- const point = new GanttDatePoint(start, `${start.format('yyyy')}年`, (this.getCellWidth() * 4) / 2 + i * (this.getCellWidth() * 4), primaryDatePointTop);
506
+ const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.year)}`, (this.getCellWidth() * 4) / 2 + i * (this.getCellWidth() * 4), primaryDatePointTop);
493
507
  points.push(point);
494
508
  }
495
509
  return points;
@@ -499,7 +513,7 @@ class GanttViewQuarter extends GanttView {
499
513
  const points = [];
500
514
  for (let i = 0; i <= quarters; i++) {
501
515
  const start = this.start.addQuarters(i);
502
- const point = new GanttDatePoint(start, start.format('QQQ'), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
516
+ const point = new GanttDatePoint(start, start.format(this.options.dateFormat.quarter), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
503
517
  points.push(point);
504
518
  }
505
519
  return points;
@@ -537,7 +551,7 @@ class GanttViewDay extends GanttView {
537
551
  for (let i = 0; i < weeks.length; i++) {
538
552
  const weekStart = new GanttDate(weeks[i]);
539
553
  const increaseWeek = weekStart.getDaysInMonth() - weekStart.getDate() >= 3 ? 0 : 1;
540
- const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format('yyyy年MM月'), (this.getCellWidth() * 7) / 2 + i * (this.getCellWidth() * 7), primaryDatePointTop);
554
+ const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format(this.options.dateFormat.yearMonth), (this.getCellWidth() * 7) / 2 + i * (this.getCellWidth() * 7), primaryDatePointTop);
541
555
  points.push(point);
542
556
  }
543
557
  return points;
@@ -586,7 +600,7 @@ class GanttViewWeek extends GanttView {
586
600
  for (let i = 0; i < weeks.length; i++) {
587
601
  const weekStart = new GanttDate(weeks[i]);
588
602
  const increaseWeek = weekStart.getDaysInMonth() - weekStart.getDate() >= 3 ? 0 : 1;
589
- const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format('yyyy年'), this.getCellWidth() / 2 + i * this.getCellWidth(), primaryDatePointTop);
603
+ const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format(this.options.dateFormat.year), this.getCellWidth() / 2 + i * this.getCellWidth(), primaryDatePointTop);
590
604
  points.push(point);
591
605
  }
592
606
  return points;
@@ -596,7 +610,7 @@ class GanttViewWeek extends GanttView {
596
610
  const points = [];
597
611
  for (let i = 0; i < weeks.length; i++) {
598
612
  const start = new GanttDate(weeks[i]);
599
- const point = new GanttDatePoint(start, `第${start.format('w')}周`, i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
613
+ const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.week)}`, i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
600
614
  points.push(point);
601
615
  }
602
616
  return points;
@@ -642,7 +656,7 @@ class GanttViewYear extends GanttView {
642
656
  const pointTop = 27;
643
657
  for (let i = 0; i <= years; i++) {
644
658
  const start = this.start.addYears(i);
645
- const point = new GanttDatePoint(start, `${start.format('yyyy')}年`, i * this.getCellWidth() + this.getCellWidth() / 2, pointTop);
659
+ const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.year)}`, i * this.getCellWidth() + this.getCellWidth() / 2, pointTop);
646
660
  points.push(point);
647
661
  }
648
662
  return points;
@@ -715,40 +729,43 @@ function flatten(array) {
715
729
  return pre.concat(Array.isArray(cur) ? flatten(cur) : cur);
716
730
  }, []);
717
731
  }
718
- function recursiveItems(items, level) {
732
+ function recursiveItems(items) {
719
733
  const result = [];
720
734
  (items || []).forEach((item) => {
721
- item.level = level;
722
735
  result.push(item);
723
736
  if (item.expanded && item.children) {
724
- result.push(...recursiveItems(item.children, level + 1));
737
+ result.push(...recursiveItems(item.children));
725
738
  }
726
739
  });
727
740
  return result;
728
741
  }
729
- function keyBy(array, key) {
730
- const result = {};
731
- array.forEach(item => {
732
- const keyValue = item[key];
733
- result[keyValue] = item;
742
+ function getFlatItems(items) {
743
+ const result = [];
744
+ (items || []).forEach((item) => {
745
+ result.push(item);
746
+ if (item.children) {
747
+ result.push(...getFlatItems(item.children));
748
+ }
734
749
  });
735
750
  return result;
736
751
  }
737
752
 
738
753
  class GanttUpper {
739
- constructor(elementRef, cdr, ngZone) {
754
+ constructor(elementRef, cdr, ngZone, config) {
740
755
  this.elementRef = elementRef;
741
756
  this.cdr = cdr;
742
757
  this.ngZone = ngZone;
758
+ this.config = config;
743
759
  this.originItems = [];
744
760
  this.originGroups = [];
745
761
  this.viewType = GanttViewType.month;
746
762
  this.showTodayLine = true;
763
+ this.viewOptions = {};
747
764
  this.loadOnScroll = new EventEmitter();
748
765
  this.dragStarted = new EventEmitter();
766
+ this.dragMoved = new EventEmitter();
749
767
  this.dragEnded = new EventEmitter();
750
768
  this.barClick = new EventEmitter();
751
- this.computeAllRefs = true;
752
769
  this.linkDragEnded = new EventEmitter();
753
770
  this.items = [];
754
771
  this.groups = [];
@@ -756,9 +773,32 @@ class GanttUpper {
756
773
  this.expandChange = new EventEmitter();
757
774
  this.firstChange = true;
758
775
  this.unsubscribe$ = new Subject();
759
- this.expandedItemIds = [];
776
+ this._selectable = false;
777
+ this._multiple = false;
760
778
  this.ganttClass = true;
761
779
  }
780
+ set selectable(value) {
781
+ var _a;
782
+ this._selectable = coerceBooleanProperty(value);
783
+ if (this._selectable) {
784
+ this.selectionModel = this.initSelectionModel();
785
+ }
786
+ else {
787
+ (_a = this.selectionModel) === null || _a === void 0 ? void 0 : _a.clear();
788
+ }
789
+ }
790
+ get selectable() {
791
+ return this._selectable;
792
+ }
793
+ set multiple(value) {
794
+ this._multiple = coerceBooleanProperty(value);
795
+ if (this.selectable) {
796
+ this.selectionModel = this.initSelectionModel();
797
+ }
798
+ }
799
+ get multiple() {
800
+ return this._multiple;
801
+ }
762
802
  get element() {
763
803
  return this.elementRef.nativeElement;
764
804
  }
@@ -779,21 +819,6 @@ class GanttUpper {
779
819
  }
780
820
  setupItems() {
781
821
  this.originItems = uniqBy(this.originItems, 'id');
782
- // 根据上一次数据展开状态同步新的数据展开状态
783
- this.originItems.forEach((originItem) => {
784
- var _a, _b;
785
- const oldItem = this.items.find((item) => {
786
- return item.id === originItem.id;
787
- });
788
- if (!this.firstChange) {
789
- if (oldItem && !((_a = oldItem.children) === null || _a === void 0 ? void 0 : _a.length) && ((_b = originItem.children) === null || _b === void 0 ? void 0 : _b.length)) {
790
- originItem.expanded = originItem.expanded || this.expandedItemIds.includes(originItem.id);
791
- }
792
- else {
793
- originItem.expanded = this.expandedItemIds.includes(originItem.id);
794
- }
795
- }
796
- });
797
822
  this.items = [];
798
823
  if (this.groups.length > 0) {
799
824
  this.originItems.forEach((origin) => {
@@ -812,17 +837,23 @@ class GanttUpper {
812
837
  }
813
838
  }
814
839
  setupExpandedState() {
840
+ this.originItems = uniqBy(this.originItems, 'id');
815
841
  let items = [];
842
+ const flatOriginItems = getFlatItems(this.originItems);
816
843
  if (this.items.length > 0) {
817
844
  items = recursiveItems(this.items);
818
845
  }
819
846
  else {
820
847
  items = flatten(this.groups.map((group) => recursiveItems(group.items)));
821
848
  }
822
- this.expandedItemIds = [];
823
849
  items.forEach((item) => {
824
850
  if (item.origin.expanded) {
825
- this.expandedItemIds.push(item.id);
851
+ const newItem = flatOriginItems.find((originItem) => originItem.id === item.id);
852
+ if (newItem) {
853
+ if (newItem.expanded === undefined) {
854
+ newItem.expanded = true;
855
+ }
856
+ }
826
857
  }
827
858
  });
828
859
  }
@@ -851,27 +882,40 @@ class GanttUpper {
851
882
  };
852
883
  }
853
884
  computeRefs() {
854
- if (this.computeAllRefs) {
855
- this.groups.forEach((group) => {
856
- const groupItems = recursiveItems(group.items);
857
- this.computeItemsRefs(...groupItems);
858
- });
859
- const items = recursiveItems(this.items);
860
- this.computeItemsRefs(...items);
861
- }
885
+ this.groups.forEach((group) => {
886
+ const groupItems = recursiveItems(group.items);
887
+ this.computeItemsRefs(...groupItems);
888
+ });
889
+ const items = recursiveItems(this.items);
890
+ this.computeItemsRefs(...items);
891
+ }
892
+ expandGroups(expanded) {
893
+ this.groups.forEach((group) => {
894
+ group.setExpand(expanded);
895
+ });
896
+ this.expandChange.next();
897
+ this.cdr.detectChanges();
898
+ }
899
+ initSelectionModel() {
900
+ return new SelectionModel(this.multiple, []);
862
901
  }
863
902
  onInit() {
864
903
  this.styles = Object.assign({}, defaultStyles, this.styles);
904
+ this.viewOptions.dateFormat = Object.assign({}, defaultConfig.dateFormat, this.config.dateFormat, this.viewOptions.dateFormat);
865
905
  this.createView();
866
906
  this.setupGroups();
867
907
  this.setupItems();
868
908
  this.computeRefs();
909
+ this.initSelectionModel();
869
910
  this.firstChange = false;
870
911
  this.ngZone.onStable.pipe(take(1)).subscribe(() => {
871
912
  this.element.style.opacity = '1';
872
913
  this.dragContainer.dragStarted.subscribe((event) => {
873
914
  this.dragStarted.emit(event);
874
915
  });
916
+ this.dragContainer.dragMoved.subscribe((event) => {
917
+ this.dragMoved.emit(event);
918
+ });
875
919
  this.dragContainer.dragEnded.subscribe((event) => {
876
920
  this.dragEnded.emit(event);
877
921
  this.computeRefs();
@@ -912,18 +956,55 @@ class GanttUpper {
912
956
  });
913
957
  });
914
958
  }
915
- trackBy(item, index) {
959
+ trackBy(index, item) {
916
960
  return item.id || index;
917
961
  }
918
962
  detectChanges() {
919
963
  this.cdr.detectChanges();
920
964
  }
965
+ expandGroup(group) {
966
+ group.setExpand(!group.expanded);
967
+ this.expandChange.emit();
968
+ this.cdr.detectChanges();
969
+ }
970
+ // public functions
971
+ expandAll() {
972
+ this.expandGroups(true);
973
+ }
974
+ collapseAll() {
975
+ this.expandGroups(false);
976
+ }
977
+ getGanttItem(id) {
978
+ return this.getGanttItems([id])[0] || null;
979
+ }
980
+ getGanttItems(ids) {
981
+ let items = [];
982
+ if (this.items.length > 0) {
983
+ items = recursiveItems(this.items);
984
+ }
985
+ else {
986
+ items = flatten(this.groups.map((group) => recursiveItems(group.items)));
987
+ }
988
+ return items.filter((item) => ids.includes(item.id));
989
+ }
990
+ isSelected(id) {
991
+ if (!this.selectable) {
992
+ return false;
993
+ }
994
+ if (!this.selectionModel.hasValue()) {
995
+ return false;
996
+ }
997
+ return this.selectionModel.isSelected(id);
998
+ }
921
999
  }
922
- GanttUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttUpper, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
923
- GanttUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.2", type: GanttUpper, inputs: { originItems: ["items", "originItems"], originGroups: ["groups", "originGroups"], viewType: "viewType", start: "start", end: "end", showTodayLine: "showTodayLine", draggable: "draggable", styles: "styles", viewOptions: "viewOptions", disabledLoadOnScroll: "disabledLoadOnScroll" }, outputs: { loadOnScroll: "loadOnScroll", dragStarted: "dragStarted", dragEnded: "dragEnded", barClick: "barClick" }, host: { properties: { "class.gantt": "this.ganttClass" } }, queries: [{ propertyName: "barTemplate", first: true, predicate: ["bar"], descendants: true, static: true }, { propertyName: "rangeTemplate", first: true, predicate: ["range"], descendants: true, static: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, static: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true, static: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ["groupHeader"], descendants: true, static: true }], ngImport: i0 });
1000
+ GanttUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttUpper, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Directive });
1001
+ GanttUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.2", type: GanttUpper, inputs: { originItems: ["items", "originItems"], originGroups: ["groups", "originGroups"], viewType: "viewType", start: "start", end: "end", showTodayLine: "showTodayLine", draggable: "draggable", styles: "styles", viewOptions: "viewOptions", disabledLoadOnScroll: "disabledLoadOnScroll", selectable: "selectable", multiple: "multiple" }, outputs: { loadOnScroll: "loadOnScroll", dragStarted: "dragStarted", dragMoved: "dragMoved", dragEnded: "dragEnded", barClick: "barClick" }, host: { properties: { "class.gantt": "this.ganttClass" } }, queries: [{ propertyName: "barTemplate", first: true, predicate: ["bar"], descendants: true, static: true }, { propertyName: "rangeTemplate", first: true, predicate: ["range"], descendants: true, static: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, static: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true, static: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ["groupHeader"], descendants: true, static: true }], ngImport: i0 });
924
1002
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttUpper, decorators: [{
925
1003
  type: Directive
926
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }]; }, propDecorators: { originItems: [{
1004
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
1005
+ type: Inject,
1006
+ args: [GANTT_GLOBAL_CONFIG]
1007
+ }] }]; }, propDecorators: { originItems: [{
927
1008
  type: Input,
928
1009
  args: ['items']
929
1010
  }], originGroups: [{
@@ -945,10 +1026,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
945
1026
  type: Input
946
1027
  }], disabledLoadOnScroll: [{
947
1028
  type: Input
1029
+ }], selectable: [{
1030
+ type: Input
1031
+ }], multiple: [{
1032
+ type: Input
948
1033
  }], loadOnScroll: [{
949
1034
  type: Output
950
1035
  }], dragStarted: [{
951
1036
  type: Output
1037
+ }], dragMoved: [{
1038
+ type: Output
952
1039
  }], dragEnded: [{
953
1040
  type: Output
954
1041
  }], barClick: [{
@@ -1013,7 +1100,7 @@ class NgxGanttTableComponent {
1013
1100
  ngOnInit() { }
1014
1101
  }
1015
1102
  NgxGanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1016
- NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttTableComponent, selector: "ngx-gantt-table", outputs: { columnChanges: "columnChanges" }, ngImport: i0, template: '', isInline: true });
1103
+ NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttTableComponent, selector: "ngx-gantt-table", outputs: { columnChanges: "columnChanges" }, queries: [{ propertyName: "rowBeforeTemplate", first: true, predicate: ["rowBeforeSlot"], descendants: true, static: true }, { propertyName: "rowAfterTemplate", first: true, predicate: ["rowAfterSlot"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1017
1104
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableComponent, decorators: [{
1018
1105
  type: Component,
1019
1106
  args: [{
@@ -1022,176 +1109,188 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
1022
1109
  }]
1023
1110
  }], ctorParameters: function () { return []; }, propDecorators: { columnChanges: [{
1024
1111
  type: Output
1112
+ }], rowBeforeTemplate: [{
1113
+ type: ContentChild,
1114
+ args: ['rowBeforeSlot', { static: true }]
1115
+ }], rowAfterTemplate: [{
1116
+ type: ContentChild,
1117
+ args: ['rowAfterSlot', { static: true }]
1025
1118
  }] } });
1026
1119
 
1027
- const scrollThreshold = 50;
1028
- var ScrollDirection;
1029
- (function (ScrollDirection) {
1030
- ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
1031
- ScrollDirection[ScrollDirection["LEFT"] = 1] = "LEFT";
1032
- ScrollDirection[ScrollDirection["RIGHT"] = 2] = "RIGHT";
1033
- })(ScrollDirection || (ScrollDirection = {}));
1034
- class GanttDomService {
1035
- constructor() {
1036
- this.unsubscribe$ = new Subject();
1037
- }
1038
- monitorScrollChange() {
1039
- merge(fromEvent(this.mainContainer, 'scroll'), fromEvent(this.sideContainer, 'scroll'))
1040
- .pipe(takeUntil(this.unsubscribe$))
1041
- .subscribe((event) => {
1042
- this.syncScroll(event);
1043
- });
1044
- fromEvent(this.mainContainer, 'scroll')
1045
- .pipe(startWith(), takeUntil(this.unsubscribe$))
1046
- .subscribe((event) => {
1047
- // if (this.mainContainer.scrollLeft > 0) {
1048
- // this.side.classList.add('gantt-side-has-shadow');
1049
- // } else {
1050
- // this.side.classList.remove('gantt-side-has-shadow');
1051
- // }
1052
- });
1053
- }
1054
- syncScroll(event) {
1055
- const target = event.currentTarget;
1056
- this.calendarHeader.scrollLeft = this.mainContainer.scrollLeft;
1057
- this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
1058
- this.sideContainer.scrollTop = target.scrollTop;
1059
- this.mainContainer.scrollTop = target.scrollTop;
1060
- }
1061
- disableBrowserWheelEvent() {
1062
- const container = this.mainContainer;
1063
- fromEvent(container, 'wheel')
1064
- .pipe(takeUntil(this.unsubscribe$))
1065
- .subscribe((event) => {
1066
- const delta = event.deltaX;
1067
- if (!delta) {
1068
- return;
1069
- }
1070
- if ((container.scrollLeft + container.offsetWidth === container.scrollWidth && delta > 0) ||
1071
- (container.scrollLeft === 0 && delta < 0)) {
1072
- event.preventDefault();
1073
- }
1074
- });
1075
- }
1076
- initialize(root) {
1077
- this.root = root.nativeElement;
1078
- this.side = this.root.getElementsByClassName('gantt-side')[0];
1079
- this.container = this.root.getElementsByClassName('gantt-container')[0];
1080
- this.sideContainer = this.root.getElementsByClassName('gantt-side-container')[0];
1081
- this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
1082
- this.calendarHeader = this.root.getElementsByClassName('gantt-calendar-header')[0];
1083
- this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-grid')[0];
1084
- this.monitorScrollChange();
1085
- this.disableBrowserWheelEvent();
1086
- }
1087
- getViewerScroll() {
1088
- return fromEvent(this.mainContainer, 'scroll').pipe(map(() => this.mainContainer.scrollLeft), pairwise(), map(([previous, current]) => {
1089
- const event = {
1090
- target: this.mainContainer,
1091
- direction: ScrollDirection.NONE
1092
- };
1093
- if (current - previous < 0) {
1094
- if (this.mainContainer.scrollLeft < scrollThreshold && this.mainContainer.scrollLeft > 0) {
1095
- event.direction = ScrollDirection.LEFT;
1096
- }
1097
- }
1098
- if (current - previous > 0) {
1099
- if (this.mainContainer.scrollWidth - this.mainContainer.clientWidth - this.mainContainer.scrollLeft < scrollThreshold) {
1100
- event.direction = ScrollDirection.RIGHT;
1101
- }
1102
- }
1103
- return event;
1104
- }));
1120
+ const GANTT_ABSTRACT_TOKEN = new InjectionToken('gantt-abstract-token');
1121
+
1122
+ const angleRight = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="amnavigation/angle-right" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.498l-.005.005L2.3 5.831 3.13 5l4.848 4.848L12.826 5l.83.831-5.673 5.672-.005-.005z" transform="rotate(-90 7.978 8.252)"></path></g></svg>`;
1123
+ const angleDown = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="aknavigation/angle-down" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.997l-.005.006L2.3 6.33l.83-.831 4.848 4.848L12.826 5.5l.83.83-5.673 5.673-.005-.006z" ></path></g></svg>`;
1124
+ const plusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="kxaction/plus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm5.45 6.2V4.75h1.2V7.4h2.65v1.2H8.65v2.65h-1.2V8.6H4.8V7.4h2.65z"></path></g></svg>`;
1125
+ const minusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="jnaction/minus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm2.8 6.2h6.5v1.2H4.8V7.4z"></path></g></svg>`;
1126
+ const loadingIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve">
1127
+ <path fill="#aaa" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)">
1128
+ <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform>
1129
+ </path>
1130
+ </svg>`;
1131
+ const emptyIcon = `<svg
1132
+ width="148px"
1133
+ height="134px"
1134
+ viewBox="0 0 148 134"
1135
+ version="1.1"
1136
+ xmlns="http://www.w3.org/2000/svg"
1137
+ xmlns:xlink="http://www.w3.org/1999/xlink"
1138
+ >
1139
+ <defs>
1140
+ <filter x="0.0%" y="0.0%" width="100.0%" height="100.0%" filterUnits="objectBoundingBox" id="filter-1">
1141
+ <feGaussianBlur stdDeviation="0" in="SourceGraphic"></feGaussianBlur>
1142
+ </filter>
1143
+ </defs>
1144
+ <g id="148x134" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1145
+ <g id="编组-6" transform="translate(1.000000, 1.000000)">
1146
+ <ellipse
1147
+ id="椭圆形"
1148
+ fill="#EDEEF2"
1149
+ opacity="0.3"
1150
+ filter="url(#filter-1)"
1151
+ cx="73.0800017"
1152
+ cy="115.920003"
1153
+ rx="73.0800017"
1154
+ ry="16.8000004"
1155
+ ></ellipse>
1156
+ <g id="编组-5" transform="translate(15.120000, 0.000000)">
1157
+ <polygon
1158
+ id="矩形"
1159
+ fill="#E2E4E9"
1160
+ points="19.2789848 49.5600011 99.1200023 48.7200011 117.600003 75.9297673 117.600003 92.313049 0 92.313049 0 75.0356267"
1161
+ ></polygon>
1162
+ <path
1163
+ d="M23.5200005,0 L94.0800002,0 C97.7913538,2.06413823e-16 100.8,3.00864655 100.8,6.72000015 L100.8,99.1200023 L100.8,99.1200023 L16.8000004,99.1200023 L16.8000004,6.72000015 C16.8000004,3.00864655 19.8086469,1.56994302e-15 23.5200005,0 Z"
1164
+ id="矩形"
1165
+ fill="#F9FAFB"
1166
+ ></path>
1167
+ <path
1168
+ d="M30.9200007,12.4400003 L86.6800019,12.4400003 C88.5356787,12.4400003 90.040002,13.9443236 90.040002,15.8000004 L90.040002,42.000001 C90.040002,43.8556778 88.5356787,45.360001 86.6800019,45.360001 L30.9200007,45.360001 C29.0643239,45.360001 27.5600006,43.8556778 27.5600006,42.000001 L27.5600006,15.8000004 C27.5600006,13.9443236 29.0643239,12.4400003 30.9200007,12.4400003 Z"
1169
+ id="矩形"
1170
+ fill="#E8EAEE"
1171
+ ></path>
1172
+ <text
1173
+ id="&lt;/null&gt;"
1174
+ font-family="PingFangSC-Medium, PingFang SC"
1175
+ font-size="15.1200003"
1176
+ font-weight="400"
1177
+ fill="#BCBECD"
1178
+ >
1179
+ <tspan x="33.6000008" y="32.8000004">&lt;/null&gt;</tspan>
1180
+ </text>
1181
+ <rect id="矩形" fill="#E8EAEE" x="27.5600006" y="52.0800012" width="61.4800014" height="5.04000011" rx="2.52000006"></rect>
1182
+ <rect
1183
+ id="矩形备份"
1184
+ fill="#E8EAEE"
1185
+ x="27.5600006"
1186
+ y="63.8400014"
1187
+ width="61.4800014"
1188
+ height="5.04000011"
1189
+ rx="2.52000006"
1190
+ ></rect>
1191
+ <path
1192
+ d="M0,75.6000017 L29.280235,75.6000017 C32.0637502,75.6000017 34.3202352,77.8564866 34.3202352,80.6400018 L34.3202352,86.2591426 C34.3202352,89.0426578 36.5767201,91.2991427 39.3602353,91.2991427 L78.4136737,91.2991427 C81.1971889,91.2991427 83.4536738,89.0426578 83.4536738,86.2591426 L83.4536738,80.6400018 C83.4536738,77.8564866 85.7101587,75.6000017 88.4936739,75.6000017 L117.600003,75.6000017 L117.600003,75.6000017 L117.600003,110.880003 C117.600003,115.519195 113.839194,119.280003 109.200002,119.280003 L8.40000019,119.280003 C3.76080819,119.280003 -6.53729019e-15,115.519195 0,110.880003 L0,75.6000017 L0,75.6000017 Z"
1193
+ id="矩形"
1194
+ fill="#EDEFF2"
1195
+ ></path>
1196
+ </g>
1197
+ </g>
1198
+ </g>
1199
+ </svg>`;
1200
+ const icons = {
1201
+ 'angle-right': angleRight,
1202
+ 'angle-down': angleDown,
1203
+ 'plus-square': plusSquare,
1204
+ 'minus-square': minusSquare,
1205
+ loading: loadingIcon,
1206
+ empty: emptyIcon
1207
+ };
1208
+
1209
+ class GanttIconComponent {
1210
+ constructor(elementRef) {
1211
+ this.elementRef = elementRef;
1212
+ this.isIcon = true;
1105
1213
  }
1106
- getResize() {
1107
- return fromEvent(window, 'resize').pipe(auditTime(150));
1214
+ set iconName(name) {
1215
+ this.setSvg(name);
1108
1216
  }
1109
- scrollMainContainer(left) {
1110
- if (isNumber(left)) {
1111
- const scrollLeft = left - this.mainContainer.clientWidth / 2;
1112
- this.mainContainer.scrollLeft = scrollLeft > scrollThreshold ? scrollLeft : 0;
1113
- this.calendarHeader.scrollLeft = this.mainContainer.scrollLeft;
1114
- this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
1217
+ ngOnInit() { }
1218
+ ngAfterViewInit() { }
1219
+ setSvg(name) {
1220
+ const iconSvg = icons[name];
1221
+ if (iconSvg) {
1222
+ this.elementRef.nativeElement.innerHTML = iconSvg;
1223
+ }
1224
+ else {
1225
+ this.elementRef.nativeElement.innerHTML = '';
1115
1226
  }
1116
- }
1117
- ngOnDestroy() {
1118
- this.unsubscribe$.next();
1119
- this.unsubscribe$.complete();
1120
1227
  }
1121
1228
  }
1122
- GanttDomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1123
- GanttDomServiceprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService });
1124
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService, decorators: [{
1125
- type: Injectable
1126
- }], ctorParameters: function () { return []; } });
1229
+ GanttIconComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttIconComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1230
+ GanttIconComponentcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttIconComponent, selector: "gantt-icon", inputs: { iconName: "iconName" }, host: { properties: { "class.gantt-icon": "this.isIcon" } }, ngImport: i0, template: '', isInline: true });
1231
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttIconComponent, decorators: [{
1232
+ type: Component,
1233
+ args: [{
1234
+ selector: 'gantt-icon',
1235
+ template: ''
1236
+ }]
1237
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { isIcon: [{
1238
+ type: HostBinding,
1239
+ args: ['class.gantt-icon']
1240
+ }], iconName: [{
1241
+ type: Input
1242
+ }] } });
1127
1243
 
1128
- class GanttDragContainer {
1129
- constructor() {
1130
- this.dragStarted = new EventEmitter();
1131
- this.dragEnded = new EventEmitter();
1132
- this.linkDragStarted = new EventEmitter();
1133
- this.linkDragEntered = new EventEmitter();
1134
- this.linkDragEnded = new EventEmitter();
1135
- }
1136
- emitLinkDragStarted(from, item) {
1137
- this.linkDraggingId = item.id;
1138
- this.linkDragFrom = from;
1139
- this.linkDragSource = this.linkDragFrom === 'source' ? item : null;
1140
- this.linkDragTarget = this.linkDragFrom === 'target' ? item : null;
1141
- this.linkDragStarted.emit({
1142
- source: this.linkDragSource && this.linkDragSource.origin,
1143
- target: this.linkDragTarget && this.linkDragTarget.origin
1144
- });
1145
- }
1146
- emitLinkDragEntered(item) {
1147
- if (this.linkDragFrom === 'source') {
1148
- this.linkDragTarget = item;
1149
- }
1150
- else {
1151
- this.linkDragSource = item;
1152
- }
1153
- this.linkDragEntered.emit({
1154
- source: this.linkDragSource.origin,
1155
- target: this.linkDragTarget.origin
1156
- });
1244
+ class IsGanttRangeItemPipe {
1245
+ transform(value) {
1246
+ return value === GanttItemType.range;
1157
1247
  }
1158
- emitLinkDragLeaved() {
1159
- if (this.linkDragFrom === 'source') {
1160
- this.linkDragTarget = null;
1161
- }
1162
- else {
1163
- this.linkDragSource = null;
1164
- }
1248
+ }
1249
+ IsGanttRangeItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1250
+ IsGanttRangeItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, name: "isGanttRangeItem" });
1251
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, decorators: [{
1252
+ type: Pipe,
1253
+ args: [{
1254
+ name: 'isGanttRangeItem'
1255
+ }]
1256
+ }] });
1257
+ class IsGanttBarItemPipe {
1258
+ transform(value) {
1259
+ return value === GanttItemType.bar;
1165
1260
  }
1166
- emitLinkDragEnded() {
1167
- this.linkDraggingId = null;
1168
- if (this.linkDragSource && this.linkDragTarget) {
1169
- this.linkDragSource.addLink(this.linkDragTarget.id);
1170
- this.linkDragEnded.emit({
1171
- source: this.linkDragSource.origin,
1172
- target: this.linkDragTarget.origin
1173
- });
1174
- }
1175
- this.linkDragSource = null;
1176
- this.linkDragTarget = null;
1261
+ }
1262
+ IsGanttBarItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1263
+ IsGanttBarItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, name: "isGanttBarItem" });
1264
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, decorators: [{
1265
+ type: Pipe,
1266
+ args: [{
1267
+ name: 'isGanttBarItem'
1268
+ }]
1269
+ }] });
1270
+ class IsGanttCustomItemPipe {
1271
+ transform(value) {
1272
+ return value === GanttItemType.custom;
1177
1273
  }
1178
1274
  }
1179
- GanttDragContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1180
- GanttDragContainerprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer });
1181
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer, decorators: [{
1182
- type: Injectable
1183
- }], ctorParameters: function () { return []; } });
1184
-
1185
- const GANTT_ABSTRACT_TOKEN = new InjectionToken('gantt-abstract-token');
1275
+ IsGanttCustomItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1276
+ IsGanttCustomItemPipepipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, name: "isGanttCustomItem" });
1277
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, decorators: [{
1278
+ type: Pipe,
1279
+ args: [{
1280
+ name: 'isGanttCustomItem'
1281
+ }]
1282
+ }] });
1186
1283
 
1187
1284
  const defaultColumnWidth = 100;
1188
1285
  const minColumnWidth = 80;
1189
- class GanttTableHeaderComponent {
1190
- constructor(elementRef, gantt) {
1191
- this.elementRef = elementRef;
1286
+ class GanttTableComponent {
1287
+ constructor(gantt, ganttUpper, elementRef) {
1192
1288
  this.gantt = gantt;
1193
- this.tableWidth = 0;
1194
- this.className = `gantt-table-header gantt-table-row`;
1289
+ this.ganttUpper = ganttUpper;
1290
+ this.elementRef = elementRef;
1291
+ this.itemClick = new EventEmitter();
1292
+ this.ganttTableClass = true;
1293
+ this.ganttTableEmptyClass = false;
1195
1294
  }
1196
1295
  set columns(columns) {
1197
1296
  columns.forEach((column) => {
@@ -1202,14 +1301,27 @@ class GanttTableHeaderComponent {
1202
1301
  this.columnList = columns;
1203
1302
  }
1204
1303
  ngOnInit() { }
1205
- ngAfterViewInit() {
1206
- this.tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
1304
+ ngOnChanges(changes) {
1305
+ var _a, _b;
1306
+ if (!((_a = changes.groups.currentValue) === null || _a === void 0 ? void 0 : _a.length) && !((_b = changes.items.currentValue) === null || _b === void 0 ? void 0 : _b.length)) {
1307
+ this.ganttTableEmptyClass = true;
1308
+ }
1309
+ else {
1310
+ this.ganttTableEmptyClass = false;
1311
+ }
1207
1312
  }
1208
1313
  dragFixed(config) {
1209
1314
  if (config.movedWidth < config.minWidth) {
1210
1315
  config.target.style.transform = `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`;
1211
1316
  }
1212
1317
  }
1318
+ expandGroup(group) {
1319
+ this.gantt.expandGroup(group);
1320
+ }
1321
+ expandChildren(event, item) {
1322
+ event.stopPropagation();
1323
+ this.gantt.expandChildren(item);
1324
+ }
1213
1325
  dragStarted(event) {
1214
1326
  const target = event.source.element.nativeElement;
1215
1327
  this.dragStartLeft = target.getBoundingClientRect().left;
@@ -1239,7 +1351,6 @@ class GanttTableHeaderComponent {
1239
1351
  this.showAuxiliaryLine(event);
1240
1352
  }
1241
1353
  columnDragEnded(event, column) {
1242
- const beforeWidth = parseInt(column.columnWidth, 10);
1243
1354
  const target = event.source.element.nativeElement;
1244
1355
  const left = target.getBoundingClientRect().left;
1245
1356
  const width = parseInt(column.columnWidth, 10) + (left - this.dragStartLeft);
@@ -1248,7 +1359,6 @@ class GanttTableHeaderComponent {
1248
1359
  if (this.gantt.table) {
1249
1360
  this.gantt.table.columnChanges.emit({ columns: this.columnList });
1250
1361
  }
1251
- this.tableWidth = this.tableWidth - beforeWidth + columnWidth;
1252
1362
  this.hideAuxiliaryLine();
1253
1363
  event.source.reset();
1254
1364
  }
@@ -1257,15 +1367,12 @@ class GanttTableHeaderComponent {
1257
1367
  const left = target.getBoundingClientRect().left;
1258
1368
  const tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
1259
1369
  const dragWidth = left - this.dragStartLeft;
1260
- let tempWidth = 0;
1261
1370
  this.columnList.forEach((column) => {
1262
1371
  const lastColumnWidth = parseInt(column.columnWidth, 10);
1263
1372
  const distributeWidth = parseInt(String(dragWidth * (lastColumnWidth / tableWidth)), 10);
1264
1373
  const columnWidth = Math.max(lastColumnWidth + distributeWidth || 0, minColumnWidth);
1265
1374
  column.columnWidth = coerceCssPixelValue(columnWidth);
1266
- tempWidth += columnWidth;
1267
1375
  });
1268
- this.tableWidth = tempWidth;
1269
1376
  if (this.gantt.table) {
1270
1377
  this.gantt.table.columnChanges.emit({ columns: this.columnList });
1271
1378
  }
@@ -1282,89 +1389,268 @@ class GanttTableHeaderComponent {
1282
1389
  hideAuxiliaryLine() {
1283
1390
  this.draglineElementRef.nativeElement.style.display = 'none';
1284
1391
  }
1392
+ trackBy(index, item) {
1393
+ return item.id || index;
1394
+ }
1285
1395
  }
1286
- GanttTableHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableHeaderComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_ABSTRACT_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
1287
- GanttTableHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttTableHeaderComponent, selector: "gantt-table-header", inputs: { columns: "columns" }, host: { properties: { "class": "this.className" } }, viewQueries: [{ propertyName: "draglineElementRef", first: true, predicate: ["dragLine"], descendants: true, static: true }], ngImport: i0, template: "<div\n class=\"gantt-table-column\"\n [class.border-right-0]=\"i === columnList.length - 1\"\n *ngFor=\"let column of columnList; let i = index\"\n [style.width]=\"column.columnWidth\"\n>\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"></ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"column-drag-trigger gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event, column)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"columnDragEnded($event, column)\"\n ></div>\n</div>\n\n<div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"tableDragEnded($event)\"\n></div>\n\n<div #dragLine class=\"gantt-table-drag-auxiliary-line\"></div>\n", directives: [{ type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i1$1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragDisabled", "cdkDragStartDelay", "cdkDragLockAxis", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragBoundary", "cdkDragRootElement", "cdkDragPreviewContainer", "cdkDragData", "cdkDragFreeDragPosition"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }] });
1288
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableHeaderComponent, decorators: [{
1396
+ GanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableComponent, deps: [{ token: GANTT_ABSTRACT_TOKEN }, { token: GANTT_UPPER_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1397
+ GanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttTableComponent, selector: "gantt-table", inputs: { groups: "groups", items: "items", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate", rowBeforeTemplate: "rowBeforeTemplate", rowAfterTemplate: "rowAfterTemplate" }, outputs: { itemClick: "itemClick" }, host: { properties: { "class.gantt-table": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass" } }, viewQueries: [{ propertyName: "draglineElementRef", first: true, predicate: ["dragLine"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-table-header gantt-table-row\">\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let i = index\" [style.width]=\"column.columnWidth\">\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"></ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event, column)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"columnDragEnded($event, column)\"\n ></div>\n </div>\n</div>\n<div class=\"gantt-table-body\">\n <ng-container *ngIf=\"!groups.length && !items.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"groups && groups.length > 0; else itemsTemplate\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"group.class\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"group.expanded\" (click)=\"expandGroup(group)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"group.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: group.origin, group: group.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ group.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <ng-container *ngIf=\"group.expanded\">\n <ng-template\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ group: group, items: group.items, level: 0 }\"\n ></ng-template>\n </ng-container>\n </ng-container>\n </ng-container>\n</div>\n\n<div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"tableDragEnded($event)\"\n></div>\n\n<div #dragLine class=\"gantt-table-drag-auxiliary-line\"></div>\n\n<ng-template #itemsTemplate>\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items, level: 0 }\"></ng-template>\n</ng-template>\n\n<ng-template #ganttItems let-group=\"group\" let-items=\"items\" let-level=\"level\">\n <ng-container *ngFor=\"let item of items; trackBy: trackBy\">\n <div\n (click)=\"itemClick.emit({ event: $event, selectedValue: this.item.origin })\"\n class=\"gantt-table-item gantt-table-row\"\n [class.gantt-table-item-first-level-group]=\"level === 0 && (item.type | isGanttRangeItem)\"\n [class.gantt-table-item-with-group]=\"group\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let first = first\" [style.width]=\"column.columnWidth\">\n <div *ngIf=\"first\" class=\"gantt-expand-icon\" [style.marginLeft.px]=\"level * 20\">\n <ng-container *ngIf=\"level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n ></gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children, level: level + 1, group: group }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n", components: [{ type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }], directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragDisabled", "cdkDragStartDelay", "cdkDragLockAxis", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragBoundary", "cdkDragRootElement", "cdkDragData", "cdkDragFreeDragPosition"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], pipes: { "isGanttRangeItem": IsGanttRangeItemPipe } });
1398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableComponent, decorators: [{
1289
1399
  type: Component,
1290
1400
  args: [{
1291
- selector: 'gantt-table-header',
1292
- templateUrl: './gantt-table-header.component.html'
1401
+ selector: 'gantt-table',
1402
+ templateUrl: './gantt-table.component.html'
1293
1403
  }]
1294
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
1404
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1295
1405
  type: Inject,
1296
1406
  args: [GANTT_ABSTRACT_TOKEN]
1297
- }] }]; }, propDecorators: { columns: [{
1407
+ }] }, { type: GanttUpper, decorators: [{
1408
+ type: Inject,
1409
+ args: [GANTT_UPPER_TOKEN]
1410
+ }] }, { type: i0.ElementRef }]; }, propDecorators: { groups: [{
1411
+ type: Input
1412
+ }], items: [{
1413
+ type: Input
1414
+ }], columns: [{
1415
+ type: Input
1416
+ }], groupTemplate: [{
1417
+ type: Input
1418
+ }], emptyTemplate: [{
1419
+ type: Input
1420
+ }], rowBeforeTemplate: [{
1298
1421
  type: Input
1422
+ }], rowAfterTemplate: [{
1423
+ type: Input
1424
+ }], itemClick: [{
1425
+ type: Output
1299
1426
  }], draglineElementRef: [{
1300
1427
  type: ViewChild,
1301
1428
  args: ['dragLine', { static: true }]
1302
- }], className: [{
1429
+ }], ganttTableClass: [{
1430
+ type: HostBinding,
1431
+ args: ['class.gantt-table']
1432
+ }], ganttTableEmptyClass: [{
1303
1433
  type: HostBinding,
1304
- args: ['class']
1434
+ args: ['class.gantt-table-empty']
1305
1435
  }] } });
1306
1436
 
1307
- class GanttPrintService {
1308
- constructor() { }
1309
- setInlineStyles(targetElem) {
1310
- const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
1311
- for (const svgElement of svgElements) {
1312
- this.recursElementChildren(svgElement);
1313
- }
1437
+ const scrollThreshold = 50;
1438
+ var ScrollDirection;
1439
+ (function (ScrollDirection) {
1440
+ ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
1441
+ ScrollDirection[ScrollDirection["LEFT"] = 1] = "LEFT";
1442
+ ScrollDirection[ScrollDirection["RIGHT"] = 2] = "RIGHT";
1443
+ })(ScrollDirection || (ScrollDirection = {}));
1444
+ class GanttDomService {
1445
+ constructor() {
1446
+ this.unsubscribe$ = new Subject();
1314
1447
  }
1315
- recursElementChildren(node) {
1316
- const transformProperties = [
1317
- 'fill',
1318
- 'color',
1319
- 'font-size',
1320
- 'stroke',
1321
- 'font',
1322
- 'text-anchor',
1323
- 'stroke-dasharray',
1324
- 'shape-rendering',
1325
- 'stroke-width'
1326
- ];
1327
- if (!node.style) {
1328
- return;
1329
- }
1330
- const styles = getComputedStyle(node);
1331
- for (const transformProperty of transformProperties) {
1332
- node.style[transformProperty] = styles[transformProperty];
1333
- }
1334
- for (const child of Array.from(node.childNodes)) {
1335
- this.recursElementChildren(child);
1336
- }
1448
+ monitorScrollChange() {
1449
+ merge(fromEvent(this.mainContainer, 'scroll'), fromEvent(this.sideContainer, 'scroll'))
1450
+ .pipe(takeUntil(this.unsubscribe$))
1451
+ .subscribe((event) => {
1452
+ this.syncScroll(event);
1453
+ });
1454
+ fromEvent(this.mainContainer, 'scroll')
1455
+ .pipe(startWith(), takeUntil(this.unsubscribe$))
1456
+ .subscribe((event) => {
1457
+ // if (this.mainContainer.scrollLeft > 0) {
1458
+ // this.side.classList.add('gantt-side-has-shadow');
1459
+ // } else {
1460
+ // this.side.classList.remove('gantt-side-has-shadow');
1461
+ // }
1462
+ });
1337
1463
  }
1338
- register(root) {
1464
+ syncScroll(event) {
1465
+ const target = event.currentTarget;
1466
+ this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
1467
+ this.sideContainer.scrollTop = target.scrollTop;
1468
+ this.mainContainer.scrollTop = target.scrollTop;
1469
+ }
1470
+ disableBrowserWheelEvent() {
1471
+ const container = this.mainContainer;
1472
+ fromEvent(container, 'wheel')
1473
+ .pipe(takeUntil(this.unsubscribe$))
1474
+ .subscribe((event) => {
1475
+ const delta = event.deltaX;
1476
+ if (!delta) {
1477
+ return;
1478
+ }
1479
+ if ((container.scrollLeft + container.offsetWidth === container.scrollWidth && delta > 0) ||
1480
+ (container.scrollLeft === 0 && delta < 0)) {
1481
+ event.preventDefault();
1482
+ }
1483
+ });
1484
+ }
1485
+ initialize(root) {
1339
1486
  this.root = root.nativeElement;
1487
+ this.side = this.root.getElementsByClassName('gantt-side')[0];
1488
+ this.container = this.root.getElementsByClassName('gantt-container')[0];
1489
+ this.sideContainer = this.root.getElementsByClassName('gantt-side-container')[0];
1340
1490
  this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
1491
+ this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-overlay')[0];
1492
+ this.monitorScrollChange();
1493
+ this.disableBrowserWheelEvent();
1341
1494
  }
1342
- print(name = 'download', ignoreElementClass) {
1343
- const root = this.root;
1344
- const mainContainer = this.mainContainer;
1345
- // set print width
1346
- const printWidth = root.offsetWidth;
1347
- // set print height
1348
- const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
1349
- html2canvas(root, {
1350
- logging: false,
1351
- allowTaint: true,
1352
- useCORS: true,
1353
- width: printWidth,
1354
- height: printHeight,
1355
- ignoreElements: (element) => {
1356
- if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
1357
- return true;
1358
- }
1359
- if (element.classList.contains('gantt-calendar-today-overlay')) {
1360
- return true;
1495
+ getViewerScroll() {
1496
+ return fromEvent(this.mainContainer, 'scroll').pipe(map(() => this.mainContainer.scrollLeft), pairwise(), map(([previous, current]) => {
1497
+ const event = {
1498
+ target: this.mainContainer,
1499
+ direction: ScrollDirection.NONE
1500
+ };
1501
+ if (current - previous < 0) {
1502
+ if (this.mainContainer.scrollLeft < scrollThreshold && this.mainContainer.scrollLeft > 0) {
1503
+ event.direction = ScrollDirection.LEFT;
1504
+ }
1505
+ }
1506
+ if (current - previous > 0) {
1507
+ if (this.mainContainer.scrollWidth - this.mainContainer.clientWidth - this.mainContainer.scrollLeft < scrollThreshold) {
1508
+ event.direction = ScrollDirection.RIGHT;
1509
+ }
1510
+ }
1511
+ return event;
1512
+ }));
1513
+ }
1514
+ getResize() {
1515
+ return fromEvent(window, 'resize').pipe(auditTime(150));
1516
+ }
1517
+ scrollMainContainer(left) {
1518
+ if (isNumber(left)) {
1519
+ const scrollLeft = left - this.mainContainer.clientWidth / 2;
1520
+ this.mainContainer.scrollLeft = scrollLeft > scrollThreshold ? scrollLeft : 0;
1521
+ this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
1522
+ }
1523
+ }
1524
+ ngOnDestroy() {
1525
+ this.unsubscribe$.next();
1526
+ this.unsubscribe$.complete();
1527
+ }
1528
+ }
1529
+ GanttDomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1530
+ GanttDomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService });
1531
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService, decorators: [{
1532
+ type: Injectable
1533
+ }], ctorParameters: function () { return []; } });
1534
+
1535
+ class GanttDragContainer {
1536
+ constructor() {
1537
+ this.dragStarted = new EventEmitter();
1538
+ this.dragMoved = new EventEmitter();
1539
+ this.dragEnded = new EventEmitter();
1540
+ this.linkDragStarted = new EventEmitter();
1541
+ this.linkDragEntered = new EventEmitter();
1542
+ this.linkDragEnded = new EventEmitter();
1543
+ }
1544
+ emitLinkDragStarted(from, item) {
1545
+ this.linkDraggingId = item.id;
1546
+ this.linkDragFrom = from;
1547
+ this.linkDragSource = this.linkDragFrom === 'source' ? item : null;
1548
+ this.linkDragTarget = this.linkDragFrom === 'target' ? item : null;
1549
+ this.linkDragStarted.emit({
1550
+ source: this.linkDragSource && this.linkDragSource.origin,
1551
+ target: this.linkDragTarget && this.linkDragTarget.origin
1552
+ });
1553
+ }
1554
+ emitLinkDragEntered(item) {
1555
+ if (this.linkDragFrom === 'source') {
1556
+ this.linkDragTarget = item;
1557
+ }
1558
+ else {
1559
+ this.linkDragSource = item;
1560
+ }
1561
+ this.linkDragEntered.emit({
1562
+ source: this.linkDragSource.origin,
1563
+ target: this.linkDragTarget.origin
1564
+ });
1565
+ }
1566
+ emitLinkDragLeaved() {
1567
+ if (this.linkDragFrom === 'source') {
1568
+ this.linkDragTarget = null;
1569
+ }
1570
+ else {
1571
+ this.linkDragSource = null;
1572
+ }
1573
+ }
1574
+ emitLinkDragEnded() {
1575
+ this.linkDraggingId = null;
1576
+ if (this.linkDragSource && this.linkDragTarget) {
1577
+ this.linkDragSource.addLink(this.linkDragTarget.id);
1578
+ this.linkDragEnded.emit({
1579
+ source: this.linkDragSource.origin,
1580
+ target: this.linkDragTarget.origin
1581
+ });
1582
+ }
1583
+ this.linkDragSource = null;
1584
+ this.linkDragTarget = null;
1585
+ }
1586
+ }
1587
+ GanttDragContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1588
+ GanttDragContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer });
1589
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer, decorators: [{
1590
+ type: Injectable
1591
+ }], ctorParameters: function () { return []; } });
1592
+
1593
+ class GanttPrintService {
1594
+ constructor() { }
1595
+ setInlineStyles(targetElem) {
1596
+ const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
1597
+ for (const svgElement of svgElements) {
1598
+ this.recursElementChildren(svgElement);
1599
+ }
1600
+ }
1601
+ recursElementChildren(node) {
1602
+ const transformProperties = [
1603
+ 'fill',
1604
+ 'color',
1605
+ 'font-size',
1606
+ 'stroke',
1607
+ 'font',
1608
+ 'text-anchor',
1609
+ 'stroke-dasharray',
1610
+ 'shape-rendering',
1611
+ 'stroke-width'
1612
+ ];
1613
+ if (!node.style) {
1614
+ return;
1615
+ }
1616
+ const styles = getComputedStyle(node);
1617
+ for (const transformProperty of transformProperties) {
1618
+ node.style[transformProperty] = styles[transformProperty];
1619
+ }
1620
+ for (const child of Array.from(node.childNodes)) {
1621
+ this.recursElementChildren(child);
1622
+ }
1623
+ }
1624
+ register(root) {
1625
+ this.root = root.nativeElement;
1626
+ this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
1627
+ }
1628
+ print(name = 'download', ignoreElementClass) {
1629
+ const root = this.root;
1630
+ const mainContainer = this.mainContainer;
1631
+ // set print width
1632
+ const printWidth = root.offsetWidth;
1633
+ // set print height
1634
+ const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
1635
+ html2canvas(root, {
1636
+ logging: false,
1637
+ allowTaint: true,
1638
+ useCORS: true,
1639
+ width: printWidth,
1640
+ height: printHeight,
1641
+ ignoreElements: (element) => {
1642
+ if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
1643
+ return true;
1644
+ }
1645
+ if (element.classList.contains('gantt-calendar-today-overlay')) {
1646
+ return true;
1361
1647
  }
1362
1648
  },
1363
1649
  onclone: (cloneDocument) => {
1364
1650
  const ganttClass = root.className;
1365
1651
  const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
1366
1652
  const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
1367
- const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-grid-main');
1653
+ const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
1368
1654
  const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
1369
1655
  // change targetDom width
1370
1656
  cloneGanttDom.style.width = `${printWidth}px`;
@@ -1395,351 +1681,207 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
1395
1681
  type: Injectable
1396
1682
  }], ctorParameters: function () { return []; } });
1397
1683
 
1398
- class GanttCalendarHeaderComponent {
1684
+ const mainHeight = 5000;
1685
+ class GanttCalendarComponent {
1399
1686
  constructor(ganttUpper, ngZone, elementRef) {
1400
1687
  this.ganttUpper = ganttUpper;
1401
1688
  this.ngZone = ngZone;
1402
1689
  this.elementRef = elementRef;
1403
1690
  this.unsubscribe$ = new Subject();
1404
1691
  this.headerHeight = headerHeight;
1692
+ this.mainHeight = mainHeight;
1693
+ this.todayHeight = todayHeight;
1694
+ this.todayWidth = todayWidth;
1695
+ this.todayBorderRadius = todayBorderRadius;
1405
1696
  this.viewTypes = GanttViewType;
1406
- this.className = `gantt-calendar gantt-calendar-header`;
1697
+ this.className = true;
1407
1698
  }
1408
1699
  get view() {
1409
1700
  return this.ganttUpper.view;
1410
1701
  }
1411
- ngOnInit() {
1412
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1413
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
1414
- .pipe(takeUntil(this.unsubscribe$))
1415
- .subscribe(() => {
1416
- if (this.ganttUpper.viewType === GanttViewType.day)
1417
- this.setTodayPoint();
1418
- });
1419
- });
1420
- }
1421
1702
  setTodayPoint() {
1422
1703
  const x = this.view.getTodayXPoint();
1423
1704
  const today = new GanttDate().getDate();
1424
1705
  const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
1425
1706
  const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
1707
+ const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
1426
1708
  if (isNumber(x)) {
1427
1709
  if (rect) {
1428
1710
  rect.style.left = `${x - todayWidth / 2}px`;
1429
1711
  rect.style.top = `${headerHeight - todayHeight}px`;
1430
1712
  rect.innerHTML = today.toString();
1431
1713
  }
1714
+ if (line) {
1715
+ line.style.left = `${x}px`;
1716
+ line.style.top = `${headerHeight}px`;
1717
+ line.style.bottom = `${-mainHeight}px`;
1718
+ }
1432
1719
  }
1433
1720
  else {
1434
1721
  todayEle.style.display = 'none';
1435
1722
  }
1436
1723
  }
1437
- trackBy(point, index) {
1724
+ ngOnInit() {
1725
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1726
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
1727
+ .pipe(takeUntil(this.unsubscribe$))
1728
+ .subscribe(() => {
1729
+ this.setTodayPoint();
1730
+ });
1731
+ });
1732
+ }
1733
+ ngAfterViewInit() { }
1734
+ ngOnChanges(changes) { }
1735
+ trackBy(index, point) {
1438
1736
  return point.text || index;
1439
1737
  }
1738
+ ngOnDestroy() {
1739
+ this.unsubscribe$.next();
1740
+ this.unsubscribe$.complete();
1741
+ }
1440
1742
  }
1441
- GanttCalendarHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarHeaderComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1442
- GanttCalendarHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header", host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n</div>\n<svg [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"headerHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n</svg>\n", directives: [{ type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1443
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
1743
+ GanttCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1744
+ GanttCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttCalendarComponent, selector: "gantt-calendar-overlay", host: { properties: { "class.gantt-calendar-overlay": "this.className" } }, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1745
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarComponent, decorators: [{
1444
1746
  type: Component,
1445
1747
  args: [{
1446
- selector: 'gantt-calendar-header',
1447
- templateUrl: './calendar-header.component.html'
1748
+ selector: 'gantt-calendar-overlay',
1749
+ templateUrl: './calendar.component.html'
1448
1750
  }]
1449
1751
  }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1450
1752
  type: Inject,
1451
1753
  args: [GANTT_UPPER_TOKEN]
1452
1754
  }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
1453
1755
  type: HostBinding,
1454
- args: ['class']
1455
- }] } });
1456
-
1457
- const angleRight = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="amnavigation/angle-right" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.498l-.005.005L2.3 5.831 3.13 5l4.848 4.848L12.826 5l.83.831-5.673 5.672-.005-.005z" transform="rotate(-90 7.978 8.252)"></path></g></svg>`;
1458
- const angleDown = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="aknavigation/angle-down" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.997l-.005.006L2.3 6.33l.83-.831 4.848 4.848L12.826 5.5l.83.83-5.673 5.673-.005-.006z" ></path></g></svg>`;
1459
- const plusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="kxaction/plus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm5.45 6.2V4.75h1.2V7.4h2.65v1.2H8.65v2.65h-1.2V8.6H4.8V7.4h2.65z"></path></g></svg>`;
1460
- const minusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="jnaction/minus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm2.8 6.2h6.5v1.2H4.8V7.4z"></path></g></svg>`;
1461
- const loadingIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve">
1462
- <path fill="#aaa" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)">
1463
- <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform>
1464
- </path>
1465
- </svg>`;
1466
- const emptyIcon = `<svg
1467
- width="148px"
1468
- height="134px"
1469
- viewBox="0 0 148 134"
1470
- version="1.1"
1471
- xmlns="http://www.w3.org/2000/svg"
1472
- xmlns:xlink="http://www.w3.org/1999/xlink"
1473
- >
1474
- <defs>
1475
- <filter x="0.0%" y="0.0%" width="100.0%" height="100.0%" filterUnits="objectBoundingBox" id="filter-1">
1476
- <feGaussianBlur stdDeviation="0" in="SourceGraphic"></feGaussianBlur>
1477
- </filter>
1478
- </defs>
1479
- <g id="148x134" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1480
- <g id="编组-6" transform="translate(1.000000, 1.000000)">
1481
- <ellipse
1482
- id="椭圆形"
1483
- fill="#EDEEF2"
1484
- opacity="0.3"
1485
- filter="url(#filter-1)"
1486
- cx="73.0800017"
1487
- cy="115.920003"
1488
- rx="73.0800017"
1489
- ry="16.8000004"
1490
- ></ellipse>
1491
- <g id="编组-5" transform="translate(15.120000, 0.000000)">
1492
- <polygon
1493
- id="矩形"
1494
- fill="#E2E4E9"
1495
- points="19.2789848 49.5600011 99.1200023 48.7200011 117.600003 75.9297673 117.600003 92.313049 0 92.313049 0 75.0356267"
1496
- ></polygon>
1497
- <path
1498
- d="M23.5200005,0 L94.0800002,0 C97.7913538,2.06413823e-16 100.8,3.00864655 100.8,6.72000015 L100.8,99.1200023 L100.8,99.1200023 L16.8000004,99.1200023 L16.8000004,6.72000015 C16.8000004,3.00864655 19.8086469,1.56994302e-15 23.5200005,0 Z"
1499
- id="矩形"
1500
- fill="#F9FAFB"
1501
- ></path>
1502
- <path
1503
- d="M30.9200007,12.4400003 L86.6800019,12.4400003 C88.5356787,12.4400003 90.040002,13.9443236 90.040002,15.8000004 L90.040002,42.000001 C90.040002,43.8556778 88.5356787,45.360001 86.6800019,45.360001 L30.9200007,45.360001 C29.0643239,45.360001 27.5600006,43.8556778 27.5600006,42.000001 L27.5600006,15.8000004 C27.5600006,13.9443236 29.0643239,12.4400003 30.9200007,12.4400003 Z"
1504
- id="矩形"
1505
- fill="#E8EAEE"
1506
- ></path>
1507
- <text
1508
- id="&lt;/null&gt;"
1509
- font-family="PingFangSC-Medium, PingFang SC"
1510
- font-size="15.1200003"
1511
- font-weight="400"
1512
- fill="#BCBECD"
1513
- >
1514
- <tspan x="33.6000008" y="32.8000004">&lt;/null&gt;</tspan>
1515
- </text>
1516
- <rect id="矩形" fill="#E8EAEE" x="27.5600006" y="52.0800012" width="61.4800014" height="5.04000011" rx="2.52000006"></rect>
1517
- <rect
1518
- id="矩形备份"
1519
- fill="#E8EAEE"
1520
- x="27.5600006"
1521
- y="63.8400014"
1522
- width="61.4800014"
1523
- height="5.04000011"
1524
- rx="2.52000006"
1525
- ></rect>
1526
- <path
1527
- d="M0,75.6000017 L29.280235,75.6000017 C32.0637502,75.6000017 34.3202352,77.8564866 34.3202352,80.6400018 L34.3202352,86.2591426 C34.3202352,89.0426578 36.5767201,91.2991427 39.3602353,91.2991427 L78.4136737,91.2991427 C81.1971889,91.2991427 83.4536738,89.0426578 83.4536738,86.2591426 L83.4536738,80.6400018 C83.4536738,77.8564866 85.7101587,75.6000017 88.4936739,75.6000017 L117.600003,75.6000017 L117.600003,75.6000017 L117.600003,110.880003 C117.600003,115.519195 113.839194,119.280003 109.200002,119.280003 L8.40000019,119.280003 C3.76080819,119.280003 -6.53729019e-15,115.519195 0,110.880003 L0,75.6000017 L0,75.6000017 Z"
1528
- id="矩形"
1529
- fill="#EDEFF2"
1530
- ></path>
1531
- </g>
1532
- </g>
1533
- </g>
1534
- </svg>`;
1535
- const icons = {
1536
- 'angle-right': angleRight,
1537
- 'angle-down': angleDown,
1538
- 'plus-square': plusSquare,
1539
- 'minus-square': minusSquare,
1540
- loading: loadingIcon,
1541
- empty: emptyIcon
1542
- };
1543
-
1544
- class GanttIconComponent {
1545
- constructor(elementRef) {
1546
- this.elementRef = elementRef;
1547
- this.isIcon = true;
1548
- }
1549
- set iconName(name) {
1550
- this.setSvg(name);
1551
- }
1552
- ngOnInit() { }
1553
- ngAfterViewInit() { }
1554
- setSvg(name) {
1555
- const iconSvg = icons[name];
1556
- if (iconSvg) {
1557
- this.elementRef.nativeElement.innerHTML = iconSvg;
1558
- }
1559
- else {
1560
- this.elementRef.nativeElement.innerHTML = '';
1561
- }
1562
- }
1563
- }
1564
- GanttIconComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttIconComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1565
- GanttIconComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttIconComponent, selector: "gantt-icon", inputs: { iconName: "iconName" }, host: { properties: { "class.gantt-icon": "this.isIcon" } }, ngImport: i0, template: '', isInline: true });
1566
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttIconComponent, decorators: [{
1567
- type: Component,
1568
- args: [{
1569
- selector: 'gantt-icon',
1570
- template: ''
1571
- }]
1572
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { isIcon: [{
1573
- type: HostBinding,
1574
- args: ['class.gantt-icon']
1575
- }], iconName: [{
1576
- type: Input
1756
+ args: ['class.gantt-calendar-overlay']
1577
1757
  }] } });
1578
1758
 
1579
- class IsGanttRangeItemPipe {
1580
- transform(value) {
1581
- return value === GanttItemType.range;
1582
- }
1583
- }
1584
- IsGanttRangeItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1585
- IsGanttRangeItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, name: "isGanttRangeItem" });
1586
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, decorators: [{
1587
- type: Pipe,
1588
- args: [{
1589
- name: 'isGanttRangeItem'
1590
- }]
1591
- }] });
1592
- class IsGanttBarItemPipe {
1593
- transform(value) {
1594
- return value === GanttItemType.bar;
1595
- }
1596
- }
1597
- IsGanttBarItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1598
- IsGanttBarItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, name: "isGanttBarItem" });
1599
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, decorators: [{
1600
- type: Pipe,
1601
- args: [{
1602
- name: 'isGanttBarItem'
1603
- }]
1604
- }] });
1605
- class IsGanttCustomItemPipe {
1606
- transform(value) {
1607
- return value === GanttItemType.custom;
1608
- }
1609
- }
1610
- IsGanttCustomItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1611
- IsGanttCustomItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, name: "isGanttCustomItem" });
1612
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, decorators: [{
1613
- type: Pipe,
1614
- args: [{
1615
- name: 'isGanttCustomItem'
1616
- }]
1617
- }] });
1618
-
1619
- class GanttTableBodyComponent {
1620
- constructor(gantt) {
1621
- this.gantt = gantt;
1622
- this.ganttTableClass = true;
1623
- this.ganttTableEmptyClass = false;
1624
- }
1625
- set tempData(data) {
1626
- const firstData = data[0];
1627
- if (firstData && firstData.hasOwnProperty('items')) {
1628
- this.hasGroup = true;
1629
- }
1630
- this.ganttTableEmptyClass = (data === null || data === void 0 ? void 0 : data.length) ? false : true;
1631
- this.flatData = data;
1632
- }
1633
- set columns(columns) {
1634
- columns.forEach((column) => {
1635
- if (!column.columnWidth) {
1636
- column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1637
- }
1638
- });
1639
- this.columnList = columns;
1759
+ class GanttDragBackdropComponent {
1760
+ constructor() {
1761
+ this.backdropClass = true;
1640
1762
  }
1641
1763
  ngOnInit() { }
1642
- expandGroup(group) {
1643
- this.gantt.expandGroup(group);
1644
- }
1645
- expandChildren(item) {
1646
- this.gantt.expandChildren(item);
1647
- }
1648
- trackBy(item, index) {
1649
- return item.id || index;
1650
- }
1651
1764
  }
1652
- GanttTableBodyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableBodyComponent, deps: [{ token: GANTT_ABSTRACT_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
1653
- GanttTableBodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: { tempData: "tempData", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate" }, host: { properties: { "class.gantt-table-body": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass" } }, ngImport: i0, template: "<div class=\"gantt-table-body-container\">\n <ng-container *ngIf=\"!flatData?.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"flatData && flatData.length > 0\">\n <ng-container *ngFor=\"let data of flatData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"data.class\" *ngIf=\"data.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"data.expanded\" (click)=\"expandGroup(data)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"data.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: data.origin, group: data.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ data.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!data.items\"\n class=\"gantt-table-item gantt-table-row\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"data.level === 0 && (data.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n >\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let first = first\" [style.width]=\"column.columnWidth\">\n <div *ngIf=\"first\" class=\"gantt-expand-icon\" [style.marginLeft.px]=\"data.level * 20\">\n <ng-container *ngIf=\"data.level < gantt.maxLevel - 1 && data.expandable\">\n <gantt-icon\n *ngIf=\"!data.loading\"\n class=\"expand-icon\"\n [iconName]=\"data.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren(data)\"\n ></gantt-icon>\n <gantt-icon *ngIf=\"data.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: data.origin, item: data.origin }\"\n ></ng-template>\n </div>\n </div>\n </div>\n </ng-container>\n </ng-container>\n</div>\n", components: [{ type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], pipes: { "isGanttRangeItem": IsGanttRangeItemPipe } });
1654
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableBodyComponent, decorators: [{
1765
+ GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1766
+ GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { properties: { "class.gantt-drag-backdrop": "this.backdropClass" } }, ngImport: i0, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" });
1767
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
1655
1768
  type: Component,
1656
1769
  args: [{
1657
- selector: 'gantt-table-body',
1658
- templateUrl: './gantt-table-body.component.html'
1770
+ selector: 'gantt-drag-backdrop',
1771
+ templateUrl: `./drag-backdrop.component.html`
1659
1772
  }]
1660
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1661
- type: Inject,
1662
- args: [GANTT_ABSTRACT_TOKEN]
1663
- }] }]; }, propDecorators: { tempData: [{
1664
- type: Input
1665
- }], columns: [{
1666
- type: Input
1667
- }], groupTemplate: [{
1668
- type: Input
1669
- }], emptyTemplate: [{
1670
- type: Input
1671
- }], ganttTableClass: [{
1672
- type: HostBinding,
1673
- args: ['class.gantt-table-body']
1674
- }], ganttTableEmptyClass: [{
1773
+ }], ctorParameters: function () { return []; }, propDecorators: { backdropClass: [{
1675
1774
  type: HostBinding,
1676
- args: ['class.gantt-table-empty']
1775
+ args: ['class.gantt-drag-backdrop']
1677
1776
  }] } });
1678
1777
 
1679
- const mainHeight = 5000;
1680
- class GanttCalendarGridComponent {
1681
- constructor(ganttUpper, ngZone, elementRef) {
1682
- this.ganttUpper = ganttUpper;
1683
- this.ngZone = ngZone;
1778
+ class NgxGanttRootComponent {
1779
+ constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
1684
1780
  this.elementRef = elementRef;
1781
+ this.ngZone = ngZone;
1782
+ this.dom = dom;
1783
+ this.dragContainer = dragContainer;
1784
+ this.ganttUpper = ganttUpper;
1785
+ this.printService = printService;
1786
+ this.ganttClass = true;
1685
1787
  this.unsubscribe$ = new Subject();
1686
- this.headerHeight = headerHeight;
1687
- this.mainHeight = mainHeight;
1688
- this.todayBorderRadius = todayBorderRadius;
1689
- this.viewTypes = GanttViewType;
1690
- this.className = `gantt-calendar gantt-calendar-grid`;
1788
+ this.ganttUpper.dragContainer = dragContainer;
1691
1789
  }
1692
1790
  get view() {
1693
1791
  return this.ganttUpper.view;
1694
1792
  }
1695
- setTodayPoint() {
1696
- const x = this.view.getTodayXPoint();
1697
- const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
1698
- const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
1699
- if (isNumber(x)) {
1700
- if (line) {
1701
- line.style.left = `${x}px`;
1702
- line.style.top = `0px`;
1703
- line.style.bottom = `${-mainHeight}px`;
1704
- }
1705
- }
1706
- else {
1707
- todayEle.style.display = 'none';
1708
- }
1709
- }
1710
1793
  ngOnInit() {
1711
1794
  this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1712
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
1713
- .pipe(takeUntil(this.unsubscribe$))
1714
- .subscribe(() => {
1715
- this.setTodayPoint();
1795
+ this.dom.initialize(this.elementRef);
1796
+ if (this.printService) {
1797
+ this.printService.register(this.elementRef);
1798
+ }
1799
+ this.setupScrollClass();
1800
+ this.setupResize();
1801
+ this.setupViewScroll();
1802
+ // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
1803
+ this.elementRef.nativeElement.style.opacity = '1';
1804
+ this.ganttUpper.viewChange.pipe(startWith(null)).subscribe(() => {
1805
+ this.scrollToToday();
1716
1806
  });
1717
1807
  });
1718
1808
  }
1719
- ngAfterViewInit() { }
1720
- ngOnChanges(changes) { }
1721
- trackBy(point, index) {
1722
- return point.text || index;
1809
+ setupViewScroll() {
1810
+ if (this.ganttUpper.disabledLoadOnScroll) {
1811
+ return;
1812
+ }
1813
+ this.dom
1814
+ .getViewerScroll()
1815
+ .pipe(takeUntil(this.unsubscribe$))
1816
+ .subscribe((event) => {
1817
+ if (event.direction === ScrollDirection.LEFT) {
1818
+ const dates = this.view.addStartDate();
1819
+ if (dates) {
1820
+ event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
1821
+ this.ngZone.run(() => {
1822
+ this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
1823
+ });
1824
+ }
1825
+ }
1826
+ if (event.direction === ScrollDirection.RIGHT) {
1827
+ const dates = this.view.addEndDate();
1828
+ if (dates) {
1829
+ this.ngZone.run(() => {
1830
+ this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
1831
+ });
1832
+ }
1833
+ }
1834
+ });
1723
1835
  }
1724
- ngOnDestroy() {
1725
- this.unsubscribe$.next();
1726
- this.unsubscribe$.complete();
1836
+ setupResize() {
1837
+ this.dom
1838
+ .getResize()
1839
+ .pipe(takeUntil(this.unsubscribe$))
1840
+ .subscribe(() => {
1841
+ this.setupScrollClass();
1842
+ });
1843
+ }
1844
+ setupScrollClass() {
1845
+ const mainContainer = this.dom.mainContainer;
1846
+ const height = mainContainer.offsetHeight;
1847
+ const scrollHeight = mainContainer.scrollHeight;
1848
+ if (scrollHeight > height) {
1849
+ this.elementRef.nativeElement.className = 'gantt gantt-scroll';
1850
+ }
1851
+ else {
1852
+ this.elementRef.nativeElement.className = 'gantt';
1853
+ }
1854
+ }
1855
+ scrollToToday() {
1856
+ const x = this.view.getTodayXPoint();
1857
+ this.dom.scrollMainContainer(x);
1727
1858
  }
1728
1859
  }
1729
- GanttCalendarGridComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarGridComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1730
- GanttCalendarGridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid", host: { properties: { "class": "this.className" } }, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-grid-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight - 1\">\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n </g>\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1731
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
1860
+ NgxGanttRootComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRootComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: GanttDomService }, { token: GanttDragContainer }, { token: GANTT_UPPER_TOKEN }, { token: GanttPrintService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
1861
+ NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { properties: { "class.gantt": "this.ganttClass" } }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\">\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\">\n <gantt-calendar-overlay></gantt-calendar-overlay>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n", components: [{ type: GanttCalendarComponent, selector: "gantt-calendar-overlay" }, { type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }], directives: [{ type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
1862
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
1732
1863
  type: Component,
1733
1864
  args: [{
1734
- selector: 'gantt-calendar-grid',
1735
- templateUrl: './calendar-grid.component.html'
1865
+ selector: 'ngx-gantt-root',
1866
+ templateUrl: './root.component.html',
1867
+ providers: [GanttDomService, GanttDragContainer]
1736
1868
  }]
1737
- }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1869
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
1738
1870
  type: Inject,
1739
1871
  args: [GANTT_UPPER_TOKEN]
1740
- }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
1872
+ }] }, { type: GanttPrintService, decorators: [{
1873
+ type: Optional
1874
+ }] }]; }, propDecorators: { sideWidth: [{
1875
+ type: Input
1876
+ }], ganttClass: [{
1741
1877
  type: HostBinding,
1742
- args: ['class']
1878
+ args: ['class.gantt']
1879
+ }], sideTemplate: [{
1880
+ type: ContentChild,
1881
+ args: ['sideTemplate', { static: true }]
1882
+ }], mainTemplate: [{
1883
+ type: ContentChild,
1884
+ args: ['mainTemplate', { static: true }]
1743
1885
  }] } });
1744
1886
 
1745
1887
  var LinkColors;
@@ -1754,7 +1896,8 @@ class GanttLinksComponent {
1754
1896
  this.cdr = cdr;
1755
1897
  this.elementRef = elementRef;
1756
1898
  this.ganttDragContainer = ganttDragContainer;
1757
- this.flatData = [];
1899
+ this.groups = [];
1900
+ this.items = [];
1758
1901
  this.lineClick = new EventEmitter();
1759
1902
  this.links = [];
1760
1903
  this.linkItems = [];
@@ -1764,8 +1907,8 @@ class GanttLinksComponent {
1764
1907
  this.ganttLinksOverlay = true;
1765
1908
  }
1766
1909
  ngOnInit() {
1767
- this.firstChange = false;
1768
1910
  this.buildLinks();
1911
+ this.firstChange = false;
1769
1912
  this.ganttDragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1770
1913
  this.elementRef.nativeElement.style.visibility = 'hidden';
1771
1914
  });
@@ -1786,21 +1929,40 @@ class GanttLinksComponent {
1786
1929
  const lineHeight = this.ganttUpper.styles.lineHeight;
1787
1930
  const barHeight = this.ganttUpper.styles.barHeight;
1788
1931
  this.linkItems = [];
1789
- this.flatData.forEach((item, itemIndex) => {
1790
- if (!item.hasOwnProperty('items')) {
1791
- const ganttItem = item;
1792
- if (ganttItem.refs) {
1793
- const y = itemIndex * lineHeight + ganttItem.refs.y + barHeight / 2;
1794
- this.linkItems.push(Object.assign(Object.assign({}, ganttItem), { before: {
1795
- x: ganttItem.refs.x,
1796
- y
1797
- }, after: {
1798
- x: ganttItem.refs.x + ganttItem.refs.width,
1799
- y
1800
- } }));
1932
+ if (this.groups.length > 0) {
1933
+ let itemNum = 0;
1934
+ let groupNum = 0;
1935
+ this.groups.forEach((group) => {
1936
+ groupNum++;
1937
+ if (group.expanded) {
1938
+ const items = recursiveItems(group.items);
1939
+ items.forEach((item, itemIndex) => {
1940
+ const y = (groupNum + itemNum + itemIndex) * lineHeight + item.refs.y + barHeight / 2;
1941
+ this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
1942
+ x: item.refs.x,
1943
+ y
1944
+ }, after: {
1945
+ x: item.refs.x + item.refs.width,
1946
+ y
1947
+ } }));
1948
+ });
1949
+ itemNum += items.length;
1801
1950
  }
1802
- }
1803
- });
1951
+ });
1952
+ }
1953
+ else {
1954
+ const items = recursiveItems(this.items);
1955
+ items.forEach((item, itemIndex) => {
1956
+ const y = itemIndex * lineHeight + item.refs.y + barHeight / 2;
1957
+ this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
1958
+ x: item.refs.x,
1959
+ y
1960
+ }, after: {
1961
+ x: item.refs.x + item.refs.width,
1962
+ y
1963
+ } }));
1964
+ });
1965
+ }
1804
1966
  }
1805
1967
  generatePath(source, target) {
1806
1968
  if (source.before && source.after && target.before && target.after) {
@@ -1905,7 +2067,7 @@ class GanttLinksComponent {
1905
2067
  }
1906
2068
  }
1907
2069
  GanttLinksComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttLinksComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: GanttDragContainer }], target: i0.ɵɵFactoryTarget.Component });
1908
- GanttLinksComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { flatData: "flatData" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path [attr.d]=\"link.path\" fill=\"transparent\" stroke-width=\"2\" [attr.stroke]=\"link.color\" pointer-events=\"none\"></path>\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n (mouseenter)=\"mouseEnterPath(link)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n [attr.d]=\"link.path\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n", directives: [{ type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2070
+ GanttLinksComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { groups: "groups", items: "items" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path [attr.d]=\"link.path\" fill=\"transparent\" stroke-width=\"2\" [attr.stroke]=\"link.color\" pointer-events=\"none\"></path>\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n (mouseenter)=\"mouseEnterPath(link)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n [attr.d]=\"link.path\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n", directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1909
2071
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttLinksComponent, decorators: [{
1910
2072
  type: Component,
1911
2073
  args: [{
@@ -1915,7 +2077,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
1915
2077
  }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1916
2078
  type: Inject,
1917
2079
  args: [GANTT_UPPER_TOKEN]
1918
- }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: GanttDragContainer }]; }, propDecorators: { flatData: [{
2080
+ }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: GanttDragContainer }]; }, propDecorators: { groups: [{
2081
+ type: Input
2082
+ }], items: [{
1919
2083
  type: Input
1920
2084
  }], lineClick: [{
1921
2085
  type: Output
@@ -1943,11 +2107,10 @@ class GanttItemUpper {
1943
2107
  }
1944
2108
  }
1945
2109
  setPositions() {
1946
- var _a, _b, _c;
1947
2110
  const itemElement = this.elementRef.nativeElement;
1948
- itemElement.style.left = ((_a = this.item.refs) === null || _a === void 0 ? void 0 : _a.x) + 'px';
1949
- itemElement.style.top = ((_b = this.item.refs) === null || _b === void 0 ? void 0 : _b.y) + 'px';
1950
- itemElement.style.width = ((_c = this.item.refs) === null || _c === void 0 ? void 0 : _c.width) + 'px';
2111
+ itemElement.style.left = this.item.refs.x + 'px';
2112
+ itemElement.style.top = this.item.refs.y + 'px';
2113
+ itemElement.style.width = this.item.refs.width + 'px';
1951
2114
  if (this.item.type === GanttItemType.bar) {
1952
2115
  itemElement.style.height = this.ganttUpper.styles.barHeight + 'px';
1953
2116
  }
@@ -1991,7 +2154,7 @@ class NgxGanttRangeComponent extends GanttItemUpper {
1991
2154
  }
1992
2155
  }
1993
2156
  NgxGanttRangeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRangeComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
1994
- NgxGanttRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range", host: { properties: { "class.gantt-range": "this.ganttRangeClass" } }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"item.start && item.end\">\n <div class=\"gantt-range-main\">\n <div class=\"gantt-range-main-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n </div>\n <div class=\"gantt-range-triangle left\"></div>\n <div class=\"gantt-range-triangle right\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</ng-container>\n", directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2157
+ NgxGanttRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range", host: { properties: { "class.gantt-range": "this.ganttRangeClass" } }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"item.start && item.end\">\n <div class=\"gantt-range-main\">\n <div class=\"gantt-range-main-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n </div>\n <div class=\"gantt-range-triangle left\"></div>\n <div class=\"gantt-range-triangle right\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</ng-container>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
1995
2158
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRangeComponent, decorators: [{
1996
2159
  type: Component,
1997
2160
  args: [{
@@ -2067,6 +2230,8 @@ class GanttBarDrag {
2067
2230
  const start = this.ganttUpper.view.getDateByXPoint(x);
2068
2231
  const end = start.addDays(days);
2069
2232
  this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), end);
2233
+ this.item.updateDate(start, end);
2234
+ this.dragContainer.dragMoved.emit({ item: this.item.origin });
2070
2235
  });
2071
2236
  dragRef.ended.subscribe((event) => {
2072
2237
  const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
@@ -2101,6 +2266,7 @@ class GanttBarDrag {
2101
2266
  this.barElement.style.width = width + 'px';
2102
2267
  this.barElement.style.left = x + 'px';
2103
2268
  this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), this.ganttUpper.view.getDateByXPoint(x + width));
2269
+ this.item.updateDate(this.ganttUpper.view.getDateByXPoint(x), this.item.end);
2104
2270
  }
2105
2271
  }
2106
2272
  else {
@@ -2109,7 +2275,9 @@ class GanttBarDrag {
2109
2275
  this.barElement.style.width = width + 'px';
2110
2276
  this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(this.item.refs.x), this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
2111
2277
  }
2278
+ this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
2112
2279
  }
2280
+ this.dragContainer.dragMoved.emit({ item: this.item.origin });
2113
2281
  event.source.reset();
2114
2282
  });
2115
2283
  dragRef.ended.subscribe((event) => {
@@ -2256,11 +2424,11 @@ class GanttBarDrag {
2256
2424
  this.destroy$.complete();
2257
2425
  }
2258
2426
  }
2259
- GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag, deps: [{ token: i1$1.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }], target: i0.ɵɵFactoryTarget.Injectable });
2427
+ GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag, deps: [{ token: i1.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }], target: i0.ɵɵFactoryTarget.Injectable });
2260
2428
  GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag });
2261
2429
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag, decorators: [{
2262
2430
  type: Injectable
2263
- }], ctorParameters: function () { return [{ type: i1$1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }]; } });
2431
+ }], ctorParameters: function () { return [{ type: i1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }]; } });
2264
2432
 
2265
2433
  function linearGradient(sideOrCorner, color, stop) {
2266
2434
  return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
@@ -2327,7 +2495,7 @@ class NgxGanttBarComponent extends GanttItemUpper {
2327
2495
  }
2328
2496
  }
2329
2497
  NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2330
- NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div *ngIf=\"item.draggable && ganttUpper.draggable\" class=\"drag-handles\">\n <ng-container>\n <span class=\"handle\" (mousedown)=\"stopPropagation($event)\"></span>\n <span class=\"handle\" (mousedown)=\"stopPropagation($event)\"></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n", directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2498
+ NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div *ngIf=\"item.draggable && ganttUpper.draggable\" class=\"drag-handles\">\n <ng-container>\n <span class=\"handle\" (mousedown)=\"stopPropagation($event)\"></span>\n <span class=\"handle\" (mousedown)=\"stopPropagation($event)\"></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2331
2499
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
2332
2500
  type: Component,
2333
2501
  args: [{
@@ -2356,12 +2524,12 @@ class GanttMainComponent {
2356
2524
  this.ganttMainClass = true;
2357
2525
  }
2358
2526
  ngOnInit() { }
2359
- trackBy(item, index) {
2527
+ trackBy(index, item) {
2360
2528
  return item.id || index;
2361
2529
  }
2362
2530
  }
2363
2531
  GanttMainComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttMainComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2364
- GanttMainComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttMainComponent, selector: "gantt-main", inputs: { tempData: "tempData", flatData: "flatData", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<gantt-links-overlay [flatData]=\"flatData\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n\n<div class=\"gantt-main-groups\" *ngIf=\"tempData && tempData.length > 0\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let data of tempData; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"data.class\" *ngIf=\"data.items\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n <div class=\"gantt-item\" [style.height.px]=\"ganttUpper.styles.lineHeight\" *ngIf=\"!data.items\">\n <ng-container *ngIf=\"data.type | isGanttCustomItem\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate\" [ngTemplateOutletContext]=\"{ item: data.origin, refs: data.refs }\"></ng-template>\n </ng-container>\n <gantt-range *ngIf=\"data.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n <gantt-bar *ngIf=\"data.type | isGanttBarItem\" [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n </div>\n </ng-container>\n</div>\n", components: [{ type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: ["flatData"], outputs: ["lineClick"] }, { type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range" }, { type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: ["barClick"] }], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "isGanttCustomItem": IsGanttCustomItemPipe, "isGanttRangeItem": IsGanttRangeItemPipe, "isGanttBarItem": IsGanttBarItemPipe } });
2532
+ GanttMainComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttMainComponent, selector: "gantt-main", inputs: { groups: "groups", items: "items", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<gantt-links-overlay [groups]=\"groups\" [items]=\"items\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<!-- groups -->\n<div class=\"gantt-main-groups\" *ngIf=\"groups && groups.length > 0; else itemsTemplate\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"group.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: group }\"></ng-template>\n </div>\n <div *ngIf=\"group.expanded\" class=\"gantt-items\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: group.items }\"></ng-template>\n </div>\n </ng-container>\n</div>\n<!-- items -->\n<ng-template #itemsTemplate>\n <div class=\"gantt-main-items\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items }\"></ng-template>\n </div>\n</ng-template>\n\n<ng-template #ganttItems let-items=\"items\">\n <ng-container *ngFor=\"let item of items;\">\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-container *ngIf=\"item.type | isGanttCustomItem\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n </ng-container>\n <gantt-range *ngIf=\"item.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"item\"></gantt-range>\n <gantt-bar *ngIf=\"item.type | isGanttBarItem\" [item]=\"item\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n", components: [{ type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: ["groups", "items"], outputs: ["lineClick"] }, { type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range" }, { type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: ["barClick"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "isGanttCustomItem": IsGanttCustomItemPipe, "isGanttRangeItem": IsGanttRangeItemPipe, "isGanttBarItem": IsGanttBarItemPipe } });
2365
2533
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttMainComponent, decorators: [{
2366
2534
  type: Component,
2367
2535
  args: [{
@@ -2371,9 +2539,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2371
2539
  }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2372
2540
  type: Inject,
2373
2541
  args: [GANTT_UPPER_TOKEN]
2374
- }] }]; }, propDecorators: { tempData: [{
2542
+ }] }]; }, propDecorators: { groups: [{
2375
2543
  type: Input
2376
- }], flatData: [{
2544
+ }], items: [{
2377
2545
  type: Input
2378
2546
  }], groupHeaderTemplate: [{
2379
2547
  type: Input
@@ -2392,58 +2560,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2392
2560
  args: ['class.gantt-main-container']
2393
2561
  }] } });
2394
2562
 
2395
- class GanttDragBackdropComponent {
2396
- constructor() {
2397
- this.backdropClass = true;
2398
- }
2399
- ngOnInit() { }
2400
- }
2401
- GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2402
- GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { properties: { "class.gantt-drag-backdrop": "this.backdropClass" } }, ngImport: i0, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" });
2403
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
2404
- type: Component,
2405
- args: [{
2406
- selector: 'gantt-drag-backdrop',
2407
- templateUrl: `./drag-backdrop.component.html`
2408
- }]
2409
- }], ctorParameters: function () { return []; }, propDecorators: { backdropClass: [{
2410
- type: HostBinding,
2411
- args: ['class.gantt-drag-backdrop']
2412
- }] } });
2413
-
2414
2563
  class NgxGanttComponent extends GanttUpper {
2415
- constructor(elementRef, cdr, ngZone, dom, dragContainer, printService) {
2416
- super(elementRef, cdr, ngZone);
2417
- this.dom = dom;
2418
- this.dragContainer = dragContainer;
2419
- this.printService = printService;
2564
+ constructor(elementRef, cdr, ngZone, config) {
2565
+ super(elementRef, cdr, ngZone, config);
2420
2566
  this.maxLevel = 2;
2421
2567
  this.linkDragStarted = new EventEmitter();
2422
2568
  this.linkDragEnded = new EventEmitter();
2423
2569
  this.lineClick = new EventEmitter();
2424
- this.flatData = [];
2425
- this.tempData = [];
2570
+ this.selectedChange = new EventEmitter();
2426
2571
  this.ngUnsubscribe$ = new Subject();
2427
- this.dragContainer = dragContainer;
2428
- this.computeAllRefs = false;
2572
+ this.sideTableWidth = sideWidth;
2429
2573
  }
2430
2574
  ngOnInit() {
2431
2575
  super.onInit();
2432
- this.buildVirtualFlatData();
2433
2576
  this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2434
- this.dom.initialize(this.elementRef);
2435
- if (this.printService) {
2436
- this.printService.register(this.elementRef);
2437
- }
2438
- this.setupViewScroll();
2439
- // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
2440
- this.elementRef.nativeElement.style.opacity = '1';
2441
- this.viewChange.pipe(startWith(null)).subscribe(() => {
2442
- this.scrollToToday();
2443
- });
2444
- this.dragContainer.dragEnded.subscribe((event) => {
2445
- this.computeTempDataRefs();
2446
- });
2447
2577
  this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2448
2578
  this.linkDragStarted.emit(event);
2449
2579
  });
@@ -2451,9 +2581,6 @@ class NgxGanttComponent extends GanttUpper {
2451
2581
  this.linkDragEnded.emit(event);
2452
2582
  });
2453
2583
  });
2454
- this.view.start$.pipe(skip(1), takeUntil(this.unsubscribe$)).subscribe(() => {
2455
- this.computeTempDataRefs();
2456
- });
2457
2584
  }
2458
2585
  ngAfterViewInit() {
2459
2586
  this.columns.changes.pipe(startWith(true), takeUntil(this.ngUnsubscribe$)).subscribe(() => {
@@ -2464,40 +2591,9 @@ class NgxGanttComponent extends GanttUpper {
2464
2591
  });
2465
2592
  this.cdr.detectChanges();
2466
2593
  });
2467
- this.virtualScroll.renderedRangeStream.subscribe((range) => {
2468
- const linksElement = this.elementRef.nativeElement.querySelector('.gantt-links-overlay');
2469
- linksElement.style.top = `${-(this.styles.lineHeight * range.start)}px`;
2470
- this.rangeStart = range.start;
2471
- this.rangeEnd = range.end;
2472
- this.tempData = this.flatData.slice(range.start, range.end);
2473
- this.computeTempDataRefs();
2474
- });
2475
2594
  }
2476
2595
  ngOnChanges(changes) {
2477
2596
  super.onChanges(changes);
2478
- if (!this.firstChange) {
2479
- if (changes.viewType && changes.viewType.currentValue) {
2480
- this.tempData = this.flatData.slice(this.rangeStart, this.rangeEnd);
2481
- this.computeTempDataRefs();
2482
- }
2483
- if (changes.originItems || changes.originGroups) {
2484
- this.buildVirtualFlatData();
2485
- this.tempData = this.flatData.slice(this.rangeStart, this.rangeEnd);
2486
- this.computeTempDataRefs();
2487
- }
2488
- }
2489
- }
2490
- expandGroup(group) {
2491
- group.setExpand(!group.expanded);
2492
- this.afterExpand();
2493
- this.expandChange.emit();
2494
- this.cdr.detectChanges();
2495
- }
2496
- expandAll() {
2497
- this.expandGroups(true);
2498
- }
2499
- collapseAll() {
2500
- this.expandGroups(false);
2501
2597
  }
2502
2598
  expandChildren(item) {
2503
2599
  if (!item.expanded) {
@@ -2507,7 +2603,6 @@ class NgxGanttComponent extends GanttUpper {
2507
2603
  this.childrenResolve(item.origin)
2508
2604
  .pipe(take(1), finalize(() => {
2509
2605
  item.loading = false;
2510
- this.afterExpand();
2511
2606
  this.expandChange.emit();
2512
2607
  this.cdr.detectChanges();
2513
2608
  }))
@@ -2518,107 +2613,37 @@ class NgxGanttComponent extends GanttUpper {
2518
2613
  }
2519
2614
  else {
2520
2615
  this.computeItemsRefs(...item.children);
2521
- this.afterExpand();
2522
2616
  this.expandChange.emit();
2523
2617
  }
2524
2618
  }
2525
2619
  else {
2526
2620
  item.setExpand(false);
2527
- this.afterExpand();
2528
2621
  this.expandChange.emit();
2529
2622
  }
2530
2623
  }
2531
- buildVirtualFlatData() {
2532
- const virtualData = [];
2533
- if (this.groups.length) {
2534
- this.groups.forEach((group) => {
2535
- virtualData.push(group);
2536
- if (group.expanded) {
2537
- const items = recursiveItems(group.items, 0);
2538
- virtualData.push(...items);
2539
- }
2540
- });
2624
+ selectItem(selectEvent) {
2625
+ var _a;
2626
+ if (!this.selectable) {
2627
+ return;
2541
2628
  }
2542
- if (this.items.length) {
2543
- virtualData.push(...recursiveItems(this.items, 0));
2629
+ const { event, selectedValue } = selectEvent;
2630
+ this.selectionModel.toggle(selectedValue.id);
2631
+ const selectedIds = this.selectionModel.selected;
2632
+ if (this.multiple) {
2633
+ const selectedValue = this.getGanttItems(selectedIds).map((item) => item.origin);
2634
+ this.selectedChange.emit({ event, selectedValue });
2544
2635
  }
2545
- this.flatData = [...virtualData];
2546
- this.flatDataMap = keyBy(this.flatData, 'id');
2547
- }
2548
- afterExpand() {
2549
- this.buildVirtualFlatData();
2550
- this.tempData = this.flatData.slice(this.rangeStart, this.rangeEnd);
2551
- }
2552
- trackBy(item, index) {
2553
- return item.id || index;
2554
- }
2555
- scrollToToday() {
2556
- const x = this.view.getTodayXPoint();
2557
- this.dom.scrollMainContainer(x);
2558
- }
2559
- setupViewScroll() {
2560
- if (this.disabledLoadOnScroll) {
2561
- return;
2636
+ else {
2637
+ const selectedValue = (_a = this.getGanttItem(selectedIds[0])) === null || _a === void 0 ? void 0 : _a.origin;
2638
+ this.selectedChange.emit({ event, selectedValue });
2562
2639
  }
2563
- this.dom
2564
- .getViewerScroll()
2565
- .pipe(takeUntil(this.unsubscribe$))
2566
- .subscribe((event) => {
2567
- if (event.direction === ScrollDirection.LEFT) {
2568
- const dates = this.view.addStartDate();
2569
- if (dates) {
2570
- event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
2571
- this.ngZone.run(() => {
2572
- this.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
2573
- });
2574
- }
2575
- }
2576
- if (event.direction === ScrollDirection.RIGHT) {
2577
- const dates = this.view.addEndDate();
2578
- if (dates) {
2579
- this.ngZone.run(() => {
2580
- this.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
2581
- });
2582
- }
2583
- }
2584
- this.cdr.detectChanges();
2585
- });
2586
- }
2587
- expandGroups(expanded) {
2588
- this.groups.forEach((group) => {
2589
- group.setExpand(expanded);
2590
- });
2591
- this.afterExpand();
2592
- this.expandChange.next();
2593
- this.cdr.detectChanges();
2594
- }
2595
- computeTempDataRefs() {
2596
- const tempItemData = [];
2597
- this.tempData.forEach((data) => {
2598
- if (!data.hasOwnProperty('items')) {
2599
- const item = data;
2600
- if (item.links) {
2601
- item.links.forEach((link) => {
2602
- if (this.flatDataMap[link]) {
2603
- tempItemData.push(this.flatDataMap[link]);
2604
- }
2605
- });
2606
- }
2607
- tempItemData.push(data);
2608
- }
2609
- });
2610
- this.computeItemsRefs(...uniqBy(tempItemData, 'id'));
2611
- this.flatData = [...this.flatData];
2612
- this.tempData = [...this.tempData];
2613
2640
  }
2614
2641
  ngOnDestroy() {
2615
2642
  super.onDestroy();
2616
2643
  }
2617
2644
  }
2618
- NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GanttDomService }, { token: GanttDragContainer }, { token: GanttPrintService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
2619
- NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick" }, providers: [
2620
- GanttDomService,
2621
- GanttDragContainer,
2645
+ NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
2646
+ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
2622
2647
  {
2623
2648
  provide: GANTT_UPPER_TOKEN,
2624
2649
  useExisting: NgxGanttComponent
@@ -2627,7 +2652,7 @@ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
2627
2652
  provide: GANTT_ABSTRACT_TOKEN,
2628
2653
  useExisting: forwardRef(() => NgxGanttComponent)
2629
2654
  }
2630
- ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], viewQueries: [{ propertyName: "virtualScroll", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n</div>\n\n<cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n>\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\" [style.width.px]=\"tableHeader.tableWidth\">\n <div class=\"gantt-side-container\">\n <gantt-table-body\n [tempData]=\"tempData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n ></gantt-table-body>\n </div>\n </div>\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [tempData]=\"tempData\"\n [flatData]=\"flatData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n</cdk-virtual-scroll-viewport>\n\n<gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth\"></gantt-drag-backdrop>\n", components: [{ type: GanttTableHeaderComponent, selector: "gantt-table-header", inputs: ["columns"] }, { type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { type: i6.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: ["tempData", "columns", "groupTemplate", "emptyTemplate"] }, { type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { type: GanttMainComponent, selector: "gantt-main", inputs: ["tempData", "flatData", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }, { type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }], directives: [{ type: i6.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { type: i6.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2655
+ ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ngx-gantt-root>\n <ng-template #sideTemplate>\n <gantt-table\n [groups]=\"groups\"\n [items]=\"items\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table>\n </ng-template>\n <ng-template #mainTemplate>\n <gantt-main\n [groups]=\"groups\"\n [items]=\"items\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </ng-template>\n</ngx-gantt-root>\n", components: [{ type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }, { type: GanttTableComponent, selector: "gantt-table", inputs: ["groups", "items", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate"], outputs: ["itemClick"] }, { type: GanttMainComponent, selector: "gantt-main", inputs: ["groups", "items", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2631
2656
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttComponent, decorators: [{
2632
2657
  type: Component,
2633
2658
  args: [{
@@ -2635,8 +2660,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2635
2660
  templateUrl: './gantt.component.html',
2636
2661
  changeDetection: ChangeDetectionStrategy.OnPush,
2637
2662
  providers: [
2638
- GanttDomService,
2639
- GanttDragContainer,
2640
2663
  {
2641
2664
  provide: GANTT_UPPER_TOKEN,
2642
2665
  useExisting: NgxGanttComponent
@@ -2647,8 +2670,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2647
2670
  }
2648
2671
  ]
2649
2672
  }]
2650
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttPrintService, decorators: [{
2651
- type: Optional
2673
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
2674
+ type: Inject,
2675
+ args: [GANTT_GLOBAL_CONFIG]
2652
2676
  }] }]; }, propDecorators: { maxLevel: [{
2653
2677
  type: Input
2654
2678
  }], async: [{
@@ -2663,6 +2687,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2663
2687
  type: Output
2664
2688
  }], lineClick: [{
2665
2689
  type: Output
2690
+ }], selectedChange: [{
2691
+ type: Output
2666
2692
  }], table: [{
2667
2693
  type: ContentChild,
2668
2694
  args: [NgxGanttTableComponent]
@@ -2672,118 +2698,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2672
2698
  }], tableEmptyTemplate: [{
2673
2699
  type: ContentChild,
2674
2700
  args: ['tableEmpty', { static: true }]
2675
- }], virtualScroll: [{
2676
- type: ViewChild,
2677
- args: [CdkVirtualScrollViewport]
2678
- }] } });
2679
-
2680
- class NgxGanttRootComponent {
2681
- constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
2682
- this.elementRef = elementRef;
2683
- this.ngZone = ngZone;
2684
- this.dom = dom;
2685
- this.dragContainer = dragContainer;
2686
- this.ganttUpper = ganttUpper;
2687
- this.printService = printService;
2688
- this.ganttClass = true;
2689
- this.unsubscribe$ = new Subject();
2690
- this.ganttUpper.dragContainer = dragContainer;
2691
- }
2692
- get view() {
2693
- return this.ganttUpper.view;
2694
- }
2695
- ngOnInit() {
2696
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2697
- this.dom.initialize(this.elementRef);
2698
- if (this.printService) {
2699
- this.printService.register(this.elementRef);
2700
- }
2701
- this.setupScrollClass();
2702
- this.setupResize();
2703
- this.setupViewScroll();
2704
- // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
2705
- this.elementRef.nativeElement.style.opacity = '1';
2706
- this.ganttUpper.viewChange.pipe(startWith(null)).subscribe(() => {
2707
- this.scrollToToday();
2708
- });
2709
- });
2710
- }
2711
- setupViewScroll() {
2712
- if (this.ganttUpper.disabledLoadOnScroll) {
2713
- return;
2714
- }
2715
- this.dom
2716
- .getViewerScroll()
2717
- .pipe(takeUntil(this.unsubscribe$))
2718
- .subscribe((event) => {
2719
- if (event.direction === ScrollDirection.LEFT) {
2720
- const dates = this.view.addStartDate();
2721
- if (dates) {
2722
- event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
2723
- this.ngZone.run(() => {
2724
- this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
2725
- });
2726
- }
2727
- }
2728
- if (event.direction === ScrollDirection.RIGHT) {
2729
- const dates = this.view.addEndDate();
2730
- if (dates) {
2731
- this.ngZone.run(() => {
2732
- this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
2733
- });
2734
- }
2735
- }
2736
- });
2737
- }
2738
- setupResize() {
2739
- this.dom
2740
- .getResize()
2741
- .pipe(takeUntil(this.unsubscribe$))
2742
- .subscribe(() => {
2743
- this.setupScrollClass();
2744
- });
2745
- }
2746
- setupScrollClass() {
2747
- const mainContainer = this.dom.mainContainer;
2748
- const height = mainContainer.offsetHeight;
2749
- const scrollHeight = mainContainer.scrollHeight;
2750
- if (scrollHeight > height) {
2751
- this.elementRef.nativeElement.className = 'gantt gantt-scroll';
2752
- }
2753
- else {
2754
- this.elementRef.nativeElement.className = 'gantt';
2755
- }
2756
- }
2757
- scrollToToday() {
2758
- const x = this.view.getTodayXPoint();
2759
- this.dom.scrollMainContainer(x);
2760
- }
2761
- }
2762
- NgxGanttRootComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRootComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: GanttDomService }, { token: GanttDragContainer }, { token: GANTT_UPPER_TOKEN }, { token: GanttPrintService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
2763
- NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { properties: { "class.gantt": "this.ganttClass" } }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\">\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\">\n <gantt-calendar-header></gantt-calendar-header>\n <gantt-calendar-grid></gantt-calendar-grid>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n", components: [{ type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }], directives: [{ type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2764
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
2765
- type: Component,
2766
- args: [{
2767
- selector: 'ngx-gantt-root',
2768
- templateUrl: './root.component.html',
2769
- providers: [GanttDomService, GanttDragContainer]
2770
- }]
2771
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
2772
- type: Inject,
2773
- args: [GANTT_UPPER_TOKEN]
2774
- }] }, { type: GanttPrintService, decorators: [{
2775
- type: Optional
2776
- }] }]; }, propDecorators: { sideWidth: [{
2777
- type: Input
2778
- }], ganttClass: [{
2779
- type: HostBinding,
2780
- args: ['class.gantt']
2781
- }], sideTemplate: [{
2782
- type: ContentChild,
2783
- args: ['sideTemplate', { static: true }]
2784
- }], mainTemplate: [{
2785
- type: ContentChild,
2786
- args: ['mainTemplate', { static: true }]
2787
2701
  }] } });
2788
2702
 
2789
2703
  class NgxGanttModule {
@@ -2792,11 +2706,9 @@ NgxGanttModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version:
2792
2706
  NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, declarations: [NgxGanttComponent,
2793
2707
  NgxGanttTableComponent,
2794
2708
  NgxGanttTableColumnComponent,
2795
- GanttTableHeaderComponent,
2796
- GanttTableBodyComponent,
2709
+ GanttTableComponent,
2797
2710
  GanttMainComponent,
2798
- GanttCalendarHeaderComponent,
2799
- GanttCalendarGridComponent,
2711
+ GanttCalendarComponent,
2800
2712
  GanttLinksComponent,
2801
2713
  NgxGanttBarComponent,
2802
2714
  GanttIconComponent,
@@ -2805,17 +2717,22 @@ NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version:
2805
2717
  NgxGanttRootComponent,
2806
2718
  IsGanttRangeItemPipe,
2807
2719
  IsGanttBarItemPipe,
2808
- IsGanttCustomItemPipe], imports: [CommonModule, DragDropModule, ScrollingModule], exports: [NgxGanttComponent,
2720
+ IsGanttCustomItemPipe], imports: [CommonModule, DragDropModule], exports: [NgxGanttComponent,
2809
2721
  NgxGanttTableComponent,
2810
2722
  NgxGanttTableColumnComponent,
2811
2723
  NgxGanttRootComponent,
2812
2724
  NgxGanttBarComponent,
2813
2725
  NgxGanttRangeComponent] });
2814
- NgxGanttModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, providers: [CdkVirtualScrollViewport], imports: [[CommonModule, DragDropModule, ScrollingModule]] });
2726
+ NgxGanttModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, providers: [
2727
+ {
2728
+ provide: GANTT_GLOBAL_CONFIG,
2729
+ useValue: defaultConfig
2730
+ }
2731
+ ], imports: [[CommonModule, DragDropModule]] });
2815
2732
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, decorators: [{
2816
2733
  type: NgModule,
2817
2734
  args: [{
2818
- imports: [CommonModule, DragDropModule, ScrollingModule],
2735
+ imports: [CommonModule, DragDropModule],
2819
2736
  exports: [
2820
2737
  NgxGanttComponent,
2821
2738
  NgxGanttTableComponent,
@@ -2828,11 +2745,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2828
2745
  NgxGanttComponent,
2829
2746
  NgxGanttTableComponent,
2830
2747
  NgxGanttTableColumnComponent,
2831
- GanttTableHeaderComponent,
2832
- GanttTableBodyComponent,
2748
+ GanttTableComponent,
2833
2749
  GanttMainComponent,
2834
- GanttCalendarHeaderComponent,
2835
- GanttCalendarGridComponent,
2750
+ GanttCalendarComponent,
2836
2751
  GanttLinksComponent,
2837
2752
  NgxGanttBarComponent,
2838
2753
  GanttIconComponent,
@@ -2843,7 +2758,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2843
2758
  IsGanttBarItemPipe,
2844
2759
  IsGanttCustomItemPipe
2845
2760
  ],
2846
- providers: [CdkVirtualScrollViewport]
2761
+ providers: [
2762
+ {
2763
+ provide: GANTT_GLOBAL_CONFIG,
2764
+ useValue: defaultConfig
2765
+ }
2766
+ ]
2847
2767
  }]
2848
2768
  }] });
2849
2769
 
@@ -2855,5 +2775,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImpor
2855
2775
  * Generated bundle index. Do not edit.
2856
2776
  */
2857
2777
 
2858
- export { GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLoadOnScrollEvent, GanttPrintService, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, NgxGanttBarComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, primaryDatePointTop, secondaryDatePointTop };
2778
+ export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLoadOnScrollEvent, GanttPrintService, GanttSelectedEvent, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, NgxGanttBarComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, defaultConfig, primaryDatePointTop, secondaryDatePointTop };
2859
2779
  //# sourceMappingURL=worktile-gantt.js.map