@worktile/gantt 15.1.0-next.0 → 15.1.0-next.10

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 (39) hide show
  1. package/class/event.d.ts +8 -0
  2. package/components/bar/bar-drag.d.ts +26 -7
  3. package/components/bar/bar.component.scss +0 -22
  4. package/components/calendar/calendar.scss +1 -1
  5. package/components/drag-backdrop/drag-backdrop.component.scss +1 -0
  6. package/components/loader/loader.component.d.ts +5 -0
  7. package/components/loader/loader.component.scss +90 -0
  8. package/components/table/body/gantt-table-body.component.d.ts +7 -4
  9. package/esm2020/class/event.mjs +5 -1
  10. package/esm2020/components/bar/bar-drag.mjs +221 -76
  11. package/esm2020/components/bar/bar.component.mjs +33 -27
  12. package/esm2020/components/loader/loader.component.mjs +29 -0
  13. package/esm2020/components/table/body/gantt-table-body.component.mjs +73 -33
  14. package/esm2020/components/table/header/gantt-table-header.component.mjs +2 -2
  15. package/esm2020/gantt-abstract.mjs +1 -1
  16. package/esm2020/gantt-item-upper.mjs +8 -6
  17. package/esm2020/gantt-upper.mjs +4 -3
  18. package/esm2020/gantt.component.mjs +40 -12
  19. package/esm2020/gantt.module.mjs +4 -1
  20. package/esm2020/public-api.mjs +2 -1
  21. package/esm2020/table/gantt-column.component.mjs +13 -6
  22. package/esm2020/table/gantt-table.component.mjs +8 -2
  23. package/esm2020/utils/drag-scroll.mjs +35 -0
  24. package/fesm2015/worktile-gantt.mjs +917 -614
  25. package/fesm2015/worktile-gantt.mjs.map +1 -1
  26. package/fesm2020/worktile-gantt.mjs +898 -597
  27. package/fesm2020/worktile-gantt.mjs.map +1 -1
  28. package/gantt-abstract.d.ts +3 -1
  29. package/gantt-item-upper.d.ts +1 -0
  30. package/gantt.component.d.ts +6 -1
  31. package/gantt.component.scss +4 -0
  32. package/gantt.module.d.ts +13 -12
  33. package/package.json +1 -1
  34. package/public-api.d.ts +1 -0
  35. package/styles/index.scss +1 -0
  36. package/styles/variables.scss +3 -0
  37. package/table/gantt-column.component.d.ts +4 -2
  38. package/table/gantt-table.component.d.ts +4 -2
  39. package/utils/drag-scroll.d.ts +20 -0
@@ -1,14 +1,14 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Injectable, ViewChild, Pipe, ViewChildren, PLATFORM_ID, ElementRef, Optional, SkipSelf, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
2
+ import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Injectable, ViewChild, Pipe, ViewChildren, PLATFORM_ID, ElementRef, Optional, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { DOCUMENT, isPlatformServer, CommonModule } from '@angular/common';
5
- import { take, takeUntil, skip, switchMap, debounceTime as debounceTime$1, map, pairwise, auditTime, startWith as startWith$1, finalize } from 'rxjs/operators';
6
- import { BehaviorSubject, Subject, from, takeUntil as takeUntil$1, startWith, debounceTime, filter, merge, EMPTY, fromEvent, Observable } from 'rxjs';
5
+ import { take, takeUntil, skip, switchMap, debounceTime, map, pairwise, auditTime as auditTime$1, startWith as startWith$1, finalize } from 'rxjs/operators';
6
+ import { BehaviorSubject, Subject, from, takeUntil as takeUntil$1, startWith, auditTime, filter, merge, EMPTY, fromEvent, Observable, interval, animationFrameScheduler } from 'rxjs';
7
7
  import { fromUnixTime, getWeek, getDaysInMonth, differenceInCalendarDays, setDate, addSeconds, addMinutes, addHours, addDays, addWeeks, addMonths, addQuarters, addYears, startOfDay, startOfWeek, startOfMonth, startOfQuarter, startOfYear, endOfDay, endOfWeek, endOfMonth, endOfQuarter, endOfYear, getUnixTime, format, isWeekend, isToday, differenceInDays, differenceInCalendarQuarters, eachMonthOfInterval, eachYearOfInterval, eachWeekOfInterval, eachDayOfInterval, differenceInCalendarYears } from 'date-fns';
8
8
  export { addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarQuarters, differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, endOfDay, endOfMonth, endOfQuarter, endOfWeek, endOfYear, format, fromUnixTime, getDaysInMonth, getUnixTime, getWeek, isToday, isWeekend, setDate, startOfDay, startOfMonth, startOfQuarter, startOfWeek, startOfYear } from 'date-fns';
9
9
  import { SelectionModel } from '@angular/cdk/collections';
10
10
  import { coerceBooleanProperty, coerceCssPixelValue } from '@angular/cdk/coercion';
11
- import * as i2$1 from '@angular/cdk/scrolling';
11
+ import * as i3 from '@angular/cdk/scrolling';
12
12
  import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
13
13
  import * as i2 from '@angular/cdk/drag-drop';
14
14
  import { CdkDrag, DragDropModule } from '@angular/cdk/drag-drop';
@@ -41,6 +41,10 @@ class GanttSelectedEvent {
41
41
  }
42
42
  class GanttTableDragDroppedEvent {
43
43
  }
44
+ class GanttTableDragStartedEvent {
45
+ }
46
+ class GanttTableDragEndedEvent {
47
+ }
44
48
  class GanttTableDragEnterPredicateContext {
45
49
  }
46
50
 
@@ -1049,16 +1053,17 @@ class GanttUpper {
1049
1053
  this.ngZone.runOutsideAngular(() => {
1050
1054
  onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1051
1055
  this.element.style.opacity = '1';
1056
+ const disabledLoadOnScroll = this.disabledLoadOnScroll;
1052
1057
  this.dragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1058
+ this.disabledLoadOnScroll = true;
1053
1059
  this.dragStarted.emit(event);
1054
1060
  });
1055
1061
  this.dragContainer.dragMoved.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1056
1062
  this.dragMoved.emit(event);
1057
1063
  });
1058
1064
  this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1065
+ this.disabledLoadOnScroll = disabledLoadOnScroll;
1059
1066
  this.dragEnded.emit(event);
1060
- // this.computeRefs();
1061
- // this.detectChanges();
1062
1067
  });
1063
1068
  });
1064
1069
  });
