@worktile/gantt 11.0.3 → 12.0.2

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 (59) hide show
  1. package/bundles/worktile-gantt.umd.js +1261 -1096
  2. package/bundles/worktile-gantt.umd.js.map +1 -1
  3. package/components/bar/bar-drag.d.ts +3 -0
  4. package/components/bar/bar.component.d.ts +3 -0
  5. package/components/calendar/calendar.component.d.ts +4 -1
  6. package/components/drag-backdrop/drag-backdrop.component.d.ts +3 -0
  7. package/components/icon/icon.component.d.ts +3 -0
  8. package/components/links/links.component.d.ts +3 -0
  9. package/components/main/gantt-main.component.d.ts +3 -0
  10. package/components/range/range.component.d.ts +3 -0
  11. package/components/table/gantt-table.component.d.ts +8 -3
  12. package/esm2015/components/bar/bar-drag.js +10 -12
  13. package/esm2015/components/bar/bar.component.js +29 -22
  14. package/esm2015/components/calendar/calendar.component.js +21 -17
  15. package/esm2015/components/drag-backdrop/drag-backdrop.component.js +14 -11
  16. package/esm2015/components/icon/icon.component.js +17 -15
  17. package/esm2015/components/links/links.component.js +28 -22
  18. package/esm2015/components/main/gantt-main.component.js +40 -22
  19. package/esm2015/components/range/range.component.js +21 -16
  20. package/esm2015/components/table/gantt-table.component.js +41 -23
  21. package/esm2015/gantt-abstract.js +3 -0
  22. package/esm2015/gantt-dom.service.js +7 -5
  23. package/esm2015/gantt-drag-container.js +7 -5
  24. package/esm2015/gantt-item-upper.js +17 -14
  25. package/esm2015/gantt-print.service.js +7 -5
  26. package/esm2015/gantt-upper.js +65 -51
  27. package/esm2015/gantt.component.js +60 -34
  28. package/esm2015/gantt.module.js +56 -25
  29. package/esm2015/gantt.pipe.js +26 -16
  30. package/esm2015/public-api.js +3 -1
  31. package/esm2015/root.component.js +37 -25
  32. package/esm2015/table/gantt-column.component.js +26 -17
  33. package/esm2015/table/gantt-table.component.js +13 -11
  34. package/esm2015/utils/helpers.js +11 -1
  35. package/esm2015/views/view.js +1 -1
  36. package/esm2015/views/year.js +3 -3
  37. package/esm2015/worktile-gantt.js +1 -12
  38. package/fesm2015/worktile-gantt.js +1342 -1205
  39. package/fesm2015/worktile-gantt.js.map +1 -1
  40. package/gantt-abstract.d.ts +12 -0
  41. package/gantt-dom.service.d.ts +3 -0
  42. package/gantt-drag-container.d.ts +3 -0
  43. package/gantt-item-upper.d.ts +3 -0
  44. package/gantt-print.service.d.ts +3 -0
  45. package/gantt-upper.d.ts +3 -1
  46. package/gantt.component.d.ts +3 -2
  47. package/gantt.module.d.ts +19 -0
  48. package/gantt.pipe.d.ts +7 -0
  49. package/{style.scss → main.bundle.scss} +63 -63
  50. package/package.json +4 -5
  51. package/public-api.d.ts +2 -0
  52. package/root.component.d.ts +3 -0
  53. package/table/gantt-column.component.d.ts +3 -0
  54. package/table/gantt-table.component.d.ts +3 -0
  55. package/utils/helpers.d.ts +2 -1
  56. package/worktile-gantt.d.ts +1 -11
  57. package/bundles/worktile-gantt.umd.min.js +0 -16
  58. package/bundles/worktile-gantt.umd.min.js.map +0 -1
  59. package/worktile-gantt.metadata.json +0 -1
