@worktile/gantt 15.1.0-next.5 → 15.1.0-next.7

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.
@@ -1,9 +1,9 @@
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';
@@ -1049,16 +1049,17 @@ class GanttUpper {
1049
1049
  this.ngZone.runOutsideAngular(() => {
1050
1050
  onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1051
1051
  this.element.style.opacity = '1';
1052
+ const disabledLoadOnScroll = this.disabledLoadOnScroll;
1052
1053
  this.dragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1054
+ this.disabledLoadOnScroll = true;
1053
1055
  this.dragStarted.emit(event);
1054
1056
  });
1055
1057
  this.dragContainer.dragMoved.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1056
1058
  this.dragMoved.emit(event);
1057
1059
  });
1058
1060
  this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1061
+ this.disabledLoadOnScroll = disabledLoadOnScroll;
1059
1062
  this.dragEnded.emit(event);
1060
- // this.computeRefs();
1061
- // this.detectChanges();
1062
1063
  });
1063
1064
  });
1064
1065
  });
@@ -1732,7 +1733,7 @@ class GanttTableBodyComponent {
1732
1733
  this.ganttTableDragging = false;
1733
1734
  this.hasExpandIcon = false;
1734
1735
  // 缓存 Element 和 DragRef 的关系,方便在 Item 拖动时查找
1735
- this.itemDragRefMap = new Map();
1736
+ this.itemDragsMap = new Map();
1736
1737
  this.itemDragMoved = new Subject();
1737
1738
  this.destroy$ = new Subject();
1738
1739
  }