@@ -1237,22 +1242,29 @@ class NgxGanttTableColumnComponent {
1237
1242
  set width(width) {
1238
1243
  this.columnWidth = coerceCssPixelValue(width);
1239
1244
  }
1240
- constructor(ganttUpper) {
1245
+ constructor(ganttUpper, elementRef) {
1241
1246
  this.ganttUpper = ganttUpper;
1247
+ this.elementRef = elementRef;
1248
+ }
1249
+ get classList() {
1250
+ return this.elementRef.nativeElement.classList;
1242
1251
  }
1243
1252
  }
1244
- NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
1245
- NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name", showExpandIcon: "showExpandIcon" }, 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 });
1253
+ NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1254
+ NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name", showExpandIcon: "showExpandIcon" }, host: { classAttribute: "gantt-table-column" }, 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 });
1246
1255
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, decorators: [{
1247
1256
  type: Component,
1248
1257
  args: [{
1249
1258
  selector: 'ngx-gantt-column',
1250
- template: ''
1259
+ template: '',
1260
+ host: {
1261
+ class: 'gantt-table-column'
1262
+ }
1251
1263
  }]
1252
1264
  }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1253
1265
  type: Inject,
1254
1266
  args: [GANTT_UPPER_TOKEN]
1255
- }] }]; }, propDecorators: { width: [{
1267
+ }] }, { type: i0.ElementRef }]; }, propDecorators: { width: [{
1256
1268
  type: Input
1257
1269
  }], name: [{
1258
1270
  type: Input
@@ -1270,11 +1282,13 @@ class NgxGanttTableComponent {
1270
1282
  constructor() {
1271
1283
  this.draggable = false;
1272
1284
  this.dragDropped = new EventEmitter();
1285
+ this.dragStarted = new EventEmitter();
1286
+ this.dragEnded = new EventEmitter();
1273
1287
  this.columnChanges = new EventEmitter();
1274
1288
  }
1275
1289
  }
1276
1290
  NgxGanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1277
- NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableComponent, selector: "ngx-gantt-table", inputs: { draggable: "draggable", dropEnterPredicate: "dropEnterPredicate" }, outputs: { dragDropped: "dragDropped", columnChanges: "columnChanges" }, queries: [{ propertyName: "rowBeforeTemplate", first: true, predicate: ["rowBeforeSlot"], descendants: true, static: true }, { propertyName: "rowAfterTemplate", first: true, predicate: ["rowAfterSlot"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1291
+ NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableComponent, selector: "ngx-gantt-table", inputs: { draggable: "draggable", dropEnterPredicate: "dropEnterPredicate" }, outputs: { dragDropped: "dragDropped", dragStarted: "dragStarted", dragEnded: "dragEnded", columnChanges: "columnChanges" }, queries: [{ propertyName: "rowBeforeTemplate", first: true, predicate: ["rowBeforeSlot"], descendants: true, static: true }, { propertyName: "rowAfterTemplate", first: true, predicate: ["rowAfterSlot"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1278
1292
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableComponent, decorators: [{
1279
1293
  type: Component,
1280
1294
  args: [{
@@ -1287,6 +1301,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1287
1301
  type: Input
1288
1302
  }], dragDropped: [{
1289
1303
  type: Output
1304
+ }], dragStarted: [{
1305
+ type: Output
1306
+ }], dragEnded: [{
1307
+ type: Output
1290
1308
  }], columnChanges: [{
1291
1309
  type: Output
1292
1310
  }], rowBeforeTemplate: [{
@@ -1421,7 +1439,7 @@ class GanttTableHeaderComponent {
1421
1439
  this.columnsChange();
1422
1440
  this.columns.changes.pipe(takeUntil$1(this.unsubscribe$)).subscribe(() => {
1423
1441
  this.columnsChange();
1424
- this.cdr.detectChanges();
1442
+ this.gantt.cdr.detectChanges();
1425
1443
  });
1426
1444
  }
1427
1445
  columnsChange() {
@@ -1719,13 +1737,15 @@ class GanttTableBodyComponent {
1719
1737
  this.document = document;
1720
1738
  this.draggable = false;
1721
1739
  this.dragDropped = new EventEmitter();
1740
+ this.dragStarted = new EventEmitter();
1741
+ this.dragEnded = new EventEmitter();
1722
1742
  this.itemClick = new EventEmitter();
1723
1743
  this.ganttTableClass = true;
1724
1744
  this.ganttTableEmptyClass = false;
1725
1745
  this.ganttTableDragging = false;
1726
1746
  this.hasExpandIcon = false;
1727
1747
  // 缓存 Element 和 DragRef 的关系,方便在 Item 拖动时查找
1728
- this.itemDragRefMap = new Map();
1748
+ this.itemDragsMap = new Map();
1729
1749
  this.itemDragMoved = new Subject();
1730
1750
  this.destroy$ = new Subject();
1731
1751
  }
@@ -1747,17 +1767,17 @@ class GanttTableBodyComponent {
1747
1767
  this.cdkDrags.changes
1748
1768
  .pipe(startWith(this.cdkDrags), takeUntil$1(this.destroy$))
1749
1769
  .subscribe((drags) => {
1750
- this.itemDragRefMap.clear();
1770
+ this.itemDragsMap.clear();
1751
1771
  drags.forEach((drag) => {
1752
1772
  if (drag.data) {
1753
1773
  // cdkDrag 变化时,缓存 Element 与 DragRef 的关系,方便 Drag Move 时查找
1754
- this.itemDragRefMap.set(drag.element.nativeElement, drag);
1774
+ this.itemDragsMap.set(drag.element.nativeElement, drag);
1755
1775
  }
1756
1776
  });
1757
1777
  });
1758
1778
  this.itemDragMoved
1759
- .pipe(debounceTime(30),
1760
- // debounce 可能会导致拖动结束后仍然执行 moved ,所以通过判断 dragging 状态来过滤无效 moved
1779
+ .pipe(auditTime(30),
1780
+ // auditTime 可能会导致拖动结束后仍然执行 moved ,所以通过判断 dragging 状态来过滤无效 moved
1761
1781
  filter((event) => event.source._dragRef.isDragging()), takeUntil$1(this.destroy$))
1762
1782
  .subscribe((event) => {
1763
1783
  this.onItemDragMoved(event);
@@ -1773,10 +1793,14 @@ class GanttTableBodyComponent {
1773
1793
  onItemDragStarted(event) {
1774
1794
  this.ganttTableDragging = true;
1775
1795
  // 拖动开始时隐藏所有的子项
1776
- const children = this.getChildrenElementsByDragRef(event.source);
1796
+ const children = this.getChildrenElementsByElement(event.source.element.nativeElement);
1777
1797
  children.forEach((element) => {
1778
1798
  element.classList.add('drag-item-hide');
1779
1799
  });
1800
+ this.dragStarted.emit({
1801
+ source: event.source.data?.origin,
1802
+ sourceParent: this.getParentByItem(event.source.data)?.origin
1803
+ });
1780
1804
  }
1781
1805
  emitItemDragMoved(event) {
1782
1806
  this.itemDragMoved.next(event);
@@ -1797,12 +1821,12 @@ class GanttTableBodyComponent {
1797
1821
  }
1798
1822
  // 缓存放置目标Id 并计算鼠标相对应的位置
1799
1823
  this.itemDropTarget = {
1800
- id: this.itemDragRefMap.get(targetElement)?.data.id,
1824
+ id: this.itemDragsMap.get(targetElement)?.data.id,
1801
1825
  position: this.getTargetPosition(targetElement, event)
1802
1826
  };
1803
1827
  // 执行外部传入的 dropEnterPredicate 判断是否允许拖入目标项
1804
1828
  if (this.dropEnterPredicate) {
1805
- const targetDragRef = this.itemDragRefMap.get(targetElement);
1829
+ const targetDragRef = this.itemDragsMap.get(targetElement);
1806
1830
  if (this.dropEnterPredicate({
1807
1831
  source: event.source.data.origin,
1808
1832
  target: targetDragRef.data.origin,
@@ -1812,6 +1836,7 @@ class GanttTableBodyComponent {
1812
1836
  }
1813
1837
  else {
1814
1838
  this.itemDropTarget = null;
1839
+ this.cleanupDragArtifacts(false);
1815
1840
  }
1816
1841
  }
1817
1842
  else {
@@ -1820,31 +1845,38 @@ class GanttTableBodyComponent {
1820
1845
  }
1821
1846
  onItemDragEnded(event) {
1822
1847
  this.ganttTableDragging = false;
1848
+ this.dragEnded.emit({
1849
+ source: event.source.data?.origin,
1850
+ sourceParent: this.getParentByItem(event.source.data)?.origin
1851
+ });
1823
1852
  }
1824
1853
  onListDropped(event) {
1825
1854
  if (!this.itemDropTarget) {
1826
1855
  return;
1827
1856
  }
1828
- const targetDragRef = this.cdkDrags.find((item) => item.data?.id === this.itemDropTarget.id);
1829
1857
  const sourceItem = event.item.data;
1858
+ const sourceParent = this.getParentByItem(sourceItem);
1859
+ const sourceChildren = this.getExpandChildrenByDrag(event.item);
1860
+ const targetDragRef = this.cdkDrags.find((item) => item.data?.id === this.itemDropTarget.id);
1830
1861
  const targetItem = targetDragRef?.data;
1831
- this.removeItem(sourceItem);
1862
+ const targetParent = this.getParentByItem(targetItem);
1863
+ this.removeItem(sourceItem, sourceChildren);
1832
1864
  switch (this.itemDropTarget.position) {
1833
1865
  case 'before':
1834
1866
  case 'after':
1835
- this.insertItem(targetItem, sourceItem, this.itemDropTarget.position);
1867
+ this.insertItem(targetItem, sourceItem, sourceChildren, this.itemDropTarget.position);
1836
1868
  sourceItem.updateLevel(targetItem.level);
1837
1869
  break;
1838
1870
  case 'inside':
1839
- this.insertChildrenItem(targetItem, sourceItem);
1871
+ this.insertChildrenItem(targetItem, sourceItem, sourceChildren);
1840
1872
  sourceItem.updateLevel(targetItem.level + 1);
1841
1873
  break;
1842
1874
  }
1843
1875
  this.dragDropped.emit({
1844
1876
  source: sourceItem.origin,
1845
- sourceParent: this.getParentByItem(sourceItem)?.origin,
1877
+ sourceParent: sourceParent?.origin,
1846
1878
  target: targetItem.origin,
1847
- targetParent: this.getParentByItem(targetItem)?.origin,
1879
+ targetParent: targetParent?.origin,
1848
1880
  dropPosition: this.itemDropTarget.position
1849
1881
  });
1850
1882
  this.cleanupDragArtifacts(true);
@@ -1856,19 +1888,30 @@ class GanttTableBodyComponent {
1856
1888
  this.destroy$.next();
1857
1889
  this.destroy$.complete();
1858
1890
  }
1859
- removeItem(item) {
1860
- this.renderData.splice(this.renderData.indexOf(item), 1);
1861
- this.flatData.splice(this.flatData.indexOf(item), 1);
1891
+ removeItem(item, children) {
1892
+ this.renderData.splice(this.renderData.indexOf(item), 1 + children.length);
1893
+ this.flatData.splice(this.flatData.indexOf(item), 1 + children.length);
1862
1894
  }
1863
- insertItem(target, inserted, position) {
1864
- const appendIndex = position === 'after' ? 1 : 0;
1865
- this.renderData.splice(this.renderData.indexOf(target) + appendIndex, 0, inserted);
1866
- this.flatData.splice(this.flatData.indexOf(target) + appendIndex, 0, inserted);
1895
+ insertItem(target, inserted, children, position) {
1896
+ if (position === 'before') {
1897
+ this.renderData.splice(this.renderData.indexOf(target), 0, inserted, ...children);
1898
+ this.flatData.splice(this.flatData.indexOf(target), 0, inserted, ...children);
1899
+ }
1900
+ else {
1901
+ const dragRef = this.cdkDrags.find((drag) => drag.data === target);
1902
+ // 如果目标项是展开的,插入的 index 位置需要考虑子项的数量
1903
+ let childrenCount = 0;
1904
+ if (target.expanded) {
1905
+ childrenCount = this.getChildrenElementsByElement(dragRef.element.nativeElement)?.length || 0;
1906
+ }
1907
+ this.renderData.splice(this.renderData.indexOf(target) + 1 + childrenCount, 0, inserted, ...children);
1908
+ this.flatData.splice(this.flatData.indexOf(target) + 1 + childrenCount, 0, inserted, ...children);
1909
+ }
1867
1910
  }
1868
- insertChildrenItem(target, inserted) {
1911
+ insertChildrenItem(target, inserted, children) {
1869
1912
  if (target.expanded) {
1870
- this.renderData.splice(this.renderData.indexOf(target) + target.children.length + 1, 0, inserted);
1871
- this.flatData.splice(this.flatData.indexOf(target) + target.children.length + 1, 0, inserted);
1913
+ this.renderData.splice(this.renderData.indexOf(target) + target.children.length + 1, 0, inserted, ...children);
1914
+ this.flatData.splice(this.flatData.indexOf(target) + target.children.length + 1, 0, inserted, ...children);
1872
1915
  }
1873
1916
  target.children.push(inserted);
1874
1917
  }
@@ -1877,15 +1920,26 @@ class GanttTableBodyComponent {
1877
1920
  return n.children?.includes(item);
1878
1921
  });
1879
1922
  }
1880
- getChildrenElementsByDragRef(dragRef) {
1923
+ getExpandChildrenByDrag(dragRef) {
1924
+ if (!dragRef.data.expanded) {
1925
+ return [];
1926
+ }
1927
+ else {
1928
+ const childrenElements = this.getChildrenElementsByElement(dragRef.element.nativeElement);
1929
+ return childrenElements.map((element) => this.itemDragsMap.get(element).data);
1930
+ }
1931
+ }
1932
+ getChildrenElementsByElement(dragElement) {
1881
1933
  // 通过循环持续查找 next element,如果 element 的 level 小于当前 item 的 level,则为它的 children
1882
1934
  const children = [];
1883
- let nextElement = dragRef.getPlaceholderElement().nextElementSibling;
1884
- let nextDragRef = this.itemDragRefMap.get(nextElement);
1935
+ const dragRef = this.itemDragsMap.get(dragElement);
1936
+ // 如果当前的 Drag 正在拖拽,会创建 PlaceholderElement 占位,所以以 PlaceholderElement 向下查找
1937
+ let nextElement = (dragRef.getPlaceholderElement() || dragElement).nextElementSibling;
1938
+ let nextDragRef = this.itemDragsMap.get(nextElement);
1885
1939
  while (nextDragRef && nextDragRef.data.level > dragRef.data.level) {
1886
1940
  children.push(nextElement);
1887
1941
  nextElement = nextElement.nextElementSibling;
1888
- nextDragRef = this.itemDragRefMap.get(nextElement);
1942
+ nextDragRef = this.itemDragsMap.get(nextElement);
1889
1943
  }
1890
1944
  return children;
1891
1945
  }
@@ -1912,18 +1966,18 @@ class GanttTableBodyComponent {
1912
1966
  cleanupDragArtifacts(dropped = false) {
1913
1967
  if (dropped) {
1914
1968
  this.itemDropTarget = null;
1969
+ this.document.querySelectorAll('.drag-item-hide').forEach((element) => element.classList.remove('drag-item-hide'));
1915
1970
  }
1916
1971
  this.document.querySelectorAll('.drop-position-before').forEach((element) => element.classList.remove('drop-position-before'));
1917
1972
  this.document.querySelectorAll('.drop-position-after').forEach((element) => element.classList.remove('drop-position-after'));
1918
1973
  this.document.querySelectorAll('.drop-position-inside').forEach((element) => element.classList.remove('drop-position-inside'));
1919
- this.document.querySelectorAll('.drag-item-hide').forEach((element) => element.classList.remove('drop-item-hide'));
1920
1974
  }
1921
1975
  }
1922
1976
  GanttTableBodyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableBodyComponent, deps: [{ token: GANTT_ABSTRACT_TOKEN }, { token: GANTT_UPPER_TOKEN }, { token: i0.ChangeDetectorRef }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
1923
- GanttTableBodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: { renderData: "renderData", flatData: "flatData", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate", rowBeforeTemplate: "rowBeforeTemplate", rowAfterTemplate: "rowAfterTemplate", draggable: "draggable", dropEnterPredicate: "dropEnterPredicate" }, outputs: { dragDropped: "dragDropped", itemClick: "itemClick" }, host: { properties: { "class.gantt-table-draggable": "this.draggable", "class.gantt-table-body": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass", "class.gantt-table-dragging": "this.ganttTableDragging" } }, viewQueries: [{ propertyName: "cdkDrags", predicate: (CdkDrag), descendants: true }], ngImport: i0, template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.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=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div class=\"gantt-table-column\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i2.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i2.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "component", type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }] });
1977
+ GanttTableBodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: { renderData: "renderData", flatData: "flatData", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate", rowBeforeTemplate: "rowBeforeTemplate", rowAfterTemplate: "rowAfterTemplate", draggable: "draggable", dropEnterPredicate: "dropEnterPredicate" }, outputs: { dragDropped: "dragDropped", dragStarted: "dragStarted", dragEnded: "dragEnded", itemClick: "itemClick" }, host: { properties: { "class.gantt-table-draggable": "this.draggable", "class.gantt-table-body": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass", "class.gantt-table-dragging": "this.ganttTableDragging" } }, viewQueries: [{ propertyName: "cdkDrags", predicate: (CdkDrag), descendants: true }], ngImport: i0, template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.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=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div [classList]=\"column.classList\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && ((gantt.async && item.expandable) || item.children?.length > 0)\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i2.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i2.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "component", type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }] });
1924
1978
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableBodyComponent, decorators: [{
1925
1979
  type: Component,
1926
- args: [{ selector: 'gantt-table-body', template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.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=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div class=\"gantt-table-column\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n" }]
1980
+ args: [{ selector: 'gantt-table-body', template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.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=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div [classList]=\"column.classList\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && ((gantt.async && item.expandable) || item.children?.length > 0)\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n" }]
1927
1981
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1928
1982
  type: Inject,
1929
1983
  args: [GANTT_ABSTRACT_TOKEN]
@@ -1956,6 +2010,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1956
2010
  type: Input
1957
2011
  }], dragDropped: [{
1958
2012
  type: Output
2013
+ }], dragStarted: [{
2014
+ type: Output
2015
+ }], dragEnded: [{
2016
+ type: Output
1959
2017
  }], itemClick: [{
1960
2018
  type: Output
1961
2019
  }], ganttTableClass: [{
@@ -2253,7 +2311,7 @@ class GanttLinksComponent {
2253
2311
  this.elementRef.nativeElement.style.visibility = 'hidden';
2254
2312
  });
2255
2313
  merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded, this.ngZone.onStable.pipe(take(1)).pipe(switchMap(() => this.ganttUpper.table?.dragDropped || EMPTY)))
2256
- .pipe(skip(1), debounceTime$1(0), takeUntil(this.unsubscribe$))
2314
+ .pipe(skip(1), debounceTime(0), takeUntil(this.unsubscribe$))
2257
2315
  .subscribe(() => {
2258
2316
  this.elementRef.nativeElement.style.visibility = 'visible';
2259
2317
  this.buildLinks();
@@ -2440,6 +2498,41 @@ function normalizePassiveListenerOptions(options) {
2440
2498
  /** Options used to bind passive event listeners. */
2441
2499
  const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
2442
2500
 
2501
+ /**
2502
+ * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
2503
+ * viewport. The value comes from trying it out manually until it feels right.
2504
+ */
2505
+ const SCROLL_PROXIMITY_THRESHOLD = 0.05;
2506
+ /**
2507
+ * Gets whether the horizontal auto-scroll direction of a node.
2508
+ * @param clientRect Dimensions of the node.
2509
+ * @param pointerX Position of the user's pointer along the x axis.
2510
+ */
2511
+ function getHorizontalScrollDirection(clientRect, pointerX) {
2512
+ const { left, right, width } = clientRect;
2513
+ const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
2514
+ if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
2515
+ return 1 /* AutoScrollHorizontalDirection.LEFT */;
2516
+ }
2517
+ else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
2518
+ return 2 /* AutoScrollHorizontalDirection.RIGHT */;
2519
+ }
2520
+ return 0 /* AutoScrollHorizontalDirection.NONE */;
2521
+ }
2522
+ /**
2523
+ * Checks whether the pointer coordinates are close to a ClientRect.
2524
+ * @param rect ClientRect to check against.
2525
+ * @param threshold Threshold around the ClientRect.
2526
+ * @param pointerX Coordinates along the X axis.
2527
+ * @param pointerY Coordinates along the Y axis.
2528
+ */
2529
+ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
2530
+ const { top, right, bottom, left, width, height } = rect;
2531
+ const xThreshold = width * threshold;
2532
+ const yThreshold = height * threshold;
2533
+ return pointerY > top - yThreshold && pointerY < bottom + yThreshold && pointerX > left - xThreshold && pointerX < right + xThreshold;
2534
+ }
2535
+
2443
2536
  const scrollThreshold = 50;
2444
2537
  var ScrollDirection;
2445
2538
  (function (ScrollDirection) {
@@ -2523,7 +2616,7 @@ class GanttDomService {
2523
2616
  .subscribe(subscriber)));
2524
2617
  }
2525
2618
  getResize() {
2526
- return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime(150));
2619
+ return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime$1(150));
2527
2620
  }
2528
2621
  scrollMainContainer(left) {
2529
2622
  if (isNumber(left)) {
@@ -2547,388 +2640,147 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2547
2640
  args: [PLATFORM_ID]
2548
2641
  }] }]; } });
2549
2642
 
2550
- class GanttDragBackdropComponent {
2643
+ /**
2644
+ * Proximity, as a ratio to width/height, at which a
2645
+ * dragged item will affect the drop container.
2646
+ */
2647
+ const DROP_PROXIMITY_THRESHOLD = 0.05;
2648
+ const dragMinWidth = 10;
2649
+ const autoScrollStep = 5;
2650
+ const activeClass = 'gantt-bar-active';
2651
+ const dropActiveClass = 'gantt-bar-drop-active';
2652
+ const singleDropActiveClass = 'gantt-bar-single-drop-active';
2653
+ function createSvgElement(qualifiedName, className) {
2654
+ const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2655
+ element.classList.add(className);
2656
+ return element;
2551
2657
  }
2552
- GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2553
- GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { classAttribute: "gantt-drag-backdrop" }, 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" });
2554
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
2555
- type: Component,
2556
- args: [{ selector: 'gantt-drag-backdrop', host: {
2557
- class: 'gantt-drag-backdrop'
2558
- }, 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" }]
2559
- }] });
2560
-
2561
- class GanttCalendarHeaderComponent {
2562
- get view() {
2563
- return this.ganttUpper.view;
2658
+ class GanttBarDrag {
2659
+ get dragDisabled() {
2660
+ return !this.item.draggable || !this.ganttUpper.draggable;
2564
2661
  }
2565
- constructor(ganttUpper, ngZone, elementRef) {
2566
- this.ganttUpper = ganttUpper;
2567
- this.ngZone = ngZone;
2568
- this.elementRef = elementRef;
2569
- this.unsubscribe$ = new Subject();
2570
- this.headerHeight = headerHeight;
2571
- this.viewTypes = GanttViewType;
2572
- this.className = `gantt-calendar gantt-calendar-header`;
2662
+ get linkDragDisabled() {
2663
+ return !this.item.linkable || !this.ganttUpper.linkable;
2573
2664
  }
2574
- ngOnInit() {
2575
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2576
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2577
- .pipe(takeUntil(this.unsubscribe$))
2665
+ get barHandleDragMoveAndScrollDistance() {
2666
+ return this.barHandleDragMoveDistance + this.dragScrollDistance;
2667
+ }
2668
+ constructor(dragDrop, dom, dragContainer, _ngZone) {
2669
+ this.dragDrop = dragDrop;
2670
+ this.dom = dom;
2671
+ this.dragContainer = dragContainer;
2672
+ this._ngZone = _ngZone;
2673
+ this.dragRefs = [];
2674
+ this.destroy$ = new Subject();
2675
+ /** Used to signal to the current auto-scroll sequence when to stop. */
2676
+ this.stopScrollTimers$ = new Subject();
2677
+ /** move distance when drag bar */
2678
+ this.barDragMoveDistance = 0;
2679
+ /** move distance when drag bar handle */
2680
+ this.barHandleDragMoveDistance = 0;
2681
+ /** scrolling state when drag */
2682
+ this.dragScrolling = false;
2683
+ /** dragScrollDistance */
2684
+ this.dragScrollDistance = 0;
2685
+ /** Horizontal direction in which the list is currently scrolling. */
2686
+ this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
2687
+ this.startScrollInterval = () => {
2688
+ this.stopScrolling();
2689
+ interval(0, animationFrameScheduler)
2690
+ .pipe(takeUntil(this.stopScrollTimers$))
2578
2691
  .subscribe(() => {
2579
- if (this.ganttUpper.viewType === GanttViewType.day)
2580
- this.setTodayPoint();
2692
+ const node = this.dom.mainContainer;
2693
+ const scrollStep = autoScrollStep;
2694
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2695
+ node.scrollBy(-scrollStep, 0);
2696
+ }
2697
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2698
+ node.scrollBy(scrollStep, 0);
2699
+ }
2581
2700
  });
2582
- });
2583
- }
2584
- setTodayPoint() {
2585
- const x = this.view.getTodayXPoint();
2586
- const today = new GanttDate().getDate();
2587
- const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
2588
- const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
2589
- if (isNumber(x)) {
2590
- if (rect) {
2591
- rect.style.left = `${x - todayWidth / 2}px`;
2592
- rect.style.top = `${headerHeight - todayHeight}px`;
2593
- rect.innerHTML = today.toString();
2594
- }
2595
- }
2596
- else {
2597
- todayEle.style.display = 'none';
2598
- }
2599
- }
2600
- trackBy(point, index) {
2601
- return point.text || index;
2701
+ };
2602
2702
  }
2603
- }
2604
- GanttCalendarHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
2605
- GanttCalendarHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header", host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n</div>\n<svg [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\n class=\"primary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text\n class=\"secondary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"headerHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n</svg>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
2606
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
2607
- type: Component,
2608
- args: [{ selector: 'gantt-calendar-header', template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n</div>\n<svg [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\n class=\"primary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text\n class=\"secondary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"headerHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n</svg>\n" }]
2609
- }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2610
- type: Inject,
2611
- args: [GANTT_UPPER_TOKEN]
2612
- }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
2613
- type: HostBinding,
2614
- args: ['class']
2615
- }] } });
2616
-
2617
- const mainHeight = 5000;
2618
- class GanttCalendarGridComponent {
2619
- get view() {
2620
- return this.ganttUpper.view;
2703
+ createDragRef(element) {
2704
+ const dragRef = this.dragDrop.createDrag(element);
2705
+ return dragRef;
2621
2706
  }
2622
- constructor(ganttUpper, ngZone, elementRef) {
2623
- this.ganttUpper = ganttUpper;
2624
- this.ngZone = ngZone;
2625
- this.elementRef = elementRef;
2626
- this.unsubscribe$ = new Subject();
2627
- this.headerHeight = headerHeight;
2628
- this.mainHeight = mainHeight;
2629
- this.todayBorderRadius = todayBorderRadius;
2630
- this.viewTypes = GanttViewType;
2631
- this.className = `gantt-calendar gantt-calendar-grid`;
2707
+ createDragScrollEvent(dragRef) {
2708
+ return fromEvent(this.dom.mainContainer, 'scroll', passiveListenerOptions).pipe(takeUntil(dragRef.ended));
2632
2709
  }
2633
- setTodayPoint() {
2634
- const x = this.view.getTodayXPoint();
2635
- const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
2636
- const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
2637
- if (isNumber(x)) {
2638
- if (line) {
2639
- line.style.left = `${x}px`;
2640
- line.style.top = `0px`;
2641
- line.style.bottom = `${-mainHeight}px`;
2710
+ createMouseEvents() {
2711
+ const dropClass = this.ganttUpper.config.linkOptions?.dependencyTypes?.length === 1 &&
2712
+ this.ganttUpper.config.linkOptions?.dependencyTypes[0] === GanttLinkType.fs
2713
+ ? singleDropActiveClass
2714
+ : dropActiveClass;
2715
+ fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
2716
+ .pipe(takeUntil(this.destroy$))
2717
+ .subscribe(() => {
2718
+ if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2719
+ if (this.item.linkable) {
2720
+ this.barElement.classList.add(dropClass);
2721
+ this.dragContainer.emitLinkDragEntered({
2722
+ item: this.item,
2723
+ element: this.barElement
2724
+ });
2725
+ }
2642
2726
  }
2643
- }
2644
- else {
2645
- todayEle.style.display = 'none';
2646
- }
2727
+ else {
2728
+ this.barElement.classList.add(activeClass);
2729
+ }
2730
+ });
2731
+ fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
2732
+ .pipe(takeUntil(this.destroy$))
2733
+ .subscribe(() => {
2734
+ if (!this.dragContainer.linkDraggingId) {
2735
+ this.barElement.classList.remove(activeClass);
2736
+ }
2737
+ else {
2738
+ this.dragContainer.emitLinkDragLeaved();
2739
+ }
2740
+ this.barElement.classList.remove(dropClass);
2741
+ });
2647
2742
  }
2648
- ngOnInit() {
2649
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2650
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2651
- .pipe(takeUntil(this.unsubscribe$))
2652
- .subscribe(() => {
2653
- this.setTodayPoint();
2743
+ createBarDrag() {
2744
+ const dragRef = this.createDragRef(this.barElement);
2745
+ dragRef.lockAxis = 'x';
2746
+ dragRef.withBoundaryElement(this.dom.mainItems);
2747
+ dragRef.started.subscribe(() => {
2748
+ this.setDraggingStyles();
2749
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2750
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2751
+ if (dragRef.isDragging()) {
2752
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2753
+ this.dragScrollDistance = dragScrollDistance;
2754
+ dragRef['_boundaryRect'] = this.dom.mainItems.getBoundingClientRect();
2755
+ this.barDragMove();
2756
+ }
2654
2757
  });
2758
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2655
2759
  });
2656
- }
2657
- trackBy(point, index) {
2658
- return point.text || index;
2659
- }
2660
- ngOnDestroy() {
2661
- this.unsubscribe$.next();
2662
- this.unsubscribe$.complete();
2663
- }
2664
- }
2665
- GanttCalendarGridComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
2666
- GanttCalendarGridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid", host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-grid-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight - 1\">\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n </g>\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2667
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
2668
- type: Component,
2669
- args: [{ selector: 'gantt-calendar-grid', template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-grid-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight - 1\">\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n </g>\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n" }]
2670
- }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2671
- type: Inject,
2672
- args: [GANTT_UPPER_TOKEN]
2673
- }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
2674
- type: HostBinding,
2675
- args: ['class']
2676
- }] } });
2677
-
2678
- class NgxGanttToolbarComponent {
2679
- constructor(ganttUpper) {
2680
- this.ganttUpper = ganttUpper;
2681
- this.ganttItemClass = true;
2682
- this.ganttViewsMap = keyBy(ganttViews, 'value');
2683
- }
2684
- selectView(view) {
2685
- this.ganttUpper.changeView(view);
2686
- }
2687
- }
2688
- NgxGanttToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2689
- NgxGanttToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: { template: "template" }, host: { properties: { "class.gantt-toolbar": "this.ganttItemClass" } }, ngImport: i0, template: "<div class=\"toolbar-container\">\n <ng-container *ngIf=\"!template\">\n <div class=\"toolbar-views\" *ngIf=\"this.ganttUpper.toolbarOptions?.viewTypes?.length\">\n <ng-container *ngFor=\"let view of this.ganttUpper.toolbarOptions?.viewTypes\">\n <div class=\"toolbar-view\" *ngIf=\"ganttViewsMap[view]\" [class.active]=\"view === this.ganttUpper.viewType\" (click)=\"selectView(view)\">\n {{ ganttViewsMap[view].name }}\n </div>\n </ng-container>\n </div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
2690
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, decorators: [{
2691
- type: Component,
2692
- args: [{ selector: 'ngx-gantt-toolbar,gantt-toolbar', template: "<div class=\"toolbar-container\">\n <ng-container *ngIf=\"!template\">\n <div class=\"toolbar-views\" *ngIf=\"this.ganttUpper.toolbarOptions?.viewTypes?.length\">\n <ng-container *ngFor=\"let view of this.ganttUpper.toolbarOptions?.viewTypes\">\n <div class=\"toolbar-view\" *ngIf=\"ganttViewsMap[view]\" [class.active]=\"view === this.ganttUpper.viewType\" (click)=\"selectView(view)\">\n {{ ganttViewsMap[view].name }}\n </div>\n </ng-container>\n </div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n</div>\n" }]
2693
- }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2694
- type: Inject,
2695
- args: [GANTT_UPPER_TOKEN]
2696
- }] }]; }, propDecorators: { template: [{
2697
- type: Input
2698
- }], ganttItemClass: [{
2699
- type: HostBinding,
2700
- args: ['class.gantt-toolbar']
2701
- }] } });
2702
-
2703
- class NgxGanttRootComponent {
2704
- get view() {
2705
- return this.ganttUpper.view;
2706
- }
2707
- constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
2708
- this.elementRef = elementRef;
2709
- this.ngZone = ngZone;
2710
- this.dom = dom;
2711
- this.dragContainer = dragContainer;
2712
- this.ganttUpper = ganttUpper;
2713
- this.printService = printService;
2714
- this.unsubscribe$ = new Subject();
2715
- this.ganttUpper.dragContainer = dragContainer;
2716
- }
2717
- ngOnInit() {
2718
- // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
2719
- // the `onStable` will never emit any value.
2720
- const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
2721
- // Normally this isn't in the zone, but it can cause performance regressions for apps
2722
- // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
2723
- this.ngZone.runOutsideAngular(() => {
2724
- onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2725
- this.dom.initialize(this.elementRef);
2726
- if (this.printService) {
2727
- this.printService.register(this.elementRef);
2728
- }
2729
- this.setupScrollClass();
2730
- this.setupResize();
2731
- this.setupViewScroll();
2732
- // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
2733
- this.elementRef.nativeElement.style.opacity = '1';
2734
- this.ganttUpper.viewChange.pipe(startWith$1(null), takeUntil(this.unsubscribe$)).subscribe(() => {
2735
- this.scrollToToday();
2736
- });
2737
- });
2738
- });
2739
- }
2740
- ngOnDestroy() {
2741
- this.unsubscribe$.next();
2742
- }
2743
- setupViewScroll() {
2744
- if (this.ganttUpper.disabledLoadOnScroll) {
2745
- return;
2746
- }
2747
- this.dom
2748
- .getViewerScroll(passiveListenerOptions)
2749
- .pipe(takeUntil(this.unsubscribe$))
2750
- .subscribe((event) => {
2751
- if (event.direction === ScrollDirection.LEFT) {
2752
- const dates = this.view.addStartDate();
2753
- if (dates) {
2754
- event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
2755
- if (this.ganttUpper.loadOnScroll.observers) {
2756
- this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
2757
- }
2758
- }
2759
- }
2760
- if (event.direction === ScrollDirection.RIGHT) {
2761
- const dates = this.view.addEndDate();
2762
- if (dates && this.ganttUpper.loadOnScroll.observers) {
2763
- this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
2764
- }
2765
- }
2766
- });
2767
- }
2768
- setupResize() {
2769
- this.dom
2770
- .getResize()
2771
- .pipe(takeUntil(this.unsubscribe$))
2772
- .subscribe(() => {
2773
- this.setupScrollClass();
2774
- });
2775
- }
2776
- setupScrollClass() {
2777
- const mainContainer = this.dom.mainContainer;
2778
- const height = mainContainer.offsetHeight;
2779
- const scrollHeight = mainContainer.scrollHeight;
2780
- if (scrollHeight > height) {
2781
- this.elementRef.nativeElement.className = 'gantt gantt-scroll';
2782
- }
2783
- else {
2784
- this.elementRef.nativeElement.className = 'gantt';
2785
- }
2786
- }
2787
- scrollToToday() {
2788
- const x = this.view.getTodayXPoint();
2789
- this.dom.scrollMainContainer(x);
2790
- }
2791
- scrollToDate(date) {
2792
- let x;
2793
- if (typeof date === 'number') {
2794
- x = this.view.getXPointByDate(new GanttDate(date));
2795
- }
2796
- else {
2797
- x = this.view.getXPointByDate(date);
2798
- }
2799
- this.dom.scrollMainContainer(x);
2800
- }
2801
- }
2802
- NgxGanttRootComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", 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 });
2803
- NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { classAttribute: "gantt" }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], viewQueries: [{ propertyName: "backdrop", first: true, predicate: GanttDragBackdropComponent, descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" *ngIf=\"sideTemplate\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\" cdkScrollable>\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\" *ngIf=\"mainTemplate\">\n <gantt-calendar-header></gantt-calendar-header>\n <gantt-calendar-grid></gantt-calendar-grid>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n<ng-content></ng-content>\n<gantt-toolbar *ngIf=\"ganttUpper.showToolbar || ganttUpper.toolbarTemplate\" [template]=\"ganttUpper.toolbarTemplate\"> </gantt-toolbar>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2$1.CdkScrollable, selector: "[cdk-scrollable], [cdkScrollable]" }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: ["template"] }] });
2804
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
2805
- type: Component,
2806
- args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
2807
- class: 'gantt'
2808
- }, template: "<div class=\"gantt-side\" *ngIf=\"sideTemplate\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\" cdkScrollable>\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\" *ngIf=\"mainTemplate\">\n <gantt-calendar-header></gantt-calendar-header>\n <gantt-calendar-grid></gantt-calendar-grid>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n<ng-content></ng-content>\n<gantt-toolbar *ngIf=\"ganttUpper.showToolbar || ganttUpper.toolbarTemplate\" [template]=\"ganttUpper.toolbarTemplate\"> </gantt-toolbar>\n" }]
2809
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
2810
- type: Inject,
2811
- args: [GANTT_UPPER_TOKEN]
2812
- }] }, { type: GanttPrintService, decorators: [{
2813
- type: Optional
2814
- }] }]; }, propDecorators: { sideWidth: [{
2815
- type: Input
2816
- }], sideTemplate: [{
2817
- type: ContentChild,
2818
- args: ['sideTemplate', { static: true }]
2819
- }], mainTemplate: [{
2820
- type: ContentChild,
2821
- args: ['mainTemplate', { static: true }]
2822
- }], backdrop: [{
2823
- type: ViewChild,
2824
- args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
2825
- }] } });
2826
-
2827
- const dragMinWidth = 10;
2828
- const autoScrollStep = 10;
2829
- const activeClass = 'gantt-bar-active';
2830
- const dropActiveClass = 'gantt-bar-drop-active';
2831
- const singleDropActiveClass = 'gantt-bar-single-drop-active';
2832
- function createSvgElement(qualifiedName, className) {
2833
- const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2834
- element.classList.add(className);
2835
- return element;
2836
- }
2837
- class GanttBarDrag {
2838
- get dragDisabled() {
2839
- return !this.item.draggable || !this.ganttUpper.draggable;
2840
- }
2841
- get linkDragDisabled() {
2842
- return !this.item.linkable || !this.ganttUpper.linkable;
2843
- }
2844
- constructor(dragDrop, dom, dragContainer, root) {
2845
- this.dragDrop = dragDrop;
2846
- this.dom = dom;
2847
- this.dragContainer = dragContainer;
2848
- this.root = root;
2849
- this.dragRefs = [];
2850
- this.destroy$ = new Subject();
2851
- // scrolling state when drag
2852
- this.dragScrolling = false;
2853
- }
2854
- createDragRef(element) {
2855
- const dragRef = this.dragDrop.createDrag(element);
2856
- // dragRef.withPreviewContainer(this.dom.mainContainer as HTMLElement);
2857
- return dragRef;
2858
- }
2859
- createDragScrollEvent(dragRef) {
2860
- return fromEvent(this.dom.mainContainer, 'scroll', passiveListenerOptions).pipe(takeUntil(dragRef.ended));
2861
- }
2862
- createMouseEvents() {
2863
- const dropClass = this.ganttUpper.config.linkOptions?.dependencyTypes?.length === 1 &&
2864
- this.ganttUpper.config.linkOptions?.dependencyTypes[0] === GanttLinkType.fs
2865
- ? singleDropActiveClass
2866
- : dropActiveClass;
2867
- fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
2868
- .pipe(takeUntil(this.destroy$))
2869
- .subscribe(() => {
2870
- if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2871
- if (this.item.linkable) {
2872
- this.barElement.classList.add(dropClass);
2873
- this.dragContainer.emitLinkDragEntered({
2874
- item: this.item,
2875
- element: this.barElement
2876
- });
2877
- }
2878
- }
2879
- else {
2880
- this.barElement.classList.add(activeClass);
2881
- }
2882
- });
2883
- fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
2884
- .pipe(takeUntil(this.destroy$))
2885
- .subscribe(() => {
2886
- if (!this.dragContainer.linkDraggingId) {
2887
- this.barElement.classList.remove(activeClass);
2888
- }
2889
- else {
2890
- this.dragContainer.emitLinkDragLeaved();
2891
- }
2892
- this.barElement.classList.remove(dropClass);
2893
- });
2894
- }
2895
- createBarDrag() {
2896
- const dragRef = this.createDragRef(this.barElement);
2897
- dragRef.lockAxis = 'x';
2898
- dragRef.withBoundaryElement(this.dom.mainItems);
2899
- dragRef.started.subscribe(() => {
2900
- this.setDraggingStyles();
2901
- this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2902
- this.createDragScrollEvent(dragRef).subscribe(() => {
2903
- if (this.dropListRef.isDragging()) {
2904
- this.dragScrolling = true;
2905
- const scrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2906
- this.barDragMove(dragRef, scrollDistance + this.barDragMoveDistance);
2907
- }
2908
- });
2909
- this.dragContainer.dragStarted.emit({ item: this.item.origin });
2910
- });
2911
- dragRef.moved.subscribe((event) => {
2912
- this.barDragMove(dragRef, event.distance.x);
2913
- if (!this.dragScrolling) {
2914
- this.barDragMoveDistance = event.distance.x;
2915
- }
2916
- });
2917
- dragRef.ended.subscribe((event) => {
2918
- this.item.updateRefs({
2919
- width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2920
- x: this.ganttUpper.view.getXPointByDate(this.item.start),
2921
- y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2922
- });
2923
- this.clearDraggingStyles();
2924
- this.closeDragBackdrop();
2925
- event.source.reset();
2926
- this.dragScrolling = false;
2927
- this.barDragMoveDistance = 0;
2928
- this.dragContainer.dragEnded.emit({ item: this.item.origin });
2929
- });
2930
- this.barDragRef = dragRef;
2931
- return dragRef;
2760
+ dragRef.moved.subscribe((event) => {
2761
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2762
+ this.barDragMoveDistance = event.distance.x;
2763
+ if (!this.dragScrolling) {
2764
+ this.barDragMove();
2765
+ }
2766
+ });
2767
+ dragRef.ended.subscribe((event) => {
2768
+ this.clearDraggingStyles();
2769
+ this.closeDragBackdrop();
2770
+ event.source.reset();
2771
+ this.stopScrolling();
2772
+ this.dragScrolling = false;
2773
+ this.dragScrollDistance = 0;
2774
+ this.barDragMoveDistance = 0;
2775
+ this.item.updateRefs({
2776
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2777
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2778
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2779
+ });
2780
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2781
+ });
2782
+ this.barDragRef = dragRef;
2783
+ return dragRef;
2932
2784
  }