@@ -1,11 +1,14 @@
1
- import { EventEmitter, Directive, ElementRef, ChangeDetectorRef, NgZone, Input, Output, ContentChild, HostBinding, InjectionToken, Component, Inject, ChangeDetectionStrategy, ContentChildren, ViewChild, Injectable, Optional, Pipe, NgModule } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { EventEmitter, Directive, Input, Output, ContentChild, HostBinding, InjectionToken, Component, Inject, Pipe, ViewChild, Injectable, Optional, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
+ import * as i2 from '@angular/common';
2
4
  import { CommonModule } from '@angular/common';
3
- import { take, skip, takeUntil, startWith, finalize, map, pairwise, auditTime } from 'rxjs/operators';
5
+ import { take, skip, takeUntil, startWith, map, pairwise, auditTime, finalize } from 'rxjs/operators';
4
6
  import { BehaviorSubject, Subject, merge, fromEvent } from 'rxjs';
5
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';
6
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';
7
9
  import { coerceCssPixelValue } from '@angular/cdk/coercion';
8
- import { DragDrop, DragDropModule } from '@angular/cdk/drag-drop';
10
+ import * as i1 from '@angular/cdk/drag-drop';
11
+ import { DragDropModule } from '@angular/cdk/drag-drop';
9
12
  import html2canvas from 'html2canvas';
10
13
 
11
14
  class GanttDatePoint {
@@ -292,14 +295,14 @@ class GanttGroupInternal {
292
295
 
293
296
  const primaryDatePointTop = 18;
294
297
  const secondaryDatePointTop = 36;
295
- const viewOptions = {
298
+ const viewOptions$5 = {
296
299
  min: new GanttDate().addYears(-1).startOfYear(),
297
300
  max: new GanttDate().addYears(1).endOfYear()
298
301
  };
299
302
  class GanttView {
300
303
  constructor(start, end, options) {
301
304
  this.showTimeline = true;
302
- this.options = Object.assign({}, viewOptions, options);
305
+ this.options = Object.assign({}, viewOptions$5, options);
303
306
  const startDate = start.isCustom
304
307
  ? this.startOf(start.date)
305
308
  : this.startOf(start.date.value < this.options.start.value ? start.date : this.options.start);
@@ -409,7 +412,7 @@ class GanttView {
409
412
  }
410
413
  }
411
414
 
412
- const viewOptions$1 = {
415
+ const viewOptions$4 = {
413
416
  start: new GanttDate().startOfQuarter().addQuarters(-1),
414
417
  end: new GanttDate().endOfQuarter().addQuarters(2),
415
418
  cellWidth: 280,
@@ -418,7 +421,7 @@ const viewOptions$1 = {
418
421
  };
419
422
  class GanttViewMonth extends GanttView {
420
423
  constructor(start, end, options) {
421
- super(start, end, Object.assign({}, viewOptions$1, options));
424
+ super(start, end, Object.assign({}, viewOptions$4, options));
422
425
  }
423
426
  startOf(date) {
424
427
  return date.startOfQuarter();
@@ -454,7 +457,7 @@ class GanttViewMonth extends GanttView {
454
457
  }
455
458
  }
456
459
 
457
- const viewOptions$2 = {
460
+ const viewOptions$3 = {
458
461
  start: new GanttDate().addYears(-1).startOfYear(),
459
462
  end: new GanttDate().addYears(1).endOfYear(),
460
463
  min: new GanttDate().addYears(-2).startOfYear(),
@@ -465,7 +468,7 @@ const viewOptions$2 = {
465
468
  };
466
469
  class GanttViewQuarter extends GanttView {
467
470
  constructor(start, end, options) {
468
- super(start, end, Object.assign({}, viewOptions$2, options));
471
+ super(start, end, Object.assign({}, viewOptions$3, options));
469
472
  }
470
473
  startOf(date) {
471
474
  return date.startOfYear();
@@ -501,7 +504,7 @@ class GanttViewQuarter extends GanttView {
501
504
  }
502
505
  }
503
506
 
504
- const viewOptions$3 = {
507
+ const viewOptions$2 = {
505
508
  cellWidth: 35,
506
509
  start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
507
510
  end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
@@ -510,7 +513,7 @@ const viewOptions$3 = {
510
513
  };
511
514
  class GanttViewDay extends GanttView {
512
515
  constructor(start, end, options) {
513
- super(start, end, Object.assign({}, viewOptions$3, options));
516
+ super(start, end, Object.assign({}, viewOptions$2, options));
514
517
  this.showWeekBackdrop = true;
515
518
  this.showTimeline = false;
516
519
  }
@@ -552,7 +555,7 @@ class GanttViewDay extends GanttView {
552
555
  }
553
556
  }
554
557
 
555
- const viewOptions$4 = {
558
+ const viewOptions$1 = {
556
559
  cellWidth: 280,
557
560
  start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
558
561
  end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
@@ -561,7 +564,7 @@ const viewOptions$4 = {
561
564
  };
562
565
  class GanttViewWeek extends GanttView {
563
566
  constructor(start, end, options) {
564
- super(start, end, Object.assign({}, viewOptions$4, options));
567
+ super(start, end, Object.assign({}, viewOptions$1, options));
565
568
  }
566
569
  startOf(date) {
567
570
  return date.startOfWeek({ weekStartsOn: 1 });
@@ -598,16 +601,16 @@ class GanttViewWeek extends GanttView {
598
601
  }
599
602
  }
600
603
 
601
- const viewOptions$5 = {
604
+ const viewOptions = {
602
605
  cellWidth: 480,
603
- start: new GanttDate().addYears(-1).startOfYear(),
604
- end: new GanttDate().addYears(1).endOfYear(),
606
+ start: new GanttDate().addYears(-2).startOfYear(),
607
+ end: new GanttDate().addYears(2).endOfYear(),
605
608
  addAmount: 1,
606
609
  addUnit: 'year'
607
610
  };
608
611
  class GanttViewYear extends GanttView {
609
612
  constructor(start, end, options) {
610
- super(start, end, Object.assign({}, viewOptions$5, options));
613
+ super(start, end, Object.assign({}, viewOptions, options));
611
614
  }
612
615
  startOf(date) {
613
616
  return date.startOfYear();
@@ -720,6 +723,16 @@ function recursiveItems(items) {
720
723
  });
721
724
  return result;
722
725
  }
726
+ function getFlatItems(items) {
727
+ const result = [];
728
+ (items || []).forEach((item) => {
729
+ result.push(item);
730
+ if (item.children) {
731
+ result.push(...getFlatItems(item.children));
732
+ }
733
+ });
734
+ return result;
735
+ }
723
736
 
724
737
  class GanttUpper {
725
738
  constructor(elementRef, cdr, ngZone) {
@@ -741,7 +754,6 @@ class GanttUpper {
741
754
  this.expandChange = new EventEmitter();
742
755
  this.firstChange = true;
743
756
  this.unsubscribe$ = new Subject();
744
- this.expandedItemIds = [];
745
757
  this.ganttClass = true;
746
758
  }
747
759
  get element() {
@@ -764,21 +776,6 @@ class GanttUpper {
764
776
  }
765
777
  setupItems() {
766
778
  this.originItems = uniqBy(this.originItems, 'id');
767
- // 根据上一次数据展开状态同步新的数据展开状态
768
- this.originItems.forEach((originItem) => {
769
- var _a, _b;
770
- const oldItem = this.items.find((item) => {
771
- return item.id === originItem.id;
772
- });
773
- if (!this.firstChange) {
774
- if (oldItem && !((_a = oldItem.children) === null || _a === void 0 ? void 0 : _a.length) && ((_b = originItem.children) === null || _b === void 0 ? void 0 : _b.length)) {
775
- originItem.expanded = originItem.expanded || this.expandedItemIds.includes(originItem.id);
776
- }
777
- else {
778
- originItem.expanded = this.expandedItemIds.includes(originItem.id);
779
- }
780
- }
781
- });
782
779
  this.items = [];
783
780
  if (this.groups.length > 0) {
784
781
  this.originItems.forEach((origin) => {
@@ -797,17 +794,23 @@ class GanttUpper {
797
794
  }
798
795
  }
799
796
  setupExpandedState() {
797
+ this.originItems = uniqBy(this.originItems, 'id');
800
798
  let items = [];
799
+ const flatOriginItems = getFlatItems(this.originItems);
801
800
  if (this.items.length > 0) {
802
801
  items = recursiveItems(this.items);
803
802
  }
804
803
  else {
805
804
  items = flatten(this.groups.map((group) => recursiveItems(group.items)));
806
805
  }
807
- this.expandedItemIds = [];
808
806
  items.forEach((item) => {
809
807
  if (item.origin.expanded) {
810
- this.expandedItemIds.push(item.id);
808
+ const newItem = flatOriginItems.find((originItem) => originItem.id === item.id);
809
+ if (newItem) {
810
+ if (newItem.expanded === undefined) {
811
+ newItem.expanded = true;
812
+ }
813
+ }
811
814
  }
812
815
  });
813
816
  }
@@ -921,36 +924,59 @@ class GanttUpper {
921
924
  this.expandGroups(false);
922
925
  }
923
926
  }
924
- GanttUpper.decorators = [
925
- { type: Directive }
926
- ];
927
- GanttUpper.ctorParameters = () => [
928
- { type: ElementRef },
929
- { type: ChangeDetectorRef },
930
- { type: NgZone }
931
- ];
932
- GanttUpper.propDecorators = {
933
- originItems: [{ type: Input, args: ['items',] }],
934
- originGroups: [{ type: Input, args: ['groups',] }],
935
- viewType: [{ type: Input }],
936
- start: [{ type: Input }],
937
- end: [{ type: Input }],
938
- showTodayLine: [{ type: Input }],
939
- draggable: [{ type: Input }],
940
- styles: [{ type: Input }],
941
- viewOptions: [{ type: Input }],
942
- disabledLoadOnScroll: [{ type: Input }],
943
- loadOnScroll: [{ type: Output }],
944
- dragStarted: [{ type: Output }],
945
- dragEnded: [{ type: Output }],
946
- barClick: [{ type: Output }],
947
- barTemplate: [{ type: ContentChild, args: ['bar', { static: true },] }],
948
- rangeTemplate: [{ type: ContentChild, args: ['range', { static: true },] }],
949
- itemTemplate: [{ type: ContentChild, args: ['item', { static: true },] }],
950
- groupTemplate: [{ type: ContentChild, args: ['group', { static: true },] }],
951
- groupHeaderTemplate: [{ type: ContentChild, args: ['groupHeader', { static: true },] }],
952
- ganttClass: [{ type: HostBinding, args: ['class.gantt',] }]
953
- };
927
+ 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 });
928
+ 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 });
929
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttUpper, decorators: [{
930
+ type: Directive
931
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }]; }, propDecorators: { originItems: [{
932
+ type: Input,
933
+ args: ['items']
934
+ }], originGroups: [{
935
+ type: Input,
936
+ args: ['groups']
937
+ }], viewType: [{
938
+ type: Input
939
+ }], start: [{
940
+ type: Input
941
+ }], end: [{
942
+ type: Input
943
+ }], showTodayLine: [{
944
+ type: Input
945
+ }], draggable: [{
946
+ type: Input
947
+ }], styles: [{
948
+ type: Input
949
+ }], viewOptions: [{
950
+ type: Input
951
+ }], disabledLoadOnScroll: [{
952
+ type: Input
953
+ }], loadOnScroll: [{
954
+ type: Output
955
+ }], dragStarted: [{
956
+ type: Output
957
+ }], dragEnded: [{
958
+ type: Output
959
+ }], barClick: [{
960
+ type: Output
961
+ }], barTemplate: [{
962
+ type: ContentChild,
963
+ args: ['bar', { static: true }]
964
+ }], rangeTemplate: [{
965
+ type: ContentChild,
966
+ args: ['range', { static: true }]
967
+ }], itemTemplate: [{
968
+ type: ContentChild,
969
+ args: ['item', { static: true }]
970
+ }], groupTemplate: [{
971
+ type: ContentChild,
972
+ args: ['group', { static: true }]
973
+ }], groupHeaderTemplate: [{
974
+ type: ContentChild,
975
+ args: ['groupHeader', { static: true }]
976
+ }], ganttClass: [{
977
+ type: HostBinding,
978
+ args: ['class.gantt']
979
+ }] } });
954
980
  const GANTT_UPPER_TOKEN = new InjectionToken('GANTT_UPPER_TOKEN');
955
981
 
956
982
  class NgxGanttTableColumnComponent {
@@ -962,21 +988,28 @@ class NgxGanttTableColumnComponent {
962
988
  }
963
989
  ngOnInit() { }
964
990
  }
965
- NgxGanttTableColumnComponent.decorators = [
966
- { type: Component, args: [{
967
- selector: 'ngx-gantt-column',
968
- template: ''
969
- },] }
970
- ];
971
- NgxGanttTableColumnComponent.ctorParameters = () => [
972
- { type: GanttUpper, decorators: [{ type: Inject, args: [GANTT_UPPER_TOKEN,] }] }
973
- ];
974
- NgxGanttTableColumnComponent.propDecorators = {
975
- width: [{ type: Input }],
976
- name: [{ type: Input }],
977
- templateRef: [{ type: ContentChild, args: ['cell', { static: true },] }],
978
- headerTemplateRef: [{ type: ContentChild, args: ['header', { static: true },] }]
979
- };
991
+ NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
992
+ NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
993
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableColumnComponent, decorators: [{
994
+ type: Component,
995
+ args: [{
996
+ selector: 'ngx-gantt-column',
997
+ template: ''
998
+ }]
999
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1000
+ type: Inject,
1001
+ args: [GANTT_UPPER_TOKEN]
1002
+ }] }]; }, propDecorators: { width: [{
1003
+ type: Input
1004
+ }], name: [{
1005
+ type: Input
1006
+ }], templateRef: [{
1007
+ type: ContentChild,
1008
+ args: ['cell', { static: true }]
1009
+ }], headerTemplateRef: [{
1010
+ type: ContentChild,
1011
+ args: ['header', { static: true }]
1012
+ }] } });
980
1013
 
981
1014
  class NgxGanttTableComponent {
982
1015
  constructor() {
@@ -984,199 +1017,195 @@ class NgxGanttTableComponent {
984
1017
  }
985
1018
  ngOnInit() { }
986
1019
  }
987
- NgxGanttTableComponent.decorators = [
988
- { type: Component, args: [{
989
- selector: 'ngx-gantt-table',
990
- template: ''
991
- },] }
992
- ];
993
- NgxGanttTableComponent.ctorParameters = () => [];
994
- NgxGanttTableComponent.propDecorators = {
995
- columnChanges: [{ type: Output }]
1020
+ NgxGanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1021
+ 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 });
1022
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableComponent, decorators: [{
1023
+ type: Component,
1024
+ args: [{
1025
+ selector: 'ngx-gantt-table',
1026
+ template: ''
1027
+ }]
1028
+ }], ctorParameters: function () { return []; }, propDecorators: { columnChanges: [{
1029
+ type: Output
1030
+ }] } });
1031
+
1032
+ const GANTT_ABSTRACT_TOKEN = new InjectionToken('gantt-abstract-token');
1033
+
1034
+ 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>`;
1035
+ 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>`;
1036
+ 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>`;
1037
+ 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>`;
1038
+ 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">
1039
+ <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)">
1040
+ <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform>
1041
+ </path>
1042
+ </svg>`;
1043
+ const emptyIcon = `<svg
1044
+ width="148px"
1045
+ height="134px"
1046
+ viewBox="0 0 148 134"
1047
+ version="1.1"
1048
+ xmlns="http://www.w3.org/2000/svg"
1049
+ xmlns:xlink="http://www.w3.org/1999/xlink"
1050
+ >
1051
+ <defs>
1052
+ <filter x="0.0%" y="0.0%" width="100.0%" height="100.0%" filterUnits="objectBoundingBox" id="filter-1">
1053
+ <feGaussianBlur stdDeviation="0" in="SourceGraphic"></feGaussianBlur>
1054
+ </filter>
1055
+ </defs>
1056
+ <g id="148x134" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1057
+ <g id="编组-6" transform="translate(1.000000, 1.000000)">
1058
+ <ellipse
1059
+ id="椭圆形"
1060
+ fill="#EDEEF2"
1061
+ opacity="0.3"
1062
+ filter="url(#filter-1)"
1063
+ cx="73.0800017"
1064
+ cy="115.920003"
1065
+ rx="73.0800017"
1066
+ ry="16.8000004"
1067
+ ></ellipse>
1068
+ <g id="编组-5" transform="translate(15.120000, 0.000000)">
1069
+ <polygon
1070
+ id="矩形"
1071
+ fill="#E2E4E9"
1072
+ points="19.2789848 49.5600011 99.1200023 48.7200011 117.600003 75.9297673 117.600003 92.313049 0 92.313049 0 75.0356267"
1073
+ ></polygon>
1074
+ <path
1075
+ 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"
1076
+ id="矩形"
1077
+ fill="#F9FAFB"
1078
+ ></path>
1079
+ <path
1080
+ 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"
1081
+ id="矩形"
1082
+ fill="#E8EAEE"
1083
+ ></path>
1084
+ <text
1085
+ id="&lt;/null&gt;"
1086
+ font-family="PingFangSC-Medium, PingFang SC"
1087
+ font-size="15.1200003"
1088
+ font-weight="400"
1089
+ fill="#BCBECD"
1090
+ >
1091
+ <tspan x="33.6000008" y="32.8000004">&lt;/null&gt;</tspan>
1092
+ </text>
1093
+ <rect id="矩形" fill="#E8EAEE" x="27.5600006" y="52.0800012" width="61.4800014" height="5.04000011" rx="2.52000006"></rect>
1094
+ <rect
1095
+ id="矩形备份"
1096
+ fill="#E8EAEE"
1097
+ x="27.5600006"
1098
+ y="63.8400014"
1099
+ width="61.4800014"
1100
+ height="5.04000011"
1101
+ rx="2.52000006"
1102
+ ></rect>
1103
+ <path
1104
+ 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"
1105
+ id="矩形"
1106
+ fill="#EDEFF2"
1107
+ ></path>
1108
+ </g>
1109
+ </g>
1110
+ </g>
1111
+ </svg>`;
1112
+ const icons = {
1113
+ 'angle-right': angleRight,
1114
+ 'angle-down': angleDown,
1115
+ 'plus-square': plusSquare,
1116
+ 'minus-square': minusSquare,
1117
+ loading: loadingIcon,
1118
+ empty: emptyIcon
996
1119
  };
997
1120
 
998
- const defaultColumnWidth = 100;
999
- const minColumnWidth = 80;
1000
- class NgxGanttComponent extends GanttUpper {
1001
- constructor(elementRef, cdr, ngZone) {
1002
- super(elementRef, cdr, ngZone);
1003
- this.maxLevel = 2;
1004
- this.linkDragStarted = new EventEmitter();
1005
- this.linkDragEnded = new EventEmitter();
1006
- this.lineClick = new EventEmitter();
1007
- this.ngUnsubscribe$ = new Subject();
1008
- this.sideTableWidth = sideWidth;
1009
- }
1010
- ngOnInit() {
1011
- super.onInit();
1012
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1013
- this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
1014
- this.linkDragStarted.emit(event);
1015
- });
1016
- this.dragContainer.linkDragEnded.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
1017
- this.linkDragEnded.emit(event);
1018
- });
1019
- });
1020
- }
1021
- ngAfterViewInit() {
1022
- this.columns.changes.pipe(startWith(true), takeUntil(this.ngUnsubscribe$)).subscribe(() => {
1023
- this.columns.forEach((column) => {
1024
- if (!column.columnWidth) {
1025
- column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1026
- }
1027
- });
1028
- this.cdr.detectChanges();
1029
- });
1121
+ class GanttIconComponent {
1122
+ constructor(elementRef) {
1123
+ this.elementRef = elementRef;
1124
+ this.isIcon = true;
1030
1125
  }
1031
- ngOnChanges(changes) {
1032
- super.onChanges(changes);
1126
+ set iconName(name) {
1127
+ this.setSvg(name);
1033
1128
  }
1034
- expandChildren(item) {
1035
- if (!item.expanded) {
1036
- item.setExpand(true);
1037
- if (this.async && this.childrenResolve && item.children.length === 0) {
1038
- item.loading = true;
1039
- this.childrenResolve(item.origin)
1040
- .pipe(take(1), finalize(() => {
1041
- item.loading = false;
1042
- this.expandChange.emit();
1043
- this.cdr.detectChanges();
1044
- }))
1045
- .subscribe((items) => {
1046
- item.addChildren(items);
1047
- this.computeItemsRefs(...item.children);
1048
- });
1049
- }
1050
- else {
1051
- this.computeItemsRefs(...item.children);
1052
- this.expandChange.emit();
1053
- }
1129
+ ngOnInit() { }
1130
+ ngAfterViewInit() { }
1131
+ setSvg(name) {
1132
+ const iconSvg = icons[name];
1133
+ if (iconSvg) {
1134
+ this.elementRef.nativeElement.innerHTML = iconSvg;
1054
1135
  }
1055
1136
  else {
1056
- item.setExpand(false);
1057
- this.expandChange.emit();
1137
+ this.elementRef.nativeElement.innerHTML = '';
1058
1138
  }
1059
1139
  }
1060
- ngOnDestroy() {
1061
- super.onDestroy();
1140
+ }
1141
+ GanttIconComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttIconComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1142
+ 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 });
1143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttIconComponent, decorators: [{
1144
+ type: Component,
1145
+ args: [{
1146
+ selector: 'gantt-icon',
1147
+ template: ''
1148
+ }]
1149
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { isIcon: [{
1150
+ type: HostBinding,
1151
+ args: ['class.gantt-icon']
1152
+ }], iconName: [{
1153
+ type: Input
1154
+ }] } });
1155
+
1156
+ class IsGanttRangeItemPipe {
1157
+ transform(value) {
1158
+ return value === GanttItemType.range;
1062
1159
  }
1063
1160
  }
1064
- NgxGanttComponent.decorators = [
1065
- { type: Component, args: [{
1066
- selector: 'ngx-gantt',
1067
- template: "<ngx-gantt-root>\n <ng-template #sideTemplate>\n <gantt-table [groups]=\"groups\" [items]=\"items\" [columns]=\"columns\" [groupTemplate]=\"groupTemplate\" [emptyTemplate]=\"tableEmptyTemplate\"></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",
1068
- changeDetection: ChangeDetectionStrategy.OnPush,
1069
- providers: [
1070
- {
1071
- provide: GANTT_UPPER_TOKEN,
1072
- useExisting: NgxGanttComponent
1073
- }
1074
- ]
1075
- },] }
1076
- ];
1077
- NgxGanttComponent.ctorParameters = () => [
1078
- { type: ElementRef },
1079
- { type: ChangeDetectorRef },
1080
- { type: NgZone }
1081
- ];
1082
- NgxGanttComponent.propDecorators = {
1083
- maxLevel: [{ type: Input }],
1084
- async: [{ type: Input }],
1085
- childrenResolve: [{ type: Input }],
1086
- linkable: [{ type: Input }],
1087
- linkDragStarted: [{ type: Output }],
1088
- linkDragEnded: [{ type: Output }],
1089
- lineClick: [{ type: Output }],
1090
- table: [{ type: ContentChild, args: [NgxGanttTableComponent,] }],
1091
- columns: [{ type: ContentChildren, args: [NgxGanttTableColumnComponent, { descendants: true },] }],
1092
- tableEmptyTemplate: [{ type: ContentChild, args: ['tableEmpty', { static: true },] }]
1093
- };
1161
+ IsGanttRangeItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1162
+ IsGanttRangeItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, name: "isGanttRangeItem" });
1163
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, decorators: [{
1164
+ type: Pipe,
1165
+ args: [{
1166
+ name: 'isGanttRangeItem'
1167
+ }]
1168
+ }] });
1169
+ class IsGanttBarItemPipe {
1170
+ transform(value) {
1171
+ return value === GanttItemType.bar;
1172
+ }
1173
+ }
1174
+ IsGanttBarItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1175
+ IsGanttBarItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, name: "isGanttBarItem" });
1176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, decorators: [{
1177
+ type: Pipe,
1178
+ args: [{
1179
+ name: 'isGanttBarItem'
1180
+ }]
1181
+ }] });
1182
+ class IsGanttCustomItemPipe {
1183
+ transform(value) {
1184
+ return value === GanttItemType.custom;
1185
+ }
1186
+ }
1187
+ IsGanttCustomItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1188
+ IsGanttCustomItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, name: "isGanttCustomItem" });
1189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, decorators: [{
1190
+ type: Pipe,
1191
+ args: [{
1192
+ name: 'isGanttCustomItem'
1193
+ }]
1194
+ }] });
1094
1195
 
1095
- const mainHeight = 5000;
1096
- class GanttCalendarComponent {
1097
- constructor(ganttUpper, ngZone, elementRef) {
1098
- this.ganttUpper = ganttUpper;
1099
- this.ngZone = ngZone;
1196
+ const defaultColumnWidth = 100;
1197
+ const minColumnWidth = 80;
1198
+ class GanttTableComponent {
1199
+ constructor(gantt, elementRef) {
1200
+ this.gantt = gantt;
1100
1201
  this.elementRef = elementRef;
1101
- this.unsubscribe$ = new Subject();
1102
- this.headerHeight = headerHeight;
1103
- this.mainHeight = mainHeight;
1104
- this.todayHeight = todayHeight;
1105
- this.todayWidth = todayWidth;
1106
- this.todayBorderRadius = todayBorderRadius;
1107
- this.viewTypes = GanttViewType;
1108
- this.className = true;
1109
- }
1110
- get view() {
1111
- return this.ganttUpper.view;
1202
+ this.ganttTableClass = true;
1203
+ this.ganttTableEmptyClass = false;
1112
1204
  }
1113
- setTodayPoint() {
1114
- const x = this.view.getTodayXPoint();
1115
- const today = new GanttDate().getDate();
1116
- const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
1117
- const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
1118
- const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
1119
- if (isNumber(x)) {
1120
- if (rect) {
1121
- rect.style.left = `${x - todayWidth / 2}px`;
1122
- rect.style.top = `${headerHeight - todayHeight}px`;
1123
- rect.innerHTML = today.toString();
1124
- }
1125
- if (line) {
1126
- line.style.left = `${x}px`;
1127
- line.style.top = `${headerHeight}px`;
1128
- line.style.bottom = `${-mainHeight}px`;
1129
- }
1130
- }
1131
- else {
1132
- todayEle.style.display = 'none';
1133
- }
1134
- }
1135
- ngOnInit() {
1136
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1137
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
1138
- .pipe(takeUntil(this.unsubscribe$))
1139
- .subscribe(() => {
1140
- this.setTodayPoint();
1141
- });
1142
- });
1143
- }
1144
- ngAfterViewInit() { }
1145
- ngOnChanges(changes) { }
1146
- trackBy(point, index) {
1147
- return point.text || index;
1148
- }
1149
- ngOnDestroy() {
1150
- this.unsubscribe$.next();
1151
- this.unsubscribe$.complete();
1152
- }
1153
- }
1154
- GanttCalendarComponent.decorators = [
1155
- { type: Component, args: [{
1156
- selector: 'gantt-calendar-overlay',
1157
- 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"
1158
- },] }
1159
- ];
1160
- GanttCalendarComponent.ctorParameters = () => [
1161
- { type: GanttUpper, decorators: [{ type: Inject, args: [GANTT_UPPER_TOKEN,] }] },
1162
- { type: NgZone },
1163
- { type: ElementRef }
1164
- ];
1165
- GanttCalendarComponent.propDecorators = {
1166
- className: [{ type: HostBinding, args: ['class.gantt-calendar-overlay',] }]
1167
- };
1168
-
1169
- class GanttTableComponent {
1170
- constructor(gantt, elementRef) {
1171
- this.gantt = gantt;
1172
- this.elementRef = elementRef;
1173
- this.ganttTableClass = true;
1174
- this.ganttTableEmptyClass = false;
1175
- }
1176
- set columns(columns) {
1177
- columns.forEach((column) => {
1178
- if (!column.columnWidth) {
1179
- column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1205
+ set columns(columns) {
1206
+ columns.forEach((column) => {
1207
+ if (!column.columnWidth) {
1208
+ column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1180
1209
  }
1181
1210
  });
1182
1211
  this.columnList = columns;
@@ -1270,26 +1299,37 @@ class GanttTableComponent {
1270
1299
  this.draglineElementRef.nativeElement.style.display = 'none';
1271
1300
  }
1272
1301
  }
1273
- GanttTableComponent.decorators = [
1274
- { type: Component, args: [{
1275
- selector: 'gantt-table',
1276
- 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\">\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\">\n <div\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 [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]=\"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(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 </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"
1277
- },] }
1278
- ];
1279
- GanttTableComponent.ctorParameters = () => [
1280
- { type: NgxGanttComponent },
1281
- { type: ElementRef }
1282
- ];
1283
- GanttTableComponent.propDecorators = {
1284
- groups: [{ type: Input }],
1285
- items: [{ type: Input }],
1286
- columns: [{ type: Input }],
1287
- groupTemplate: [{ type: Input }],
1288
- emptyTemplate: [{ type: Input }],
1289
- draglineElementRef: [{ type: ViewChild, args: ['dragLine', { static: true },] }],
1290
- ganttTableClass: [{ type: HostBinding, args: ['class.gantt-table',] }],
1291
- ganttTableEmptyClass: [{ type: HostBinding, args: ['class.gantt-table-empty',] }]
1292
- };
1302
+ GanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableComponent, deps: [{ token: GANTT_ABSTRACT_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1303
+ 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" }, 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\">\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\">\n <div\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 [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]=\"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(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 </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 } });
1304
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableComponent, decorators: [{
1305
+ type: Component,
1306
+ args: [{
1307
+ selector: 'gantt-table',
1308
+ templateUrl: './gantt-table.component.html'
1309
+ }]
1310
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1311
+ type: Inject,
1312
+ args: [GANTT_ABSTRACT_TOKEN]
1313
+ }] }, { type: i0.ElementRef }]; }, propDecorators: { groups: [{
1314
+ type: Input
1315
+ }], items: [{
1316
+ type: Input
1317
+ }], columns: [{
1318
+ type: Input
1319
+ }], groupTemplate: [{
1320
+ type: Input
1321
+ }], emptyTemplate: [{
1322
+ type: Input
1323
+ }], draglineElementRef: [{
1324
+ type: ViewChild,
1325
+ args: ['dragLine', { static: true }]
1326
+ }], ganttTableClass: [{
1327
+ type: HostBinding,
1328
+ args: ['class.gantt-table']
1329
+ }], ganttTableEmptyClass: [{
1330
+ type: HostBinding,
1331
+ args: ['class.gantt-table-empty']
1332
+ }] } });
1293
1333
 
1294
1334
  const scrollThreshold = 50;
1295
1335
  var ScrollDirection;
@@ -1383,10 +1423,11 @@ class GanttDomService {
1383
1423
  this.unsubscribe$.complete();
1384
1424
  }
1385
1425
  }
1386
- GanttDomService.decorators = [
1387
- { type: Injectable }
1388
- ];
1389
- GanttDomService.ctorParameters = () => [];
1426
+ GanttDomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1427
+ GanttDomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService });
1428
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService, decorators: [{
1429
+ type: Injectable
1430
+ }], ctorParameters: function () { return []; } });
1390
1431
 
1391
1432
  class GanttDragContainer {
1392
1433
  constructor() {
@@ -1439,286 +1480,526 @@ class GanttDragContainer {
1439
1480
  this.linkDragTarget = null;
1440
1481
  }
1441
1482
  }
1442
- GanttDragContainer.decorators = [
1443
- { type: Injectable }
1444
- ];
1445
- GanttDragContainer.ctorParameters = () => [];
1483
+ GanttDragContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1484
+ GanttDragContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer });
1485
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer, decorators: [{
1486
+ type: Injectable
1487
+ }], ctorParameters: function () { return []; } });
1446
1488
 
1447
- const dragMinWidth = 10;
1448
- const activeClass = 'gantt-bar-active';
1449
- const linkDropClass = 'gantt-bar-link-drop';
1450
- function createSvgElement(qualifiedName, className) {
1451
- const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
1452
- element.classList.add(className);
1453
- return element;
1454
- }
1455
- class GanttBarDrag {
1456
- constructor(dragDrop, dom, dragContainer) {
1457
- this.dragDrop = dragDrop;
1458
- this.dom = dom;
1459
- this.dragContainer = dragContainer;
1460
- this.dragRefs = [];
1461
- this.destroy$ = new Subject();
1489
+ class GanttPrintService {
1490
+ constructor() { }
1491
+ setInlineStyles(targetElem) {
1492
+ const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
1493
+ for (const svgElement of svgElements) {
1494
+ this.recursElementChildren(svgElement);
1495
+ }
1462
1496
  }
1463
- get dragDisabled() {
1464
- return !this.item.draggable || !this.ganttUpper.draggable;
1497
+ recursElementChildren(node) {
1498
+ const transformProperties = [
1499
+ 'fill',
1500
+ 'color',
1501
+ 'font-size',
1502
+ 'stroke',
1503
+ 'font',
1504
+ 'text-anchor',
1505
+ 'stroke-dasharray',
1506
+ 'shape-rendering',
1507
+ 'stroke-width'
1508
+ ];
1509
+ if (!node.style) {
1510
+ return;
1511
+ }
1512
+ const styles = getComputedStyle(node);
1513
+ for (const transformProperty of transformProperties) {
1514
+ node.style[transformProperty] = styles[transformProperty];
1515
+ }
1516
+ for (const child of Array.from(node.childNodes)) {
1517
+ this.recursElementChildren(child);
1518
+ }
1465
1519
  }
1466
- get linkDragDisabled() {
1467
- return !this.item.linkable || !this.ganttUpper.linkable;
1520
+ register(root) {
1521
+ this.root = root.nativeElement;
1522
+ this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
1468
1523
  }
1469
- createMouseEvents() {
1470
- fromEvent(this.barElement, 'mouseenter')
1471
- .pipe(takeUntil(this.destroy$))
1472
- .subscribe(() => {
1473
- if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
1474
- if (this.item.linkable) {
1475
- this.barElement.classList.add(linkDropClass);
1476
- this.dragContainer.emitLinkDragEntered(this.item);
1524
+ print(name = 'download', ignoreElementClass) {
1525
+ const root = this.root;
1526
+ const mainContainer = this.mainContainer;
1527
+ // set print width
1528
+ const printWidth = root.offsetWidth;
1529
+ // set print height
1530
+ const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
1531
+ html2canvas(root, {
1532
+ logging: false,
1533
+ allowTaint: true,
1534
+ useCORS: true,
1535
+ width: printWidth,
1536
+ height: printHeight,
1537
+ ignoreElements: (element) => {
1538
+ if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
1539
+ return true;
1477
1540
  }
1541
+ if (element.classList.contains('gantt-calendar-today-overlay')) {
1542
+ return true;
1543
+ }
1544
+ },
1545
+ onclone: (cloneDocument) => {
1546
+ const ganttClass = root.className;
1547
+ const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
1548
+ const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
1549
+ const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
1550
+ const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
1551
+ // change targetDom width
1552
+ cloneGanttDom.style.width = `${printWidth}px`;
1553
+ cloneGanttDom.style.height = `${printHeight}px`;
1554
+ cloneGanttDom.style.overflow = `unset`;
1555
+ cloneGanttContainerDom.style.backgroundColor = '#fff';
1556
+ cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
1557
+ cloneCalendarOverlay.setAttribute('style', `background: transparent`);
1558
+ if (cloneLinksOverlay) {
1559
+ cloneLinksOverlay.setAttribute('height', `${printHeight}`);
1560
+ cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
1561
+ }
1562
+ // setInlineStyles for svg
1563
+ this.setInlineStyles(cloneGanttDom);
1478
1564
  }
1479
- else {
1480
- this.barElement.classList.add(activeClass);
1481
- }
1565
+ }).then((canvas) => {
1566
+ const link = document.createElement('a');
1567
+ const dataUrl = canvas.toDataURL('image/png');
1568
+ link.download = `${name}.png`;
1569
+ link.href = dataUrl;
1570
+ link.click();
1482
1571
  });
1483
- fromEvent(this.barElement, 'mouseleave')
1484
- .pipe(takeUntil(this.destroy$))
1485
- .subscribe(() => {
1486
- if (!this.dragContainer.linkDraggingId) {
1487
- this.barElement.classList.remove(activeClass);
1572
+ }
1573
+ }
1574
+ GanttPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttPrintService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1575
+ GanttPrintService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttPrintService });
1576
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttPrintService, decorators: [{
1577
+ type: Injectable
1578
+ }], ctorParameters: function () { return []; } });
1579
+
1580
+ const mainHeight = 5000;
1581
+ class GanttCalendarComponent {
1582
+ constructor(ganttUpper, ngZone, elementRef) {
1583
+ this.ganttUpper = ganttUpper;
1584
+ this.ngZone = ngZone;
1585
+ this.elementRef = elementRef;
1586
+ this.unsubscribe$ = new Subject();
1587
+ this.headerHeight = headerHeight;
1588
+ this.mainHeight = mainHeight;
1589
+ this.todayHeight = todayHeight;
1590
+ this.todayWidth = todayWidth;
1591
+ this.todayBorderRadius = todayBorderRadius;
1592
+ this.viewTypes = GanttViewType;
1593
+ this.className = true;
1594
+ }
1595
+ get view() {
1596
+ return this.ganttUpper.view;
1597
+ }
1598
+ setTodayPoint() {
1599
+ const x = this.view.getTodayXPoint();
1600
+ const today = new GanttDate().getDate();
1601
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
1602
+ const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
1603
+ const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
1604
+ if (isNumber(x)) {
1605
+ if (rect) {
1606
+ rect.style.left = `${x - todayWidth / 2}px`;
1607
+ rect.style.top = `${headerHeight - todayHeight}px`;
1608
+ rect.innerHTML = today.toString();
1488
1609
  }
1489
- else {
1490
- this.dragContainer.emitLinkDragLeaved();
1610
+ if (line) {
1611
+ line.style.left = `${x}px`;
1612
+ line.style.top = `${headerHeight}px`;
1613
+ line.style.bottom = `${-mainHeight}px`;
1491
1614
  }
1492
- this.barElement.classList.remove(linkDropClass);
1493
- });
1615
+ }
1616
+ else {
1617
+ todayEle.style.display = 'none';
1618
+ }
1494
1619
  }
1495
- createBarDrag() {
1496
- const dragRef = this.dragDrop.createDrag(this.barElement);
1497
- dragRef.lockAxis = 'x';
1498
- dragRef.started.subscribe(() => {
1499
- this.setDraggingStyles();
1500
- this.dragContainer.dragStarted.emit({ item: this.item.origin });
1501
- });
1502
- dragRef.moved.subscribe((event) => {
1503
- const x = this.item.refs.x + event.distance.x;
1504
- const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
1505
- const start = this.ganttUpper.view.getDateByXPoint(x);
1506
- const end = start.addDays(days);
1507
- this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), end);
1508
- });
1509
- dragRef.ended.subscribe((event) => {
1510
- const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
1511
- const start = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x);
1512
- const end = start.addDays(days);
1513
- this.item.updateDate(start, end);
1514
- this.clearDraggingStyles();
1515
- this.closeDragBackdrop();
1516
- event.source.reset();
1517
- this.dragContainer.dragEnded.emit({ item: this.item.origin });
1620
+ ngOnInit() {
1621
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1622
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
1623
+ .pipe(takeUntil(this.unsubscribe$))
1624
+ .subscribe(() => {
1625
+ this.setTodayPoint();
1626
+ });
1518
1627
  });
1519
- this.barDragRef = dragRef;
1520
- return dragRef;
1521
1628
  }
1522
- createBarHandleDrags() {
1523
- const dragRefs = [];
1524
- const handles = this.barElement.querySelectorAll('.drag-handles .handle');
1525
- handles.forEach((handle, index) => {
1526
- const isBefore = index === 0;
1527
- const dragRef = this.dragDrop.createDrag(handle);
1528
- dragRef.lockAxis = 'x';
1529
- dragRef.withBoundaryElement(this.dom.root);
1530
- dragRef.started.subscribe(() => {
1531
- this.setDraggingStyles();
1532
- this.dragContainer.dragStarted.emit({ item: this.item.origin });
1533
- });
1534
- dragRef.moved.subscribe((event) => {
1535
- if (isBefore) {
1536
- const x = this.item.refs.x + event.distance.x;
1537
- const width = this.item.refs.width + event.distance.x * -1;
1538
- if (width > dragMinWidth) {
1539
- this.barElement.style.width = width + 'px';
1540
- this.barElement.style.left = x + 'px';
1541
- this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), this.ganttUpper.view.getDateByXPoint(x + width));
1542
- }
1543
- }
1544
- else {
1545
- const width = this.item.refs.width + event.distance.x;
1546
- if (width > dragMinWidth) {
1547
- this.barElement.style.width = width + 'px';
1548
- this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(this.item.refs.x), this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
1549
- }
1550
- }
1551
- event.source.reset();
1552
- });
1553
- dragRef.ended.subscribe((event) => {
1554
- if (isBefore) {
1555
- const width = this.item.refs.width + event.distance.x * -1;
1556
- if (width > dragMinWidth) {
1557
- this.item.updateDate(this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x), this.item.end);
1558
- }
1559
- else {
1560
- this.item.updateDate(this.item.end.startOfDay(), this.item.end);
1561
- }
1562
- }
1563
- else {
1564
- const width = this.item.refs.width + event.distance.x;
1565
- if (width > dragMinWidth) {
1566
- this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + this.item.refs.width + event.distance.x));
1567
- }
1568
- else {
1569
- this.item.updateDate(this.item.start, this.item.start.endOfDay());
1570
- }
1571
- }
1572
- this.clearDraggingStyles();
1573
- this.closeDragBackdrop();
1574
- this.dragContainer.dragEnded.emit({ item: this.item.origin });
1575
- });
1576
- dragRefs.push(dragRef);
1577
- });
1578
- return dragRefs;
1579
- }
1580
- createLinkHandleDrags() {
1581
- const dragRefs = [];
1582
- const handles = this.barElement.querySelectorAll('.link-handles .handle');
1583
- handles.forEach((handle, index) => {
1584
- const isBefore = index === 0;
1585
- const dragRef = this.dragDrop.createDrag(handle);
1586
- dragRef.withBoundaryElement(this.dom.root);
1587
- dragRef.beforeStarted.subscribe(() => {
1588
- handle.style.pointerEvents = 'none';
1589
- if (this.barDragRef) {
1590
- this.barDragRef.disabled = true;
1591
- }
1592
- this.createLinkDraggingLine();
1593
- this.dragContainer.emitLinkDragStarted(isBefore ? 'target' : 'source', this.item);
1594
- });
1595
- dragRef.moved.subscribe(() => {
1596
- const positions = this.calcLinkLinePositions(handle, isBefore);
1597
- this.linkDraggingLine.setAttribute('x1', positions.x1.toString());
1598
- this.linkDraggingLine.setAttribute('y1', positions.y1.toString());
1599
- this.linkDraggingLine.setAttribute('x2', positions.x2.toString());
1600
- this.linkDraggingLine.setAttribute('y2', positions.y2.toString());
1601
- });
1602
- dragRef.ended.subscribe((event) => {
1603
- event.source.reset();
1604
- handle.style.pointerEvents = '';
1605
- if (this.barDragRef) {
1606
- this.barDragRef.disabled = false;
1607
- }
1608
- this.barElement.classList.remove(activeClass);
1609
- this.destroyLinkDraggingLine();
1610
- this.dragContainer.emitLinkDragEnded();
1611
- });
1612
- dragRefs.push(dragRef);
1613
- });
1614
- return dragRefs;
1629
+ ngAfterViewInit() { }
1630
+ ngOnChanges(changes) { }
1631
+ trackBy(point, index) {
1632
+ return point.text || index;
1615
1633
  }
1616
- openDragBackdrop(dragElement, start, end) {
1617
- const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
1618
- const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
1619
- const rootRect = this.dom.root.getBoundingClientRect();
1620
- const dragRect = dragElement.getBoundingClientRect();
1621
- const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
1622
- const width = dragRect.right - dragRect.left;
1623
- dragMaskElement.style.left = left + 'px';
1624
- dragMaskElement.style.width = width + 'px';
1625
- dragMaskElement.querySelector('.start').innerHTML = start.format('MM-dd');
1626
- dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
1627
- dragMaskElement.style.display = 'block';
1628
- dragBackdropElement.style.display = 'block';
1634
+ ngOnDestroy() {
1635
+ this.unsubscribe$.next();
1636
+ this.unsubscribe$.complete();
1629
1637
  }
1630
- closeDragBackdrop() {
1631
- const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
1632
- const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
1633
- dragMaskElement.style.display = 'none';
1634
- dragBackdropElement.style.display = 'none';
1638
+ }
1639
+ 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 });
1640
+ 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"] }] });
1641
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarComponent, decorators: [{
1642
+ type: Component,
1643
+ args: [{
1644
+ selector: 'gantt-calendar-overlay',
1645
+ templateUrl: './calendar.component.html'
1646
+ }]
1647
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1648
+ type: Inject,
1649
+ args: [GANTT_UPPER_TOKEN]
1650
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
1651
+ type: HostBinding,
1652
+ args: ['class.gantt-calendar-overlay']
1653
+ }] } });
1654
+
1655
+ class GanttDragBackdropComponent {
1656
+ constructor() {
1657
+ this.backdropClass = true;
1635
1658
  }
1636
- setDraggingStyles() {
1637
- this.barElement.style.pointerEvents = 'none';
1638
- this.barElement.classList.add('gantt-bar-draggable-drag');
1659
+ ngOnInit() { }
1660
+ }
1661
+ GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1662
+ 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" });
1663
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
1664
+ type: Component,
1665
+ args: [{
1666
+ selector: 'gantt-drag-backdrop',
1667
+ templateUrl: `./drag-backdrop.component.html`
1668
+ }]
1669
+ }], ctorParameters: function () { return []; }, propDecorators: { backdropClass: [{
1670
+ type: HostBinding,
1671
+ args: ['class.gantt-drag-backdrop']
1672
+ }] } });
1673
+
1674
+ class NgxGanttRootComponent {
1675
+ constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
1676
+ this.elementRef = elementRef;
1677
+ this.ngZone = ngZone;
1678
+ this.dom = dom;
1679
+ this.dragContainer = dragContainer;
1680
+ this.ganttUpper = ganttUpper;
1681
+ this.printService = printService;
1682
+ this.ganttClass = true;
1683
+ this.unsubscribe$ = new Subject();
1684
+ this.ganttUpper.dragContainer = dragContainer;
1639
1685
  }
1640
- clearDraggingStyles() {
1641
- this.barElement.style.pointerEvents = '';
1642
- this.barElement.classList.remove('gantt-bar-draggable-drag');
1686
+ get view() {
1687
+ return this.ganttUpper.view;
1643
1688
  }
1644
- calcLinkLinePositions(target, isBefore) {
1645
- const rootRect = this.dom.root.getBoundingClientRect();
1646
- const targetRect = target.getBoundingClientRect();
1647
- const layerRect = target.parentElement.parentElement.getBoundingClientRect();
1648
- return {
1649
- x1: layerRect.left + (isBefore ? 0 : layerRect.width) - rootRect.left,
1650
- y1: layerRect.top + layerRect.height / 2 - rootRect.top,
1651
- x2: targetRect.left - rootRect.left + targetRect.width / 2,
1652
- y2: targetRect.top - rootRect.top + targetRect.height / 2
1653
- };
1689
+ ngOnInit() {
1690
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1691
+ this.dom.initialize(this.elementRef);
1692
+ if (this.printService) {
1693
+ this.printService.register(this.elementRef);
1694
+ }
1695
+ this.setupScrollClass();
1696
+ this.setupResize();
1697
+ this.setupViewScroll();
1698
+ // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
1699
+ this.elementRef.nativeElement.style.opacity = '1';
1700
+ this.ganttUpper.viewChange.pipe(startWith(null)).subscribe(() => {
1701
+ this.scrollToToday();
1702
+ });
1703
+ });
1654
1704
  }
1655
- createLinkDraggingLine() {
1656
- if (!this.linkDraggingLine) {
1657
- const svgElement = createSvgElement('svg', 'gantt-link-drag-container');
1658
- const linElement = createSvgElement('line', 'link-dragging-line');
1659
- svgElement.appendChild(linElement);
1660
- this.dom.root.appendChild(svgElement);
1661
- this.linkDraggingLine = linElement;
1705
+ setupViewScroll() {
1706
+ if (this.ganttUpper.disabledLoadOnScroll) {
1707
+ return;
1662
1708
  }
1709
+ this.dom
1710
+ .getViewerScroll()
1711
+ .pipe(takeUntil(this.unsubscribe$))
1712
+ .subscribe((event) => {
1713
+ if (event.direction === ScrollDirection.LEFT) {
1714
+ const dates = this.view.addStartDate();
1715
+ if (dates) {
1716
+ event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
1717
+ this.ngZone.run(() => {
1718
+ this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
1719
+ });
1720
+ }
1721
+ }
1722
+ if (event.direction === ScrollDirection.RIGHT) {
1723
+ const dates = this.view.addEndDate();
1724
+ if (dates) {
1725
+ this.ngZone.run(() => {
1726
+ this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
1727
+ });
1728
+ }
1729
+ }
1730
+ });
1663
1731
  }
1664
- destroyLinkDraggingLine() {
1665
- if (this.linkDraggingLine) {
1666
- this.linkDraggingLine.parentElement.remove();
1667
- this.linkDraggingLine = null;
1668
- }
1732
+ setupResize() {
1733
+ this.dom
1734
+ .getResize()
1735
+ .pipe(takeUntil(this.unsubscribe$))
1736
+ .subscribe(() => {
1737
+ this.setupScrollClass();
1738
+ });
1669
1739
  }
1670
- createDrags(elementRef, item, ganttUpper) {
1671
- this.item = item;
1672
- this.barElement = elementRef.nativeElement;
1673
- this.ganttUpper = ganttUpper;
1674
- if (!item.draggable || (this.dragDisabled && this.linkDragDisabled)) {
1675
- return;
1740
+ setupScrollClass() {
1741
+ const mainContainer = this.dom.mainContainer;
1742
+ const height = mainContainer.offsetHeight;
1743
+ const scrollHeight = mainContainer.scrollHeight;
1744
+ if (scrollHeight > height) {
1745
+ this.elementRef.nativeElement.className = 'gantt gantt-scroll';
1676
1746
  }
1677
1747
  else {
1678
- this.createMouseEvents();
1679
- if (!this.dragDisabled) {
1680
- const dragRef = this.createBarDrag();
1681
- const dragHandlesRefs = this.createBarHandleDrags();
1682
- this.dragRefs.push(dragRef, ...dragHandlesRefs);
1683
- }
1684
- if (!this.linkDragDisabled) {
1685
- const linkDragRefs = this.createLinkHandleDrags();
1686
- this.dragRefs.push(...linkDragRefs);
1687
- }
1748
+ this.elementRef.nativeElement.className = 'gantt';
1688
1749
  }
1689
1750
  }
1690
- ngOnDestroy() {
1691
- this.closeDragBackdrop();
1692
- this.dragRefs.forEach((dragRef) => dragRef.dispose());
1693
- this.destroy$.next();
1694
- this.destroy$.complete();
1751
+ scrollToToday() {
1752
+ const x = this.view.getTodayXPoint();
1753
+ this.dom.scrollMainContainer(x);
1695
1754
  }
1696
1755
  }
1697
- GanttBarDrag.decorators = [
1698
- { type: Injectable }
1699
- ];
1700
- GanttBarDrag.ctorParameters = () => [
1701
- { type: DragDrop },
1702
- { type: GanttDomService },
1703
- { type: GanttDragContainer }
1704
- ];
1756
+ 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 });
1757
+ 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"] }] });
1758
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
1759
+ type: Component,
1760
+ args: [{
1761
+ selector: 'ngx-gantt-root',
1762
+ templateUrl: './root.component.html',
1763
+ providers: [GanttDomService, GanttDragContainer]
1764
+ }]
1765
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
1766
+ type: Inject,
1767
+ args: [GANTT_UPPER_TOKEN]
1768
+ }] }, { type: GanttPrintService, decorators: [{
1769
+ type: Optional
1770
+ }] }]; }, propDecorators: { sideWidth: [{
1771
+ type: Input
1772
+ }], ganttClass: [{
1773
+ type: HostBinding,
1774
+ args: ['class.gantt']
1775
+ }], sideTemplate: [{
1776
+ type: ContentChild,
1777
+ args: ['sideTemplate', { static: true }]
1778
+ }], mainTemplate: [{
1779
+ type: ContentChild,
1780
+ args: ['mainTemplate', { static: true }]
1781
+ }] } });
1705
1782
 
1706
- class GanttItemUpper {
1707
- constructor(elementRef, ganttUpper) {
1708
- this.elementRef = elementRef;
1783
+ var LinkColors;
1784
+ (function (LinkColors) {
1785
+ LinkColors["default"] = "#cacaca";
1786
+ LinkColors["blocked"] = "#FF7575";
1787
+ LinkColors["active"] = "#348FE4";
1788
+ })(LinkColors || (LinkColors = {}));
1789
+ class GanttLinksComponent {
1790
+ constructor(ganttUpper, cdr, elementRef, ganttDragContainer) {
1709
1791
  this.ganttUpper = ganttUpper;
1792
+ this.cdr = cdr;
1793
+ this.elementRef = elementRef;
1794
+ this.ganttDragContainer = ganttDragContainer;
1795
+ this.groups = [];
1796
+ this.items = [];
1797
+ this.lineClick = new EventEmitter();
1798
+ this.links = [];
1799
+ this.linkItems = [];
1800
+ this.bezierWeight = -0.5;
1710
1801
  this.firstChange = true;
1711
1802
  this.unsubscribe$ = new Subject();
1803
+ this.ganttLinksOverlay = true;
1712
1804
  }
1713
- onInit() {
1805
+ ngOnInit() {
1806
+ this.buildLinks();
1714
1807
  this.firstChange = false;
1715
- this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1716
- this.setPositions();
1808
+ this.ganttDragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1809
+ this.elementRef.nativeElement.style.visibility = 'hidden';
1810
+ });
1811
+ merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded)
1812
+ .pipe(takeUntil(this.unsubscribe$), skip(1))
1813
+ .subscribe(() => {
1814
+ this.elementRef.nativeElement.style.visibility = 'visible';
1815
+ this.buildLinks();
1816
+ this.cdr.detectChanges();
1717
1817
  });
1718
1818
  }
1719
- onChanges() {
1819
+ ngOnChanges() {
1720
1820
  if (!this.firstChange) {
1721
- this.setPositions();
1821
+ this.buildLinks();
1822
+ }
1823
+ }
1824
+ computeItemPosition() {
1825
+ const lineHeight = this.ganttUpper.styles.lineHeight;
1826
+ const barHeight = this.ganttUpper.styles.barHeight;
1827
+ this.linkItems = [];
1828
+ if (this.groups.length > 0) {
1829
+ let itemNum = 0;
1830
+ let groupNum = 0;
1831
+ this.groups.forEach((group) => {
1832
+ groupNum++;
1833
+ if (group.expanded) {
1834
+ const items = recursiveItems(group.items);
1835
+ items.forEach((item, itemIndex) => {
1836
+ const y = (groupNum + itemNum + itemIndex) * lineHeight + item.refs.y + barHeight / 2;
1837
+ this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
1838
+ x: item.refs.x,
1839
+ y
1840
+ }, after: {
1841
+ x: item.refs.x + item.refs.width,
1842
+ y
1843
+ } }));
1844
+ });
1845
+ itemNum += items.length;
1846
+ }
1847
+ });
1848
+ }
1849
+ else {
1850
+ const items = recursiveItems(this.items);
1851
+ items.forEach((item, itemIndex) => {
1852
+ const y = itemIndex * lineHeight + item.refs.y + barHeight / 2;
1853
+ this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
1854
+ x: item.refs.x,
1855
+ y
1856
+ }, after: {
1857
+ x: item.refs.x + item.refs.width,
1858
+ y
1859
+ } }));
1860
+ });
1861
+ }
1862
+ }
1863
+ generatePath(source, target) {
1864
+ if (source.before && source.after && target.before && target.after) {
1865
+ const x1 = source.after.x;
1866
+ const y1 = source.after.y;
1867
+ const x4 = target.before.x;
1868
+ const y4 = target.before.y;
1869
+ const dx = Math.abs(x4 - x1) * this.bezierWeight;
1870
+ const x2 = x1 - dx;
1871
+ const x3 = x4 + dx;
1872
+ const centerX = (x1 + x4) / 2;
1873
+ const centerY = (y1 + y4) / 2;
1874
+ let controlX = this.ganttUpper.styles.lineHeight / 2;
1875
+ const controlY = this.ganttUpper.styles.lineHeight / 2;
1876
+ if (x1 >= x4) {
1877
+ if (y4 > y1) {
1878
+ if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
1879
+ return `M ${x1} ${y1}
1880
+ C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 + controlX} ${x1} ${y1 + controlY}
1881
+ L ${x1} ${y1 + controlY} ${centerX} ${centerY}
1882
+
1883
+ M ${x4} ${y4}
1884
+ C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 - controlX} ${x4} ${y4 - controlY}
1885
+ L ${x4} ${y4 - controlY} ${centerX} ${centerY}`;
1886
+ }
1887
+ else {
1888
+ controlX = this.ganttUpper.styles.lineHeight;
1889
+ return `M ${x1} ${y1}
1890
+ C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 + controlX} ${centerX} ${centerY}
1891
+
1892
+
1893
+ M ${x4} ${y4}
1894
+ C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 - controlX} ${centerX} ${centerY}`;
1895
+ }
1896
+ }
1897
+ else {
1898
+ if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
1899
+ return `M ${x1} ${y1}
1900
+ C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 - controlX} ${x1} ${y1 - controlY}
1901
+ L ${x1} ${y1 - controlY} ${centerX} ${centerY}
1902
+
1903
+ M ${x4} ${y4}
1904
+ C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 + controlX} ${x4} ${y4 + controlY}
1905
+ L ${x4} ${y4 + controlY} ${centerX} ${centerY}
1906
+ `;
1907
+ }
1908
+ else {
1909
+ controlX = this.ganttUpper.styles.lineHeight;
1910
+ return `M ${x1} ${y1}
1911
+ C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 - controlX} ${centerX} ${centerY}
1912
+
1913
+ M ${x4} ${y4}
1914
+ C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 + controlX} ${centerX} ${centerY}`;
1915
+ }
1916
+ }
1917
+ }
1918
+ return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
1919
+ }
1920
+ }
1921
+ buildLinks() {
1922
+ this.computeItemPosition();
1923
+ this.links = [];
1924
+ this.linkItems.forEach((source) => {
1925
+ if (source.origin.start || source.origin.end) {
1926
+ source.links.forEach((linkId) => {
1927
+ const target = this.linkItems.find((item) => item.id === linkId);
1928
+ if (target && (target.origin.start || target.origin.end)) {
1929
+ this.links.push({
1930
+ path: this.generatePath(source, target),
1931
+ source: source.origin,
1932
+ target: target.origin,
1933
+ color: source.end.getTime() > target.start.getTime() ? LinkColors.blocked : LinkColors.default
1934
+ });
1935
+ }
1936
+ });
1937
+ }
1938
+ });
1939
+ }
1940
+ trackBy(index) {
1941
+ return index;
1942
+ }
1943
+ onLineClick(event, link) {
1944
+ this.lineClick.emit({
1945
+ event,
1946
+ source: link.source,
1947
+ target: link.target
1948
+ });
1949
+ }
1950
+ mouseEnterPath(link) {
1951
+ if (link.color === LinkColors.default) {
1952
+ link.color = LinkColors.active;
1953
+ }
1954
+ }
1955
+ mouseLeavePath(link) {
1956
+ if (link.color === LinkColors.active) {
1957
+ link.color = LinkColors.default;
1958
+ }
1959
+ }
1960
+ ngOnDestroy() {
1961
+ this.unsubscribe$.next();
1962
+ this.unsubscribe$.complete();
1963
+ }
1964
+ }
1965
+ 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 });
1966
+ 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"] }] });
1967
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttLinksComponent, decorators: [{
1968
+ type: Component,
1969
+ args: [{
1970
+ selector: 'gantt-links-overlay',
1971
+ templateUrl: './links.component.html'
1972
+ }]
1973
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1974
+ type: Inject,
1975
+ args: [GANTT_UPPER_TOKEN]
1976
+ }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: GanttDragContainer }]; }, propDecorators: { groups: [{
1977
+ type: Input
1978
+ }], items: [{
1979
+ type: Input
1980
+ }], lineClick: [{
1981
+ type: Output
1982
+ }], ganttLinksOverlay: [{
1983
+ type: HostBinding,
1984
+ args: ['class.gantt-links-overlay']
1985
+ }] } });
1986
+
1987
+ class GanttItemUpper {
1988
+ constructor(elementRef, ganttUpper) {
1989
+ this.elementRef = elementRef;
1990
+ this.ganttUpper = ganttUpper;
1991
+ this.firstChange = true;
1992
+ this.unsubscribe$ = new Subject();
1993
+ }
1994
+ onInit() {
1995
+ this.firstChange = false;
1996
+ this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1997
+ this.setPositions();
1998
+ });
1999
+ }
2000
+ onChanges() {
2001
+ if (!this.firstChange) {
2002
+ this.setPositions();
1722
2003
  }
1723
2004
  }
1724
2005
  setPositions() {
@@ -1740,753 +2021,609 @@ class GanttItemUpper {
1740
2021
  this.unsubscribe$.complete();
1741
2022
  }
1742
2023
  }
1743
- GanttItemUpper.decorators = [
1744
- { type: Directive }
1745
- ];
1746
- GanttItemUpper.ctorParameters = () => [
1747
- { type: ElementRef },
1748
- { type: GanttUpper, decorators: [{ type: Inject, args: [GANTT_UPPER_TOKEN,] }] }
1749
- ];
1750
- GanttItemUpper.propDecorators = {
1751
- template: [{ type: Input }],
1752
- item: [{ type: Input }]
1753
- };
2024
+ GanttItemUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttItemUpper, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Directive });
2025
+ GanttItemUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.2", type: GanttItemUpper, inputs: { template: "template", item: "item" }, ngImport: i0 });
2026
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttItemUpper, decorators: [{
2027
+ type: Directive
2028
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
2029
+ type: Inject,
2030
+ args: [GANTT_UPPER_TOKEN]
2031
+ }] }]; }, propDecorators: { template: [{
2032
+ type: Input
2033
+ }], item: [{
2034
+ type: Input
2035
+ }] } });
1754
2036
 
1755
- function linearGradient(sideOrCorner, color, stop) {
1756
- return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
1757
- }
1758
- class NgxGanttBarComponent extends GanttItemUpper {
1759
- constructor(dragContainer, drag, elementRef, ganttUpper) {
2037
+ class NgxGanttRangeComponent extends GanttItemUpper {
2038
+ constructor(elementRef, ganttUpper) {
1760
2039
  super(elementRef, ganttUpper);
1761
- this.dragContainer = dragContainer;
1762
- this.drag = drag;
1763
- this.ganttUpper = ganttUpper;
1764
- this.barClick = new EventEmitter();
1765
- this.ganttItemClass = true;
1766
- this.color = 'red';
2040
+ this.ganttRangeClass = true;
1767
2041
  }
1768
2042
  ngOnInit() {
1769
2043
  super.onInit();
1770
- this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1771
- this.setContentBackground();
1772
- });
1773
- }
1774
- ngAfterViewInit() {
1775
- this.drag.createDrags(this.elementRef, this.item, this.ganttUpper);
1776
- this.setContentBackground();
1777
2044
  }
1778
2045
  ngOnChanges() {
1779
2046
  super.onChanges();
1780
2047
  }
1781
- onBarClick(event) {
1782
- this.barClick.emit({ event, item: this.item.origin });
1783
- }
1784
- setContentBackground() {
1785
- const contentElement = this.contentElementRef.nativeElement;
1786
- const color = this.item.color || barBackground;
1787
- const style = this.item.barStyle || {};
1788
- if (this.item.origin.start && this.item.origin.end) {
1789
- style.background = color;
1790
- style.borderRadius = '';
1791
- }
1792
- if (this.item.origin.start && !this.item.origin.end) {
1793
- style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
1794
- style.borderRadius = '4px 12.5px 12.5px 4px';
1795
- }
1796
- if (!this.item.origin.start && this.item.origin.end) {
1797
- style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
1798
- style.borderRadius = '12.5px 4px 4px 12.5px';
1799
- }
1800
- if (this.item.progress >= 0) {
1801
- const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
1802
- style.background = hexToRgb(color, 0.3);
1803
- style.borderRadius = '';
1804
- contentProgressElement.style.background = color;
1805
- }
1806
- for (const key in style) {
1807
- if (style.hasOwnProperty(key)) {
1808
- contentElement.style[key] = style[key];
1809
- }
1810
- }
1811
- }
1812
- stopPropagation(event) {
1813
- event.stopPropagation();
1814
- }
1815
2048
  ngOnDestroy() {
1816
2049
  super.onDestroy();
1817
2050
  }
1818
2051
  }
1819
- NgxGanttBarComponent.decorators = [
1820
- { type: Component, args: [{
1821
- selector: 'ngx-gantt-bar,gantt-bar',
1822
- 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",
1823
- providers: [GanttBarDrag]
1824
- },] }
1825
- ];
1826
- NgxGanttBarComponent.ctorParameters = () => [
1827
- { type: GanttDragContainer },
1828
- { type: GanttBarDrag },
1829
- { type: ElementRef },
1830
- { type: GanttUpper, decorators: [{ type: Inject, args: [GANTT_UPPER_TOKEN,] }] }
1831
- ];
1832
- NgxGanttBarComponent.propDecorators = {
1833
- barClick: [{ type: Output }],
1834
- contentElementRef: [{ type: ViewChild, args: ['content',] }],
1835
- ganttItemClass: [{ type: HostBinding, args: ['class.gantt-bar',] }]
1836
- };
2052
+ 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 });
2053
+ 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"] }] });
2054
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRangeComponent, decorators: [{
2055
+ type: Component,
2056
+ args: [{
2057
+ selector: 'ngx-gantt-range,gantt-range',
2058
+ templateUrl: './range.component.html'
2059
+ }]
2060
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
2061
+ type: Inject,
2062
+ args: [GANTT_UPPER_TOKEN]
2063
+ }] }]; }, propDecorators: { ganttRangeClass: [{
2064
+ type: HostBinding,
2065
+ args: ['class.gantt-range']
2066
+ }] } });
1837
2067
 
1838
- class GanttMainComponent {
1839
- constructor(ganttUpper) {
1840
- this.ganttUpper = ganttUpper;
1841
- this.barClick = new EventEmitter();
1842
- this.lineClick = new EventEmitter();
1843
- this.ganttMainClass = true;
2068
+ const dragMinWidth = 10;
2069
+ const activeClass = 'gantt-bar-active';
2070
+ const linkDropClass = 'gantt-bar-link-drop';
2071
+ function createSvgElement(qualifiedName, className) {
2072
+ const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2073
+ element.classList.add(className);
2074
+ return element;
2075
+ }
2076
+ class GanttBarDrag {
2077
+ constructor(dragDrop, dom, dragContainer) {
2078
+ this.dragDrop = dragDrop;
2079
+ this.dom = dom;
2080
+ this.dragContainer = dragContainer;
2081
+ this.dragRefs = [];
2082
+ this.destroy$ = new Subject();
1844
2083
  }
1845
- ngOnInit() { }
1846
- trackBy(item, index) {
1847
- return item.id || index;
2084
+ get dragDisabled() {
2085
+ return !this.item.draggable || !this.ganttUpper.draggable;
1848
2086
  }
1849
- }
1850
- GanttMainComponent.decorators = [
1851
- { type: Component, args: [{
1852
- selector: 'gantt-main',
1853
- 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; trackBy: trackBy\">\n <div class=\"gantt-item\" [style.height.px]=\"ganttUpper.styles.lineHeight\">\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"
1854
- },] }
1855
- ];
1856
- GanttMainComponent.ctorParameters = () => [
1857
- { type: GanttUpper, decorators: [{ type: Inject, args: [GANTT_UPPER_TOKEN,] }] }
1858
- ];
1859
- GanttMainComponent.propDecorators = {
1860
- groups: [{ type: Input }],
1861
- items: [{ type: Input }],
1862
- groupHeaderTemplate: [{ type: Input }],
1863
- itemTemplate: [{ type: Input }],
1864
- barTemplate: [{ type: Input }],
1865
- rangeTemplate: [{ type: Input }],
1866
- barClick: [{ type: Output }],
1867
- lineClick: [{ type: Output }],
1868
- ganttMainClass: [{ type: HostBinding, args: ['class.gantt-main-container',] }]
1869
- };
1870
-
1871
- 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>`;
1872
- 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>`;
1873
- 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>`;
1874
- 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>`;
1875
- 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">
1876
- <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)">
1877
- <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform>
1878
- </path>
1879
- </svg>`;
1880
- const emptyIcon = `<svg
1881
- width="148px"
1882
- height="134px"
1883
- viewBox="0 0 148 134"
1884
- version="1.1"
1885
- xmlns="http://www.w3.org/2000/svg"
1886
- xmlns:xlink="http://www.w3.org/1999/xlink"
1887
- >
1888
- <defs>
1889
- <filter x="0.0%" y="0.0%" width="100.0%" height="100.0%" filterUnits="objectBoundingBox" id="filter-1">
1890
- <feGaussianBlur stdDeviation="0" in="SourceGraphic"></feGaussianBlur>
1891
- </filter>
1892
- </defs>
1893
- <g id="148x134" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1894
- <g id="编组-6" transform="translate(1.000000, 1.000000)">
1895
- <ellipse
1896
- id="椭圆形"
1897
- fill="#EDEEF2"
1898
- opacity="0.3"
1899
- filter="url(#filter-1)"
1900
- cx="73.0800017"
1901
- cy="115.920003"
1902
- rx="73.0800017"
1903
- ry="16.8000004"
1904
- ></ellipse>
1905
- <g id="编组-5" transform="translate(15.120000, 0.000000)">
1906
- <polygon
1907
- id="矩形"
1908
- fill="#E2E4E9"
1909
- points="19.2789848 49.5600011 99.1200023 48.7200011 117.600003 75.9297673 117.600003 92.313049 0 92.313049 0 75.0356267"
1910
- ></polygon>
1911
- <path
1912
- 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"
1913
- id="矩形"
1914
- fill="#F9FAFB"
1915
- ></path>
1916
- <path
1917
- 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"
1918
- id="矩形"
1919
- fill="#E8EAEE"
1920
- ></path>
1921
- <text
1922
- id="&lt;/null&gt;"
1923
- font-family="PingFangSC-Medium, PingFang SC"
1924
- font-size="15.1200003"
1925
- font-weight="400"
1926
- fill="#BCBECD"
1927
- >
1928
- <tspan x="33.6000008" y="32.8000004">&lt;/null&gt;</tspan>
1929
- </text>
1930
- <rect id="矩形" fill="#E8EAEE" x="27.5600006" y="52.0800012" width="61.4800014" height="5.04000011" rx="2.52000006"></rect>
1931
- <rect
1932
- id="矩形备份"
1933
- fill="#E8EAEE"
1934
- x="27.5600006"
1935
- y="63.8400014"
1936
- width="61.4800014"
1937
- height="5.04000011"
1938
- rx="2.52000006"
1939
- ></rect>
1940
- <path
1941
- 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"
1942
- id="矩形"
1943
- fill="#EDEFF2"
1944
- ></path>
1945
- </g>
1946
- </g>
1947
- </g>
1948
- </svg>`;
1949
- const icons = {
1950
- 'angle-right': angleRight,
1951
- 'angle-down': angleDown,
1952
- 'plus-square': plusSquare,
1953
- 'minus-square': minusSquare,
1954
- loading: loadingIcon,
1955
- empty: emptyIcon
1956
- };
1957
-
1958
- class GanttIconComponent {
1959
- constructor(elementRef) {
1960
- this.elementRef = elementRef;
1961
- this.isIcon = true;
1962
- }
1963
- set iconName(name) {
1964
- this.setSvg(name);
1965
- }
1966
- ngOnInit() { }
1967
- ngAfterViewInit() { }
1968
- setSvg(name) {
1969
- const iconSvg = icons[name];
1970
- if (iconSvg) {
1971
- this.elementRef.nativeElement.innerHTML = iconSvg;
1972
- }
1973
- else {
1974
- this.elementRef.nativeElement.innerHTML = '';
1975
- }
1976
- }
1977
- }
1978
- GanttIconComponent.decorators = [
1979
- { type: Component, args: [{
1980
- selector: 'gantt-icon',
1981
- template: ''
1982
- },] }
1983
- ];
1984
- GanttIconComponent.ctorParameters = () => [
1985
- { type: ElementRef }
1986
- ];
1987
- GanttIconComponent.propDecorators = {
1988
- isIcon: [{ type: HostBinding, args: ['class.gantt-icon',] }],
1989
- iconName: [{ type: Input }]
1990
- };
1991
-
1992
- class GanttDragBackdropComponent {
1993
- constructor() {
1994
- this.backdropClass = true;
1995
- }
1996
- ngOnInit() { }
1997
- }
1998
- GanttDragBackdropComponent.decorators = [
1999
- { type: Component, args: [{
2000
- selector: 'gantt-drag-backdrop',
2001
- 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"
2002
- },] }
2003
- ];
2004
- GanttDragBackdropComponent.ctorParameters = () => [];
2005
- GanttDragBackdropComponent.propDecorators = {
2006
- backdropClass: [{ type: HostBinding, args: ['class.gantt-drag-backdrop',] }]
2007
- };
2008
-
2009
- var LinkColors;
2010
- (function (LinkColors) {
2011
- LinkColors["default"] = "#cacaca";
2012
- LinkColors["blocked"] = "#FF7575";
2013
- LinkColors["active"] = "#348FE4";
2014
- })(LinkColors || (LinkColors = {}));
2015
- class GanttLinksComponent {
2016
- constructor(ganttUpper, cdr, elementRef, ganttDragContainer) {
2017
- this.ganttUpper = ganttUpper;
2018
- this.cdr = cdr;
2019
- this.elementRef = elementRef;
2020
- this.ganttDragContainer = ganttDragContainer;
2021
- this.groups = [];
2022
- this.items = [];
2023
- this.lineClick = new EventEmitter();
2024
- this.links = [];
2025
- this.linkItems = [];
2026
- this.bezierWeight = -0.5;
2027
- this.firstChange = true;
2028
- this.unsubscribe$ = new Subject();
2029
- this.ganttLinksOverlay = true;
2087
+ get linkDragDisabled() {
2088
+ return !this.item.linkable || !this.ganttUpper.linkable;
2030
2089
  }
2031
- ngOnInit() {
2032
- this.buildLinks();
2033
- this.firstChange = false;
2034
- this.ganttDragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2035
- this.elementRef.nativeElement.style.visibility = 'hidden';
2090
+ createMouseEvents() {
2091
+ fromEvent(this.barElement, 'mouseenter')
2092
+ .pipe(takeUntil(this.destroy$))
2093
+ .subscribe(() => {
2094
+ if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2095
+ if (this.item.linkable) {
2096
+ this.barElement.classList.add(linkDropClass);
2097
+ this.dragContainer.emitLinkDragEntered(this.item);
2098
+ }
2099
+ }
2100
+ else {
2101
+ this.barElement.classList.add(activeClass);
2102
+ }
2036
2103
  });
2037
- merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded)
2038
- .pipe(takeUntil(this.unsubscribe$), skip(1))
2104
+ fromEvent(this.barElement, 'mouseleave')
2105
+ .pipe(takeUntil(this.destroy$))
2039
2106
  .subscribe(() => {
2040
- this.elementRef.nativeElement.style.visibility = 'visible';
2041
- this.buildLinks();
2042
- this.cdr.detectChanges();
2107
+ if (!this.dragContainer.linkDraggingId) {
2108
+ this.barElement.classList.remove(activeClass);
2109
+ }
2110
+ else {
2111
+ this.dragContainer.emitLinkDragLeaved();
2112
+ }
2113
+ this.barElement.classList.remove(linkDropClass);
2043
2114
  });
2044
2115
  }
2045
- ngOnChanges() {
2046
- if (!this.firstChange) {
2047
- this.buildLinks();
2048
- }
2116
+ createBarDrag() {
2117
+ const dragRef = this.dragDrop.createDrag(this.barElement);
2118
+ dragRef.lockAxis = 'x';
2119
+ dragRef.started.subscribe(() => {
2120
+ this.setDraggingStyles();
2121
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2122
+ });
2123
+ dragRef.moved.subscribe((event) => {
2124
+ const x = this.item.refs.x + event.distance.x;
2125
+ const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
2126
+ const start = this.ganttUpper.view.getDateByXPoint(x);
2127
+ const end = start.addDays(days);
2128
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), end);
2129
+ });
2130
+ dragRef.ended.subscribe((event) => {
2131
+ const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
2132
+ const start = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x);
2133
+ const end = start.addDays(days);
2134
+ this.item.updateDate(start, end);
2135
+ this.clearDraggingStyles();
2136
+ this.closeDragBackdrop();
2137
+ event.source.reset();
2138
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2139
+ });
2140
+ this.barDragRef = dragRef;
2141
+ return dragRef;
2049
2142
  }