@@ -1754,17 +1755,17 @@ class GanttTableBodyComponent {
1754
1755
  this.cdkDrags.changes
1755
1756
  .pipe(startWith(this.cdkDrags), takeUntil$1(this.destroy$))
1756
1757
  .subscribe((drags) => {
1757
- this.itemDragRefMap.clear();
1758
+ this.itemDragsMap.clear();
1758
1759
  drags.forEach((drag) => {
1759
1760
  if (drag.data) {
1760
1761
  // cdkDrag 变化时,缓存 Element 与 DragRef 的关系,方便 Drag Move 时查找
1761
- this.itemDragRefMap.set(drag.element.nativeElement, drag);
1762
+ this.itemDragsMap.set(drag.element.nativeElement, drag);
1762
1763
  }
1763
1764
  });
1764
1765
  });
1765
1766
  this.itemDragMoved
1766
- .pipe(debounceTime(30),
1767
- // debounce 可能会导致拖动结束后仍然执行 moved ,所以通过判断 dragging 状态来过滤无效 moved
1767
+ .pipe(auditTime(30),
1768
+ // auditTime 可能会导致拖动结束后仍然执行 moved ,所以通过判断 dragging 状态来过滤无效 moved
1768
1769
  filter((event) => event.source._dragRef.isDragging()), takeUntil$1(this.destroy$))
1769
1770
  .subscribe((event) => {
1770
1771
  this.onItemDragMoved(event);
@@ -1804,12 +1805,12 @@ class GanttTableBodyComponent {
1804
1805
  }
1805
1806
  // 缓存放置目标Id 并计算鼠标相对应的位置
1806
1807
  this.itemDropTarget = {
1807
- id: this.itemDragRefMap.get(targetElement)?.data.id,
1808
+ id: this.itemDragsMap.get(targetElement)?.data.id,
1808
1809
  position: this.getTargetPosition(targetElement, event)
1809
1810
  };
1810
1811
  // 执行外部传入的 dropEnterPredicate 判断是否允许拖入目标项
1811
1812
  if (this.dropEnterPredicate) {
1812
- const targetDragRef = this.itemDragRefMap.get(targetElement);
1813
+ const targetDragRef = this.itemDragsMap.get(targetElement);
1813
1814
  if (this.dropEnterPredicate({
1814
1815
  source: event.source.data.origin,
1815
1816
  target: targetDragRef.data.origin,
@@ -1832,26 +1833,29 @@ class GanttTableBodyComponent {
1832
1833
  if (!this.itemDropTarget) {
1833
1834
  return;
1834
1835
  }
1835
- const targetDragRef = this.cdkDrags.find((item) => item.data?.id === this.itemDropTarget.id);
1836
1836
  const sourceItem = event.item.data;
1837
+ const sourceParent = this.getParentByItem(sourceItem);
1838
+ const sourceChildren = this.getExpandChildrenByDrag(event.item);
1839
+ const targetDragRef = this.cdkDrags.find((item) => item.data?.id === this.itemDropTarget.id);
1837
1840
  const targetItem = targetDragRef?.data;
1838
- this.removeItem(sourceItem);
1841
+ const targetParent = this.getParentByItem(targetItem);
1842
+ this.removeItem(sourceItem, sourceChildren);
1839
1843
  switch (this.itemDropTarget.position) {
1840
1844
  case 'before':
1841
1845
  case 'after':
1842
- this.insertItem(targetItem, sourceItem, this.itemDropTarget.position);
1846
+ this.insertItem(targetItem, sourceItem, sourceChildren, this.itemDropTarget.position);
1843
1847
  sourceItem.updateLevel(targetItem.level);
1844
1848
  break;
1845
1849
  case 'inside':
1846
- this.insertChildrenItem(targetItem, sourceItem);
1850
+ this.insertChildrenItem(targetItem, sourceItem, sourceChildren);
1847
1851
  sourceItem.updateLevel(targetItem.level + 1);
1848
1852
  break;
1849
1853
  }
1850
1854
  this.dragDropped.emit({
1851
1855
  source: sourceItem.origin,
1852
- sourceParent: this.getParentByItem(sourceItem)?.origin,
1856
+ sourceParent: sourceParent?.origin,
1853
1857
  target: targetItem.origin,
1854
- targetParent: this.getParentByItem(targetItem)?.origin,
1858
+ targetParent: targetParent?.origin,
1855
1859
  dropPosition: this.itemDropTarget.position
1856
1860
  });
1857
1861
  this.cleanupDragArtifacts(true);
@@ -1863,14 +1867,14 @@ class GanttTableBodyComponent {
1863
1867
  this.destroy$.next();
1864
1868
  this.destroy$.complete();
1865
1869
  }
1866
- removeItem(item) {
1867
- this.renderData.splice(this.renderData.indexOf(item), 1);
1868
- this.flatData.splice(this.flatData.indexOf(item), 1);
1870
+ removeItem(item, children) {
1871
+ this.renderData.splice(this.renderData.indexOf(item), 1 + children.length);
1872
+ this.flatData.splice(this.flatData.indexOf(item), 1 + children.length);
1869
1873
  }
1870
- insertItem(target, inserted, position) {
1874
+ insertItem(target, inserted, children, position) {
1871
1875
  if (position === 'before') {
1872
- this.renderData.splice(this.renderData.indexOf(target), 0, inserted);
1873
- this.flatData.splice(this.flatData.indexOf(target), 0, inserted);
1876
+ this.renderData.splice(this.renderData.indexOf(target), 0, inserted, ...children);
1877
+ this.flatData.splice(this.flatData.indexOf(target), 0, inserted, ...children);
1874
1878
  }
1875
1879
  else {
1876
1880
  const dragRef = this.cdkDrags.find((drag) => drag.data === target);
@@ -1879,14 +1883,14 @@ class GanttTableBodyComponent {
1879
1883
  if (target.expanded) {
1880
1884
  childrenCount = this.getChildrenElementsByElement(dragRef.element.nativeElement)?.length || 0;
1881
1885
  }
1882
- this.renderData.splice(this.renderData.indexOf(target) + 1 + childrenCount, 0, inserted);
1883
- this.flatData.splice(this.flatData.indexOf(target) + 1 + childrenCount, 0, inserted);
1886
+ this.renderData.splice(this.renderData.indexOf(target) + 1 + childrenCount, 0, inserted, ...children);
1887
+ this.flatData.splice(this.flatData.indexOf(target) + 1 + childrenCount, 0, inserted, ...children);
1884
1888
  }
1885
1889
  }
1886
- insertChildrenItem(target, inserted) {
1890
+ insertChildrenItem(target, inserted, children) {
1887
1891
  if (target.expanded) {
1888
- this.renderData.splice(this.renderData.indexOf(target) + target.children.length + 1, 0, inserted);
1889
- this.flatData.splice(this.flatData.indexOf(target) + target.children.length + 1, 0, inserted);
1892
+ this.renderData.splice(this.renderData.indexOf(target) + target.children.length + 1, 0, inserted, ...children);
1893
+ this.flatData.splice(this.flatData.indexOf(target) + target.children.length + 1, 0, inserted, ...children);
1890
1894
  }
1891
1895
  target.children.push(inserted);
1892
1896
  }
@@ -1895,17 +1899,26 @@ class GanttTableBodyComponent {
1895
1899
  return n.children?.includes(item);
1896
1900
  });
1897
1901
  }
1902
+ getExpandChildrenByDrag(dragRef) {
1903
+ if (!dragRef.data.expanded) {
1904
+ return [];
1905
+ }
1906
+ else {
1907
+ const childrenElements = this.getChildrenElementsByElement(dragRef.element.nativeElement);
1908
+ return childrenElements.map((element) => this.itemDragsMap.get(element).data);
1909
+ }
1910
+ }
1898
1911
  getChildrenElementsByElement(dragElement) {
1899
1912
  // 通过循环持续查找 next element,如果 element 的 level 小于当前 item 的 level,则为它的 children
1900
1913
  const children = [];
1901
- const dragRef = this.itemDragRefMap.get(dragElement);
1914
+ const dragRef = this.itemDragsMap.get(dragElement);
1902
1915
  // 如果当前的 Drag 正在拖拽,会创建 PlaceholderElement 占位,所以以 PlaceholderElement 向下查找
1903
1916
  let nextElement = (dragRef.getPlaceholderElement() || dragElement).nextElementSibling;
1904
- let nextDragRef = this.itemDragRefMap.get(nextElement);
1917
+ let nextDragRef = this.itemDragsMap.get(nextElement);
1905
1918
  while (nextDragRef && nextDragRef.data.level > dragRef.data.level) {
1906
1919
  children.push(nextElement);
1907
1920
  nextElement = nextElement.nextElementSibling;
1908
- nextDragRef = this.itemDragRefMap.get(nextElement);
1921
+ nextDragRef = this.itemDragsMap.get(nextElement);
1909
1922
  }
1910
1923
  return children;
1911
1924
  }
@@ -1932,18 +1945,18 @@ class GanttTableBodyComponent {
1932
1945
  cleanupDragArtifacts(dropped = false) {
1933
1946
  if (dropped) {
1934
1947
  this.itemDropTarget = null;
1948
+ this.document.querySelectorAll('.drag-item-hide').forEach((element) => element.classList.remove('drag-item-hide'));
1935
1949
  }
1936
1950
  this.document.querySelectorAll('.drop-position-before').forEach((element) => element.classList.remove('drop-position-before'));
1937
1951
  this.document.querySelectorAll('.drop-position-after').forEach((element) => element.classList.remove('drop-position-after'));
1938
1952
  this.document.querySelectorAll('.drop-position-inside').forEach((element) => element.classList.remove('drop-position-inside'));
1939
- this.document.querySelectorAll('.drag-item-hide').forEach((element) => element.classList.remove('drop-item-hide'));
1940
1953
  }
1941
1954
  }
1942
1955
  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 });
1943
- 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 [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 && 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" }] });
1956
+ 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 [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" }] });
1944
1957
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableBodyComponent, decorators: [{
1945
1958
  type: Component,
1946
- 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 && 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" }]
1959
+ 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" }]
1947
1960
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1948
1961
  type: Inject,
1949
1962
  args: [GANTT_ABSTRACT_TOKEN]
@@ -2273,7 +2286,7 @@ class GanttLinksComponent {
2273
2286
  this.elementRef.nativeElement.style.visibility = 'hidden';
2274
2287
  });
2275
2288
  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)))
2276
- .pipe(skip(1), debounceTime$1(0), takeUntil(this.unsubscribe$))
2289
+ .pipe(skip(1), debounceTime(0), takeUntil(this.unsubscribe$))
2277
2290
  .subscribe(() => {
2278
2291
  this.elementRef.nativeElement.style.visibility = 'visible';
2279
2292
  this.buildLinks();
@@ -2460,6 +2473,41 @@ function normalizePassiveListenerOptions(options) {
2460
2473
  /** Options used to bind passive event listeners. */
2461
2474
  const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
2462
2475
 
2476
+ /**
2477
+ * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
2478
+ * viewport. The value comes from trying it out manually until it feels right.
2479
+ */
2480
+ const SCROLL_PROXIMITY_THRESHOLD = 0.05;
2481
+ /**
2482
+ * Gets whether the horizontal auto-scroll direction of a node.
2483
+ * @param clientRect Dimensions of the node.
2484
+ * @param pointerX Position of the user's pointer along the x axis.
2485
+ */
2486
+ function getHorizontalScrollDirection(clientRect, pointerX) {
2487
+ const { left, right, width } = clientRect;
2488
+ const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
2489
+ if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
2490
+ return 1 /* AutoScrollHorizontalDirection.LEFT */;
2491
+ }
2492
+ else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
2493
+ return 2 /* AutoScrollHorizontalDirection.RIGHT */;
2494
+ }
2495
+ return 0 /* AutoScrollHorizontalDirection.NONE */;
2496
+ }
2497
+ /**
2498
+ * Checks whether the pointer coordinates are close to a ClientRect.
2499
+ * @param rect ClientRect to check against.
2500
+ * @param threshold Threshold around the ClientRect.
2501
+ * @param pointerX Coordinates along the X axis.
2502
+ * @param pointerY Coordinates along the Y axis.
2503
+ */
2504
+ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
2505
+ const { top, right, bottom, left, width, height } = rect;
2506
+ const xThreshold = width * threshold;
2507
+ const yThreshold = height * threshold;
2508
+ return pointerY > top - yThreshold && pointerY < bottom + yThreshold && pointerX > left - xThreshold && pointerX < right + xThreshold;
2509
+ }
2510
+
2463
2511
  const scrollThreshold = 50;
2464
2512
  var ScrollDirection;
2465
2513
  (function (ScrollDirection) {
@@ -2543,7 +2591,7 @@ class GanttDomService {
2543
2591
  .subscribe(subscriber)));
2544
2592
  }
2545
2593
  getResize() {
2546
- return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime(150));
2594
+ return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime$1(150));
2547
2595
  }
2548
2596
  scrollMainContainer(left) {
2549
2597
  if (isNumber(left)) {
@@ -2567,452 +2615,191 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2567
2615
  args: [PLATFORM_ID]
2568
2616
  }] }]; } });
2569
2617
 
2570
- class GanttDragBackdropComponent {
2618
+ /**
2619
+ * Proximity, as a ratio to width/height, at which a
2620
+ * dragged item will affect the drop container.
2621
+ */
2622
+ const DROP_PROXIMITY_THRESHOLD = 0.05;
2623
+ const dragMinWidth = 10;
2624
+ const autoScrollStep = 5;
2625
+ const activeClass = 'gantt-bar-active';
2626
+ const dropActiveClass = 'gantt-bar-drop-active';
2627
+ const singleDropActiveClass = 'gantt-bar-single-drop-active';
2628
+ function createSvgElement(qualifiedName, className) {
2629
+ const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2630
+ element.classList.add(className);
2631
+ return element;
2571
2632
  }
2572
- GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2573
- 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" });
2574
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
2575
- type: Component,
2576
- args: [{ selector: 'gantt-drag-backdrop', host: {
2577
- class: 'gantt-drag-backdrop'
2578
- }, 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" }]
2579
- }] });
2580
-
2581
- class GanttCalendarHeaderComponent {
2582
- get view() {
2583
- return this.ganttUpper.view;
2633
+ class GanttBarDrag {
2634
+ get dragDisabled() {
2635
+ return !this.item.draggable || !this.ganttUpper.draggable;
2584
2636
  }
2585
- constructor(ganttUpper, ngZone, elementRef) {
2586
- this.ganttUpper = ganttUpper;
2587
- this.ngZone = ngZone;
2588
- this.elementRef = elementRef;
2589
- this.unsubscribe$ = new Subject();
2590
- this.headerHeight = headerHeight;
2591
- this.viewTypes = GanttViewType;
2592
- this.className = `gantt-calendar gantt-calendar-header`;
2637
+ get linkDragDisabled() {
2638
+ return !this.item.linkable || !this.ganttUpper.linkable;
2593
2639
  }
2594
- ngOnInit() {
2595
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2596
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2597
- .pipe(takeUntil(this.unsubscribe$))
2640
+ constructor(dragDrop, dom, dragContainer, _ngZone) {
2641
+ this.dragDrop = dragDrop;
2642
+ this.dom = dom;
2643
+ this.dragContainer = dragContainer;
2644
+ this._ngZone = _ngZone;
2645
+ this.dragRefs = [];
2646
+ this.destroy$ = new Subject();
2647
+ /** Used to signal to the current auto-scroll sequence when to stop. */
2648
+ this.stopScrollTimers$ = new Subject();
2649
+ /** move distance when drag bar */
2650
+ this.barDragMoveDistance = 0;
2651
+ /** move distance when drag bar handle */
2652
+ this.barHandleDragMoveDistance = 0;
2653
+ /** scrolling state when drag */
2654
+ this.dragScrolling = false;
2655
+ /** dragScrollDistance */
2656
+ this.dragScrollDistance = 0;
2657
+ /** Horizontal direction in which the list is currently scrolling. */
2658
+ this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
2659
+ this.startScrollInterval = () => {
2660
+ this.stopScrolling();
2661
+ interval(0, animationFrameScheduler)
2662
+ .pipe(takeUntil(this.stopScrollTimers$))
2598
2663
  .subscribe(() => {
2599
- if (this.ganttUpper.viewType === GanttViewType.day)
2600
- this.setTodayPoint();
2664
+ const node = this.dom.mainContainer;
2665
+ const scrollStep = autoScrollStep;
2666
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2667
+ node.scrollBy(-scrollStep, 0);
2668
+ }
2669
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2670
+ node.scrollBy(scrollStep, 0);
2671
+ }
2601
2672
  });
2602
- });
2603
- }
2604
- setTodayPoint() {
2605
- const x = this.view.getTodayXPoint();
2606
- const today = new GanttDate().getDate();
2607
- const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
2608
- const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
2609
- if (isNumber(x)) {
2610
- if (rect) {
2611
- rect.style.left = `${x - todayWidth / 2}px`;
2612
- rect.style.top = `${headerHeight - todayHeight}px`;
2613
- rect.innerHTML = today.toString();
2614
- }
2615
- }
2616
- else {
2617
- todayEle.style.display = 'none';
2618
- }
2619
- }
2620
- trackBy(point, index) {
2621
- return point.text || index;
2673
+ };
2622
2674
  }
2623
- }
2624
- 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 });
2625
- 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"] }] });
2626
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
2627
- type: Component,
2628
- 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" }]
2629
- }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2630
- type: Inject,
2631
- args: [GANTT_UPPER_TOKEN]
2632
- }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
2633
- type: HostBinding,
2634
- args: ['class']
2635
- }] } });
2636
-
2637
- const mainHeight = 5000;
2638
- class GanttCalendarGridComponent {
2639
- get view() {
2640
- return this.ganttUpper.view;
2675
+ createDragRef(element) {
2676
+ const dragRef = this.dragDrop.createDrag(element);
2677
+ return dragRef;
2641
2678
  }
2642
- constructor(ganttUpper, ngZone, elementRef) {
2643
- this.ganttUpper = ganttUpper;
2644
- this.ngZone = ngZone;
2645
- this.elementRef = elementRef;
2646
- this.unsubscribe$ = new Subject();
2647
- this.headerHeight = headerHeight;
2648
- this.mainHeight = mainHeight;
2649
- this.todayBorderRadius = todayBorderRadius;
2650
- this.viewTypes = GanttViewType;
2651
- this.className = `gantt-calendar gantt-calendar-grid`;
2679
+ createDragScrollEvent(dragRef) {
2680
+ return fromEvent(this.dom.mainContainer, 'scroll', passiveListenerOptions).pipe(takeUntil(dragRef.ended));
2652
2681
  }
2653
- setTodayPoint() {
2654
- const x = this.view.getTodayXPoint();
2655
- const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
2656
- const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
2657
- if (isNumber(x)) {
2658
- if (line) {
2659
- line.style.left = `${x}px`;
2660
- line.style.top = `0px`;
2661
- line.style.bottom = `${-mainHeight}px`;
2682
+ createMouseEvents() {
2683
+ const dropClass = this.ganttUpper.config.linkOptions?.dependencyTypes?.length === 1 &&
2684
+ this.ganttUpper.config.linkOptions?.dependencyTypes[0] === GanttLinkType.fs
2685
+ ? singleDropActiveClass
2686
+ : dropActiveClass;
2687
+ fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
2688
+ .pipe(takeUntil(this.destroy$))
2689
+ .subscribe(() => {
2690
+ if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2691
+ if (this.item.linkable) {
2692
+ this.barElement.classList.add(dropClass);
2693
+ this.dragContainer.emitLinkDragEntered({
2694
+ item: this.item,
2695
+ element: this.barElement
2696
+ });
2697
+ }
2662
2698
  }
2663
- }
2664
- else {
2665
- todayEle.style.display = 'none';
2666
- }
2699
+ else {
2700
+ this.barElement.classList.add(activeClass);
2701
+ }
2702
+ });
2703
+ fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
2704
+ .pipe(takeUntil(this.destroy$))
2705
+ .subscribe(() => {
2706
+ if (!this.dragContainer.linkDraggingId) {
2707
+ this.barElement.classList.remove(activeClass);
2708
+ }
2709
+ else {
2710
+ this.dragContainer.emitLinkDragLeaved();
2711
+ }
2712
+ this.barElement.classList.remove(dropClass);
2713
+ });
2667
2714
  }
2668
- ngOnInit() {
2669
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2670
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2671
- .pipe(takeUntil(this.unsubscribe$))
2672
- .subscribe(() => {
2673
- this.setTodayPoint();
2715
+ createBarDrag() {
2716
+ const dragRef = this.createDragRef(this.barElement);
2717
+ dragRef.lockAxis = 'x';
2718
+ dragRef.withBoundaryElement(this.dom.mainItems);
2719
+ dragRef.started.subscribe(() => {
2720
+ this.setDraggingStyles();
2721
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2722
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2723
+ if (dragRef.isDragging()) {
2724
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2725
+ this.dragScrollDistance = dragScrollDistance;
2726
+ dragRef['_boundaryRect'] = this.dom.mainItems.getBoundingClientRect();
2727
+ this.barDragMove();
2728
+ }
2674
2729
  });
2730
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2675
2731
  });
2732
+ dragRef.moved.subscribe((event) => {
2733
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2734
+ this.barDragMoveDistance = event.distance.x;
2735
+ if (!this.dragScrolling) {
2736
+ this.barDragMove();
2737
+ }
2738
+ });
2739
+ dragRef.ended.subscribe((event) => {
2740
+ this.clearDraggingStyles();
2741
+ this.closeDragBackdrop();
2742
+ event.source.reset();
2743
+ this.stopScrolling();
2744
+ this.dragScrolling = false;
2745
+ this.dragScrollDistance = 0;
2746
+ this.barDragMoveDistance = 0;
2747
+ this.item.updateRefs({
2748
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2749
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2750
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2751
+ });
2752
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2753
+ });
2754
+ this.barDragRef = dragRef;
2755
+ return dragRef;
2676
2756
  }
2677
- trackBy(point, index) {
2678
- return point.text || index;
2679
- }
2680
- ngOnDestroy() {
2681
- this.unsubscribe$.next();
2682
- this.unsubscribe$.complete();
2683
- }
2684
- }
2685
- 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 });
2686
- 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"] }] });
2687
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
2688
- type: Component,
2689
- 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" }]
2690
- }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2691
- type: Inject,
2692
- args: [GANTT_UPPER_TOKEN]
2693
- }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
2694
- type: HostBinding,
2695
- args: ['class']
2696
- }] } });
2697
-
2698
- class NgxGanttToolbarComponent {
2699
- constructor(ganttUpper) {
2700
- this.ganttUpper = ganttUpper;
2701
- this.ganttItemClass = true;
2702
- this.ganttViewsMap = keyBy(ganttViews, 'value');
2703
- }
2704
- selectView(view) {
2705
- this.ganttUpper.changeView(view);
2706
- }
2707
- }
2708
- 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 });
2709
- 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"] }] });
2710
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, decorators: [{
2711
- type: Component,
2712
- 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" }]
2713
- }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2714
- type: Inject,
2715
- args: [GANTT_UPPER_TOKEN]
2716
- }] }]; }, propDecorators: { template: [{
2717
- type: Input
2718
- }], ganttItemClass: [{
2719
- type: HostBinding,
2720
- args: ['class.gantt-toolbar']
2721
- }] } });
2722
-
2723
- class NgxGanttRootComponent {
2724
- get view() {
2725
- return this.ganttUpper.view;
2726
- }
2727
- constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
2728
- this.elementRef = elementRef;
2729
- this.ngZone = ngZone;
2730
- this.dom = dom;
2731
- this.dragContainer = dragContainer;
2732
- this.ganttUpper = ganttUpper;
2733
- this.printService = printService;
2734
- this.unsubscribe$ = new Subject();
2735
- this.ganttUpper.dragContainer = dragContainer;
2736
- }
2737
- ngOnInit() {
2738
- // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
2739
- // the `onStable` will never emit any value.
2740
- const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
2741
- // Normally this isn't in the zone, but it can cause performance regressions for apps
2742
- // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
2743
- this.ngZone.runOutsideAngular(() => {
2744
- onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2745
- this.dom.initialize(this.elementRef);
2746
- if (this.printService) {
2747
- this.printService.register(this.elementRef);
2748
- }
2749
- this.setupScrollClass();
2750
- this.setupResize();
2751
- this.setupViewScroll();
2752
- // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
2753
- this.elementRef.nativeElement.style.opacity = '1';
2754
- this.ganttUpper.viewChange.pipe(startWith$1(null), takeUntil(this.unsubscribe$)).subscribe(() => {
2755
- this.scrollToToday();
2756
- });
2757
- });
2758
- });
2759
- }
2760
- ngOnDestroy() {
2761
- this.unsubscribe$.next();
2762
- }
2763
- setupViewScroll() {
2764
- if (this.ganttUpper.disabledLoadOnScroll) {
2765
- return;
2766
- }
2767
- this.dom
2768
- .getViewerScroll(passiveListenerOptions)
2769
- .pipe(takeUntil(this.unsubscribe$))
2770
- .subscribe((event) => {
2771
- if (event.direction === ScrollDirection.LEFT) {
2772
- const dates = this.view.addStartDate();
2773
- if (dates) {
2774
- event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
2775
- if (this.ganttUpper.loadOnScroll.observers) {
2776
- this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
2777
- }
2778
- }
2779
- }
2780
- if (event.direction === ScrollDirection.RIGHT) {
2781
- const dates = this.view.addEndDate();
2782
- if (dates && this.ganttUpper.loadOnScroll.observers) {
2783
- this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
2784
- }
2785
- }
2786
- });
2787
- }
2788
- setupResize() {
2789
- this.dom
2790
- .getResize()
2791
- .pipe(takeUntil(this.unsubscribe$))
2792
- .subscribe(() => {
2793
- this.setupScrollClass();
2794
- });
2795
- }
2796
- setupScrollClass() {
2797
- const mainContainer = this.dom.mainContainer;
2798
- const height = mainContainer.offsetHeight;
2799
- const scrollHeight = mainContainer.scrollHeight;
2800
- if (scrollHeight > height) {
2801
- this.elementRef.nativeElement.className = 'gantt gantt-scroll';
2802
- }
2803
- else {
2804
- this.elementRef.nativeElement.className = 'gantt';
2805
- }
2806
- }
2807
- scrollToToday() {
2808
- const x = this.view.getTodayXPoint();
2809
- this.dom.scrollMainContainer(x);
2810
- }
2811
- scrollToDate(date) {
2812
- let x;
2813
- if (typeof date === 'number') {
2814
- x = this.view.getXPointByDate(new GanttDate(date));
2815
- }
2816
- else {
2817
- x = this.view.getXPointByDate(date);
2818
- }
2819
- this.dom.scrollMainContainer(x);
2820
- }
2821
- }
2822
- 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 });
2823
- 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"] }] });
2824
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
2825
- type: Component,
2826
- args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
2827
- class: 'gantt'
2828
- }, 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" }]
2829
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
2830
- type: Inject,
2831
- args: [GANTT_UPPER_TOKEN]
2832
- }] }, { type: GanttPrintService, decorators: [{
2833
- type: Optional
2834
- }] }]; }, propDecorators: { sideWidth: [{
2835
- type: Input
2836
- }], sideTemplate: [{
2837
- type: ContentChild,
2838
- args: ['sideTemplate', { static: true }]
2839
- }], mainTemplate: [{
2840
- type: ContentChild,
2841
- args: ['mainTemplate', { static: true }]
2842
- }], backdrop: [{
2843
- type: ViewChild,
2844
- args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
2845
- }] } });
2846
-
2847
- /**
2848
- * Proximity, as a ratio to width/height, at which a
2849
- * dragged item will affect the drop container.
2850
- */
2851
- const DROP_PROXIMITY_THRESHOLD = 0.05;
2852
- const dragMinWidth = 10;
2853
- const autoScrollStep = 5;
2854
- const activeClass = 'gantt-bar-active';
2855
- const dropActiveClass = 'gantt-bar-drop-active';
2856
- const singleDropActiveClass = 'gantt-bar-single-drop-active';
2857
- function createSvgElement(qualifiedName, className) {
2858
- const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2859
- element.classList.add(className);
2860
- return element;
2861
- }
2862
- class GanttBarDrag {
2863
- get dragDisabled() {
2864
- return !this.item.draggable || !this.ganttUpper.draggable;
2865
- }
2866
- get linkDragDisabled() {
2867
- return !this.item.linkable || !this.ganttUpper.linkable;
2868
- }
2869
- constructor(dragDrop, dom, dragContainer, _ngZone, root) {
2870
- this.dragDrop = dragDrop;
2871
- this.dom = dom;
2872
- this.dragContainer = dragContainer;
2873
- this._ngZone = _ngZone;
2874
- this.root = root;
2875
- this.dragRefs = [];
2876
- this.destroy$ = new Subject();
2877
- /** Used to signal to the current auto-scroll sequence when to stop. */
2878
- this.stopScrollTimers$ = new Subject();
2879
- /** move distance when drag bar */
2880
- this.barDragMoveDistance = 0;
2881
- /** move distance when drag bar handle */
2882
- this.barHandleDragMoveDistance = 0;
2883
- /** scrolling state when drag */
2884
- this.dragScrolling = false;
2885
- /** dragScrollDistance */
2886
- this.dragScrollDistance = 0;
2887
- /** Horizontal direction in which the list is currently scrolling. */
2888
- this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
2889
- }
2890
- createDragRef(element) {
2891
- const dragRef = this.dragDrop.createDrag(element);
2892
- return dragRef;
2893
- }
2894
- createDragScrollEvent(dragRef) {
2895
- return fromEvent(this.dom.mainContainer, 'scroll', passiveListenerOptions).pipe(takeUntil(dragRef.ended));
2896
- }
2897
- createMouseEvents() {
2898
- const dropClass = this.ganttUpper.config.linkOptions?.dependencyTypes?.length === 1 &&
2899
- this.ganttUpper.config.linkOptions?.dependencyTypes[0] === GanttLinkType.fs
2900
- ? singleDropActiveClass
2901
- : dropActiveClass;
2902
- fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
2903
- .pipe(takeUntil(this.destroy$))
2904
- .subscribe(() => {
2905
- if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2906
- if (this.item.linkable) {
2907
- this.barElement.classList.add(dropClass);
2908
- this.dragContainer.emitLinkDragEntered({
2909
- item: this.item,
2910
- element: this.barElement
2911
- });
2912
- }
2913
- }
2914
- else {
2915
- this.barElement.classList.add(activeClass);
2916
- }
2917
- });
2918
- fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
2919
- .pipe(takeUntil(this.destroy$))
2920
- .subscribe(() => {
2921
- if (!this.dragContainer.linkDraggingId) {
2922
- this.barElement.classList.remove(activeClass);
2923
- }
2924
- else {
2925
- this.dragContainer.emitLinkDragLeaved();
2926
- }
2927
- this.barElement.classList.remove(dropClass);
2928
- });
2929
- }
2930
- createBarDrag() {
2931
- const dragRef = this.createDragRef(this.barElement);
2932
- dragRef.lockAxis = 'x';
2933
- dragRef.withBoundaryElement(this.dom.mainItems);
2934
- dragRef.started.subscribe(() => {
2935
- this.setDraggingStyles();
2936
- // this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2937
- // this.createDragScrollEvent(dragRef).subscribe(() => {
2938
- // if (dragRef.isDragging()) {
2939
- // const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2940
- // this.dragScrollDistance = dragScrollDistance;
2941
- // this.barDragMove();
2942
- // }
2943
- // });
2944
- this.dragContainer.dragStarted.emit({ item: this.item.origin });
2945
- });
2946
- dragRef.moved.subscribe((event) => {
2947
- // this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2948
- this.barDragMoveDistance = event.distance.x;
2949
- if (!this.dragScrolling) {
2950
- this.barDragMove();
2951
- }
2952
- });
2953
- dragRef.ended.subscribe((event) => {
2954
- this.clearDraggingStyles();
2955
- this.closeDragBackdrop();
2956
- event.source.reset();
2957
- // this.stopScrolling();
2958
- // this.dragScrolling = false;
2959
- // this.dragScrollDistance = 0;
2960
- this.barDragMoveDistance = 0;
2961
- this.item.updateRefs({
2962
- width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2963
- x: this.ganttUpper.view.getXPointByDate(this.item.start),
2964
- y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2965
- });
2966
- this.dragContainer.dragEnded.emit({ item: this.item.origin });
2967
- });
2968
- this.barDragRef = dragRef;
2969
- return dragRef;
2970
- }
2971
- createBarHandleDrags() {
2972
- const dragRefs = [];
2973
- const handles = this.barElement.querySelectorAll('.drag-handles .handle');
2974
- handles.forEach((handle, index) => {
2975
- const isBefore = index === 0;
2976
- const dragRef = this.createDragRef(handle);
2977
- dragRef.lockAxis = 'x';
2978
- dragRef.withBoundaryElement(this.dom.mainItems);
2979
- dragRef.started.subscribe(() => {
2980
- this.setDraggingStyles();
2981
- // this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2982
- // this.createDragScrollEvent(dragRef).subscribe(() => {
2983
- // if (dragRef.isDragging()) {
2984
- // const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2985
- // this.dragScrollDistance = dragScrollDistance;
2986
- // this.barHandleDragMove(isBefore);
2987
- // }
2988
- // });
2989
- this.dragContainer.dragStarted.emit({ item: this.item.origin });
2990
- });
2991
- dragRef.moved.subscribe((event) => {
2992
- // this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2993
- this.barHandleDragMoveDistance = event.distance.x;
2994
- if (!this.dragScrolling) {
2995
- this.barHandleDragMove(isBefore);
2996
- }
2997
- });
2998
- dragRef.ended.subscribe((event) => {
2999
- this.clearDraggingStyles();
3000
- this.closeDragBackdrop();
3001
- event.source.reset();
3002
- // this.stopScrolling();
3003
- // this.dragScrolling = false;
3004
- // this.dragScrollDistance = 0;
3005
- this.barHandleDragMoveDistance = 0;
3006
- this.item.updateRefs({
3007
- width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
3008
- x: this.ganttUpper.view.getXPointByDate(this.item.start),
3009
- y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
3010
- });
3011
- this.dragContainer.dragEnded.emit({ item: this.item.origin });
3012
- });
3013
- dragRefs.push(dragRef);
3014
- });
3015
- return dragRefs;
2757
+ createBarHandleDrags() {
2758
+ const dragRefs = [];
2759
+ const handles = this.barElement.querySelectorAll('.drag-handles .handle');
2760
+ handles.forEach((handle, index) => {
2761
+ const isBefore = index === 0;
2762
+ const dragRef = this.createDragRef(handle);
2763
+ dragRef.lockAxis = 'x';
2764
+ dragRef.withBoundaryElement(this.dom.mainItems);
2765
+ dragRef.started.subscribe(() => {
2766
+ this.setDraggingStyles();
2767
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2768
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2769
+ if (dragRef.isDragging()) {
2770
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2771
+ this.dragScrollDistance = dragScrollDistance;
2772
+ dragRef['_boundaryRect'] = this.dom.mainItems.getBoundingClientRect();
2773
+ this.barHandleDragMove(isBefore);
2774
+ }
2775
+ });
2776
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2777
+ });
2778
+ dragRef.moved.subscribe((event) => {
2779
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2780
+ this.barHandleDragMoveDistance = event.distance.x;
2781
+ if (!this.dragScrolling) {
2782
+ this.barHandleDragMove(isBefore);
2783
+ }
2784
+ });
2785
+ dragRef.ended.subscribe((event) => {
2786
+ this.clearDraggingStyles();
2787
+ this.closeDragBackdrop();
2788
+ event.source.reset();
2789
+ this.stopScrolling();
2790
+ this.dragScrolling = false;
2791
+ this.dragScrollDistance = 0;
2792
+ this.barHandleDragMoveDistance = 0;
2793
+ this.item.updateRefs({
2794
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2795
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2796
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2797
+ });
2798
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2799
+ });
2800
+ dragRefs.push(dragRef);
2801
+ });
2802
+ return dragRefs;
3016
2803
  }