2933
2785
  createBarHandleDrags() {
2934
2786
  const dragRefs = [];
@@ -2942,43 +2794,51 @@ class GanttBarDrag {
2942
2794
  this.setDraggingStyles();
2943
2795
  this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2944
2796
  this.createDragScrollEvent(dragRef).subscribe(() => {
2945
- if (this.dropListRef.isDragging()) {
2946
- this.dragScrolling = true;
2947
- const scrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2948
- this.barHandleDragMove(scrollDistance + this.barHandleDragMoveDistance, isBefore);
2797
+ if (dragRef.isDragging()) {
2798
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2799
+ this.dragScrollDistance = dragScrollDistance;
2800
+ dragRef['_boundaryRect'] = this.dom.mainItems.getBoundingClientRect();
2801
+ if (this.dragScrolling && this.isStartGreaterThanEndWhenBarHandleDragMove(isBefore)) {
2802
+ this.stopScrolling();
2803
+ this.dragScrolling = false;
2804
+ }
2805
+ if (isBefore) {
2806
+ this.barBeforeHandleDragMove();
2807
+ }
2808
+ else {
2809
+ this.barAfterHandleDragMove();
2810
+ }
2949
2811
  }
2950
2812
  });
2951
2813
  this.dragContainer.dragStarted.emit({ item: this.item.origin });
2952
2814
  });
2953
2815
  dragRef.moved.subscribe((event) => {
2954
- this.barHandleDragMove(event.distance.x, isBefore);
2955
- if (!this.dragScrolling) {
2956
- this.barHandleDragMoveDistance = event.distance.x;
2816
+ if (this.barHandleDragMoveRecordDays && this.barHandleDragMoveRecordDays > 0) {
2817
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2957
2818
  }
2958
- });
2959
- dragRef.ended.subscribe((event) => {
2960
- if (isBefore) {
2961
- const width = this.item.refs.width + event.distance.x * -1;
2962
- if (width <= dragMinWidth) {
2963
- this.item.updateDate(this.item.end.startOfDay(), this.item.end);
2819
+ this.barHandleDragMoveDistance = event.distance.x;
2820
+ if (!this.dragScrolling) {
2821
+ if (isBefore) {
2822
+ this.barBeforeHandleDragMove();
2964
2823
  }
2965
- }
2966
- else {
2967
- const width = this.item.refs.width + event.distance.x;
2968
- if (width <= dragMinWidth) {
2969
- this.item.updateDate(this.item.start, this.item.start.endOfDay());
2824
+ else {
2825
+ this.barAfterHandleDragMove();
2970
2826
  }
2971
2827
  }
2972
- this.item.updateRefs({
2973
- width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2974
- x: this.ganttUpper.view.getXPointByDate(this.item.start),
2975
- y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2976
- });
2828
+ });
2829
+ dragRef.ended.subscribe((event) => {
2977
2830
  this.clearDraggingStyles();
2978
2831
  this.closeDragBackdrop();
2979
2832
  event.source.reset();
2833
+ this.stopScrolling();
2980
2834
  this.dragScrolling = false;
2835
+ this.dragScrollDistance = 0;
2981
2836
  this.barHandleDragMoveDistance = 0;
2837
+ this.item.updateRefs({
2838
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2839
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2840
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2841
+ });
2982
2842
  this.dragContainer.dragEnded.emit({ item: this.item.origin });
2983
2843
  });
2984
2844
  dragRefs.push(dragRef);
@@ -3039,13 +2899,19 @@ class GanttBarDrag {
3039
2899
  return dragRefs;
3040
2900
  }
3041
2901
  openDragBackdrop(dragElement, start, end) {
3042
- // const dragBackdropElement = this.root.backdrop.nativeElement;
3043
- // const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask') as HTMLElement;
3044
2902
  const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
3045
2903
  const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
3046
2904
  const rootRect = this.dom.root.getBoundingClientRect();
3047
2905
  const dragRect = dragElement.getBoundingClientRect();
3048
- const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
2906
+ let left = dragRect.left - rootRect.left - (this.dom.side.clientWidth + 1);
2907
+ if (this.dragScrolling) {
2908
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2909
+ left += autoScrollStep;
2910
+ }
2911
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2912
+ left -= autoScrollStep;
2913
+ }
2914
+ }
3049
2915
  const width = dragRect.right - dragRect.left;
3050
2916
  // Note: updating styles will cause re-layout so we have to place them consistently one by one.
3051
2917
  dragMaskElement.style.left = left + 'px';
@@ -3070,8 +2936,8 @@ class GanttBarDrag {
3070
2936
  this.barElement.style.pointerEvents = '';
3071
2937
  this.barElement.classList.remove('gantt-bar-draggable-drag');
3072
2938
  }
3073
- barDragMove(dragRef, distance) {
3074
- const currentX = this.item.refs.x + distance;
2939
+ barDragMove() {
2940
+ const currentX = this.item.refs.x + this.barDragMoveDistance + this.dragScrollDistance;
3075
2941
  const currentDate = this.ganttUpper.view.getDateByXPoint(currentX);
3076
2942
  const currentStartX = this.ganttUpper.view.getXPointByDate(currentDate);
3077
2943
  const dayWidth = this.ganttUpper.view.getDayOccupancyWidth(currentDate);
@@ -3082,31 +2948,62 @@ class GanttBarDrag {
3082
2948
  start = start.addDays(1);
3083
2949
  end = end.addDays(1);
3084
2950
  }
3085
- this.openDragBackdrop(dragRef['_preview'], this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
3086
- this.item.updateDate(start, end);
2951
+ if (this.dragScrolling) {
2952
+ const left = currentX - this.barDragMoveDistance;
2953
+ this.barElement.style.left = left + 'px';
2954
+ }
2955
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
2956
+ if (!this.isStartOrEndInsideView(start, end)) {
2957
+ return;
2958
+ }
2959
+ this.item.updateDate(start, end);
2960
+ this.dragContainer.dragMoved.emit({ item: this.item.origin });
2961
+ }
2962
+ barBeforeHandleDragMove() {
2963
+ const { x, start, oneDayWidth } = this.startOfBarHandle();
2964
+ const width = this.item.refs.width + this.barHandleDragMoveAndScrollDistance * -1;
2965
+ const days = differenceInDays(this.item.end.value, start.value);
2966
+ if (width > dragMinWidth && days > 0) {
2967
+ this.barElement.style.width = width + 'px';
2968
+ this.barElement.style.left = x + 'px';
2969
+ this.openDragBackdrop(this.barElement, start, this.item.end);
2970
+ if (!this.isStartOrEndInsideView(start, this.item.end)) {
2971
+ return;
2972
+ }
2973
+ this.item.updateDate(start, this.item.end);
2974
+ }
2975
+ else {
2976
+ if (this.barHandleDragMoveRecordDays > 0 && days <= 0) {
2977
+ this.barElement.style.width = oneDayWidth + 'px';
2978
+ const x = this.ganttUpper.view.getXPointByDate(this.item.end);
2979
+ this.barElement.style.left = x + 'px';
2980
+ }
2981
+ this.openDragBackdrop(this.barElement, this.item.end.startOfDay(), this.item.end);
2982
+ this.item.updateDate(this.item.end.startOfDay(), this.item.end);
2983
+ }
2984
+ this.barHandleDragMoveRecordDays = days;
3087
2985
  this.dragContainer.dragMoved.emit({ item: this.item.origin });
3088
2986
  }
3089
- barHandleDragMove(distance, isBefore) {
3090
- if (isBefore) {
3091
- const x = this.item.refs.x + distance;
3092
- const width = this.item.refs.width + distance * -1;
3093
- const start = this.ganttUpper.view.getDateByXPoint(x);
3094
- if (width > dragMinWidth) {
3095
- this.barElement.style.width = width + 'px';
3096
- this.barElement.style.left = x + 'px';
3097
- this.openDragBackdrop(this.barElement, start, this.item.end);
3098
- this.item.updateDate(start, this.item.end);
2987
+ barAfterHandleDragMove() {
2988
+ const { width, end } = this.endOfBarHandle();
2989
+ const days = differenceInDays(end.value, this.item.start.value);
2990
+ if (width > dragMinWidth && days > 0) {
2991
+ this.barElement.style.width = width + 'px';
2992
+ this.openDragBackdrop(this.barElement, this.item.start, end);
2993
+ if (!this.isStartOrEndInsideView(this.item.start, end)) {
2994
+ return;
3099
2995
  }
2996
+ this.item.updateDate(this.item.start, end);
3100
2997
  }
3101
2998
  else {
3102
- const width = this.item.refs.width + distance;
3103
- const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
3104
- if (width > dragMinWidth) {
3105
- this.barElement.style.width = width + 'px';
3106
- this.openDragBackdrop(this.barElement, this.item.start, end);
3107
- this.item.updateDate(this.item.start, end);
2999
+ if (this.barHandleDragMoveRecordDays > 0 && days <= 0) {
3000
+ const oneDayWidth = this.ganttUpper.view.getDateRangeWidth(this.item.start, this.item.start.endOfDay());
3001
+ this.barElement.style.width = oneDayWidth + 'px';
3108
3002
  }
3003
+ this.openDragBackdrop(this.barElement, this.item.start, this.item.start.endOfDay());
3004
+ this.item.updateDate(this.item.start, this.item.start.endOfDay());
3109
3005
  }
3006
+ this.barHandleDragMoveRecordDays = days;
3110
3007
  this.dragContainer.dragMoved.emit({ item: this.item.origin });
3111
3008
  }
3112
3009
  calcLinkLinePositions(target, isBefore) {
@@ -3136,6 +3033,77 @@ class GanttBarDrag {
3136
3033
  this.linkDraggingLine = null;
3137
3034
  }
3138
3035
  }
3036
+ startScrollingIfNecessary(pointerX, pointerY) {
3037
+ const clientRect = this.dom.mainContainer.getBoundingClientRect();
3038
+ const scrollLeft = this.dom.mainContainer.scrollLeft;
3039
+ if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
3040
+ const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
3041
+ if ((horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */ && scrollLeft > 0) ||
3042
+ (horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */ &&
3043
+ scrollLeft < this.ganttUpper.view.width - clientRect.width)) {
3044
+ this._horizontalScrollDirection = horizontalScrollDirection;
3045
+ this.dragScrolling = true;
3046
+ this._ngZone.runOutsideAngular(this.startScrollInterval);
3047
+ }
3048
+ else {
3049
+ this.dragScrolling = false;
3050
+ this.stopScrolling();
3051
+ }
3052
+ }
3053
+ }
3054
+ // Conditions to stop auto-scroll: when the start is greater than the end and the bar appears in the view
3055
+ isStartGreaterThanEndWhenBarHandleDragMove(isBefore) {
3056
+ let isStartGreaterThanEnd;
3057
+ let isBarAppearsInView;
3058
+ const scrollLeft = this.dom.mainContainer.scrollLeft;
3059
+ const clientWidth = this.dom.mainContainer.clientWidth;
3060
+ const xThreshold = clientWidth * DROP_PROXIMITY_THRESHOLD;
3061
+ if (isBefore) {
3062
+ const { start, oneDayWidth } = this.startOfBarHandle();
3063
+ const xPointerByEndDate = this.ganttUpper.view.getXPointByDate(this.item.end);
3064
+ isStartGreaterThanEnd = start.value > this.item.end.value;
3065
+ isBarAppearsInView = xPointerByEndDate + oneDayWidth + xThreshold <= scrollLeft + clientWidth;
3066
+ }
3067
+ else {
3068
+ const { end } = this.endOfBarHandle();
3069
+ const xPointerByStartDate = this.ganttUpper.view.getXPointByDate(this.item.start);
3070
+ isStartGreaterThanEnd = end.value < this.item.start.value;
3071
+ isBarAppearsInView = scrollLeft + xThreshold <= xPointerByStartDate;
3072
+ }
3073
+ return isStartGreaterThanEnd && isBarAppearsInView ? true : false;
3074
+ }
3075
+ // Some data information about dragging start until it is equal to or greater than end
3076
+ startOfBarHandle() {
3077
+ const x = this.item.refs.x + this.barHandleDragMoveAndScrollDistance;
3078
+ return {
3079
+ x,
3080
+ start: this.ganttUpper.view.getDateByXPoint(x),
3081
+ oneDayWidth: this.ganttUpper.view.getDateRangeWidth(this.item.end.startOfDay(), this.item.end)
3082
+ };
3083
+ }
3084
+ // Some data information about dragging end of bar handle
3085
+ endOfBarHandle() {
3086
+ const width = this.item.refs.width + this.barHandleDragMoveAndScrollDistance;
3087
+ return {
3088
+ width,
3089
+ end: this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width)
3090
+ };
3091
+ }
3092
+ stopScrolling() {
3093
+ this.stopScrollTimers$.next();
3094
+ }
3095
+ isStartOrEndInsideView(start, end) {
3096
+ const itemStart = start.getUnixTime();
3097
+ const itemEnd = end.getUnixTime();
3098
+ const viewStart = this.ganttUpper.view.start.getUnixTime();
3099
+ const viewEnd = this.ganttUpper.view.end.getUnixTime();
3100
+ if (itemStart < viewStart || itemEnd > viewEnd) {
3101
+ return false;
3102
+ }
3103
+ else {
3104
+ return true;
3105
+ }
3106
+ }
3139
3107
  createDrags(elementRef, item, ganttUpper) {
3140
3108
  this.item = item;
3141
3109
  this.barElement = elementRef.nativeElement;
@@ -3149,13 +3117,6 @@ class GanttBarDrag {
3149
3117
  const dragRef = this.createBarDrag();
3150
3118
  const dragHandlesRefs = this.createBarHandleDrags();
3151
3119
  this.dragRefs.push(dragRef, ...dragHandlesRefs);
3152
- // 创建拖拽容器并将所有元素添加到容器中,利用容器来实现自动滚动
3153
- if (!this.dropListRef) {
3154
- this.dropListRef = this.dragDrop.createDropList(this.dom.mainContainer);
3155
- this.dropListRef.autoScrollStep = autoScrollStep;
3156
- this.dropListRef.withOrientation('horizontal');
3157
- }
3158
- this.dropListRef.withItems([dragRef, ...dragHandlesRefs]);
3159
3120
  }
3160
3121
  if (!this.linkDragDisabled) {
3161
3122
  const linkDragRefs = this.createLinkHandleDrags();
@@ -3171,15 +3132,15 @@ class GanttBarDrag {
3171
3132
  this.dragRefs.forEach((dragRef) => dragRef.dispose());
3172
3133
  this.destroy$.next();
3173
3134
  this.destroy$.complete();
3135
+ this.stopScrolling();
3136
+ this.stopScrollTimers$.complete();
3174
3137
  }
3175
3138
  }
3176
- GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, deps: [{ token: i2.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
3139
+ GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, deps: [{ token: i2.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
3177
3140
  GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag });
3178
3141
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, decorators: [{
3179
3142
  type: Injectable
3180
- }], ctorParameters: function () { return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: NgxGanttRootComponent, decorators: [{
3181
- type: SkipSelf
3182
- }] }]; } });
3143
+ }], ctorParameters: function () { return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: i0.NgZone }]; } });
3183
3144
 
3184
3145
  class GanttItemUpper {
3185
3146
  constructor(elementRef, ganttUpper) {
@@ -3187,10 +3148,11 @@ class GanttItemUpper {
3187
3148
  this.ganttUpper = ganttUpper;
3188
3149
  this.firstChange = true;
3189
3150
  this.unsubscribe$ = new Subject();
3151
+ this.refsUnsubscribe$ = new Subject();
3190
3152
  }
3191
3153
  ngOnInit() {
3192
3154
  this.firstChange = false;
3193
- this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3155
+ this.item.refs$.pipe(takeUntil(this.refsUnsubscribe$)).subscribe(() => {
3194
3156
  this.setPositions();
3195
3157
  });
3196
3158
  }
@@ -3200,11 +3162,10 @@ class GanttItemUpper {
3200
3162
  }
3201
3163
  }
3202
3164
  itemChange(item) {
3203
- this.unsubscribe$.next();
3204
- this.unsubscribe$.complete();
3165
+ this.refsUnsubscribe$.next();
3166
+ this.refsUnsubscribe$.complete();
3205
3167
  this.item = item;
3206
- this.setPositions();
3207
- this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3168
+ this.item.refs$.pipe(takeUntil(this.refsUnsubscribe$)).subscribe(() => {
3208
3169
  this.setPositions();
3209
3170
  });
3210
3171
  }
@@ -3223,6 +3184,8 @@ class GanttItemUpper {
3223
3184
  ngOnDestroy() {
3224
3185
  this.unsubscribe$.next();
3225
3186
  this.unsubscribe$.complete();
3187
+ this.refsUnsubscribe$.next();
3188
+ this.refsUnsubscribe$.complete();
3226
3189
  }
3227
3190
  }
3228
3191
  GanttItemUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttItemUpper, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Directive });