2050
- computeItemPosition() {
2051
- const lineHeight = this.ganttUpper.styles.lineHeight;
2052
- const barHeight = this.ganttUpper.styles.barHeight;
2053
- this.linkItems = [];
2054
- if (this.groups.length > 0) {
2055
- let itemNum = 0;
2056
- let groupNum = 0;
2057
- this.groups.forEach((group) => {
2058
- groupNum++;
2059
- if (group.expanded) {
2060
- const items = recursiveItems(group.items);
2061
- items.forEach((item, itemIndex) => {
2062
- const y = (groupNum + itemNum + itemIndex) * lineHeight + item.refs.y + barHeight / 2;
2063
- this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
2064
- x: item.refs.x,
2065
- y
2066
- }, after: {
2067
- x: item.refs.x + item.refs.width,
2068
- y
2069
- } }));
2070
- });
2071
- itemNum += items.length;
2072
- }
2143
+ createBarHandleDrags() {
2144
+ const dragRefs = [];
2145
+ const handles = this.barElement.querySelectorAll('.drag-handles .handle');
2146
+ handles.forEach((handle, index) => {
2147
+ const isBefore = index === 0;
2148
+ const dragRef = this.dragDrop.createDrag(handle);
2149
+ dragRef.lockAxis = 'x';
2150
+ dragRef.withBoundaryElement(this.dom.root);
2151
+ dragRef.started.subscribe(() => {
2152
+ this.setDraggingStyles();
2153
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2073
2154
  });
2074
- }
2075
- else {
2076
- const items = recursiveItems(this.items);
2077
- items.forEach((item, itemIndex) => {
2078
- const y = itemIndex * lineHeight + item.refs.y + barHeight / 2;
2079
- this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
2080
- x: item.refs.x,
2081
- y
2082
- }, after: {
2083
- x: item.refs.x + item.refs.width,
2084
- y
2085
- } }));
2155
+ dragRef.moved.subscribe((event) => {
2156
+ if (isBefore) {
2157
+ const x = this.item.refs.x + event.distance.x;
2158
+ const width = this.item.refs.width + event.distance.x * -1;
2159
+ if (width > dragMinWidth) {
2160
+ this.barElement.style.width = width + 'px';
2161
+ this.barElement.style.left = x + 'px';
2162
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), this.ganttUpper.view.getDateByXPoint(x + width));
2163
+ }
2164
+ }
2165
+ else {
2166
+ const width = this.item.refs.width + event.distance.x;
2167
+ if (width > dragMinWidth) {
2168
+ this.barElement.style.width = width + 'px';
2169
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(this.item.refs.x), this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
2170
+ }
2171
+ }
2172
+ event.source.reset();
2086
2173
  });