3017
2804
  createLinkHandleDrags() {
3018
2805
  const dragRefs = [];
@@ -3068,13 +2855,19 @@ class GanttBarDrag {
3068
2855
  return dragRefs;
3069
2856
  }
3070
2857
  openDragBackdrop(dragElement, start, end) {
3071
- // const dragBackdropElement = this.root.backdrop.nativeElement;
3072
- // const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask') as HTMLElement;
3073
2858
  const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
3074
2859
  const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
3075
2860
  const rootRect = this.dom.root.getBoundingClientRect();
3076
2861
  const dragRect = dragElement.getBoundingClientRect();
3077
- const left = dragRect.left - rootRect.left - (this.dom.side.clientWidth + 1);
2862
+ let left = dragRect.left - rootRect.left - (this.dom.side.clientWidth + 1);
2863
+ if (this.dragScrolling) {
2864
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2865
+ left += autoScrollStep;
2866
+ }
2867
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2868
+ left -= autoScrollStep;
2869
+ }
2870
+ }
3078
2871
  const width = dragRect.right - dragRect.left;
3079
2872
  // Note: updating styles will cause re-layout so we have to place them consistently one by one.
3080
2873
  dragMaskElement.style.left = left + 'px';
@@ -3112,7 +2905,8 @@ class GanttBarDrag {
3112
2905
  end = end.addDays(1);
3113
2906
  }