@@ -3261,6 +3224,10 @@ class NgxGanttBarComponent extends GanttItemUpper {
3261
3224
  super.ngOnChanges(changes);
3262
3225
  if (!this.firstChange) {
3263
3226
  this.drag.updateItem(this.item);
3227
+ if (changes.item.currentValue.refs?.width !== changes.item.previousValue.refs?.width ||
3228
+ changes.item.currentValue.color !== changes.item.previousValue.color) {
3229
+ this.setContentBackground();
3230
+ }
3264
3231
  }
3265
3232
  }
3266
3233
  ngAfterViewInit() {
@@ -3284,166 +3251,494 @@ class NgxGanttBarComponent extends GanttItemUpper {
3284
3251
  event.stopPropagation();
3285
3252
  });
3286
3253
  }
3287
- onBarClick(event) {
3288
- this.barClick.emit({ event, item: this.item.origin });
3289
- }
3290
- setContentBackground() {
3291
- const contentElement = this.contentElementRef.nativeElement;
3292
- const color = this.item.color || barBackground;
3293
- const style = this.item.barStyle || {};
3294
- if (this.item.origin.start && this.item.origin.end) {
3295
- style.background = color;
3296
- style.borderRadius = '';
3297
- }
3298
- if (this.item.origin.start && !this.item.origin.end) {
3299
- style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
3300
- style.borderRadius = '4px 12.5px 12.5px 4px';
3301
- }
3302
- if (!this.item.origin.start && this.item.origin.end) {
3303
- style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
3304
- style.borderRadius = '12.5px 4px 4px 12.5px';
3305
- }
3306
- if (this.item.progress >= 0) {
3307
- const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
3308
- style.background = hexToRgb(color, 0.3);
3309
- style.borderRadius = '';
3310
- contentProgressElement.style.background = color;
3311
- }
3312
- for (const key in style) {
3313
- if (style.hasOwnProperty(key)) {
3314
- contentElement.style[key] = style[key];
3315
- }
3316
- }
3254
+ onBarClick(event) {
3255
+ this.barClick.emit({ event, item: this.item.origin });
3256
+ }
3257
+ setContentBackground() {
3258
+ if (this.item.refs?.width) {
3259
+ const contentElement = this.contentElementRef.nativeElement;
3260
+ const color = this.item.color || barBackground;
3261
+ const style = this.item.barStyle || {};
3262
+ if (this.item.origin.start && this.item.origin.end) {
3263
+ style.background = color;
3264
+ style.borderRadius = '';
3265
+ }
3266
+ if (this.item.origin.start && !this.item.origin.end) {
3267
+ style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
3268
+ style.borderRadius = '4px 12.5px 12.5px 4px';
3269
+ }
3270
+ if (!this.item.origin.start && this.item.origin.end) {
3271
+ style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
3272
+ style.borderRadius = '12.5px 4px 4px 12.5px';
3273
+ }
3274
+ if (this.item.progress >= 0) {
3275
+ const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
3276
+ style.background = hexToRgb(color, 0.3);
3277
+ style.borderRadius = '';
3278
+ contentProgressElement.style.background = color;
3279
+ }
3280
+ for (const key in style) {
3281
+ if (style.hasOwnProperty(key)) {
3282
+ contentElement.style[key] = style[key];
3283
+ }
3284
+ }
3285
+ }
3286
+ }
3287
+ stopPropagation(event) {
3288
+ event.stopPropagation();
3289
+ }
3290
+ }
3291
+ NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
3292
+ NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", 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 }, { propertyName: "handles", predicate: ["handle"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></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", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3293
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
3294
+ type: Component,
3295
+ args: [{ selector: 'ngx-gantt-bar,gantt-bar', providers: [GanttBarDrag], template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></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" }]
3296
+ }], ctorParameters: function () { return [{ type: GanttDragContainer }, { type: GanttBarDrag }, { type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3297
+ type: Inject,
3298
+ args: [GANTT_UPPER_TOKEN]
3299
+ }] }, { type: i0.NgZone }]; }, propDecorators: { barClick: [{
3300
+ type: Output
3301
+ }], contentElementRef: [{
3302
+ type: ViewChild,
3303
+ args: ['content']
3304
+ }], ganttItemClass: [{
3305
+ type: HostBinding,
3306
+ args: ['class.gantt-bar']
3307
+ }], handles: [{
3308
+ type: ViewChildren,
3309
+ args: ['handle']
3310
+ }] } });
3311
+
3312
+ class NgxGanttRangeComponent extends GanttItemUpper {
3313
+ constructor(elementRef, ganttUpper) {
3314
+ super(elementRef, ganttUpper);
3315
+ this.ganttRangeClass = true;
3316
+ }
3317
+ }
3318
+ NgxGanttRangeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRangeComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
3319
+ NgxGanttRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range", host: { properties: { "class.gantt-range": "this.ganttRangeClass" } }, usesInheritance: 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", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3320
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRangeComponent, decorators: [{
3321
+ type: Component,
3322
+ args: [{ selector: 'ngx-gantt-range,gantt-range', 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" }]
3323
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3324
+ type: Inject,
3325
+ args: [GANTT_UPPER_TOKEN]
3326
+ }] }]; }, propDecorators: { ganttRangeClass: [{
3327
+ type: HostBinding,
3328
+ args: ['class.gantt-range']
3329
+ }] } });
3330
+
3331
+ class NgxGanttBaselineComponent {
3332
+ constructor(elementRef, ganttUpper) {
3333
+ this.elementRef = elementRef;
3334
+ this.ganttUpper = ganttUpper;
3335
+ this.unsubscribe$ = new Subject();
3336
+ this.ganttBaselineClass = true;
3337
+ }
3338
+ ngOnInit() {
3339
+ this.baselineItem.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3340
+ this.setPositions();
3341
+ });
3342
+ }
3343
+ setPositions() {
3344
+ const itemElement = this.elementRef.nativeElement;
3345
+ itemElement.style.left = this.baselineItem.refs.x + 'px';
3346
+ itemElement.style.bottom = '2px';
3347
+ itemElement.style.width = this.baselineItem.refs.width + 'px';
3348
+ }
3349
+ }
3350
+ NgxGanttBaselineComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBaselineComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
3351
+ NgxGanttBaselineComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttBaselineComponent, selector: "ngx-gantt-baseline,gantt-baseline", inputs: { baselineItem: "baselineItem" }, host: { properties: { "class.gantt-baseline": "this.ganttBaselineClass" } }, ngImport: i0, template: "<div #content *ngIf=\"baselineItem\" class=\"baseline-content\"></div>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3352
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBaselineComponent, decorators: [{
3353
+ type: Component,
3354
+ args: [{ selector: 'ngx-gantt-baseline,gantt-baseline', template: "<div #content *ngIf=\"baselineItem\" class=\"baseline-content\"></div>\n" }]
3355
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3356
+ type: Inject,
3357
+ args: [GANTT_UPPER_TOKEN]
3358
+ }] }]; }, propDecorators: { baselineItem: [{
3359
+ type: Input
3360
+ }], ganttBaselineClass: [{
3361
+ type: HostBinding,
3362
+ args: ['class.gantt-baseline']
3363
+ }] } });
3364
+
3365
+ class GanttMainComponent {
3366
+ constructor(ganttUpper) {
3367
+ this.ganttUpper = ganttUpper;
3368
+ this.barClick = new EventEmitter();
3369
+ this.lineClick = new EventEmitter();
3370
+ this.ganttMainClass = true;
3371
+ }
3372
+ trackBy(index, item) {
3373
+ return item.id || index;
3374
+ }
3375
+ }
3376
+ GanttMainComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
3377
+ GanttMainComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttMainComponent, selector: "gantt-main", inputs: { renderData: "renderData", flatData: "flatData", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<!-- <gantt-links-overlay [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\n<!-- items -->\n<!-- <ng-template #itemsTemplate>\n <div class=\"gantt-main-items\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items }\"></ng-template>\n </div>\n</ng-template>\n\n<ng-template #ganttItems let-items=\"items\">\n <ng-container *ngFor=\"let item of items\">\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-container *ngIf=\"item.type | isGanttCustomItem\">\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: item.origin,\n refs: item.refs,\n baseline: ganttUpper.baselineItemsMap[item.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[item.id]?.refs\n }\"\n >\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"(item.type | isGanttRangeItem) || (item.type | isGanttBarItem)\">\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 <gantt-baseline *ngIf=\"ganttUpper.baselineItemsMap[item.id]\" [baselineItem]=\"ganttUpper.baselineItemsMap[item.id]\"></gantt-baseline>\n </ng-container>\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\n<gantt-links-overlay [flatData]=\"flatData\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<div class=\"gantt-main-groups\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let data of renderData; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"data.class\" *ngIf=\"data.items\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n <div\n *ngIf=\"!data.items\"\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(data.id)\"\n >\n <ng-container *ngIf=\"data.type | isGanttCustomItem\">\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: data.origin,\n refs: data.refs,\n baseline: ganttUpper.baselineItemsMap[data.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[data.id]?.refs\n }\"\n >\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"(data.type | isGanttRangeItem) || (data.type | isGanttBarItem)\">\n <gantt-range *ngIf=\"data.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n <gantt-bar *ngIf=\"data.type | isGanttBarItem\" [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n <gantt-baseline *ngIf=\"ganttUpper.baselineItemsMap[data.id]\" [baselineItem]=\"ganttUpper.baselineItemsMap[data.id]\"></gantt-baseline>\n </ng-container>\n </div>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: ["flatData"], outputs: ["lineClick"] }, { kind: "component", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: ["barClick"] }, { kind: "component", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range" }, { kind: "component", type: NgxGanttBaselineComponent, selector: "ngx-gantt-baseline,gantt-baseline", inputs: ["baselineItem"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }, { kind: "pipe", type: IsGanttBarItemPipe, name: "isGanttBarItem" }, { kind: "pipe", type: IsGanttCustomItemPipe, name: "isGanttCustomItem" }] });
3378
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, decorators: [{
3379
+ type: Component,
3380
+ args: [{ selector: 'gantt-main', 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\n<!-- items -->\n<!-- <ng-template #itemsTemplate>\n <div class=\"gantt-main-items\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items }\"></ng-template>\n </div>\n</ng-template>\n\n<ng-template #ganttItems let-items=\"items\">\n <ng-container *ngFor=\"let item of items\">\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-container *ngIf=\"item.type | isGanttCustomItem\">\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: item.origin,\n refs: item.refs,\n baseline: ganttUpper.baselineItemsMap[item.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[item.id]?.refs\n }\"\n >\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"(item.type | isGanttRangeItem) || (item.type | isGanttBarItem)\">\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 <gantt-baseline *ngIf=\"ganttUpper.baselineItemsMap[item.id]\" [baselineItem]=\"ganttUpper.baselineItemsMap[item.id]\"></gantt-baseline>\n </ng-container>\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\n<gantt-links-overlay [flatData]=\"flatData\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<div class=\"gantt-main-groups\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let data of renderData; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"data.class\" *ngIf=\"data.items\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n <div\n *ngIf=\"!data.items\"\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(data.id)\"\n >\n <ng-container *ngIf=\"data.type | isGanttCustomItem\">\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: data.origin,\n refs: data.refs,\n baseline: ganttUpper.baselineItemsMap[data.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[data.id]?.refs\n }\"\n >\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"(data.type | isGanttRangeItem) || (data.type | isGanttBarItem)\">\n <gantt-range *ngIf=\"data.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n <gantt-bar *ngIf=\"data.type | isGanttBarItem\" [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n <gantt-baseline *ngIf=\"ganttUpper.baselineItemsMap[data.id]\" [baselineItem]=\"ganttUpper.baselineItemsMap[data.id]\"></gantt-baseline>\n </ng-container>\n </div>\n </ng-container>\n</div>\n" }]
3381
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3382
+ type: Inject,
3383
+ args: [GANTT_UPPER_TOKEN]
3384
+ }] }]; }, propDecorators: { renderData: [{
3385
+ type: Input
3386
+ }], flatData: [{
3387
+ type: Input
3388
+ }], groupHeaderTemplate: [{
3389
+ type: Input
3390
+ }], itemTemplate: [{
3391
+ type: Input
3392
+ }], barTemplate: [{
3393
+ type: Input
3394
+ }], rangeTemplate: [{
3395
+ type: Input
3396
+ }], barClick: [{
3397
+ type: Output
3398
+ }], lineClick: [{
3399
+ type: Output
3400
+ }], ganttMainClass: [{
3401
+ type: HostBinding,
3402
+ args: ['class.gantt-main-container']
3403
+ }] } });
3404
+
3405
+ class GanttCalendarHeaderComponent {
3406
+ get view() {
3407
+ return this.ganttUpper.view;
3408
+ }
3409
+ constructor(ganttUpper, ngZone, elementRef) {
3410
+ this.ganttUpper = ganttUpper;
3411
+ this.ngZone = ngZone;
3412
+ this.elementRef = elementRef;
3413
+ this.unsubscribe$ = new Subject();
3414
+ this.headerHeight = headerHeight;
3415
+ this.viewTypes = GanttViewType;
3416
+ this.className = `gantt-calendar gantt-calendar-header`;
3417
+ }
3418
+ ngOnInit() {
3419
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
3420
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
3421
+ .pipe(takeUntil(this.unsubscribe$))
3422
+ .subscribe(() => {
3423
+ if (this.ganttUpper.viewType === GanttViewType.day)
3424
+ this.setTodayPoint();
3425
+ });
3426
+ });
3427
+ }
3428
+ setTodayPoint() {
3429
+ const x = this.view.getTodayXPoint();
3430
+ const today = new GanttDate().getDate();
3431
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
3432
+ const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
3433
+ if (isNumber(x)) {
3434
+ if (rect) {
3435
+ rect.style.left = `${x - todayWidth / 2}px`;
3436
+ rect.style.top = `${headerHeight - todayHeight}px`;
3437
+ rect.innerHTML = today.toString();
3438
+ }
3439
+ }
3440
+ else {
3441
+ todayEle.style.display = 'none';
3442
+ }
3443
+ }
3444
+ trackBy(point, index) {
3445
+ return point.text || index;
3446
+ }
3447
+ }
3448
+ GanttCalendarHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
3449
+ GanttCalendarHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header", host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n</div>\n<svg [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\n class=\"primary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text\n class=\"secondary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"headerHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n</svg>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
3450
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
3451
+ type: Component,
3452
+ args: [{ selector: 'gantt-calendar-header', template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n</div>\n<svg [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\n class=\"primary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text\n class=\"secondary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"headerHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n</svg>\n" }]
3453
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3454
+ type: Inject,
3455
+ args: [GANTT_UPPER_TOKEN]
3456
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
3457
+ type: HostBinding,
3458
+ args: ['class']
3459
+ }] } });
3460
+
3461
+ const mainHeight = 5000;
3462
+ class GanttCalendarGridComponent {
3463
+ get view() {
3464
+ return this.ganttUpper.view;
3465
+ }
3466
+ constructor(ganttUpper, ngZone, elementRef) {
3467
+ this.ganttUpper = ganttUpper;
3468
+ this.ngZone = ngZone;
3469
+ this.elementRef = elementRef;
3470
+ this.unsubscribe$ = new Subject();
3471
+ this.headerHeight = headerHeight;
3472
+ this.mainHeight = mainHeight;
3473
+ this.todayBorderRadius = todayBorderRadius;
3474
+ this.viewTypes = GanttViewType;
3475
+ this.className = `gantt-calendar gantt-calendar-grid`;
3476
+ }
3477
+ setTodayPoint() {
3478
+ const x = this.view.getTodayXPoint();
3479
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
3480
+ const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
3481
+ if (isNumber(x)) {
3482
+ if (line) {
3483
+ line.style.left = `${x}px`;
3484
+ line.style.top = `0px`;
3485
+ line.style.bottom = `${-mainHeight}px`;
3486
+ }
3487
+ }
3488
+ else {
3489
+ todayEle.style.display = 'none';
3490
+ }
3491
+ }
3492
+ ngOnInit() {
3493
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
3494
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
3495
+ .pipe(takeUntil(this.unsubscribe$))
3496
+ .subscribe(() => {
3497
+ this.setTodayPoint();
3498
+ });
3499
+ });
3500
+ }
3501
+ trackBy(point, index) {
3502
+ return point.text || index;
3317
3503
  }