2087
- }
2088
- }
2089
- generatePath(source, target) {
2090
- if (source.before && source.after && target.before && target.after) {
2091
- const x1 = source.after.x;
2092
- const y1 = source.after.y;
2093
- const x4 = target.before.x;
2094
- const y4 = target.before.y;
2095
- const dx = Math.abs(x4 - x1) * this.bezierWeight;
2096
- const x2 = x1 - dx;
2097
- const x3 = x4 + dx;
2098
- const centerX = (x1 + x4) / 2;
2099
- const centerY = (y1 + y4) / 2;
2100
- let controlX = this.ganttUpper.styles.lineHeight / 2;
2101
- const controlY = this.ganttUpper.styles.lineHeight / 2;
2102
- if (x1 >= x4) {
2103
- if (y4 > y1) {
2104
- if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
2105
- return `M ${x1} ${y1}
2106
- C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 + controlX} ${x1} ${y1 + controlY}
2107
- L ${x1} ${y1 + controlY} ${centerX} ${centerY}
2108
-
2109
- M ${x4} ${y4}
2110
- C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 - controlX} ${x4} ${y4 - controlY}
2111
- L ${x4} ${y4 - controlY} ${centerX} ${centerY}`;
2174
+ dragRef.ended.subscribe((event) => {
2175
+ if (isBefore) {
2176
+ const width = this.item.refs.width + event.distance.x * -1;
2177
+ if (width > dragMinWidth) {
2178
+ this.item.updateDate(this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x), this.item.end);
2112
2179
  }
2113
2180
  else {
2114
- controlX = this.ganttUpper.styles.lineHeight;
2115
- return `M ${x1} ${y1}
2116
- C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 + controlX} ${centerX} ${centerY}
2117
-
2118
-
2119
- M ${x4} ${y4}
2120
- C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 - controlX} ${centerX} ${centerY}`;
2181
+ this.item.updateDate(this.item.end.startOfDay(), this.item.end);
2121
2182
  }
2122
2183
  }
2123
2184
  else {
2124
- if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
2125
- return `M ${x1} ${y1}
2126
- C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 - controlX} ${x1} ${y1 - controlY}
2127
- L ${x1} ${y1 - controlY} ${centerX} ${centerY}
2128
-
2129
- M ${x4} ${y4}
2130
- C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 + controlX} ${x4} ${y4 + controlY}
2131
- L ${x4} ${y4 + controlY} ${centerX} ${centerY}
2132
- `;
2185
+ const width = this.item.refs.width + event.distance.x;
2186
+ if (width > dragMinWidth) {
2187
+ this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + this.item.refs.width + event.distance.x));
2133
2188
  }
2134
2189
  else {
2135
- controlX = this.ganttUpper.styles.lineHeight;
2136
- return `M ${x1} ${y1}
2137
- C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 - controlX} ${centerX} ${centerY}
2138
-
2139
- M ${x4} ${y4}
2140
- C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 + controlX} ${centerX} ${centerY}`;
2190
+ this.item.updateDate(this.item.start, this.item.start.endOfDay());
2141
2191
  }
2142
2192
  }
2143
- }
2144
- return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
2145
- }
2146
- }
2147
- buildLinks() {
2148
- this.computeItemPosition();
2149
- this.links = [];
2150
- this.linkItems.forEach((source) => {
2151
- if (source.origin.start || source.origin.end) {
2152
- source.links.forEach((linkId) => {
2153
- const target = this.linkItems.find((item) => item.id === linkId);
2154
- if (target && (target.origin.start || target.origin.end)) {
2155
- this.links.push({
2156
- path: this.generatePath(source, target),
2157
- source: source.origin,
2158
- target: target.origin,
2159
- color: source.end.getTime() > target.start.getTime() ? LinkColors.blocked : LinkColors.default
2160
- });
2161
- }
2162
- });
2163
- }
2164
- });
2165
- }
2166
- trackBy(index) {
2167
- return index;
2168
- }
2169
- onLineClick(event, link) {
2170
- this.lineClick.emit({
2171
- event,
2172
- source: link.source,
2173
- target: link.target
2193
+ this.clearDraggingStyles();
2194
+ this.closeDragBackdrop();
2195
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2196
+ });
2197
+ dragRefs.push(dragRef);
2174
2198
  });