3114
2907
  if (this.dragScrolling) {
3115
- this.barElement.style.left = currentX - this.barDragMoveDistance + 'px';
2908
+ const left = currentX - this.barDragMoveDistance;
2909
+ this.barElement.style.left = left + 'px';
3116
2910
  }
3117
2911
  this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
3118
2912
  if (!this.isStartOrEndInsideView(start, end)) {
@@ -3128,13 +2922,13 @@ class GanttBarDrag {
3128
2922
  const width = this.item.refs.width + distance * -1;
3129
2923
  const start = this.ganttUpper.view.getDateByXPoint(x);
3130
2924
  const days = differenceInDays(this.item.end.value, start.value);
3131
- if (!this.isStartOrEndInsideView(start, this.item.end)) {
3132
- return;
3133
- }
3134
2925
  if (width > dragMinWidth && days > 0) {
3135
2926
  this.barElement.style.width = width + 'px';
3136
2927
  this.barElement.style.left = x + 'px';
3137
2928
  this.openDragBackdrop(this.barElement, start, this.item.end);
2929
+ if (!this.isStartOrEndInsideView(start, this.item.end)) {
2930
+ return;
2931
+ }
3138
2932
  this.item.updateDate(start, this.item.end);
3139
2933
  }
3140
2934
  else {
@@ -3146,12 +2940,12 @@ class GanttBarDrag {
3146
2940
  const width = this.item.refs.width + distance;
3147
2941
  const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
3148
2942
  const days = differenceInDays(end.value, this.item.start.value);
3149
- if (!this.isStartOrEndInsideView(this.item.start, end)) {
3150
- return;
3151
- }
3152
2943
  if (width > dragMinWidth && days > 0) {
3153
2944
  this.barElement.style.width = width + 'px';
3154
2945
  this.openDragBackdrop(this.barElement, this.item.start, end);
2946
+ if (!this.isStartOrEndInsideView(this.item.start, end)) {
2947
+ return;
2948
+ }
3155
2949
  this.item.updateDate(this.item.start, end);
3156
2950
  }
3157
2951
  else {
@@ -3188,37 +2982,27 @@ class GanttBarDrag {
3188
2982
  this.linkDraggingLine = null;
3189
2983
  }
3190
2984
  }
3191
- // private startScrollInterval = () => {
3192
- // this.stopScrolling();
3193
- // interval(0, animationFrameScheduler)
3194
- // .pipe(takeUntil(this.stopScrollTimers$))
3195
- // .subscribe(() => {
3196
- // const node = this.dom.mainContainer;
3197
- // const scrollStep = autoScrollStep;
3198
- // if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.LEFT) {
3199
- // node.scrollBy(-scrollStep, 0);
3200
- // } else if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.RIGHT) {
3201
- // node.scrollBy(scrollStep, 0);
3202
- // }
3203
- // });
3204
- // };
3205
- // private startScrollingIfNecessary(pointerX: number, pointerY: number) {
3206
- // const clientRect = this.dom.mainContainer.getBoundingClientRect();
3207
- // if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
3208
- // const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
3209
- // if (horizontalScrollDirection) {
3210
- // this._horizontalScrollDirection = horizontalScrollDirection;
3211
- // this.dragScrolling = true;
3212
- // this._ngZone.runOutsideAngular(this.startScrollInterval);
3213
- // } else {
3214
- // this.dragScrolling = false;
3215
- // this.stopScrolling();
3216
- // }
3217
- // }
3218
- // }
3219
- // private stopScrolling() {
3220
- // this.stopScrollTimers$.next();
3221
- // }
2985
+ startScrollingIfNecessary(pointerX, pointerY) {
2986
+ const clientRect = this.dom.mainContainer.getBoundingClientRect();
2987
+ const scrollLeft = this.dom.mainContainer.scrollLeft;
2988
+ if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
2989
+ const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
2990
+ if ((horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */ && scrollLeft > 0) ||
2991
+ (horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */ &&
2992
+ scrollLeft < this.ganttUpper.view.width - clientRect.width)) {
2993
+ this._horizontalScrollDirection = horizontalScrollDirection;
2994
+ this.dragScrolling = true;
2995
+ this._ngZone.runOutsideAngular(this.startScrollInterval);
2996
+ }
2997
+ else {
2998
+ this.dragScrolling = false;
2999
+ this.stopScrolling();
3000
+ }
3001
+ }
3002
+ }
3003
+ stopScrolling() {
3004
+ this.stopScrollTimers$.next();
3005
+ }
3222
3006
  isStartOrEndInsideView(start, end) {
3223
3007
  const itemStart = start.getUnixTime();
3224
3008
  const itemEnd = end.getUnixTime();
@@ -3259,17 +3043,15 @@ class GanttBarDrag {
3259
3043
  this.dragRefs.forEach((dragRef) => dragRef.dispose());
3260
3044
  this.destroy$.next();
3261
3045
  this.destroy$.complete();
3262
- // this.stopScrolling();
3046
+ this.stopScrolling();
3263
3047
  this.stopScrollTimers$.complete();
3264
3048
  }
3265
3049
  }
3266
- 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 }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
3050
+ 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 });
3267
3051
  GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag });
3268
3052
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, decorators: [{
3269
3053
  type: Injectable
3270
- }], ctorParameters: function () { return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: i0.NgZone }, { type: NgxGanttRootComponent, decorators: [{
3271
- type: SkipSelf
3272
- }] }]; } });
3054
+ }], ctorParameters: function () { return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: i0.NgZone }]; } });
3273
3055
 
3274
3056
  class GanttItemUpper {
3275
3057
  constructor(elementRef, ganttUpper) {
@@ -3475,59 +3257,176 @@ class NgxGanttBaselineComponent {
3475
3257
  itemElement.style.width = this.baselineItem.refs.width + 'px';
3476
3258
  }
3477
3259
  }
3478
- 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 });
3479
- 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"] }] });
3480
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBaselineComponent, decorators: [{
3260
+ 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 });
3261
+ 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"] }] });
3262
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBaselineComponent, decorators: [{
3263
+ type: Component,
3264
+ args: [{ selector: 'ngx-gantt-baseline,gantt-baseline', template: "<div #content *ngIf=\"baselineItem\" class=\"baseline-content\"></div>\n" }]
3265
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3266
+ type: Inject,
3267
+ args: [GANTT_UPPER_TOKEN]
3268
+ }] }]; }, propDecorators: { baselineItem: [{
3269
+ type: Input
3270
+ }], ganttBaselineClass: [{
3271
+ type: HostBinding,
3272
+ args: ['class.gantt-baseline']
3273
+ }] } });
3274
+
3275
+ class GanttMainComponent {
3276
+ constructor(ganttUpper) {
3277
+ this.ganttUpper = ganttUpper;
3278
+ this.barClick = new EventEmitter();
3279
+ this.lineClick = new EventEmitter();
3280
+ this.ganttMainClass = true;
3281
+ }
3282
+ trackBy(index, item) {
3283
+ return item.id || index;
3284
+ }
3285
+ }
3286
+ 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 });
3287
+ 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" }] });
3288
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, decorators: [{
3289
+ type: Component,
3290
+ 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" }]
3291
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3292
+ type: Inject,
3293
+ args: [GANTT_UPPER_TOKEN]
3294
+ }] }]; }, propDecorators: { renderData: [{
3295
+ type: Input
3296
+ }], flatData: [{
3297
+ type: Input
3298
+ }], groupHeaderTemplate: [{
3299
+ type: Input
3300
+ }], itemTemplate: [{
3301
+ type: Input
3302
+ }], barTemplate: [{
3303
+ type: Input
3304
+ }], rangeTemplate: [{
3305
+ type: Input
3306
+ }], barClick: [{
3307
+ type: Output
3308
+ }], lineClick: [{
3309
+ type: Output
3310
+ }], ganttMainClass: [{
3311
+ type: HostBinding,
3312
+ args: ['class.gantt-main-container']
3313
+ }] } });
3314
+
3315
+ class GanttCalendarHeaderComponent {
3316
+ get view() {
3317
+ return this.ganttUpper.view;
3318
+ }
3319
+ constructor(ganttUpper, ngZone, elementRef) {
3320
+ this.ganttUpper = ganttUpper;
3321
+ this.ngZone = ngZone;
3322
+ this.elementRef = elementRef;
3323
+ this.unsubscribe$ = new Subject();
3324
+ this.headerHeight = headerHeight;
3325
+ this.viewTypes = GanttViewType;
3326
+ this.className = `gantt-calendar gantt-calendar-header`;
3327
+ }
3328
+ ngOnInit() {
3329
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
3330
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
3331
+ .pipe(takeUntil(this.unsubscribe$))
3332
+ .subscribe(() => {
3333
+ if (this.ganttUpper.viewType === GanttViewType.day)
3334
+ this.setTodayPoint();
3335
+ });
3336
+ });
3337
+ }
3338
+ setTodayPoint() {
3339
+ const x = this.view.getTodayXPoint();
3340
+ const today = new GanttDate().getDate();
3341
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
3342
+ const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
3343
+ if (isNumber(x)) {
3344
+ if (rect) {
3345
+ rect.style.left = `${x - todayWidth / 2}px`;
3346
+ rect.style.top = `${headerHeight - todayHeight}px`;
3347
+ rect.innerHTML = today.toString();
3348
+ }
3349
+ }
3350
+ else {
3351
+ todayEle.style.display = 'none';
3352
+ }
3353
+ }
3354
+ trackBy(point, index) {
3355
+ return point.text || index;
3356
+ }
3357
+ }
3358
+ 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 });
3359
+ 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"] }] });
3360
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
3481
3361
  type: Component,