3318
- stopPropagation(event) {
3319
- event.stopPropagation();
3504
+ ngOnDestroy() {
3505
+ this.unsubscribe$.next();
3506
+ this.unsubscribe$.complete();
3320
3507
  }
3321
3508
  }
3322
- NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
3323
- NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", 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 }, { propertyName: "handles", predicate: ["handle"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></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", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3324
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
3509
+ GanttCalendarGridComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
3510
+ GanttCalendarGridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid", host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-grid-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight - 1\">\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n </g>\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3511
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
3325
3512
  type: Component,
3326
- args: [{ selector: 'ngx-gantt-bar,gantt-bar', providers: [GanttBarDrag], template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></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" }]
3327
- }], ctorParameters: function () { return [{ type: GanttDragContainer }, { type: GanttBarDrag }, { type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3513
+ args: [{ selector: 'gantt-calendar-grid', template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-grid-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight - 1\">\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n </g>\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n" }]
3514
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3328
3515
  type: Inject,
3329
3516
  args: [GANTT_UPPER_TOKEN]
3330
- }] }, { type: i0.NgZone }]; }, propDecorators: { barClick: [{
3331
- type: Output
3332
- }], contentElementRef: [{
3333
- type: ViewChild,
3334
- args: ['content']
3335
- }], ganttItemClass: [{
3517
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
3336
3518
  type: HostBinding,
3337
- args: ['class.gantt-bar']
3338
- }], handles: [{
3339
- type: ViewChildren,
3340
- args: ['handle']
3519
+ args: ['class']
3341
3520
  }] } });