2199
+ return dragRefs;
2175
2200
  }
2176
- mouseEnterPath(link) {
2177
- if (link.color === LinkColors.default) {
2178
- link.color = LinkColors.active;
2179
- }
2180
- }
2181
- mouseLeavePath(link) {
2182
- if (link.color === LinkColors.active) {
2183
- link.color = LinkColors.default;
2184
- }
2185
- }
2186
- ngOnDestroy() {
2187
- this.unsubscribe$.next();
2188
- this.unsubscribe$.complete();
2189
- }
2190
- }
2191
- GanttLinksComponent.decorators = [
2192
- { type: Component, args: [{
2193
- selector: 'gantt-links-overlay',
2194
- 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"
2195
- },] }
2196
- ];
2197
- GanttLinksComponent.ctorParameters = () => [
2198
- { type: GanttUpper, decorators: [{ type: Inject, args: [GANTT_UPPER_TOKEN,] }] },
2199
- { type: ChangeDetectorRef },
2200
- { type: ElementRef },
2201
- { type: GanttDragContainer }
2202
- ];
2203
- GanttLinksComponent.propDecorators = {
2204
- groups: [{ type: Input }],
2205
- items: [{ type: Input }],
2206
- lineClick: [{ type: Output }],
2207
- ganttLinksOverlay: [{ type: HostBinding, args: ['class.gantt-links-overlay',] }]
2208
- };
2209
-
2210
- class GanttPrintService {
2211
- constructor() { }
2212
- setInlineStyles(targetElem) {
2213
- const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
2214
- for (const svgElement of svgElements) {
2215
- this.recursElementChildren(svgElement);
2216
- }
2217
- }
2218
- recursElementChildren(node) {
2219
- const transformProperties = [
2220
- 'fill',
2221
- 'color',
2222
- 'font-size',
2223
- 'stroke',
2224
- 'font',
2225
- 'text-anchor',
2226
- 'stroke-dasharray',
2227
- 'shape-rendering',
2228
- 'stroke-width'
2229
- ];
2230
- if (!node.style) {
2231
- return;
2232
- }
2233
- const styles = getComputedStyle(node);
2234
- for (const transformProperty of transformProperties) {
2235
- node.style[transformProperty] = styles[transformProperty];
2236
- }
2237
- for (const child of Array.from(node.childNodes)) {
2238
- this.recursElementChildren(child);
2239
- }
2240
- }
2241
- register(root) {
2242
- this.root = root.nativeElement;
2243
- this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
2244
- }
2245
- print(name = 'download', ignoreElementClass) {
2246
- const root = this.root;
2247
- const mainContainer = this.mainContainer;
2248
- // set print width
2249
- const printWidth = root.offsetWidth;
2250
- // set print height
2251
- const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
2252
- html2canvas(root, {
2253
- logging: false,
2254
- allowTaint: true,
2255
- useCORS: true,
2256
- width: printWidth,
2257
- height: printHeight,
2258
- ignoreElements: (element) => {
2259
- if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
2260
- return true;
2261
- }
2262
- if (element.classList.contains('gantt-calendar-today-overlay')) {
2263
- return true;
2201
+ createLinkHandleDrags() {
2202
+ const dragRefs = [];
2203
+ const handles = this.barElement.querySelectorAll('.link-handles .handle');
2204
+ handles.forEach((handle, index) => {
2205
+ const isBefore = index === 0;
2206
+ const dragRef = this.dragDrop.createDrag(handle);
2207
+ dragRef.withBoundaryElement(this.dom.root);
2208
+ dragRef.beforeStarted.subscribe(() => {
2209
+ handle.style.pointerEvents = 'none';
2210
+ if (this.barDragRef) {
2211
+ this.barDragRef.disabled = true;
2264
2212
  }
2265
- },
2266
- onclone: (cloneDocument) => {
2267
- const ganttClass = root.className;
2268
- const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
2269
- const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
2270
- const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
2271
- const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
2272
- // change targetDom width
2273
- cloneGanttDom.style.width = `${printWidth}px`;
2274
- cloneGanttDom.style.height = `${printHeight}px`;
2275
- cloneGanttDom.style.overflow = `unset`;
2276
- cloneGanttContainerDom.style.backgroundColor = '#fff';
2277
- cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
2278
- cloneCalendarOverlay.setAttribute('style', `background: transparent`);
2279
- if (cloneLinksOverlay) {
2280
- cloneLinksOverlay.setAttribute('height', `${printHeight}`);
2281
- cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
2213
+ this.createLinkDraggingLine();
2214
+ this.dragContainer.emitLinkDragStarted(isBefore ? 'target' : 'source', this.item);
2215
+ });
2216
+ dragRef.moved.subscribe(() => {
2217
+ const positions = this.calcLinkLinePositions(handle, isBefore);
2218
+ this.linkDraggingLine.setAttribute('x1', positions.x1.toString());
2219
+ this.linkDraggingLine.setAttribute('y1', positions.y1.toString());
2220
+ this.linkDraggingLine.setAttribute('x2', positions.x2.toString());
2221
+ this.linkDraggingLine.setAttribute('y2', positions.y2.toString());
2222
+ });
2223
+ dragRef.ended.subscribe((event) => {
2224
+ event.source.reset();
2225
+ handle.style.pointerEvents = '';
2226
+ if (this.barDragRef) {
2227
+ this.barDragRef.disabled = false;
2282
2228
  }
2283
- // setInlineStyles for svg
2284
- this.setInlineStyles(cloneGanttDom);
2285
- }
2286
- }).then((canvas) => {
2287
- const link = document.createElement('a');
2288
- const dataUrl = canvas.toDataURL('image/png');
2289
- link.download = `${name}.png`;
2290
- link.href = dataUrl;
2291
- link.click();
2292
- });
2293
- }
2294
- }
2295
- GanttPrintService.decorators = [
2296
- { type: Injectable }
2297
- ];
2298
- GanttPrintService.ctorParameters = () => [];
2299
-
2300
- class NgxGanttRootComponent {
2301
- constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
2302
- this.elementRef = elementRef;
2303
- this.ngZone = ngZone;
2304
- this.dom = dom;
2305
- this.dragContainer = dragContainer;
2306
- this.ganttUpper = ganttUpper;
2307
- this.printService = printService;
2308
- this.ganttClass = true;
2309
- this.unsubscribe$ = new Subject();
2310
- this.ganttUpper.dragContainer = dragContainer;
2311
- }
2312
- get view() {
2313
- return this.ganttUpper.view;
2314
- }
2315
- ngOnInit() {
2316
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2317
- this.dom.initialize(this.elementRef);
2318
- if (this.printService) {
2319
- this.printService.register(this.elementRef);
2320
- }
2321
- this.setupScrollClass();
2322
- this.setupResize();
2323
- this.setupViewScroll();
2324
- // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
2325
- this.elementRef.nativeElement.style.opacity = '1';
2326
- this.ganttUpper.viewChange.pipe(startWith(null)).subscribe(() => {
2327
- this.scrollToToday();
2229
+ this.barElement.classList.remove(activeClass);
2230
+ this.destroyLinkDraggingLine();
2231
+ this.dragContainer.emitLinkDragEnded();
2328
2232
  });
2233
+ dragRefs.push(dragRef);
2329
2234
  });
2235
+ return dragRefs;
2330
2236
  }
2331
- setupViewScroll() {
2332
- if (this.ganttUpper.disabledLoadOnScroll) {
2333
- return;
2237
+ openDragBackdrop(dragElement, start, end) {
2238
+ const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
2239
+ const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
2240
+ const rootRect = this.dom.root.getBoundingClientRect();
2241
+ const dragRect = dragElement.getBoundingClientRect();
2242
+ const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
2243
+ const width = dragRect.right - dragRect.left;
2244
+ dragMaskElement.style.left = left + 'px';
2245
+ dragMaskElement.style.width = width + 'px';
2246
+ dragMaskElement.querySelector('.start').innerHTML = start.format('MM-dd');
2247
+ dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
2248
+ dragMaskElement.style.display = 'block';
2249
+ dragBackdropElement.style.display = 'block';
2250
+ }
2251
+ closeDragBackdrop() {
2252
+ const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
2253
+ const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
2254
+ dragMaskElement.style.display = 'none';
2255
+ dragBackdropElement.style.display = 'none';
2256
+ }
2257
+ setDraggingStyles() {
2258
+ this.barElement.style.pointerEvents = 'none';
2259
+ this.barElement.classList.add('gantt-bar-draggable-drag');
2260
+ }
2261
+ clearDraggingStyles() {
2262
+ this.barElement.style.pointerEvents = '';
2263
+ this.barElement.classList.remove('gantt-bar-draggable-drag');
2264
+ }
2265
+ calcLinkLinePositions(target, isBefore) {
2266
+ const rootRect = this.dom.root.getBoundingClientRect();
2267
+ const targetRect = target.getBoundingClientRect();
2268
+ const layerRect = target.parentElement.parentElement.getBoundingClientRect();
2269
+ return {
2270
+ x1: layerRect.left + (isBefore ? 0 : layerRect.width) - rootRect.left,
2271
+ y1: layerRect.top + layerRect.height / 2 - rootRect.top,
2272
+ x2: targetRect.left - rootRect.left + targetRect.width / 2,
2273
+ y2: targetRect.top - rootRect.top + targetRect.height / 2
2274
+ };
2275
+ }
2276
+ createLinkDraggingLine() {
2277
+ if (!this.linkDraggingLine) {
2278
+ const svgElement = createSvgElement('svg', 'gantt-link-drag-container');
2279
+ const linElement = createSvgElement('line', 'link-dragging-line');
2280
+ svgElement.appendChild(linElement);
2281
+ this.dom.root.appendChild(svgElement);
2282
+ this.linkDraggingLine = linElement;
2334
2283
  }
2335
- this.dom
2336
- .getViewerScroll()
2337
- .pipe(takeUntil(this.unsubscribe$))
2338
- .subscribe((event) => {
2339
- if (event.direction === ScrollDirection.LEFT) {
2340
- const dates = this.view.addStartDate();
2341
- if (dates) {
2342
- event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
2343
- this.ngZone.run(() => {
2344
- this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
2345
- });
2346
- }
2347
- }
2348
- if (event.direction === ScrollDirection.RIGHT) {
2349
- const dates = this.view.addEndDate();
2350
- if (dates) {
2351
- this.ngZone.run(() => {
2352
- this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
2353
- });
2354
- }
2355
- }
2356
- });
2357
2284
  }
2358
- setupResize() {
2359
- this.dom
2360
- .getResize()
2361
- .pipe(takeUntil(this.unsubscribe$))
2362
- .subscribe(() => {
2363
- this.setupScrollClass();
2364
- });
2285
+ destroyLinkDraggingLine() {
2286
+ if (this.linkDraggingLine) {
2287
+ this.linkDraggingLine.parentElement.remove();
2288
+ this.linkDraggingLine = null;
2289
+ }
2365
2290
  }
2366
- setupScrollClass() {
2367
- const mainContainer = this.dom.mainContainer;
2368
- const height = mainContainer.offsetHeight;
2369
- const scrollHeight = mainContainer.scrollHeight;
2370
- if (scrollHeight > height) {
2371
- this.elementRef.nativeElement.className = 'gantt gantt-scroll';
2291
+ createDrags(elementRef, item, ganttUpper) {
2292
+ this.item = item;
2293
+ this.barElement = elementRef.nativeElement;
2294
+ this.ganttUpper = ganttUpper;
2295
+ if (!item.draggable || (this.dragDisabled && this.linkDragDisabled)) {
2296
+ return;
2372
2297
  }
2373
2298
  else {
2374
- this.elementRef.nativeElement.className = 'gantt';
2299
+ this.createMouseEvents();
2300
+ if (!this.dragDisabled) {
2301
+ const dragRef = this.createBarDrag();
2302
+ const dragHandlesRefs = this.createBarHandleDrags();
2303
+ this.dragRefs.push(dragRef, ...dragHandlesRefs);
2304
+ }
2305
+ if (!this.linkDragDisabled) {
2306
+ const linkDragRefs = this.createLinkHandleDrags();
2307
+ this.dragRefs.push(...linkDragRefs);
2308
+ }
2375
2309
  }
2376
2310
  }
2377
- scrollToToday() {
2378
- const x = this.view.getTodayXPoint();
2379
- this.dom.scrollMainContainer(x);
2311
+ ngOnDestroy() {
2312
+ this.closeDragBackdrop();
2313
+ this.dragRefs.forEach((dragRef) => dragRef.dispose());
2314
+ this.destroy$.next();
2315
+ this.destroy$.complete();
2380
2316
  }
2381
2317
  }
2382
- NgxGanttRootComponent.decorators = [
2383
- { type: Component, args: [{
2384
- selector: 'ngx-gantt-root',
2385
- 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",
2386
- providers: [GanttDomService, GanttDragContainer]
2387
- },] }
2388
- ];
2389
- NgxGanttRootComponent.ctorParameters = () => [
2390
- { type: ElementRef },
2391
- { type: NgZone },
2392
- { type: GanttDomService },
2393
- { type: GanttDragContainer },
2394
- { type: GanttUpper, decorators: [{ type: Inject, args: [GANTT_UPPER_TOKEN,] }] },
2395
- { type: GanttPrintService, decorators: [{ type: Optional }] }
2396
- ];
2397
- NgxGanttRootComponent.propDecorators = {
2398
- sideWidth: [{ type: Input }],
2399
- ganttClass: [{ type: HostBinding, args: ['class.gantt',] }],
2400
- sideTemplate: [{ type: ContentChild, args: ['sideTemplate', { static: true },] }],
2401
- mainTemplate: [{ type: ContentChild, args: ['mainTemplate', { static: true },] }]
2402
- };
2318
+ 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 });
2319
+ GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag });
2320
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag, decorators: [{
2321
+ type: Injectable
2322
+ }], ctorParameters: function () { return [{ type: i1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }]; } });
2403
2323
 
2404
- class NgxGanttRangeComponent extends GanttItemUpper {
2405
- constructor(elementRef, ganttUpper) {
2324
+ function linearGradient(sideOrCorner, color, stop) {
2325
+ return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
2326
+ }
2327
+ class NgxGanttBarComponent extends GanttItemUpper {
2328
+ constructor(dragContainer, drag, elementRef, ganttUpper) {
2406
2329
  super(elementRef, ganttUpper);
2407
- this.ganttRangeClass = true;
2330
+ this.dragContainer = dragContainer;
2331
+ this.drag = drag;
2332
+ this.ganttUpper = ganttUpper;
2333
+ this.barClick = new EventEmitter();
2334
+ this.ganttItemClass = true;
2335
+ this.color = 'red';
2408
2336
  }
2409
2337
  ngOnInit() {
2410
2338
  super.onInit();
2339
+ this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2340
+ this.setContentBackground();
2341
+ });
2342
+ }
2343
+ ngAfterViewInit() {
2344
+ this.drag.createDrags(this.elementRef, this.item, this.ganttUpper);
2345
+ this.setContentBackground();
2411
2346
  }
2412
2347
  ngOnChanges() {
2413
2348
  super.onChanges();
2414
2349
  }
2350
+ onBarClick(event) {
2351
+ this.barClick.emit({ event, item: this.item.origin });
2352
+ }
2353
+ setContentBackground() {
2354
+ const contentElement = this.contentElementRef.nativeElement;
2355
+ const color = this.item.color || barBackground;
2356
+ const style = this.item.barStyle || {};
2357
+ if (this.item.origin.start && this.item.origin.end) {
2358
+ style.background = color;
2359
+ style.borderRadius = '';
2360
+ }
2361
+ if (this.item.origin.start && !this.item.origin.end) {
2362
+ style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
2363
+ style.borderRadius = '4px 12.5px 12.5px 4px';
2364
+ }
2365
+ if (!this.item.origin.start && this.item.origin.end) {
2366
+ style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
2367
+ style.borderRadius = '12.5px 4px 4px 12.5px';
2368
+ }
2369
+ if (this.item.progress >= 0) {
2370
+ const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
2371
+ style.background = hexToRgb(color, 0.3);
2372
+ style.borderRadius = '';
2373
+ contentProgressElement.style.background = color;
2374
+ }
2375
+ for (const key in style) {
2376
+ if (style.hasOwnProperty(key)) {
2377
+ contentElement.style[key] = style[key];
2378
+ }
2379
+ }
2380
+ }
2381
+ stopPropagation(event) {
2382
+ event.stopPropagation();
2383
+ }
2415
2384
  ngOnDestroy() {
2416
2385
  super.onDestroy();
2417
2386
  }
2418
2387
  }
2419
- NgxGanttRangeComponent.decorators = [
2420
- { type: Component, args: [{
2421
- selector: 'ngx-gantt-range,gantt-range',
2422
- 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"
2423
- },] }
2424
- ];
2425
- NgxGanttRangeComponent.ctorParameters = () => [
2426
- { type: ElementRef },
2427
- { type: GanttUpper, decorators: [{ type: Inject, args: [GANTT_UPPER_TOKEN,] }] }
2428
- ];
2429
- NgxGanttRangeComponent.propDecorators = {
2430
- ganttRangeClass: [{ type: HostBinding, args: ['class.gantt-range',] }]
2431
- };
2388
+ 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 });
2389
+ 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"] }] });
2390
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
2391
+ type: Component,
2392
+ args: [{
2393
+ selector: 'ngx-gantt-bar,gantt-bar',
2394
+ templateUrl: './bar.component.html',
2395
+ providers: [GanttBarDrag]
2396
+ }]
2397
+ }], ctorParameters: function () { return [{ type: GanttDragContainer }, { type: GanttBarDrag }, { type: i0.ElementRef }, { type: GanttUpper, decorators: [{
2398
+ type: Inject,
2399
+ args: [GANTT_UPPER_TOKEN]
2400
+ }] }]; }, propDecorators: { barClick: [{
2401
+ type: Output
2402
+ }], contentElementRef: [{
2403
+ type: ViewChild,
2404
+ args: ['content']
2405
+ }], ganttItemClass: [{
2406
+ type: HostBinding,
2407
+ args: ['class.gantt-bar']
2408
+ }] } });
2432
2409
 
