@worktile/gantt 15.1.0-next.4 → 15.1.0-next.6

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.
@@ -2,8 +2,8 @@ import * as i0 from '@angular/core';
2
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';
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 } 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';
@@ -1246,12 +1246,15 @@ class NgxGanttTableColumnComponent {
1246
1246
  }
1247
1247
  }
1248
1248
  NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1249
- NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name", showExpandIcon: "showExpandIcon" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1249
+ NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name", showExpandIcon: "showExpandIcon" }, host: { classAttribute: "gantt-table-column" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1250
1250
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, decorators: [{
1251
1251
  type: Component,
1252
1252
  args: [{
1253
1253
  selector: 'ngx-gantt-column',
1254
- template: ''
1254
+ template: '',
1255
+ host: {
1256
+ class: 'gantt-table-column'
1257
+ }
1255
1258
  }]
1256
1259
  }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1257
1260
  type: Inject,
@@ -1729,7 +1732,7 @@ class GanttTableBodyComponent {
1729
1732
  this.ganttTableDragging = false;
1730
1733
  this.hasExpandIcon = false;
1731
1734
  // 缓存 Element 和 DragRef 的关系,方便在 Item 拖动时查找
1732
- this.itemDragRefMap = new Map();
1735
+ this.itemDragsMap = new Map();
1733
1736
  this.itemDragMoved = new Subject();
1734
1737
  this.destroy$ = new Subject();
1735
1738
  }
@@ -1737,7 +1740,6 @@ class GanttTableBodyComponent {
1737
1740
  this.columns.changes.pipe(startWith(this.columns), takeUntil$1(this.destroy$)).subscribe(() => {
1738
1741
  this.hasExpandIcon = false;
1739
1742
  this.columns.forEach((column) => {
1740
- // column.classList.add('gantt-table-column');
1741
1743
  if (!column.columnWidth) {
1742
1744
  column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1743
1745
  }
@@ -1752,17 +1754,17 @@ class GanttTableBodyComponent {
1752
1754
  this.cdkDrags.changes
1753
1755
  .pipe(startWith(this.cdkDrags), takeUntil$1(this.destroy$))
1754
1756
  .subscribe((drags) => {
1755
- this.itemDragRefMap.clear();
1757
+ this.itemDragsMap.clear();
1756
1758
  drags.forEach((drag) => {
1757
1759
  if (drag.data) {
1758
1760
  // cdkDrag 变化时,缓存 Element 与 DragRef 的关系,方便 Drag Move 时查找
1759
- this.itemDragRefMap.set(drag.element.nativeElement, drag);
1761
+ this.itemDragsMap.set(drag.element.nativeElement, drag);
1760
1762
  }
1761
1763
  });
1762
1764
  });
1763
1765
  this.itemDragMoved
1764
- .pipe(debounceTime(30),
1765
- // debounce 可能会导致拖动结束后仍然执行 moved ,所以通过判断 dragging 状态来过滤无效 moved
1766
+ .pipe(auditTime(30),
1767
+ // auditTime 可能会导致拖动结束后仍然执行 moved ,所以通过判断 dragging 状态来过滤无效 moved
1766
1768
  filter((event) => event.source._dragRef.isDragging()), takeUntil$1(this.destroy$))
1767
1769
  .subscribe((event) => {
1768
1770
  this.onItemDragMoved(event);
@@ -1802,12 +1804,12 @@ class GanttTableBodyComponent {
1802
1804
  }
1803
1805
  // 缓存放置目标Id 并计算鼠标相对应的位置
1804
1806
  this.itemDropTarget = {
1805
- id: this.itemDragRefMap.get(targetElement)?.data.id,
1807
+ id: this.itemDragsMap.get(targetElement)?.data.id,
1806
1808
  position: this.getTargetPosition(targetElement, event)
1807
1809
  };
1808
1810
  // 执行外部传入的 dropEnterPredicate 判断是否允许拖入目标项
1809
1811
  if (this.dropEnterPredicate) {
1810
- const targetDragRef = this.itemDragRefMap.get(targetElement);
1812
+ const targetDragRef = this.itemDragsMap.get(targetElement);
1811
1813
  if (this.dropEnterPredicate({
1812
1814
  source: event.source.data.origin,
1813
1815
  target: targetDragRef.data.origin,
@@ -1830,26 +1832,29 @@ class GanttTableBodyComponent {
1830
1832
  if (!this.itemDropTarget) {
1831
1833
  return;
1832
1834
  }
1833
- const targetDragRef = this.cdkDrags.find((item) => item.data?.id === this.itemDropTarget.id);
1834
1835
  const sourceItem = event.item.data;
1836
+ const sourceParent = this.getParentByItem(sourceItem);
1837
+ const sourceChildren = this.getExpandChildrenByDrag(event.item);
1838
+ const targetDragRef = this.cdkDrags.find((item) => item.data?.id === this.itemDropTarget.id);
1835
1839
  const targetItem = targetDragRef?.data;
1836
- this.removeItem(sourceItem);
1840
+ const targetParent = this.getParentByItem(targetItem);
1841
+ this.removeItem(sourceItem, sourceChildren);
1837
1842
  switch (this.itemDropTarget.position) {
1838
1843
  case 'before':
1839
1844
  case 'after':
1840
- this.insertItem(targetItem, sourceItem, this.itemDropTarget.position);
1845
+ this.insertItem(targetItem, sourceItem, sourceChildren, this.itemDropTarget.position);
1841
1846
  sourceItem.updateLevel(targetItem.level);
1842
1847
  break;
1843
1848
  case 'inside':
1844
- this.insertChildrenItem(targetItem, sourceItem);
1849
+ this.insertChildrenItem(targetItem, sourceItem, sourceChildren);
1845
1850
  sourceItem.updateLevel(targetItem.level + 1);
1846
1851
  break;
1847
1852
  }
1848
1853
  this.dragDropped.emit({
1849
1854
  source: sourceItem.origin,
1850
- sourceParent: this.getParentByItem(sourceItem)?.origin,
1855
+ sourceParent: sourceParent?.origin,
1851
1856
  target: targetItem.origin,
1852
- targetParent: this.getParentByItem(targetItem)?.origin,
1857
+ targetParent: targetParent?.origin,
1853
1858
  dropPosition: this.itemDropTarget.position
1854
1859
  });
1855
1860
  this.cleanupDragArtifacts(true);
@@ -1861,14 +1866,14 @@ class GanttTableBodyComponent {
1861
1866
  this.destroy$.next();
1862
1867
  this.destroy$.complete();
1863
1868
  }
1864
- removeItem(item) {
1865
- this.renderData.splice(this.renderData.indexOf(item), 1);
1866
- this.flatData.splice(this.flatData.indexOf(item), 1);
1869
+ removeItem(item, children) {
1870
+ this.renderData.splice(this.renderData.indexOf(item), 1 + children.length);
1871
+ this.flatData.splice(this.flatData.indexOf(item), 1 + children.length);
1867
1872
  }
1868
- insertItem(target, inserted, position) {
1873
+ insertItem(target, inserted, children, position) {
1869
1874
  if (position === 'before') {
1870
- this.renderData.splice(this.renderData.indexOf(target), 0, inserted);
1871
- this.flatData.splice(this.flatData.indexOf(target), 0, inserted);
1875
+ this.renderData.splice(this.renderData.indexOf(target), 0, inserted, ...children);
1876
+ this.flatData.splice(this.flatData.indexOf(target), 0, inserted, ...children);
1872
1877
  }
1873
1878
  else {
1874
1879
  const dragRef = this.cdkDrags.find((drag) => drag.data === target);
@@ -1877,14 +1882,14 @@ class GanttTableBodyComponent {
1877
1882
  if (target.expanded) {
1878
1883
  childrenCount = this.getChildrenElementsByElement(dragRef.element.nativeElement)?.length || 0;
1879
1884
  }
1880
- this.renderData.splice(this.renderData.indexOf(target) + 1 + childrenCount, 0, inserted);
1881
- this.flatData.splice(this.flatData.indexOf(target) + 1 + childrenCount, 0, inserted);
1885
+ this.renderData.splice(this.renderData.indexOf(target) + 1 + childrenCount, 0, inserted, ...children);
1886
+ this.flatData.splice(this.flatData.indexOf(target) + 1 + childrenCount, 0, inserted, ...children);
1882
1887
  }
1883
1888
  }
1884
- insertChildrenItem(target, inserted) {
1889
+ insertChildrenItem(target, inserted, children) {
1885
1890
  if (target.expanded) {
1886
- this.renderData.splice(this.renderData.indexOf(target) + target.children.length + 1, 0, inserted);
1887
- this.flatData.splice(this.flatData.indexOf(target) + target.children.length + 1, 0, inserted);
1891
+ this.renderData.splice(this.renderData.indexOf(target) + target.children.length + 1, 0, inserted, ...children);
1892
+ this.flatData.splice(this.flatData.indexOf(target) + target.children.length + 1, 0, inserted, ...children);
1888
1893
  }
1889
1894
  target.children.push(inserted);
1890
1895
  }
@@ -1893,17 +1898,26 @@ class GanttTableBodyComponent {
1893
1898
  return n.children?.includes(item);
1894
1899
  });
1895
1900
  }
1901
+ getExpandChildrenByDrag(dragRef) {
1902
+ if (!dragRef.data.expanded) {
1903
+ return [];
1904
+ }
1905
+ else {
1906
+ const childrenElements = this.getChildrenElementsByElement(dragRef.element.nativeElement);
1907
+ return childrenElements.map((element) => this.itemDragsMap.get(element).data);
1908
+ }
1909
+ }
1896
1910
  getChildrenElementsByElement(dragElement) {
1897
1911
  // 通过循环持续查找 next element,如果 element 的 level 小于当前 item 的 level,则为它的 children
1898
1912
  const children = [];
1899
- const dragRef = this.itemDragRefMap.get(dragElement);
1913
+ const dragRef = this.itemDragsMap.get(dragElement);
1900
1914
  // 如果当前的 Drag 正在拖拽,会创建 PlaceholderElement 占位,所以以 PlaceholderElement 向下查找
1901
1915
  let nextElement = (dragRef.getPlaceholderElement() || dragElement).nextElementSibling;
1902
- let nextDragRef = this.itemDragRefMap.get(nextElement);
1916
+ let nextDragRef = this.itemDragsMap.get(nextElement);
1903
1917
  while (nextDragRef && nextDragRef.data.level > dragRef.data.level) {
1904
1918
  children.push(nextElement);
1905
1919
  nextElement = nextElement.nextElementSibling;
1906
- nextDragRef = this.itemDragRefMap.get(nextElement);
1920
+ nextDragRef = this.itemDragsMap.get(nextElement);
1907
1921
  }
1908
1922
  return children;
1909
1923
  }
@@ -1930,18 +1944,18 @@ class GanttTableBodyComponent {
1930
1944
  cleanupDragArtifacts(dropped = false) {
1931
1945
  if (dropped) {
1932
1946
  this.itemDropTarget = null;
1947
+ this.document.querySelectorAll('.drag-item-hide').forEach((element) => element.classList.remove('drag-item-hide'));
1933
1948
  }
1934
1949
  this.document.querySelectorAll('.drop-position-before').forEach((element) => element.classList.remove('drop-position-before'));
1935
1950
  this.document.querySelectorAll('.drop-position-after').forEach((element) => element.classList.remove('drop-position-after'));
1936
1951
  this.document.querySelectorAll('.drop-position-inside').forEach((element) => element.classList.remove('drop-position-inside'));
1937
- this.document.querySelectorAll('.drag-item-hide').forEach((element) => element.classList.remove('drop-item-hide'));
1938
1952
  }
1939
1953
  }
1940
1954
  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 });
1941
- GanttTableBodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: { renderData: "renderData", flatData: "flatData", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate", rowBeforeTemplate: "rowBeforeTemplate", rowAfterTemplate: "rowAfterTemplate", draggable: "draggable", dropEnterPredicate: "dropEnterPredicate" }, outputs: { dragDropped: "dragDropped", itemClick: "itemClick" }, host: { properties: { "class.gantt-table-draggable": "this.draggable", "class.gantt-table-body": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass", "class.gantt-table-dragging": "this.ganttTableDragging" } }, viewQueries: [{ propertyName: "cdkDrags", predicate: (CdkDrag), descendants: true }], ngImport: i0, template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div class=\"gantt-table-column\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i2.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i2.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "component", type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }] });
1955
+ 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" }] });
1942
1956
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableBodyComponent, decorators: [{
1943
1957
  type: Component,
1944
- args: [{ selector: 'gantt-table-body', template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div class=\"gantt-table-column\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n" }]
1958
+ 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" }]
1945
1959
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1946
1960
  type: Inject,
1947
1961
  args: [GANTT_ABSTRACT_TOKEN]
@@ -2271,7 +2285,7 @@ class GanttLinksComponent {
2271
2285
  this.elementRef.nativeElement.style.visibility = 'hidden';
2272
2286
  });
2273
2287
  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)))
2274
- .pipe(skip(1), debounceTime$1(0), takeUntil(this.unsubscribe$))
2288
+ .pipe(skip(1), debounceTime(0), takeUntil(this.unsubscribe$))
2275
2289
  .subscribe(() => {
2276
2290
  this.elementRef.nativeElement.style.visibility = 'visible';
2277
2291
  this.buildLinks();
@@ -2541,7 +2555,7 @@ class GanttDomService {
2541
2555
  .subscribe(subscriber)));
2542
2556
  }
2543
2557
  getResize() {
2544
- return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime(150));
2558
+ return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime$1(150));
2545
2559
  }
2546
2560
  scrollMainContainer(left) {
2547
2561
  if (isNumber(left)) {
@@ -2994,18 +3008,6 @@ class GanttBarDrag {
2994
3008
  }
2995
3009
  });
2996
3010
  dragRef.ended.subscribe((event) => {
2997
- if (isBefore) {
2998
- const width = this.item.refs.width + event.distance.x * -1;
2999
- if (width <= dragMinWidth) {
3000
- this.item.updateDate(this.item.end.startOfDay(), this.item.end);
3001
- }
3002
- }
3003
- else {
3004
- const width = this.item.refs.width + event.distance.x;
3005
- if (width <= dragMinWidth) {
3006
- this.item.updateDate(this.item.start, this.item.start.endOfDay());
3007
- }
3008
- }
3009
3011
  this.clearDraggingStyles();
3010
3012
  this.closeDragBackdrop();
3011
3013
  event.source.reset();
@@ -3137,27 +3139,37 @@ class GanttBarDrag {
3137
3139
  const x = this.item.refs.x + distance;
3138
3140
  const width = this.item.refs.width + distance * -1;
3139
3141
  const start = this.ganttUpper.view.getDateByXPoint(x);
3140
- if (width > dragMinWidth) {
3142
+ const days = differenceInDays(this.item.end.value, start.value);
3143
+ if (!this.isStartOrEndInsideView(start, this.item.end)) {
3144
+ return;
3145
+ }
3146
+ if (width > dragMinWidth && days > 0) {
3141
3147
  this.barElement.style.width = width + 'px';
3142
3148
  this.barElement.style.left = x + 'px';
3143
3149
  this.openDragBackdrop(this.barElement, start, this.item.end);
3144
- if (!this.isStartOrEndInsideView(start, this.item.end)) {
3145
- return;
3146
- }
3147
3150
  this.item.updateDate(start, this.item.end);
3148
3151
  }
3152
+ else {
3153
+ this.openDragBackdrop(this.barElement, this.item.end.startOfDay(), this.item.end);
3154
+ this.item.updateDate(this.item.end.startOfDay(), this.item.end);
3155
+ }
3149
3156
  }
3150
3157
  else {
3151
3158
  const width = this.item.refs.width + distance;
3152
3159
  const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
3153
- if (width > dragMinWidth) {
3160
+ const days = differenceInDays(end.value, this.item.start.value);
3161
+ if (!this.isStartOrEndInsideView(this.item.start, end)) {
3162
+ return;
3163
+ }
3164
+ if (width > dragMinWidth && days > 0) {
3154
3165
  this.barElement.style.width = width + 'px';
3155
3166
  this.openDragBackdrop(this.barElement, this.item.start, end);
3156
- if (!this.isStartOrEndInsideView(this.item.start, end)) {
3157
- return;
3158
- }
3159
3167
  this.item.updateDate(this.item.start, end);
3160
3168
  }
3169
+ else {
3170
+ this.openDragBackdrop(this.barElement, this.item.start, this.item.start.endOfDay());
3171
+ this.item.updateDate(this.item.start, this.item.start.endOfDay());
3172
+ }
3161
3173
  }
3162
3174
  this.dragContainer.dragMoved.emit({ item: this.item.origin });
3163
3175
  }
@@ -3294,7 +3306,6 @@ class GanttItemUpper {
3294
3306
  this.refsUnsubscribe$.next();
3295
3307
  this.refsUnsubscribe$.complete();
3296
3308
  this.item = item;
3297
- this.setPositions();
3298
3309
  this.item.refs$.pipe(takeUntil(this.refsUnsubscribe$)).subscribe(() => {
3299
3310
  this.setPositions();
3300
3311
  });