3482
- args: [{ selector: 'ngx-gantt-baseline,gantt-baseline', template: "<div #content *ngIf=\"baselineItem\" class=\"baseline-content\"></div>\n" }]
3483
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3362
+ 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" }]
3363
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3484
3364
  type: Inject,
3485
3365
  args: [GANTT_UPPER_TOKEN]
3486
- }] }]; }, propDecorators: { baselineItem: [{
3487
- type: Input
3488
- }], ganttBaselineClass: [{
3366
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
3489
3367
  type: HostBinding,
3490
- args: ['class.gantt-baseline']
3368
+ args: ['class']
3491
3369
  }] } });
3492
3370
 
3493
- class GanttMainComponent {
3494
- constructor(ganttUpper) {
3371
+ const mainHeight = 5000;
3372
+ class GanttCalendarGridComponent {
3373
+ get view() {
3374
+ return this.ganttUpper.view;
3375
+ }
3376
+ constructor(ganttUpper, ngZone, elementRef) {
3495
3377
  this.ganttUpper = ganttUpper;
3496
- this.barClick = new EventEmitter();
3497
- this.lineClick = new EventEmitter();
3498
- this.ganttMainClass = true;
3378
+ this.ngZone = ngZone;
3379
+ this.elementRef = elementRef;
3380
+ this.unsubscribe$ = new Subject();
3381
+ this.headerHeight = headerHeight;
3382
+ this.mainHeight = mainHeight;
3383
+ this.todayBorderRadius = todayBorderRadius;
3384
+ this.viewTypes = GanttViewType;
3385
+ this.className = `gantt-calendar gantt-calendar-grid`;
3499
3386
  }
3500
- trackBy(index, item) {
3501
- return item.id || index;
3387
+ setTodayPoint() {
3388
+ const x = this.view.getTodayXPoint();
3389
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
3390
+ const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
3391
+ if (isNumber(x)) {
3392
+ if (line) {
3393
+ line.style.left = `${x}px`;
3394
+ line.style.top = `0px`;
3395
+ line.style.bottom = `${-mainHeight}px`;
3396
+ }
3397
+ }
3398
+ else {
3399
+ todayEle.style.display = 'none';
3400
+ }
3401
+ }
3402
+ ngOnInit() {
3403
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
3404
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
3405
+ .pipe(takeUntil(this.unsubscribe$))
3406
+ .subscribe(() => {
3407
+ this.setTodayPoint();
3408
+ });
3409
+ });
3410
+ }
3411
+ trackBy(point, index) {
3412
+ return point.text || index;
3413
+ }
3414
+ ngOnDestroy() {
3415
+ this.unsubscribe$.next();
3416
+ this.unsubscribe$.complete();
3502
3417
  }
3503
3418
  }
3504
- 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 });
3505
- 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" }] });
3506
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, decorators: [{
3419
+ 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 });
3420
+ 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"] }] });
3421
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
3507
3422
  type: Component,