2433
- class IsGanttRangeItemPipe {
2434
- transform(value) {
2435
- return value === GanttItemType.range;
2410
+ class GanttMainComponent {
2411
+ constructor(ganttUpper) {
2412
+ this.ganttUpper = ganttUpper;
2413
+ this.barClick = new EventEmitter();
2414
+ this.lineClick = new EventEmitter();
2415
+ this.ganttMainClass = true;
2436
2416
  }
2437
- }
2438
- IsGanttRangeItemPipe.decorators = [
2439
- { type: Pipe, args: [{
2440
- name: 'isGanttRangeItem'
2441
- },] }
2442
- ];
2443
- class IsGanttBarItemPipe {
2444
- transform(value) {
2445
- return value === GanttItemType.bar;
2417
+ ngOnInit() { }
2418
+ trackBy(item, index) {
2419
+ return item.id || index;
2446
2420
  }
2447
2421
  }
2448
- IsGanttBarItemPipe.decorators = [
2449
- { type: Pipe, args: [{
2450
- name: 'isGanttBarItem'
2451
- },] }
2452
- ];
2453
- class IsGanttCustomItemPipe {
2454
- transform(value) {
2455
- return value === GanttItemType.custom;
2422
+ 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 });
2423
+ 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; trackBy: trackBy\">\n <div class=\"gantt-item\" [style.height.px]=\"ganttUpper.styles.lineHeight\">\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 } });
2424
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttMainComponent, decorators: [{
2425
+ type: Component,
2426
+ args: [{
2427
+ selector: 'gantt-main',
2428
+ templateUrl: './gantt-main.component.html'
2429
+ }]
2430
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2431
+ type: Inject,
2432
+ args: [GANTT_UPPER_TOKEN]
2433
+ }] }]; }, propDecorators: { groups: [{
2434
+ type: Input
2435
+ }], items: [{
2436
+ type: Input
2437
+ }], groupHeaderTemplate: [{
2438
+ type: Input
2439
+ }], itemTemplate: [{
2440
+ type: Input
2441
+ }], barTemplate: [{
2442
+ type: Input
2443
+ }], rangeTemplate: [{
2444
+ type: Input
2445
+ }], barClick: [{
2446
+ type: Output
2447
+ }], lineClick: [{
2448
+ type: Output
2449
+ }], ganttMainClass: [{
2450
+ type: HostBinding,
2451
+ args: ['class.gantt-main-container']
2452
+ }] } });
2453
+
2454
+ class NgxGanttComponent extends GanttUpper {
2455
+ constructor(elementRef, cdr, ngZone) {
2456
+ super(elementRef, cdr, ngZone);
2457
+ this.maxLevel = 2;
2458
+ this.linkDragStarted = new EventEmitter();
2459
+ this.linkDragEnded = new EventEmitter();
2460
+ this.lineClick = new EventEmitter();
2461
+ this.ngUnsubscribe$ = new Subject();
2462
+ this.sideTableWidth = sideWidth;
2463
+ }
2464
+ ngOnInit() {
2465
+ super.onInit();
2466
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2467
+ this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2468
+ this.linkDragStarted.emit(event);
2469
+ });
2470
+ this.dragContainer.linkDragEnded.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2471
+ this.linkDragEnded.emit(event);
2472
+ });
2473
+ });
2474
+ }
2475
+ ngAfterViewInit() {
2476
+ this.columns.changes.pipe(startWith(true), takeUntil(this.ngUnsubscribe$)).subscribe(() => {
2477
+ this.columns.forEach((column) => {
2478
+ if (!column.columnWidth) {
2479
+ column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
2480
+ }
2481
+ });
2482
+ this.cdr.detectChanges();
2483
+ });
2484
+ }
2485
+ ngOnChanges(changes) {
2486
+ super.onChanges(changes);
2487
+ }
2488
+ expandChildren(item) {
2489
+ if (!item.expanded) {
2490
+ item.setExpand(true);
2491
+ if (this.async && this.childrenResolve && item.children.length === 0) {
2492
+ item.loading = true;
2493
+ this.childrenResolve(item.origin)
2494
+ .pipe(take(1), finalize(() => {
2495
+ item.loading = false;
2496
+ this.expandChange.emit();
2497
+ this.cdr.detectChanges();
2498
+ }))
2499
+ .subscribe((items) => {
2500
+ item.addChildren(items);
2501
+ this.computeItemsRefs(...item.children);
2502
+ });
2503
+ }
2504
+ else {
2505
+ this.computeItemsRefs(...item.children);
2506
+ this.expandChange.emit();
2507
+ }
2508
+ }
2509
+ else {
2510
+ item.setExpand(false);
2511
+ this.expandChange.emit();
2512
+ }
2513
+ }
2514
+ ngOnDestroy() {
2515
+ super.onDestroy();
2456
2516
  }