3342
3521
 
3343
- class NgxGanttRangeComponent extends GanttItemUpper {
3344
- constructor(elementRef, ganttUpper) {
3345
- super(elementRef, ganttUpper);
3346
- this.ganttRangeClass = true;
3522
+ class GanttLoaderComponent {
3523
+ }
3524
+ GanttLoaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLoaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3525
+ GanttLoaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttLoaderComponent, selector: "gantt-loader", host: { classAttribute: "gantt-loader gantt-loader-overlay" }, ngImport: i0, template: `
3526
+ <div class="gantt-loader-wrapper">
3527
+ <div class="gantt-loader-loading">
3528
+ <span class="gantt-loader-loading-spot"></span>
3529
+ </div>
3530
+ </div>
3531
+ `, isInline: true });
3532
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLoaderComponent, decorators: [{
3533
+ type: Component,
3534
+ args: [{
3535
+ selector: 'gantt-loader',
3536
+ template: `
3537
+ <div class="gantt-loader-wrapper">
3538
+ <div class="gantt-loader-loading">
3539
+ <span class="gantt-loader-loading-spot"></span>
3540
+ </div>
3541
+ </div>
3542
+ `,
3543
+ host: {
3544
+ class: 'gantt-loader gantt-loader-overlay'
3545
+ }
3546
+ }]
3547
+ }] });
3548
+
3549
+ class GanttDragBackdropComponent {
3550
+ }
3551
+ GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3552
+ GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { classAttribute: "gantt-drag-backdrop" }, 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" });
3553
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
3554
+ type: Component,
3555
+ args: [{ selector: 'gantt-drag-backdrop', host: {
3556
+ class: 'gantt-drag-backdrop'
3557
+ }, 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" }]
3558
+ }] });
3559
+
3560
+ class NgxGanttToolbarComponent {
3561
+ constructor(ganttUpper) {
3562
+ this.ganttUpper = ganttUpper;
3563
+ this.ganttItemClass = true;
3564
+ this.ganttViewsMap = keyBy(ganttViews, 'value');
3565
+ }
3566
+ selectView(view) {
3567
+ this.ganttUpper.changeView(view);
3347
3568
  }
3348
3569
  }