3508
- 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" }]
3423
+ 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" }]
3509
3424
  }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3510
3425
  type: Inject,
3511
3426
  args: [GANTT_UPPER_TOKEN]
3512
- }] }]; }, propDecorators: { renderData: [{
3513
- type: Input
3514
- }], flatData: [{
3515
- type: Input
3516
- }], groupHeaderTemplate: [{
3517
- type: Input
3518
- }], itemTemplate: [{
3519
- type: Input
3520
- }], barTemplate: [{
3521
- type: Input
3522
- }], rangeTemplate: [{
3523
- type: Input
3524
- }], barClick: [{
3525
- type: Output
3526
- }], lineClick: [{
3527
- type: Output
3528
- }], ganttMainClass: [{
3427
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
3529
3428
  type: HostBinding,
3530
- args: ['class.gantt-main-container']
3429
+ args: ['class']
3531
3430
  }] } });
3532
3431
 
3533
3432
  class GanttLoaderComponent {
@@ -3557,6 +3456,166 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3557
3456
  }]
3558
3457
  }] });
3559
3458
 
3459
+ class GanttDragBackdropComponent {
3460
+ }
3461
+ GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3462
+ 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" });
3463
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
3464
+ type: Component,
3465
+ args: [{ selector: 'gantt-drag-backdrop', host: {
3466
+ class: 'gantt-drag-backdrop'
3467
+ }, 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" }]
3468
+ }] });
3469
+
3470
+ class NgxGanttToolbarComponent {
3471
+ constructor(ganttUpper) {
3472
+ this.ganttUpper = ganttUpper;
3473
+ this.ganttItemClass = true;
3474
+ this.ganttViewsMap = keyBy(ganttViews, 'value');
3475
+ }
3476
+ selectView(view) {
3477
+ this.ganttUpper.changeView(view);
3478
+ }
3479
+ }
3480
+ 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 });
3481
+ 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"] }] });
3482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, decorators: [{
3483
+ type: Component,
3484
+ 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" }]
3485
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
3486
+ type: Inject,
3487
+ args: [GANTT_UPPER_TOKEN]
3488
+ }] }]; }, propDecorators: { template: [{
3489
+ type: Input
3490
+ }], ganttItemClass: [{
3491
+ type: HostBinding,
3492
+ args: ['class.gantt-toolbar']
3493
+ }] } });
3494
+
3495
+ class NgxGanttRootComponent {
3496
+ get view() {
3497
+ return this.ganttUpper.view;
3498
+ }
3499
+ constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
3500
+ this.elementRef = elementRef;
3501
+ this.ngZone = ngZone;
3502
+ this.dom = dom;
3503
+ this.dragContainer = dragContainer;
3504
+ this.ganttUpper = ganttUpper;
3505
+ this.printService = printService;
3506
+ this.unsubscribe$ = new Subject();
3507
+ this.ganttUpper.dragContainer = dragContainer;
3508
+ }
3509
+ ngOnInit() {
3510
+ // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
3511
+ // the `onStable` will never emit any value.
3512
+ const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
3513
+ // Normally this isn't in the zone, but it can cause performance regressions for apps
3514
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
3515
+ this.ngZone.runOutsideAngular(() => {
3516
+ onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3517
+ this.dom.initialize(this.elementRef);
3518
+ if (this.printService) {
3519
+ this.printService.register(this.elementRef);
3520
+ }
3521
+ this.setupScrollClass();
3522
+ this.setupResize();
3523
+ this.setupViewScroll();
3524
+ // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
3525
+ this.elementRef.nativeElement.style.opacity = '1';
3526
+ this.ganttUpper.viewChange.pipe(startWith$1(null), takeUntil(this.unsubscribe$)).subscribe(() => {
3527
+ this.scrollToToday();
3528
+ });
3529
+ });
3530
+ });
3531
+ }
3532
+ ngOnDestroy() {
3533
+ this.unsubscribe$.next();
3534
+ }
3535
+ setupViewScroll() {
3536
+ if (this.ganttUpper.disabledLoadOnScroll) {
3537
+ return;
3538
+ }
3539
+ this.dom
3540
+ .getViewerScroll(passiveListenerOptions)
3541
+ .pipe(takeUntil(this.unsubscribe$))
3542
+ .subscribe((event) => {
3543
+ if (event.direction === ScrollDirection.LEFT) {
3544
+ const dates = this.view.addStartDate();
3545
+ if (dates) {
3546
+ event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
3547
+ if (this.ganttUpper.loadOnScroll.observers) {
3548
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
3549
+ }
3550
+ }
3551
+ }
3552
+ if (event.direction === ScrollDirection.RIGHT) {
3553
+ const dates = this.view.addEndDate();
3554
+ if (dates && this.ganttUpper.loadOnScroll.observers) {
3555
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
3556
+ }
3557
+ }
3558
+ });
3559
+ }
3560
+ setupResize() {
3561
+ this.dom
3562
+ .getResize()
3563
+ .pipe(takeUntil(this.unsubscribe$))
3564
+ .subscribe(() => {
3565
+ this.setupScrollClass();
3566
+ });
3567
+ }
3568
+ setupScrollClass() {
3569
+ const mainContainer = this.dom.mainContainer;
3570
+ const height = mainContainer.offsetHeight;
3571
+ const scrollHeight = mainContainer.scrollHeight;
3572
+ if (scrollHeight > height) {
3573
+ this.elementRef.nativeElement.className = 'gantt gantt-scroll';
3574
+ }
3575
+ else {
3576
+ this.elementRef.nativeElement.className = 'gantt';
3577
+ }
3578
+ }
3579
+ scrollToToday() {
3580
+ const x = this.view.getTodayXPoint();
3581
+ this.dom.scrollMainContainer(x);
3582
+ }
3583
+ scrollToDate(date) {
3584
+ let x;
3585
+ if (typeof date === 'number') {
3586
+ x = this.view.getXPointByDate(new GanttDate(date));
3587
+ }
3588
+ else {
3589
+ x = this.view.getXPointByDate(date);
3590
+ }
3591
+ this.dom.scrollMainContainer(x);
3592
+ }
3593
+ }
3594
+ 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 });
3595
+ 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"] }] });
3596
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
3597
+ type: Component,
3598
+ args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
3599
+ class: 'gantt'
3600
+ }, 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" }]
3601
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
3602
+ type: Inject,
3603
+ args: [GANTT_UPPER_TOKEN]
3604
+ }] }, { type: GanttPrintService, decorators: [{
3605
+ type: Optional
3606
+ }] }]; }, propDecorators: { sideWidth: [{
3607
+ type: Input
3608
+ }], sideTemplate: [{
3609
+ type: ContentChild,
3610
+ args: ['sideTemplate', { static: true }]
3611
+ }], mainTemplate: [{
3612
+ type: ContentChild,
3613
+ args: ['mainTemplate', { static: true }]
3614
+ }], backdrop: [{
3615
+ type: ViewChild,
3616
+ args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
3617
+ }] } });
3618
+
3560
3619
  class NgxGanttComponent extends GanttUpper {
3561
3620
  set loading(loading) {
3562
3621
  if (loading) {