2457
2517
  }
2458
- IsGanttCustomItemPipe.decorators = [
2459
- { type: Pipe, args: [{
2460
- name: 'isGanttCustomItem'
2461
- },] }
2462
- ];
2518
+ 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 }], target: i0.ɵɵFactoryTarget.Component });
2519
+ 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: [
2520
+ {
2521
+ provide: GANTT_UPPER_TOKEN,
2522
+ useExisting: NgxGanttComponent
2523
+ },
2524
+ {
2525
+ provide: GANTT_ABSTRACT_TOKEN,
2526
+ useExisting: forwardRef(() => NgxGanttComponent)
2527
+ }
2528
+ ], 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 [groups]=\"groups\" [items]=\"items\" [columns]=\"columns\" [groupTemplate]=\"groupTemplate\" [emptyTemplate]=\"tableEmptyTemplate\"></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"] }, { type: GanttMainComponent, selector: "gantt-main", inputs: ["groups", "items", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2529
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttComponent, decorators: [{
2530
+ type: Component,
2531
+ args: [{
2532
+ selector: 'ngx-gantt',
2533
+ templateUrl: './gantt.component.html',
2534
+ changeDetection: ChangeDetectionStrategy.OnPush,
2535
+ providers: [
2536
+ {
2537
+ provide: GANTT_UPPER_TOKEN,
2538
+ useExisting: NgxGanttComponent
2539
+ },
2540
+ {
2541
+ provide: GANTT_ABSTRACT_TOKEN,
2542
+ useExisting: forwardRef(() => NgxGanttComponent)
2543
+ }
2544
+ ]
2545
+ }]
2546
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }]; }, propDecorators: { maxLevel: [{
2547
+ type: Input
2548
+ }], async: [{
2549
+ type: Input
2550
+ }], childrenResolve: [{
2551
+ type: Input
2552
+ }], linkable: [{
2553
+ type: Input
2554
+ }], linkDragStarted: [{
2555
+ type: Output
2556
+ }], linkDragEnded: [{
2557
+ type: Output
2558
+ }], lineClick: [{
2559
+ type: Output
2560
+ }], table: [{
2561
+ type: ContentChild,
2562
+ args: [NgxGanttTableComponent]
2563
+ }], columns: [{
2564
+ type: ContentChildren,
2565
+ args: [NgxGanttTableColumnComponent, { descendants: true }]
2566
+ }], tableEmptyTemplate: [{
2567
+ type: ContentChild,
2568
+ args: ['tableEmpty', { static: true }]
2569
+ }] } });
2463
2570
 