3349
- NgxGanttRangeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRangeComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
3350
- NgxGanttRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range", host: { properties: { "class.gantt-range": "this.ganttRangeClass" } }, usesInheritance: 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", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3351
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRangeComponent, decorators: [{
3570
+ NgxGanttToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
3571
+ NgxGanttToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: { template: "template" }, host: { properties: { "class.gantt-toolbar": "this.ganttItemClass" } }, ngImport: i0, template: "<div class=\"toolbar-container\">\n <ng-container *ngIf=\"!template\">\n <div class=\"toolbar-views\" *ngIf=\"this.ganttUpper.toolbarOptions?.viewTypes?.length\">\n <ng-container *ngFor=\"let view of this.ganttUpper.toolbarOptions?.viewTypes\">\n <div class=\"toolbar-view\" *ngIf=\"ganttViewsMap[view]\" [class.active]=\"view === this.ganttUpper.viewType\" (click)=\"selectView(view)\">\n {{ ganttViewsMap[view].name }}\n </div>\n </ng-container>\n </div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3572
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, decorators: [{
3352
3573
  type: Component,
3353
- args: [{ selector: 'ngx-gantt-range,gantt-range', 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" }]
3354
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3574
+ args: [{ selector: 'ngx-gantt-toolbar,gantt-toolbar', template: "<div class=\"toolbar-container\">\n <ng-container *ngIf=\"!template\">\n <div class=\"toolbar-views\" *ngIf=\"this.ganttUpper.toolbarOptions?.viewTypes?.length\">\n <ng-container *ngFor=\"let view of this.ganttUpper.toolbarOptions?.viewTypes\">\n <div class=\"toolbar-view\" *ngIf=\"ganttViewsMap[view]\" [class.active]=\"view === this.ganttUpper.viewType\" (click)=\"selectView(view)\">\n {{ ganttViewsMap[view].name }}\n </div>\n </ng-container>\n </div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n</div>\n" }]
3575
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3355
3576
  type: Inject,
3356
3577
  args: [GANTT_UPPER_TOKEN]
3357
- }] }]; }, propDecorators: { ganttRangeClass: [{
3578
+ }] }]; }, propDecorators: { template: [{
3579
+ type: Input
3580
+ }], ganttItemClass: [{
3358
3581
  type: HostBinding,
3359
- args: ['class.gantt-range']
3582
+ args: ['class.gantt-toolbar']
3360
3583
  }] } });
3361
3584
 
3362
- class NgxGanttBaselineComponent {
3363
- constructor(elementRef, ganttUpper) {
3585
+ class NgxGanttRootComponent {
3586
+ get view() {
3587
+ return this.ganttUpper.view;
3588
+ }
3589
+ constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
3364
3590
  this.elementRef = elementRef;
3591
+ this.ngZone = ngZone;
3592
+ this.dom = dom;
3593
+ this.dragContainer = dragContainer;
3365
3594
  this.ganttUpper = ganttUpper;
3595
+ this.printService = printService;
3366
3596
  this.unsubscribe$ = new Subject();
3367
- this.ganttBaselineClass = true;
3597
+ this.ganttUpper.dragContainer = dragContainer;
3368
3598
  }
3369
3599
  ngOnInit() {
3370
- this.baselineItem.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3371
- this.setPositions();
3600
+ // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
3601
+ // the `onStable` will never emit any value.
3602
+ const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
3603
+ // Normally this isn't in the zone, but it can cause performance regressions for apps
3604
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
3605
+ this.ngZone.runOutsideAngular(() => {
3606
+ onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3607
+ this.dom.initialize(this.elementRef);
3608
+ if (this.printService) {
3609
+ this.printService.register(this.elementRef);
3610
+ }
3611
+ this.setupScrollClass();
3612
+ this.setupResize();
3613
+ this.setupViewScroll();
3614
+ // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
3615
+ this.elementRef.nativeElement.style.opacity = '1';
3616
+ this.ganttUpper.viewChange.pipe(startWith$1(null), takeUntil(this.unsubscribe$)).subscribe(() => {
3617
+ this.scrollToToday();
3618
+ });
3619
+ });
3372
3620
  });
3373
3621
  }