2464
2571
  class NgxGanttModule {
2465
2572
  }
2466
- NgxGanttModule.decorators = [
2467
- { type: NgModule, args: [{
2468
- imports: [CommonModule, DragDropModule],
2469
- exports: [NgxGanttComponent, NgxGanttTableComponent, NgxGanttTableColumnComponent, NgxGanttRootComponent, NgxGanttBarComponent],
2470
- declarations: [
2471
- NgxGanttComponent,
2472
- NgxGanttTableComponent,
2473
- NgxGanttTableColumnComponent,
2474
- GanttTableComponent,
2475
- GanttMainComponent,
2476
- GanttCalendarComponent,
2477
- GanttLinksComponent,
2478
- NgxGanttBarComponent,
2479
- GanttIconComponent,
2480
- GanttDragBackdropComponent,
2481
- NgxGanttRangeComponent,
2482
- NgxGanttRootComponent,
2483
- IsGanttRangeItemPipe,
2484
- IsGanttBarItemPipe,
2485
- IsGanttCustomItemPipe
2486
- ],
2487
- providers: []
2488
- },] }
2489
- ];
2573
+ NgxGanttModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2574
+ NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, declarations: [NgxGanttComponent,
2575
+ NgxGanttTableComponent,
2576
+ NgxGanttTableColumnComponent,
2577
+ GanttTableComponent,
2578
+ GanttMainComponent,
2579
+ GanttCalendarComponent,
2580
+ GanttLinksComponent,
2581
+ NgxGanttBarComponent,
2582
+ GanttIconComponent,
2583
+ GanttDragBackdropComponent,
2584
+ NgxGanttRangeComponent,
2585
+ NgxGanttRootComponent,
2586
+ IsGanttRangeItemPipe,
2587
+ IsGanttBarItemPipe,
2588
+ IsGanttCustomItemPipe], imports: [CommonModule, DragDropModule], exports: [NgxGanttComponent,
2589
+ NgxGanttTableComponent,
2590
+ NgxGanttTableColumnComponent,
2591
+ NgxGanttRootComponent,
2592
+ NgxGanttBarComponent,
2593
+ NgxGanttRangeComponent] });
2594
+ NgxGanttModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, providers: [], imports: [[CommonModule, DragDropModule]] });
2595
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, decorators: [{
2596
+ type: NgModule,
2597
+ args: [{
2598
+ imports: [CommonModule, DragDropModule],
2599
+ exports: [
2600
+ NgxGanttComponent,
2601
+ NgxGanttTableComponent,
2602
+ NgxGanttTableColumnComponent,
2603
+ NgxGanttRootComponent,
2604
+ NgxGanttBarComponent,
2605
+ NgxGanttRangeComponent
2606
+ ],
2607
+ declarations: [
2608
+ NgxGanttComponent,
2609
+ NgxGanttTableComponent,
2610
+ NgxGanttTableColumnComponent,
2611
+ GanttTableComponent,
2612
+ GanttMainComponent,
2613
+ GanttCalendarComponent,
2614
+ GanttLinksComponent,
2615
+ NgxGanttBarComponent,
2616
+ GanttIconComponent,
2617
+ GanttDragBackdropComponent,
2618
+ NgxGanttRangeComponent,
2619
+ NgxGanttRootComponent,
2620
+ IsGanttRangeItemPipe,
2621
+ IsGanttBarItemPipe,
2622
+ IsGanttCustomItemPipe
2623
+ ],
2624
+ providers: []
2625
+ }]
2626
+ }] });
2490
2627
 
2491
2628
  /*
2492
2629
  * Public API Surface of gantt
@@ -2496,5 +2633,5 @@ NgxGanttModule.decorators = [
2496
2633
  * Generated bundle index. Do not edit.
2497
2634
  */
2498
2635
 
2499
- export { GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLoadOnScrollEvent, GanttPrintService, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, NgxGanttComponent, NgxGanttModule, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, defaultColumnWidth, minColumnWidth, primaryDatePointTop, secondaryDatePointTop, GanttDomService as ɵa, GanttDragContainer as ɵb, NgxGanttBarComponent as ɵc, GanttBarDrag as ɵd, GanttTableComponent as ɵe, GanttMainComponent as ɵf, GanttCalendarComponent as ɵg, GanttLinksComponent as ɵh, GanttIconComponent as ɵi, GanttDragBackdropComponent as ɵj, NgxGanttRangeComponent as ɵk };
2636
+ 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 };
2500
2637
  //# sourceMappingURL=worktile-gantt.js.map