3374
- setPositions() {
3375
- const itemElement = this.elementRef.nativeElement;
3376
- itemElement.style.left = this.baselineItem.refs.x + 'px';
3377
- itemElement.style.bottom = '2px';
3378
- itemElement.style.width = this.baselineItem.refs.width + 'px';
3622
+ ngOnDestroy() {
3623
+ this.unsubscribe$.next();
3379
3624
  }
3380
- }
3381
- NgxGanttBaselineComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBaselineComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
3382
- NgxGanttBaselineComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttBaselineComponent, selector: "ngx-gantt-baseline,gantt-baseline", inputs: { baselineItem: "baselineItem" }, host: { properties: { "class.gantt-baseline": "this.ganttBaselineClass" } }, ngImport: i0, template: "<div #content *ngIf=\"baselineItem\" class=\"baseline-content\"></div>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3383
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBaselineComponent, decorators: [{
3384
- type: Component,
3385
- args: [{ selector: 'ngx-gantt-baseline,gantt-baseline', template: "<div #content *ngIf=\"baselineItem\" class=\"baseline-content\"></div>\n" }]
3386
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3387
- type: Inject,
3388
- args: [GANTT_UPPER_TOKEN]
3389
- }] }]; }, propDecorators: { baselineItem: [{
3390
- type: Input
3391
- }], ganttBaselineClass: [{
3392
- type: HostBinding,
3393
- args: ['class.gantt-baseline']
3394
- }] } });
3395
-
3396
- class GanttMainComponent {
3397
- constructor(ganttUpper) {
3398
- this.ganttUpper = ganttUpper;
3399
- this.barClick = new EventEmitter();
3400
- this.lineClick = new EventEmitter();
3401
- this.ganttMainClass = true;
3625
+ setupViewScroll() {
3626
+ if (this.ganttUpper.disabledLoadOnScroll) {
3627
+ return;
3628
+ }
3629
+ this.dom
3630
+ .getViewerScroll(passiveListenerOptions)
3631
+ .pipe(takeUntil(this.unsubscribe$))
3632
+ .subscribe((event) => {
3633
+ if (event.direction === ScrollDirection.LEFT) {
3634
+ const dates = this.view.addStartDate();
3635
+ if (dates) {
3636
+ event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
3637
+ if (this.ganttUpper.loadOnScroll.observers) {
3638
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
3639
+ }
3640
+ }
3641
+ }
3642
+ if (event.direction === ScrollDirection.RIGHT) {
3643
+ const dates = this.view.addEndDate();
3644
+ if (dates && this.ganttUpper.loadOnScroll.observers) {
3645
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
3646
+ }
3647
+ }
3648
+ });
3402
3649
  }
3403
- trackBy(index, item) {
3404
- return item.id || index;
3650
+ setupResize() {
3651
+ this.dom
3652
+ .getResize()
3653
+ .pipe(takeUntil(this.unsubscribe$))
3654
+ .subscribe(() => {
3655
+ this.setupScrollClass();
3656
+ });
3657
+ }
3658
+ setupScrollClass() {
3659
+ const mainContainer = this.dom.mainContainer;
3660
+ const height = mainContainer.offsetHeight;
3661
+ const scrollHeight = mainContainer.scrollHeight;
3662
+ if (scrollHeight > height) {
3663
+ this.elementRef.nativeElement.className = 'gantt gantt-scroll';
3664
+ }
3665
+ else {
3666
+ this.elementRef.nativeElement.className = 'gantt';
3667
+ }
3668
+ }
3669
+ scrollToToday() {
3670
+ const x = this.view.getTodayXPoint();
3671
+ this.dom.scrollMainContainer(x);
3672
+ }
3673
+ scrollToDate(date) {
3674
+ let x;
3675
+ if (typeof date === 'number') {
3676
+ x = this.view.getXPointByDate(new GanttDate(date));
3677
+ }
3678
+ else {
3679
+ x = this.view.getXPointByDate(date);
3680
+ }
3681
+ this.dom.scrollMainContainer(x);
3405
3682
  }
3406
3683
  }
3407
- GanttMainComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
3408
- GanttMainComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttMainComponent, selector: "gantt-main", inputs: { renderData: "renderData", flatData: "flatData", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<!-- <gantt-links-overlay [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\n<!-- items -->\n<!-- <ng-template #itemsTemplate>\n <div class=\"gantt-main-items\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items }\"></ng-template>\n </div>\n</ng-template>\n\n<ng-template #ganttItems let-items=\"items\">\n <ng-container *ngFor=\"let item of items\">\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-container *ngIf=\"item.type | isGanttCustomItem\">\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: item.origin,\n refs: item.refs,\n baseline: ganttUpper.baselineItemsMap[item.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[item.id]?.refs\n }\"\n >\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"(item.type | isGanttRangeItem) || (item.type | isGanttBarItem)\">\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 <gantt-baseline *ngIf=\"ganttUpper.baselineItemsMap[item.id]\" [baselineItem]=\"ganttUpper.baselineItemsMap[item.id]\"></gantt-baseline>\n </ng-container>\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\n<gantt-links-overlay [flatData]=\"flatData\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<div class=\"gantt-main-groups\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let data of renderData; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"data.class\" *ngIf=\"data.items\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n <div\n *ngIf=\"!data.items\"\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(data.id)\"\n >\n <ng-container *ngIf=\"data.type | isGanttCustomItem\">\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: data.origin,\n refs: data.refs,\n baseline: ganttUpper.baselineItemsMap[data.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[data.id]?.refs\n }\"\n >\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"(data.type | isGanttRangeItem) || (data.type | isGanttBarItem)\">\n <gantt-range *ngIf=\"data.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n <gantt-bar *ngIf=\"data.type | isGanttBarItem\" [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n <gantt-baseline *ngIf=\"ganttUpper.baselineItemsMap[data.id]\" [baselineItem]=\"ganttUpper.baselineItemsMap[data.id]\"></gantt-baseline>\n </ng-container>\n </div>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: ["flatData"], outputs: ["lineClick"] }, { kind: "component", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: ["barClick"] }, { kind: "component", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range" }, { kind: "component", type: NgxGanttBaselineComponent, selector: "ngx-gantt-baseline,gantt-baseline", inputs: ["baselineItem"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }, { kind: "pipe", type: IsGanttBarItemPipe, name: "isGanttBarItem" }, { kind: "pipe", type: IsGanttCustomItemPipe, name: "isGanttCustomItem" }] });
3409
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, decorators: [{
3684
+ NgxGanttRootComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", 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 });
3685
+ NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { classAttribute: "gantt" }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], viewQueries: [{ propertyName: "backdrop", first: true, predicate: GanttDragBackdropComponent, descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" *ngIf=\"sideTemplate\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\" cdkScrollable>\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\" *ngIf=\"mainTemplate\">\n <gantt-calendar-header></gantt-calendar-header>\n <gantt-calendar-grid></gantt-calendar-grid>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n<ng-content></ng-content>\n<gantt-toolbar *ngIf=\"ganttUpper.showToolbar || ganttUpper.toolbarTemplate\" [template]=\"ganttUpper.toolbarTemplate\"> </gantt-toolbar>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i3.CdkScrollable, selector: "[cdk-scrollable], [cdkScrollable]" }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: ["template"] }] });
3686
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
3410
3687
  type: Component,
3411
- args: [{ selector: 'gantt-main', 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\n<!-- items -->\n<!-- <ng-template #itemsTemplate>\n <div class=\"gantt-main-items\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items }\"></ng-template>\n </div>\n</ng-template>\n\n<ng-template #ganttItems let-items=\"items\">\n <ng-container *ngFor=\"let item of items\">\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-container *ngIf=\"item.type | isGanttCustomItem\">\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: item.origin,\n refs: item.refs,\n baseline: ganttUpper.baselineItemsMap[item.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[item.id]?.refs\n }\"\n >\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"(item.type | isGanttRangeItem) || (item.type | isGanttBarItem)\">\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 <gantt-baseline *ngIf=\"ganttUpper.baselineItemsMap[item.id]\" [baselineItem]=\"ganttUpper.baselineItemsMap[item.id]\"></gantt-baseline>\n </ng-container>\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\n<gantt-links-overlay [flatData]=\"flatData\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<div class=\"gantt-main-groups\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let data of renderData; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"data.class\" *ngIf=\"data.items\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: data }\"></ng-template>\n </div>\n <div\n *ngIf=\"!data.items\"\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(data.id)\"\n >\n <ng-container *ngIf=\"data.type | isGanttCustomItem\">\n <ng-template\n [ngTemplateOutlet]=\"itemTemplate\"\n [ngTemplateOutletContext]=\"{\n item: data.origin,\n refs: data.refs,\n baseline: ganttUpper.baselineItemsMap[data.id]?.origin,\n baselineRefs: ganttUpper.baselineItemsMap[data.id]?.refs\n }\"\n >\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"(data.type | isGanttRangeItem) || (data.type | isGanttBarItem)\">\n <gantt-range *ngIf=\"data.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"data\"></gantt-range>\n <gantt-bar *ngIf=\"data.type | isGanttBarItem\" [item]=\"data\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n <gantt-baseline *ngIf=\"ganttUpper.baselineItemsMap[data.id]\" [baselineItem]=\"ganttUpper.baselineItemsMap[data.id]\"></gantt-baseline>\n </ng-container>\n </div>\n </ng-container>\n</div>\n" }]
3412
- }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3688
+ args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
3689
+ class: 'gantt'
3690
+ }, template: "<div class=\"gantt-side\" *ngIf=\"sideTemplate\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\" cdkScrollable>\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\" *ngIf=\"mainTemplate\">\n <gantt-calendar-header></gantt-calendar-header>\n <gantt-calendar-grid></gantt-calendar-grid>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n<ng-content></ng-content>\n<gantt-toolbar *ngIf=\"ganttUpper.showToolbar || ganttUpper.toolbarTemplate\" [template]=\"ganttUpper.toolbarTemplate\"> </gantt-toolbar>\n" }]
3691
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
3413
3692
  type: Inject,
3414
3693
  args: [GANTT_UPPER_TOKEN]
3415
- }] }]; }, propDecorators: { renderData: [{
3416
- type: Input
3417
- }], flatData: [{
3418
- type: Input
3419
- }], groupHeaderTemplate: [{
3420
- type: Input
3421
- }], itemTemplate: [{
3422
- type: Input
3423
- }], barTemplate: [{
3424
- type: Input
3425
- }], rangeTemplate: [{
3694
+ }] }, { type: GanttPrintService, decorators: [{
3695
+ type: Optional
3696
+ }] }]; }, propDecorators: { sideWidth: [{
3426
3697
  type: Input
3427
- }], barClick: [{
3428
- type: Output
3429
- }], lineClick: [{
3430
- type: Output
3431
- }], ganttMainClass: [{
3432
- type: HostBinding,
3433
- args: ['class.gantt-main-container']
3698
+ }], sideTemplate: [{
3699
+ type: ContentChild,
3700
+ args: ['sideTemplate', { static: true }]
3701
+ }], mainTemplate: [{
3702
+ type: ContentChild,
3703
+ args: ['mainTemplate', { static: true }]
3704
+ }], backdrop: [{
3705
+ type: ViewChild,
3706
+ args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
3434
3707
  }] } });
3435
3708
 
3436
3709
  class NgxGanttComponent extends GanttUpper {
3710
+ set loading(loading) {
3711
+ if (loading) {
3712
+ if (this.loadingDelay > 0) {
3713
+ this.loadingTimer = setTimeout(() => {
3714
+ this._loading = loading;
3715
+ this.cdr.markForCheck();
3716
+ }, this.loadingDelay);
3717
+ }
3718
+ else {
3719
+ this._loading = loading;
3720
+ }
3721
+ }
3722
+ else {
3723
+ clearTimeout(this.loadingTimer);
3724
+ this._loading = loading;
3725
+ }
3726
+ }
3727
+ get loading() {
3728
+ return this._loading;
3729
+ }
3437
3730
  constructor(elementRef, cdr, ngZone, printService, config) {
3438
3731
  super(elementRef, cdr, ngZone, config);
3439
3732
  this.printService = printService;
3440
3733
  this.maxLevel = 2;
3734
+ this.loadingDelay = 0;
3441
3735
  this.linkDragStarted = new EventEmitter();
3442
3736
  this.linkDragEnded = new EventEmitter();
3443
3737
  this.lineClick = new EventEmitter();
3444
3738
  this.selectedChange = new EventEmitter();
3445
3739
  this.flatData = [];
3446
3740
  this.renderData = [];
3741
+ this._loading = false;
3447
3742
  this.computeAllRefs = false;
3448
3743
  }
3449
3744
  ngOnInit() {
@@ -3602,7 +3897,7 @@ class NgxGanttComponent extends GanttUpper {
3602
3897
  }
3603
3898
  }
3604
3899
  NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GanttPrintService, optional: true }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
3605
- NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
3900
+ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable", loading: "loading", loadingDelay: "loadingDelay" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
3606
3901
  {
3607
3902
  provide: GANTT_UPPER_TOKEN,
3608
3903
  useExisting: NgxGanttComponent
@@ -3611,7 +3906,7 @@ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
3611
3906
  provide: GANTT_ABSTRACT_TOKEN,
3612
3907
  useExisting: forwardRef(() => NgxGanttComponent)
3613
3908
  }
3614
- ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], viewQueries: [{ propertyName: "ganttRoot", first: true, predicate: ["ganttRoot"], descendants: true }, { propertyName: "virtualScroll", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n", dependencies: [{ kind: "directive", type: i2$1.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i2$1.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i2$1.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: GanttTableHeaderComponent, selector: "gantt-table-header", inputs: ["columns"] }, { kind: "component", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: ["renderData", "flatData", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate", "draggable", "dropEnterPredicate"], outputs: ["dragDropped", "itemClick"] }, { kind: "component", type: GanttMainComponent, selector: "gantt-main", inputs: ["renderData", "flatData", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3909
+ ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], viewQueries: [{ propertyName: "ganttRoot", first: true, predicate: ["ganttRoot"], descendants: true }, { propertyName: "virtualScroll", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n <gantt-loader *ngIf=\"loading\"></gantt-loader>\n\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\" [style.width.px]=\"tableHeader.tableWidth + 1\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (dragStarted)=\"table.dragStarted.emit($event)\"\n (dragEnded)=\"table.dragEnded.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i3.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i3.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: GanttTableHeaderComponent, selector: "gantt-table-header", inputs: ["columns"] }, { kind: "component", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: ["renderData", "flatData", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate", "draggable", "dropEnterPredicate"], outputs: ["dragDropped", "dragStarted", "dragEnded", "itemClick"] }, { kind: "component", type: GanttMainComponent, selector: "gantt-main", inputs: ["renderData", "flatData", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttLoaderComponent, selector: "gantt-loader" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3615
3910
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttComponent, decorators: [{
3616
3911
  type: Component,
3617
3912
  args: [{ selector: 'ngx-gantt', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
@@ -3623,7 +3918,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3623
3918
  provide: GANTT_ABSTRACT_TOKEN,
3624
3919
  useExisting: forwardRef(() => NgxGanttComponent)
3625
3920
  }
3626
- ], template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n" }]
3921
+ ], template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n <gantt-loader *ngIf=\"loading\"></gantt-loader>\n\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\" [style.width.px]=\"tableHeader.tableWidth + 1\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (dragStarted)=\"table.dragStarted.emit($event)\"\n (dragEnded)=\"table.dragEnded.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n" }]
3627
3922
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: GanttPrintService, decorators: [{
3628
3923
  type: Optional
3629
3924
  }] }, { type: undefined, decorators: [{
@@ -3637,6 +3932,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3637
3932
  type: Input
3638
3933
  }], linkable: [{
3639
3934
  type: Input
3935
+ }], loading: [{
3936
+ type: Input
3937
+ }], loadingDelay: [{
3938
+ type: Input
3640
3939
  }], linkDragStarted: [{
3641
3940
  type: Output
3642
3941
  }], linkDragEnded: [{
@@ -3676,6 +3975,7 @@ NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
3676
3975
  GanttCalendarHeaderComponent,
3677
3976
  GanttCalendarGridComponent,
3678
3977
  GanttLinksComponent,
3978
+ GanttLoaderComponent,
3679
3979
  NgxGanttBarComponent,
3680
3980
  GanttIconComponent,
3681
3981
  GanttDragBackdropComponent,
@@ -3726,6 +4026,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3726
4026
  GanttCalendarHeaderComponent,
3727
4027
  GanttCalendarGridComponent,
3728
4028
  GanttLinksComponent,
4029
+ GanttLoaderComponent,
3729
4030
  NgxGanttBarComponent,
3730
4031
  GanttIconComponent,
3731
4032
  GanttDragBackdropComponent,
@@ -3755,5 +4056,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3755
4056
  * Generated bundle index. Do not edit.
3756
4057
  */
3757
4058
 
3758
- export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttBaselineItemInternal, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLinkLineType, GanttLinkType, GanttLoadOnScrollEvent, GanttPrintService, GanttSelectedEvent, GanttTableDragDroppedEvent, GanttTableDragEnterPredicateContext, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, LinkColors, NgxGanttBarComponent, NgxGanttBaselineComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, NgxGanttToolbarComponent, defaultConfig, ganttViews, primaryDatePointTop, registerView, secondaryDatePointTop };
4059
+ export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttBaselineItemInternal, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLinkLineType, GanttLinkType, GanttLoadOnScrollEvent, GanttLoaderComponent, GanttPrintService, GanttSelectedEvent, GanttTableDragDroppedEvent, GanttTableDragEndedEvent, GanttTableDragEnterPredicateContext, GanttTableDragStartedEvent, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, LinkColors, NgxGanttBarComponent, NgxGanttBaselineComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, NgxGanttToolbarComponent, defaultConfig, ganttViews, primaryDatePointTop, registerView, secondaryDatePointTop };
3759
4060
  //# sourceMappingURL=worktile-gantt.mjs.map