@worktile/gantt 15.0.0 → 15.1.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/class/event.d.ts +13 -0
  2. package/class/item.d.ts +7 -1
  3. package/components/bar/bar-drag.d.ts +10 -0
  4. package/components/bar/bar.component.d.ts +2 -1
  5. package/components/bar/bar.component.scss +22 -0
  6. package/components/calendar/calendar.scss +91 -0
  7. package/components/calendar/grid/calendar-grid.component.d.ts +24 -0
  8. package/components/calendar/header/calendar-header.component.d.ts +21 -0
  9. package/components/icon/icons.d.ts +1 -0
  10. package/components/links/links.component.d.ts +5 -5
  11. package/components/loader/loader.component.d.ts +5 -0
  12. package/components/loader/loader.component.scss +90 -0
  13. package/components/main/gantt-main.component.d.ts +3 -3
  14. package/components/table/body/gantt-table-body.component.d.ts +58 -0
  15. package/components/table/gantt-table.component.scss +169 -85
  16. package/components/table/gantt-table.scss +271 -0
  17. package/components/table/header/gantt-table-header.component.d.ts +31 -0
  18. package/esm2020/class/event.mjs +5 -1
  19. package/esm2020/class/item.mjs +9 -4
  20. package/esm2020/components/bar/bar-drag.mjs +106 -42
  21. package/esm2020/components/bar/bar.component.mjs +8 -2
  22. package/esm2020/components/calendar/grid/calendar-grid.component.mjs +71 -0
  23. package/esm2020/components/calendar/header/calendar-header.component.mjs +67 -0
  24. package/esm2020/components/icon/icons.mjs +4 -2
  25. package/esm2020/components/links/links.component.mjs +72 -54
  26. package/esm2020/components/loader/loader.component.mjs +29 -0
  27. package/esm2020/components/main/gantt-main.component.mjs +5 -5
  28. package/esm2020/components/table/body/gantt-table-body.component.mjs +298 -0
  29. package/esm2020/components/table/header/gantt-table-header.component.mjs +140 -0
  30. package/esm2020/gantt-dom.service.mjs +8 -12
  31. package/esm2020/gantt-item-upper.mjs +15 -6
  32. package/esm2020/gantt-print.service.mjs +2 -2
  33. package/esm2020/gantt-upper.mjs +18 -15
  34. package/esm2020/gantt.component.mjs +143 -25
  35. package/esm2020/gantt.module.mjs +28 -10
  36. package/esm2020/public-api.mjs +2 -1
  37. package/esm2020/root.component.mjs +10 -8
  38. package/esm2020/table/gantt-table.component.mjs +12 -4
  39. package/esm2020/utils/helpers.mjs +11 -1
  40. package/fesm2015/worktile-gantt.mjs +969 -378
  41. package/fesm2015/worktile-gantt.mjs.map +1 -1
  42. package/fesm2020/worktile-gantt.mjs +959 -380
  43. package/fesm2020/worktile-gantt.mjs.map +1 -1
  44. package/gantt-dom.service.d.ts +1 -0
  45. package/gantt-item-upper.d.ts +3 -2
  46. package/gantt-upper.d.ts +4 -1
  47. package/gantt.component.d.ts +26 -8
  48. package/gantt.component.scss +39 -0
  49. package/gantt.module.d.ts +19 -15
  50. package/package.json +1 -1
  51. package/public-api.d.ts +1 -0
  52. package/root.component.d.ts +1 -1
  53. package/styles/index.scss +5 -2
  54. package/styles/variables.scss +12 -7
  55. package/table/gantt-table.component.d.ts +5 -2
  56. package/components/calendar/calendar.component.d.ts +0 -26
  57. package/components/table/gantt-table.component.d.ts +0 -42
  58. package/esm2020/components/calendar/calendar.component.mjs +0 -88
  59. package/esm2020/components/table/gantt-table.component.mjs +0 -166
@@ -1,16 +1,18 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Pipe, ViewChild, Injectable, PLATFORM_ID, ElementRef, Optional, SkipSelf, ViewChildren, 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, SkipSelf, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
- import { isPlatformServer, CommonModule } from '@angular/common';
5
- import { take, takeUntil, skip, debounceTime, map, pairwise, auditTime, startWith, switchMap, finalize } from 'rxjs/operators';
6
- import { BehaviorSubject, Subject, from, merge, fromEvent, Observable, EMPTY } from 'rxjs';
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';
7
7
  import { fromUnixTime, getWeek, getDaysInMonth, differenceInCalendarDays, setDate, addSeconds, addMinutes, addHours, addDays, addWeeks, addMonths, addQuarters, addYears, startOfDay, startOfWeek, startOfMonth, startOfQuarter, startOfYear, endOfDay, endOfWeek, endOfMonth, endOfQuarter, endOfYear, getUnixTime, format, isWeekend, isToday, differenceInDays, differenceInCalendarQuarters, eachMonthOfInterval, eachYearOfInterval, eachWeekOfInterval, eachDayOfInterval, differenceInCalendarYears } from 'date-fns';
8
8
  export { addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarQuarters, differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, endOfDay, endOfMonth, endOfQuarter, endOfWeek, endOfYear, format, fromUnixTime, getDaysInMonth, getUnixTime, getWeek, isToday, isWeekend, setDate, startOfDay, startOfMonth, startOfQuarter, startOfWeek, startOfYear } from 'date-fns';
9
9
  import { SelectionModel } from '@angular/cdk/collections';
10
10
  import { coerceBooleanProperty, coerceCssPixelValue } from '@angular/cdk/coercion';
11
- import * as i1$1 from '@angular/cdk/drag-drop';
12
- import { DragDropModule } from '@angular/cdk/drag-drop';
13
- import { __decorate, __param, __awaiter } from 'tslib';
11
+ import * as i3 from '@angular/cdk/scrolling';
12
+ import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
13
+ import { __awaiter, __decorate, __param } from 'tslib';
14
+ import * as i2 from '@angular/cdk/drag-drop';
15
+ import { CdkDrag, DragDropModule } from '@angular/cdk/drag-drop';
14
16
 
15
17
  class GanttDatePoint {
16
18
  constructor(start, text, x, y, additions, style) {
@@ -37,6 +39,10 @@ class GanttBarClickEvent {
37
39
  }
38
40
  class GanttSelectedEvent {
39
41
  }
42
+ class GanttTableDragDroppedEvent {
43
+ }
44
+ class GanttTableDragEnterPredicateContext {
45
+ }
40
46
 
41
47
  class GanttDate {
42
48
  constructor(date) {
@@ -225,7 +231,7 @@ class GanttItemInternal {
225
231
  get refs() {
226
232
  return this.refs$.getValue();
227
233
  }
228
- constructor(item, options) {
234
+ constructor(item, level, options) {
229
235
  this.refs$ = new BehaviorSubject(null);
230
236
  this.origin = item;
231
237
  this.id = this.origin.id;
@@ -244,14 +250,16 @@ class GanttItemInternal {
244
250
  this.barStyle = this.origin.barStyle;
245
251
  this.linkable = this.origin.linkable === undefined ? true : this.origin.linkable;
246
252
  this.draggable = this.origin.draggable === undefined ? true : this.origin.draggable;
253
+ this.itemDraggable = this.origin.itemDraggable;
247
254
  this.expandable = this.origin.expandable || (this.origin.children || []).length > 0;
248
255
  this.expanded = this.origin.expanded === undefined ? false : this.origin.expanded;
249
256
  this.start = item.start ? new GanttDate(item.start) : null;
250
257
  this.end = item.end ? new GanttDate(item.end) : null;
258
+ this.level = level;
251
259
  // 默认填充 30 天
252
260
  this.fillDays = (options === null || options === void 0 ? void 0 : options.fillDays) || 30;
253
261
  this.children = (item.children || []).map((subItem) => {
254
- return new GanttItemInternal(subItem, { fillDays: this.fillDays });
262
+ return new GanttItemInternal(subItem, level + 1, { fillDays: this.fillDays });
255
263
  });
256
264
  this.type = this.origin.type || GanttItemType.bar;
257
265
  this.progress = this.origin.progress;
@@ -278,10 +286,13 @@ class GanttItemInternal {
278
286
  this.origin.start = this.start.getUnixTime();
279
287
  this.origin.end = this.end.getUnixTime();
280
288
  }
289
+ updateLevel(level) {
290
+ this.level = level;
291
+ }
281
292
  addChildren(items) {
282
293
  this.origin.children = items;
283
294
  this.children = (items || []).map((subItem) => {
284
- return new GanttItemInternal(subItem, { fillDays: this.fillDays });
295
+ return new GanttItemInternal(subItem, this.level + 1, { fillDays: this.fillDays });
285
296
  });
286
297
  }
287
298
  setExpand(expanded) {
@@ -803,6 +814,16 @@ function flatten(array) {
803
814
  return pre.concat(Array.isArray(cur) ? flatten(cur) : cur);
804
815
  }, []);
805
816
  }
817
+ // export function recursiveItems(items: GanttItemInternal[]) {
818
+ // const result = [];
819
+ // (items || []).forEach((item) => {
820
+ // result.push(item);
821
+ // if (item.expanded && item.children) {
822
+ // result.push(...recursiveItems(item.children));
823
+ // }
824
+ // });
825
+ // return result;
826
+ // }
806
827
  function recursiveItems(items) {
807
828
  const result = [];
808
829
  (items || []).forEach((item) => {
@@ -890,6 +911,7 @@ class GanttUpper {
890
911
  this.barClick = new EventEmitter();
891
912
  this.viewChange = new EventEmitter();
892
913
  this.expandChange = new EventEmitter();
914
+ this.computeAllRefs = true;
893
915
  this.linkDragEnded = new EventEmitter();
894
916
  this.items = [];
895
917
  this.groups = [];
@@ -924,7 +946,7 @@ class GanttUpper {
924
946
  var _a;
925
947
  const group = this.groupsMap[origin.group_id];
926
948
  if (group) {
927
- const item = new GanttItemInternal(origin, { fillDays: (_a = this.view.options) === null || _a === void 0 ? void 0 : _a.fillDays });
949
+ const item = new GanttItemInternal(origin, 0, { fillDays: (_a = this.view.options) === null || _a === void 0 ? void 0 : _a.fillDays });
928
950
  group.items.push(item);
929
951
  }
930
952
  });
@@ -932,7 +954,7 @@ class GanttUpper {
932
954
  else {
933
955
  this.originItems.forEach((origin) => {
934
956
  var _a;
935
- const item = new GanttItemInternal(origin, { fillDays: (_a = this.view.options) === null || _a === void 0 ? void 0 : _a.fillDays });
957
+ const item = new GanttItemInternal(origin, 0, { fillDays: (_a = this.view.options) === null || _a === void 0 ? void 0 : _a.fillDays });
936
958
  this.items.push(item);
937
959
  });
938
960
  }
@@ -992,12 +1014,17 @@ class GanttUpper {
992
1014
  };
993
1015
  }
994
1016
  computeRefs() {
995
- this.groups.forEach((group) => {
996
- const groupItems = recursiveItems(group.items);
997
- this.computeItemsRefs(...groupItems);
998
- });
999
- const items = recursiveItems(this.items);
1000
- this.computeItemsRefs(...items);
1017
+ if (this.computeAllRefs) {
1018
+ this.groups.forEach((group) => {
1019
+ const groupItems = recursiveItems(group.items);
1020
+ this.computeItemsRefs(...groupItems);
1021
+ });
1022
+ const items = recursiveItems(this.items);
1023
+ this.computeItemsRefs(...items);
1024
+ }
1025
+ }
1026
+ initSelectionModel() {
1027
+ return new SelectionModel(this.multiple, []);
1001
1028
  }
1002
1029
  expandGroups(expanded) {
1003
1030
  this.groups.forEach((group) => {
@@ -1006,9 +1033,6 @@ class GanttUpper {
1006
1033
  this.expandChange.next(null);
1007
1034
  this.cdr.detectChanges();
1008
1035
  }
1009
- initSelectionModel() {
1010
- return new SelectionModel(this.multiple, []);
1011
- }
1012
1036
  ngOnInit() {
1013
1037
  this.styles = Object.assign({}, defaultStyles, this.styles);
1014
1038
  this.viewOptions.dateFormat = Object.assign({}, defaultConfig.dateFormat, this.config.dateFormat, this.viewOptions.dateFormat);
@@ -1036,8 +1060,8 @@ class GanttUpper {
1036
1060
  });
1037
1061
  this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1038
1062
  this.dragEnded.emit(event);
1039
- this.computeRefs();
1040
- this.detectChanges();
1063
+ // this.computeRefs();
1064
+ // this.detectChanges();
1041
1065
  });
1042
1066
  });
1043
1067
  });
@@ -1084,12 +1108,12 @@ class GanttUpper {
1084
1108
  detectChanges() {
1085
1109
  this.cdr.detectChanges();
1086
1110
  }
1111
+ // public functions
1087
1112
  expandGroup(group) {
1088
1113
  group.setExpand(!group.expanded);
1089
1114
  this.expandChange.emit(group);
1090
1115
  this.cdr.detectChanges();
1091
1116
  }
1092
- // public functions
1093
1117
  expandAll() {
1094
1118
  this.expandGroups(true);
1095
1119
  }
@@ -1251,18 +1275,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1251
1275
 
1252
1276
  class NgxGanttTableComponent {
1253
1277
  constructor() {
1278
+ this.draggable = false;
1279
+ this.dragDropped = new EventEmitter();
1254
1280
  this.columnChanges = new EventEmitter();
1255
1281
  }
1256
1282
  }
1257
1283
  NgxGanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1258
- NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableComponent, selector: "ngx-gantt-table", outputs: { columnChanges: "columnChanges" }, queries: [{ propertyName: "rowBeforeTemplate", first: true, predicate: ["rowBeforeSlot"], descendants: true, static: true }, { propertyName: "rowAfterTemplate", first: true, predicate: ["rowAfterSlot"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1284
+ NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableComponent, selector: "ngx-gantt-table", inputs: { draggable: "draggable", dropEnterPredicate: "dropEnterPredicate" }, outputs: { dragDropped: "dragDropped", columnChanges: "columnChanges" }, queries: [{ propertyName: "rowBeforeTemplate", first: true, predicate: ["rowBeforeSlot"], descendants: true, static: true }, { propertyName: "rowAfterTemplate", first: true, predicate: ["rowAfterSlot"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1259
1285
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableComponent, decorators: [{
1260
1286
  type: Component,
1261
1287
  args: [{
1262
1288
  selector: 'ngx-gantt-table',
1263
1289
  template: ''
1264
1290
  }]
1265
- }], propDecorators: { columnChanges: [{
1291
+ }], propDecorators: { draggable: [{
1292
+ type: Input
1293
+ }], dropEnterPredicate: [{
1294
+ type: Input
1295
+ }], dragDropped: [{
1296
+ type: Output
1297
+ }], columnChanges: [{
1266
1298
  type: Output
1267
1299
  }], rowBeforeTemplate: [{
1268
1300
  type: ContentChild,
@@ -1274,6 +1306,100 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1274
1306
 
1275
1307
  const GANTT_ABSTRACT_TOKEN = new InjectionToken('gantt-abstract-token');
1276
1308
 
1309
+ class GanttPrintService {
1310
+ constructor() { }
1311
+ setInlineStyles(targetElem) {
1312
+ const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
1313
+ for (const svgElement of svgElements) {
1314
+ this.recursElementChildren(svgElement);
1315
+ }
1316
+ }
1317
+ recursElementChildren(node) {
1318
+ const transformProperties = [
1319
+ 'fill',
1320
+ 'color',
1321
+ 'font-size',
1322
+ 'stroke',
1323
+ 'font',
1324
+ 'text-anchor',
1325
+ 'stroke-dasharray',
1326
+ 'shape-rendering',
1327
+ 'stroke-width'
1328
+ ];
1329
+ if (!node.style) {
1330
+ return;
1331
+ }
1332
+ const styles = getComputedStyle(node);
1333
+ for (const transformProperty of transformProperties) {
1334
+ node.style[transformProperty] = styles[transformProperty];
1335
+ }
1336
+ for (const child of Array.from(node.childNodes)) {
1337
+ this.recursElementChildren(child);
1338
+ }
1339
+ }
1340
+ register(root) {
1341
+ this.root = root.nativeElement;
1342
+ this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
1343
+ }
1344
+ print(name = 'download', ignoreElementClass) {
1345
+ return __awaiter(this, void 0, void 0, function* () {
1346
+ const root = this.root;
1347
+ const mainContainer = this.mainContainer;
1348
+ // set print width
1349
+ const printWidth = root.offsetWidth;
1350
+ // set print height
1351
+ const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
1352
+ const html2canvas = (yield import(/* webpackChunkName: 'html2canvas' */ 'html2canvas')).default;
1353
+ html2canvas(root, {
1354
+ logging: false,
1355
+ allowTaint: true,
1356
+ useCORS: true,
1357
+ width: printWidth,
1358
+ height: printHeight,
1359
+ ignoreElements: (element) => {
1360
+ if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
1361
+ return true;
1362
+ }
1363
+ if (element.classList.contains('gantt-calendar-today-overlay')) {
1364
+ return true;
1365
+ }
1366
+ },
1367
+ onclone: (cloneDocument) => {
1368
+ const ganttClass = root.className;
1369
+ const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
1370
+ const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
1371
+ const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-grid-main');
1372
+ const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
1373
+ // change targetDom width
1374
+ cloneGanttDom.style.width = `${printWidth}px`;
1375
+ cloneGanttDom.style.height = `${printHeight}px`;
1376
+ cloneGanttDom.style.overflow = `unset`;
1377
+ cloneGanttContainerDom.style.backgroundColor = '#fff';
1378
+ cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
1379
+ cloneCalendarOverlay.setAttribute('style', `background: transparent`);
1380
+ if (cloneLinksOverlay) {
1381
+ cloneLinksOverlay.setAttribute('height', `${printHeight}`);
1382
+ cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
1383
+ }
1384
+ // setInlineStyles for svg
1385
+ this.setInlineStyles(cloneGanttDom);
1386
+ }
1387
+ }).then((canvas) => {
1388
+ const link = document.createElement('a');
1389
+ const dataUrl = canvas.toDataURL('image/png');
1390
+ link.download = `${name}.png`;
1391
+ link.href = dataUrl;
1392
+ link.click();
1393
+ });
1394
+ });
1395
+ }
1396
+ }
1397
+ GanttPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttPrintService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1398
+ GanttPrintService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttPrintService });
1399
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttPrintService, decorators: [{
1400
+ type: Injectable
1401
+ }], ctorParameters: function () { return []; } });
1402
+
1277
1403
  const supports = (typeof window !== 'undefined' && !!window.CSS && CSS.supports) || (() => false);
1278
1404
  /**
1279
1405
  * Note: we don't need to add vendor prefixes within `.scss` files since they're added automatically.
@@ -1289,6 +1415,140 @@ function setStyleWithVendorPrefix({ element, style, value }) {
1289
1415
  }
1290
1416
  }
1291
1417
 
1418
+ const defaultColumnWidth = 100;
1419
+ const minColumnWidth = 80;
1420
+ class GanttTableHeaderComponent {
1421
+ constructor(elementRef, gantt, cdr) {
1422
+ this.elementRef = elementRef;
1423
+ this.gantt = gantt;
1424
+ this.cdr = cdr;
1425
+ this.tableWidth = 0;
1426
+ this.unsubscribe$ = new Subject();
1427
+ this.className = `gantt-table-header `;
1428
+ }
1429
+ ngOnInit() {
1430
+ this.columnsChange();
1431
+ this.columns.changes.pipe(takeUntil$1(this.unsubscribe$)).subscribe(() => {
1432
+ this.columnsChange();
1433
+ this.cdr.detectChanges();
1434
+ });
1435
+ }
1436
+ columnsChange() {
1437
+ let tableWidth = 0;
1438
+ this.columns.forEach((column) => {
1439
+ if (!column.columnWidth) {
1440
+ column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1441
+ }
1442
+ tableWidth += Number(column.columnWidth.replace('px', ''));
1443
+ });
1444
+ this.tableWidth = tableWidth;
1445
+ }
1446
+ dragFixed(config) {
1447
+ if (config.movedWidth < config.minWidth) {
1448
+ setStyleWithVendorPrefix({
1449
+ element: config.target,
1450
+ style: 'transform',
1451
+ value: `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`
1452
+ });
1453
+ }
1454
+ }
1455
+ onResizeStarted(event) {
1456
+ const target = event.source.element.nativeElement;
1457
+ this.dragStartLeft = target.getBoundingClientRect().left;
1458
+ }
1459
+ onResizeMoved(event, column) {
1460
+ const target = event.source.element.nativeElement;
1461
+ const left = target.getBoundingClientRect().left;
1462
+ let originWidth;
1463
+ let movedWidth;
1464
+ let minWidth;
1465
+ if (column) {
1466
+ originWidth = parseInt(column.columnWidth, 10);
1467
+ movedWidth = originWidth + (left - this.dragStartLeft);
1468
+ minWidth = minColumnWidth;
1469
+ }
1470
+ else {
1471
+ originWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
1472
+ movedWidth = originWidth + (left - this.dragStartLeft);
1473
+ minWidth = minColumnWidth * this.columns.length;
1474
+ }
1475
+ this.dragFixed({
1476
+ target,
1477
+ originWidth,
1478
+ movedWidth,
1479
+ minWidth
1480
+ });
1481
+ this.showAuxiliaryLine(event);
1482
+ }
1483
+ onResizeEnded(event, column) {
1484
+ const beforeWidth = parseInt(column.columnWidth, 10);
1485
+ const target = event.source.element.nativeElement;
1486
+ const left = target.getBoundingClientRect().left;
1487
+ const width = parseInt(column.columnWidth, 10) + (left - this.dragStartLeft);
1488
+ const columnWidth = Math.max(width || 0, minColumnWidth);
1489
+ column.columnWidth = coerceCssPixelValue(columnWidth);
1490
+ if (this.gantt.table) {
1491
+ this.gantt.table.columnChanges.emit({ columns: this.columns });
1492
+ }
1493
+ this.tableWidth = this.tableWidth - beforeWidth + columnWidth;
1494
+ this.hideAuxiliaryLine();
1495
+ event.source.reset();
1496
+ }
1497
+ onOverallResizeEnded(event) {
1498
+ const target = event.source.element.nativeElement;
1499
+ const left = target.getBoundingClientRect().left;
1500
+ const tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
1501
+ const dragWidth = left - this.dragStartLeft;
1502
+ let tempWidth = 0;
1503
+ this.columns.forEach((column) => {
1504
+ const lastColumnWidth = parseInt(column.columnWidth, 10);
1505
+ const distributeWidth = parseInt(String(dragWidth * (lastColumnWidth / tableWidth)), 10);
1506
+ const columnWidth = Math.max(lastColumnWidth + distributeWidth || 0, minColumnWidth);
1507
+ column.columnWidth = coerceCssPixelValue(columnWidth);
1508
+ tempWidth += columnWidth;
1509
+ });
1510
+ this.tableWidth = tempWidth;
1511
+ if (this.gantt.table) {
1512
+ this.gantt.table.columnChanges.emit({ columns: this.columns });
1513
+ }
1514
+ this.hideAuxiliaryLine();
1515
+ event.source.reset();
1516
+ }
1517
+ showAuxiliaryLine(event) {
1518
+ const tableRect = this.elementRef.nativeElement.getBoundingClientRect();
1519
+ const targetRect = event.source.element.nativeElement.getBoundingClientRect();
1520
+ const distance = { x: targetRect.left - tableRect.left, y: targetRect.top - tableRect.top };
1521
+ this.resizeLineElementRef.nativeElement.style.left = `${distance.x}px`;
1522
+ this.resizeLineElementRef.nativeElement.style.display = 'block';
1523
+ }
1524
+ hideAuxiliaryLine() {
1525
+ this.resizeLineElementRef.nativeElement.style.display = 'none';
1526
+ }
1527
+ ngOnDestroy() {
1528
+ this.unsubscribe$.next();
1529
+ this.unsubscribe$.complete();
1530
+ }
1531
+ }
1532
+ GanttTableHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableHeaderComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_ABSTRACT_TOKEN }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1533
+ GanttTableHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttTableHeaderComponent, selector: "gantt-table-header", inputs: { columns: "columns" }, host: { properties: { "class": "this.className" } }, viewQueries: [{ propertyName: "resizeLineElementRef", first: true, predicate: ["resizeLine"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"d-flex\">\n <div class=\"gantt-table-column\" *ngFor=\"let column of columns; let i = index\" [style.width]=\"column.columnWidth\">\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"> </ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"column-resize-handle\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"onResizeMoved($event, column)\"\n (cdkDragStarted)=\"onResizeStarted($event)\"\n (cdkDragEnded)=\"onResizeEnded($event, column)\"\n ></div>\n </div>\n</div>\n\n<div\n class=\"table-resize-handle\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"onResizeMoved($event)\"\n (cdkDragStarted)=\"onResizeStarted($event)\"\n (cdkDragEnded)=\"onOverallResizeEnded($event)\"\n></div>\n\n<div #resizeLine class=\"table-resize-auxiliary-line\"></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"] }, { 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"] }] });
1534
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableHeaderComponent, decorators: [{
1535
+ type: Component,
1536
+ args: [{ selector: 'gantt-table-header', template: "<div class=\"d-flex\">\n <div class=\"gantt-table-column\" *ngFor=\"let column of columns; let i = index\" [style.width]=\"column.columnWidth\">\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"> </ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"column-resize-handle\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"onResizeMoved($event, column)\"\n (cdkDragStarted)=\"onResizeStarted($event)\"\n (cdkDragEnded)=\"onResizeEnded($event, column)\"\n ></div>\n </div>\n</div>\n\n<div\n class=\"table-resize-handle\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"onResizeMoved($event)\"\n (cdkDragStarted)=\"onResizeStarted($event)\"\n (cdkDragEnded)=\"onOverallResizeEnded($event)\"\n></div>\n\n<div #resizeLine class=\"table-resize-auxiliary-line\"></div>\n" }]
1537
+ }], ctorParameters: function () {
1538
+ return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
1539
+ type: Inject,
1540
+ args: [GANTT_ABSTRACT_TOKEN]
1541
+ }] }, { type: i0.ChangeDetectorRef }];
1542
+ }, propDecorators: { columns: [{
1543
+ type: Input
1544
+ }], resizeLineElementRef: [{
1545
+ type: ViewChild,
1546
+ args: ['resizeLine', { static: true }]
1547
+ }], className: [{
1548
+ type: HostBinding,
1549
+ args: ['class']
1550
+ }] } });
1551
+
1292
1552
  const angleRight = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="amnavigation/angle-right" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.498l-.005.005L2.3 5.831 3.13 5l4.848 4.848L12.826 5l.83.831-5.673 5.672-.005-.005z" transform="rotate(-90 7.978 8.252)"></path></g></svg>`;
1293
1553
  const angleDown = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="aknavigation/angle-down" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.997l-.005.006L2.3 6.33l.83-.831 4.848 4.848L12.826 5.5l.83.83-5.673 5.673-.005-.006z" ></path></g></svg>`;
1294
1554
  const plusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="kxaction/plus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm5.45 6.2V4.75h1.2V7.4h2.65v1.2H8.65v2.65h-1.2V8.6H4.8V7.4h2.65z"></path></g></svg>`;
@@ -1367,13 +1627,15 @@ xmlns:xlink="http://www.w3.org/1999/xlink"
1367
1627
  </g>
1368
1628
  </g>
1369
1629
  </svg>`;
1630
+ const dragIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="aijaction/drag--" stroke-width="1" fill-rule="evenodd"><g id="aij拖动" transform="translate(5 1)" fill-rule="nonzero"><path d="M1 2a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm4 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2zM1 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm4 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm-4 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm4 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm-4 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm4 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2z" id="aij形状结合"></path></g></g></svg>`;
1370
1631
  const icons = {
1371
1632
  'angle-right': angleRight,
1372
1633
  'angle-down': angleDown,
1373
1634
  'plus-square': plusSquare,
1374
1635
  'minus-square': minusSquare,
1375
1636
  loading: loadingIcon,
1376
- empty: emptyIcon
1637
+ empty: emptyIcon,
1638
+ drag: dragIcon
1377
1639
  };
1378
1640
 
1379
1641
  class GanttIconComponent {
@@ -1449,47 +1711,68 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1449
1711
  }]
1450
1712
  }] });
1451
1713
 
1452
- const defaultColumnWidth = 100;
1453
- const minColumnWidth = 80;
1454
- class GanttTableComponent {
1455
- set columns(columns) {
1456
- this.hasShowExpandIcon = false;
1457
- columns.forEach((column) => {
1458
- if (!column.columnWidth) {
1459
- column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1460
- }
1461
- if (column.showExpandIcon) {
1462
- this.hasShowExpandIcon = true;
1463
- }
1464
- });
1465
- this.columnList = columns;
1714
+ class GanttTableBodyComponent {
1715
+ set renderData(data) {
1716
+ const firstData = data[0];
1717
+ if (firstData && firstData.hasOwnProperty('items')) {
1718
+ this.hasGroup = true;
1719
+ }
1720
+ this.ganttTableEmptyClass = (data === null || data === void 0 ? void 0 : data.length) ? false : true;
1721
+ this._renderData = data;
1466
1722
  }
1467
- constructor(gantt, ganttUpper, elementRef) {
1723
+ get renderData() {
1724
+ return this._renderData;
1725
+ }
1726
+ constructor(gantt, ganttUpper, cdr, document) {
1468
1727
  this.gantt = gantt;
1469
1728
  this.ganttUpper = ganttUpper;
1470
- this.elementRef = elementRef;
1471
- this.hasShowExpandIcon = false;
1729
+ this.cdr = cdr;
1730
+ this.document = document;
1731
+ this.draggable = false;
1732
+ this.dragDropped = new EventEmitter();
1472
1733
  this.itemClick = new EventEmitter();
1473
1734
  this.ganttTableClass = true;
1474
1735
  this.ganttTableEmptyClass = false;
1736
+ this.ganttTableDragging = false;
1737
+ this.hasExpandIcon = false;
1738
+ // 缓存 Element 和 DragRef 的关系,方便在 Item 拖动时查找
1739
+ this.itemDragRefMap = new Map();
1740
+ this.itemDragMoved = new Subject();
1741
+ this.destroy$ = new Subject();
1475
1742
  }
1476
- ngOnChanges(changes) {
1477
- var _a, _b;
1478
- if (!((_a = changes.groups.currentValue) === null || _a === void 0 ? void 0 : _a.length) && !((_b = changes.items.currentValue) === null || _b === void 0 ? void 0 : _b.length)) {
1479
- this.ganttTableEmptyClass = true;
1480
- }
1481
- else {
1482
- this.ganttTableEmptyClass = false;
1483
- }
1743
+ ngOnInit() {
1744
+ this.columns.changes.pipe(startWith(this.columns), takeUntil$1(this.destroy$)).subscribe(() => {
1745
+ this.hasExpandIcon = false;
1746
+ this.columns.forEach((column) => {
1747
+ if (!column.columnWidth) {
1748
+ column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1749
+ }
1750
+ if (column.showExpandIcon) {
1751
+ this.hasExpandIcon = true;
1752
+ }
1753
+ });
1754
+ this.cdr.detectChanges();
1755
+ });
1484
1756
  }
1485
- dragFixed(config) {
1486
- if (config.movedWidth < config.minWidth) {
1487
- setStyleWithVendorPrefix({
1488
- element: config.target,
1489
- style: 'transform',
1490
- value: `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`
1757
+ ngAfterViewInit() {
1758
+ this.cdkDrags.changes
1759
+ .pipe(startWith(this.cdkDrags), takeUntil$1(this.destroy$))
1760
+ .subscribe((drags) => {
1761
+ this.itemDragRefMap.clear();
1762
+ drags.forEach((drag) => {
1763
+ if (drag.data) {
1764
+ // cdkDrag 变化时,缓存 Element 与 DragRef 的关系,方便 Drag Move 时查找
1765
+ this.itemDragRefMap.set(drag.element.nativeElement, drag);
1766
+ }
1491
1767
  });
1492
- }
1768
+ });
1769
+ this.itemDragMoved
1770
+ .pipe(debounceTime(30),
1771
+ // debounce 可能会导致拖动结束后仍然执行 moved ,所以通过判断 dragging 状态来过滤无效 moved
1772
+ filter((event) => event.source._dragRef.isDragging()), takeUntil$1(this.destroy$))
1773
+ .subscribe((event) => {
1774
+ this.onItemDragMoved(event);
1775
+ });
1493
1776
  }
1494
1777
  expandGroup(group) {
1495
1778
  this.gantt.expandGroup(group);
@@ -1498,80 +1781,176 @@ class GanttTableComponent {
1498
1781
  event.stopPropagation();
1499
1782
  this.gantt.expandChildren(item);
1500
1783
  }
1501
- dragStarted(event) {
1502
- const target = event.source.element.nativeElement;
1503
- this.dragStartLeft = target.getBoundingClientRect().left;
1784
+ onItemDragStarted(event) {
1785
+ this.ganttTableDragging = true;
1786
+ // 拖动开始时隐藏所有的子项
1787
+ const children = this.getChildrenElementsByElement(event.source.getPlaceholderElement());
1788
+ children.forEach((element) => {
1789
+ element.classList.add('drag-item-hide');
1790
+ });
1504
1791
  }
1505
- dragMoved(event, column) {
1506
- const target = event.source.element.nativeElement;
1507
- const left = target.getBoundingClientRect().left;
1508
- let originWidth;
1509
- let movedWidth;
1510
- let minWidth;
1511
- if (column) {
1512
- originWidth = parseInt(column.columnWidth, 10);
1513
- movedWidth = originWidth + (left - this.dragStartLeft);
1514
- minWidth = minColumnWidth;
1792
+ emitItemDragMoved(event) {
1793
+ this.itemDragMoved.next(event);
1794
+ }
1795
+ onItemDragMoved(event) {
1796
+ var _a;
1797
+ // 通过鼠标位置查找对应的目标 Item 元素
1798
+ let currentPointElement = this.document.elementFromPoint(event.pointerPosition.x, event.pointerPosition.y);
1799
+ if (!currentPointElement) {
1800
+ this.cleanupDragArtifacts();
1801
+ return;
1802
+ }
1803
+ let targetElement = currentPointElement.classList.contains('gantt-table-item')
1804
+ ? currentPointElement
1805
+ : currentPointElement.closest('.gantt-table-item');
1806
+ if (!targetElement) {
1807
+ this.cleanupDragArtifacts();
1808
+ return;
1809
+ }
1810
+ // 缓存放置目标Id 并计算鼠标相对应的位置
1811
+ this.itemDropTarget = {
1812
+ id: (_a = this.itemDragRefMap.get(targetElement)) === null || _a === void 0 ? void 0 : _a.data.id,
1813
+ position: this.getTargetPosition(targetElement, event)
1814
+ };
1815
+ // 执行外部传入的 dropEnterPredicate 判断是否允许拖入目标项
1816
+ if (this.dropEnterPredicate) {
1817
+ const targetDragRef = this.itemDragRefMap.get(targetElement);
1818
+ if (this.dropEnterPredicate({
1819
+ source: event.source.data.origin,
1820
+ target: targetDragRef.data.origin,
1821
+ dropPosition: this.itemDropTarget.position
1822
+ })) {
1823
+ this.showDropPositionPlaceholder(targetElement);
1824
+ }
1825
+ else {
1826
+ this.itemDropTarget = null;
1827
+ }
1515
1828
  }
1516
1829
  else {
1517
- originWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
1518
- movedWidth = originWidth + (left - this.dragStartLeft);
1519
- minWidth = minColumnWidth * this.columnList.length;
1830
+ this.showDropPositionPlaceholder(targetElement);
1520
1831
  }
1521
- this.dragFixed({
1522
- target,
1523
- originWidth,
1524
- movedWidth,
1525
- minWidth
1832
+ }
1833
+ onItemDragEnded(event) {
1834
+ this.ganttTableDragging = false;
1835
+ }
1836
+ onListDropped(event) {
1837
+ var _a, _b;
1838
+ if (!this.itemDropTarget) {
1839
+ return;
1840
+ }
1841
+ const targetDragRef = this.cdkDrags.find((item) => { var _a; return ((_a = item.data) === null || _a === void 0 ? void 0 : _a.id) === this.itemDropTarget.id; });
1842
+ const sourceItem = event.item.data;
1843
+ const targetItem = targetDragRef === null || targetDragRef === void 0 ? void 0 : targetDragRef.data;
1844
+ this.removeItem(sourceItem);
1845
+ switch (this.itemDropTarget.position) {
1846
+ case 'before':
1847
+ case 'after':
1848
+ this.insertItem(targetItem, sourceItem, this.itemDropTarget.position);
1849
+ sourceItem.updateLevel(targetItem.level);
1850
+ break;
1851
+ case 'inside':
1852
+ this.insertChildrenItem(targetItem, sourceItem);
1853
+ sourceItem.updateLevel(targetItem.level + 1);
1854
+ break;
1855
+ }
1856
+ this.dragDropped.emit({
1857
+ source: sourceItem.origin,
1858
+ sourceParent: (_a = this.getParentByItem(sourceItem)) === null || _a === void 0 ? void 0 : _a.origin,
1859
+ target: targetItem.origin,
1860
+ targetParent: (_b = this.getParentByItem(targetItem)) === null || _b === void 0 ? void 0 : _b.origin,
1861
+ dropPosition: this.itemDropTarget.position
1526
1862
  });
1527
- this.showAuxiliaryLine(event);
1863
+ this.cleanupDragArtifacts(true);
1528
1864
  }
1529
- columnDragEnded(event, column) {
1530
- const target = event.source.element.nativeElement;
1531
- const left = target.getBoundingClientRect().left;
1532
- const width = parseInt(column.columnWidth, 10) + (left - this.dragStartLeft);
1533
- const columnWidth = Math.max(width || 0, minColumnWidth);
1534
- column.columnWidth = coerceCssPixelValue(columnWidth);
1535
- if (this.gantt.table) {
1536
- this.gantt.table.columnChanges.emit({ columns: this.columnList });
1865
+ trackBy(index, item) {
1866
+ return item.id || index;
1867
+ }
1868
+ ngOnDestroy() {
1869
+ this.destroy$.next();
1870
+ this.destroy$.complete();
1871
+ }
1872
+ removeItem(item) {
1873
+ this.renderData.splice(this.renderData.indexOf(item), 1);
1874
+ this.flatData.splice(this.flatData.indexOf(item), 1);
1875
+ }
1876
+ insertItem(target, inserted, position) {
1877
+ var _a;
1878
+ if (position === 'before') {
1879
+ this.renderData.splice(this.renderData.indexOf(target), 0, inserted);
1880
+ this.flatData.splice(this.flatData.indexOf(target), 0, inserted);
1881
+ }
1882
+ else {
1883
+ const dragRef = this.cdkDrags.find((drag) => drag.data === target);
1884
+ // 如果目标项是展开的,插入的 index 位置需要考虑子项的数量
1885
+ let childrenCount = 0;
1886
+ if (target.expanded) {
1887
+ childrenCount = ((_a = this.getChildrenElementsByElement(dragRef.element.nativeElement)) === null || _a === void 0 ? void 0 : _a.length) || 0;
1888
+ }
1889
+ this.renderData.splice(this.renderData.indexOf(target) + 1 + childrenCount, 0, inserted);
1890
+ this.flatData.splice(this.flatData.indexOf(target) + 1 + childrenCount, 0, inserted);
1537
1891
  }
1538
- this.hideAuxiliaryLine();
1539
- event.source.reset();
1540
1892
  }
1541
- tableDragEnded(event) {
1542
- const target = event.source.element.nativeElement;
1543
- const left = target.getBoundingClientRect().left;
1544
- const tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
1545
- const dragWidth = left - this.dragStartLeft;
1546
- this.columnList.forEach((column) => {
1547
- const lastColumnWidth = parseInt(column.columnWidth, 10);
1548
- const distributeWidth = parseInt(String(dragWidth * (lastColumnWidth / tableWidth)), 10);
1549
- const columnWidth = Math.max(lastColumnWidth + distributeWidth || 0, minColumnWidth);
1550
- column.columnWidth = coerceCssPixelValue(columnWidth);
1893
+ insertChildrenItem(target, inserted) {
1894
+ if (target.expanded) {
1895
+ this.renderData.splice(this.renderData.indexOf(target) + target.children.length + 1, 0, inserted);
1896
+ this.flatData.splice(this.flatData.indexOf(target) + target.children.length + 1, 0, inserted);
1897
+ }
1898
+ target.children.push(inserted);
1899
+ }
1900
+ getParentByItem(item) {
1901
+ return (this.flatData || []).find((n) => {
1902
+ var _a;
1903
+ return (_a = n.children) === null || _a === void 0 ? void 0 : _a.includes(item);
1551
1904
  });
1552
- if (this.gantt.table) {
1553
- this.gantt.table.columnChanges.emit({ columns: this.columnList });
1905
+ }
1906
+ getChildrenElementsByElement(element) {
1907
+ // 通过循环持续查找 next element,如果 element 的 level 小于当前 item 的 level,则为它的 children
1908
+ const children = [];
1909
+ const dragRef = this.itemDragRefMap.get(element);
1910
+ let nextElement = element.nextElementSibling;
1911
+ let nextDragRef = this.itemDragRefMap.get(nextElement);
1912
+ while (nextDragRef && nextDragRef.data.level > dragRef.data.level) {
1913
+ children.push(nextElement);
1914
+ nextElement = nextElement.nextElementSibling;
1915
+ nextDragRef = this.itemDragRefMap.get(nextElement);
1554
1916
  }
1555
- this.hideAuxiliaryLine();
1556
- event.source.reset();
1917
+ return children;
1557
1918
  }
1558
- showAuxiliaryLine(event) {
1559
- const tableRect = this.elementRef.nativeElement.getBoundingClientRect();
1560
- this.draglineElementRef.nativeElement.style.left = `${event.event.clientX - tableRect.left}px`;
1561
- this.draglineElementRef.nativeElement.style.display = 'block';
1919
+ getTargetPosition(target, event) {
1920
+ const targetRect = target.getBoundingClientRect();
1921
+ const beforeOrAfterGap = targetRect.height * 0.3;
1922
+ // Item 高度分为上中下三段,其中上下的 Gap 为 height 的 30%,通过判断鼠标位置在哪一段 gap 来计算对应的位置
1923
+ if (event.pointerPosition.y - targetRect.top < beforeOrAfterGap) {
1924
+ return 'before';
1925
+ }
1926
+ else if (event.pointerPosition.y >= targetRect.bottom - beforeOrAfterGap) {
1927
+ return 'after';
1928
+ }
1929
+ else {
1930
+ return 'inside';
1931
+ }
1562
1932
  }
1563
- hideAuxiliaryLine() {
1564
- this.draglineElementRef.nativeElement.style.display = 'none';
1933
+ showDropPositionPlaceholder(targetElement) {
1934
+ this.cleanupDragArtifacts();
1935
+ if (this.itemDropTarget && targetElement) {
1936
+ targetElement.classList.add(`drop-position-${this.itemDropTarget.position}`);
1937
+ }
1565
1938
  }
1566
- trackBy(index, item) {
1567
- return item.id || index;
1939
+ cleanupDragArtifacts(dropped = false) {
1940
+ if (dropped) {
1941
+ this.itemDropTarget = null;
1942
+ }
1943
+ this.document.querySelectorAll('.drop-position-before').forEach((element) => element.classList.remove('drop-position-before'));
1944
+ this.document.querySelectorAll('.drop-position-after').forEach((element) => element.classList.remove('drop-position-after'));
1945
+ this.document.querySelectorAll('.drop-position-inside').forEach((element) => element.classList.remove('drop-position-inside'));
1946
+ this.document.querySelectorAll('.drag-item-hide').forEach((element) => element.classList.remove('drop-item-hide'));
1568
1947
  }
1569
1948
  }
1570
- GanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableComponent, deps: [{ token: GANTT_ABSTRACT_TOKEN }, { token: GANTT_UPPER_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1571
- GanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttTableComponent, selector: "gantt-table", inputs: { groups: "groups", items: "items", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate", rowBeforeTemplate: "rowBeforeTemplate", rowAfterTemplate: "rowAfterTemplate" }, outputs: { itemClick: "itemClick" }, host: { properties: { "class.gantt-table": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass" } }, viewQueries: [{ propertyName: "draglineElementRef", first: true, predicate: ["dragLine"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-table-header gantt-table-row\">\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let i = index\" [style.width]=\"column.columnWidth\">\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"></ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event, column)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"columnDragEnded($event, column)\"\n ></div>\n </div>\n</div>\n<div class=\"gantt-table-body\">\n <ng-container *ngIf=\"!groups.length && !items.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"groups && groups.length > 0; else itemsTemplate\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"group.class\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"group.expanded\" (click)=\"expandGroup(group)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"group.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: group.origin, group: group.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ group.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <ng-container *ngIf=\"group.expanded\">\n <ng-template\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ group: group, items: group.items, level: 0 }\"\n ></ng-template>\n </ng-container>\n </ng-container>\n </ng-container>\n</div>\n\n<div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"tableDragEnded($event)\"\n></div>\n\n<div #dragLine class=\"gantt-table-drag-auxiliary-line\"></div>\n\n<ng-template #itemsTemplate>\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items, level: 0 }\"></ng-template>\n</ng-template>\n\n<ng-template #ganttItems let-group=\"group\" let-items=\"items\" let-level=\"level\">\n <ng-container *ngFor=\"let item of items; trackBy: trackBy\">\n <div\n (click)=\"itemClick.emit({ event: $event, selectedValue: this.item.origin })\"\n class=\"gantt-table-item gantt-table-row\"\n [class.gantt-table-item-first-level-group]=\"level === 0 && (item.type | isGanttRangeItem)\"\n [class.gantt-table-item-with-group]=\"group\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let first = first\" [style.width]=\"column.columnWidth\">\n <div *ngIf=\"column?.showExpandIcon || (!hasShowExpandIcon && first)\" class=\"gantt-expand-icon\" [style.marginLeft.px]=\"level * 20\">\n <ng-container *ngIf=\"level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n ></gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children, level: level + 1, group: group }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n", 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: i1$1.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: "component", type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }] });
1572
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableComponent, decorators: [{
1949
+ 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 });
1950
+ 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" }] });
1951
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableBodyComponent, decorators: [{
1573
1952
  type: Component,
1574
- args: [{ selector: 'gantt-table', template: "<div class=\"gantt-table-header gantt-table-row\">\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let i = index\" [style.width]=\"column.columnWidth\">\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"></ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event, column)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"columnDragEnded($event, column)\"\n ></div>\n </div>\n</div>\n<div class=\"gantt-table-body\">\n <ng-container *ngIf=\"!groups.length && !items.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"groups && groups.length > 0; else itemsTemplate\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"group.class\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"group.expanded\" (click)=\"expandGroup(group)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"group.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: group.origin, group: group.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ group.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <ng-container *ngIf=\"group.expanded\">\n <ng-template\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ group: group, items: group.items, level: 0 }\"\n ></ng-template>\n </ng-container>\n </ng-container>\n </ng-container>\n</div>\n\n<div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"tableDragEnded($event)\"\n></div>\n\n<div #dragLine class=\"gantt-table-drag-auxiliary-line\"></div>\n\n<ng-template #itemsTemplate>\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items, level: 0 }\"></ng-template>\n</ng-template>\n\n<ng-template #ganttItems let-group=\"group\" let-items=\"items\" let-level=\"level\">\n <ng-container *ngFor=\"let item of items; trackBy: trackBy\">\n <div\n (click)=\"itemClick.emit({ event: $event, selectedValue: this.item.origin })\"\n class=\"gantt-table-item gantt-table-row\"\n [class.gantt-table-item-first-level-group]=\"level === 0 && (item.type | isGanttRangeItem)\"\n [class.gantt-table-item-with-group]=\"group\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let first = first\" [style.width]=\"column.columnWidth\">\n <div *ngIf=\"column?.showExpandIcon || (!hasShowExpandIcon && first)\" class=\"gantt-expand-icon\" [style.marginLeft.px]=\"level * 20\">\n <ng-container *ngIf=\"level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n ></gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children, level: level + 1, group: group }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n" }]
1953
+ 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" }]
1575
1954
  }], ctorParameters: function () {
1576
1955
  return [{ type: undefined, decorators: [{
1577
1956
  type: Inject,
@@ -1579,10 +1958,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1579
1958
  }] }, { type: GanttUpper, decorators: [{
1580
1959
  type: Inject,
1581
1960
  args: [GANTT_UPPER_TOKEN]
1582
- }] }, { type: i0.ElementRef }];
1583
- }, propDecorators: { groups: [{
1961
+ }] }, { type: i0.ChangeDetectorRef }, { type: Document, decorators: [{
1962
+ type: Inject,
1963
+ args: [DOCUMENT]
1964
+ }] }];
1965
+ }, propDecorators: { renderData: [{
1584
1966
  type: Input
1585
- }], items: [{
1967
+ }], flatData: [{
1586
1968
  type: Input
1587
1969
  }], columns: [{
1588
1970
  type: Input
@@ -1594,17 +1976,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1594
1976
  type: Input
1595
1977
  }], rowAfterTemplate: [{
1596
1978
  type: Input
1979
+ }], draggable: [{
1980
+ type: HostBinding,
1981
+ args: ['class.gantt-table-draggable']
1982
+ }, {
1983
+ type: Input
1984
+ }], dropEnterPredicate: [{
1985
+ type: Input
1986
+ }], dragDropped: [{
1987
+ type: Output
1597
1988
  }], itemClick: [{
1598
1989
  type: Output
1599
- }], draglineElementRef: [{
1600
- type: ViewChild,
1601
- args: ['dragLine', { static: true }]
1602
1990
  }], ganttTableClass: [{
1603
1991
  type: HostBinding,
1604
- args: ['class.gantt-table']
1992
+ args: ['class.gantt-table-body']
1605
1993
  }], ganttTableEmptyClass: [{
1606
1994
  type: HostBinding,
1607
1995
  args: ['class.gantt-table-empty']
1996
+ }], ganttTableDragging: [{
1997
+ type: HostBinding,
1998
+ args: ['class.gantt-table-dragging']
1999
+ }], cdkDrags: [{
2000
+ type: ViewChildren,
2001
+ args: [(CdkDrag)]
1608
2002
  }] } });
1609
2003
 
1610
2004
  class GanttLinkLine {
@@ -1864,13 +2258,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1864
2258
  } });
1865
2259
 
1866
2260
  class GanttLinksComponent {
1867
- constructor(ganttUpper, cdr, elementRef, ganttDragContainer) {
2261
+ constructor(ganttUpper, cdr, elementRef, ganttDragContainer, ngZone) {
1868
2262
  this.ganttUpper = ganttUpper;
1869
2263
  this.cdr = cdr;
1870
2264
  this.elementRef = elementRef;
1871
2265
  this.ganttDragContainer = ganttDragContainer;
1872
- this.groups = [];
1873
- this.items = [];
2266
+ this.ngZone = ngZone;
2267
+ // @Input() groups: GanttGroupInternal[] = [];
2268
+ // @Input() items: GanttItemInternal[] = [];
2269
+ this.flatData = [];
1874
2270
  this.lineClick = new EventEmitter();
1875
2271
  this.links = [];
1876
2272
  this.ganttLinkTypes = GanttLinkType;
@@ -1883,13 +2279,14 @@ class GanttLinksComponent {
1883
2279
  ngOnInit() {
1884
2280
  this.linkLine = createLineGenerator(this.ganttUpper.linkOptions.lineType, this.ganttUpper);
1885
2281
  this.showArrow = this.ganttUpper.linkOptions.showArrow;
1886
- this.buildLinks();
2282
+ // this.buildLinks();
1887
2283
  this.firstChange = false;
2284
+ this.buildLinks();
1888
2285
  this.ganttDragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1889
2286
  this.elementRef.nativeElement.style.visibility = 'hidden';
1890
2287
  });
1891
- merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded)
1892
- .pipe(skip(1), debounceTime(0), takeUntil(this.unsubscribe$))
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(() => { var _a; return ((_a = this.ganttUpper.table) === null || _a === void 0 ? void 0 : _a.dragDropped) || EMPTY; })))
2289
+ .pipe(skip(1), debounceTime$1(0), takeUntil(this.unsubscribe$))
1893
2290
  .subscribe(() => {
1894
2291
  this.elementRef.nativeElement.style.visibility = 'visible';
1895
2292
  this.buildLinks();
@@ -1905,40 +2302,62 @@ class GanttLinksComponent {
1905
2302
  const lineHeight = this.ganttUpper.styles.lineHeight;
1906
2303
  const barHeight = this.ganttUpper.styles.barHeight;
1907
2304
  this.linkItems = [];
1908
- if (this.groups.length > 0) {
1909
- let itemNum = 0;
1910
- let groupNum = 0;
1911
- this.groups.forEach((group) => {
1912
- groupNum++;
1913
- if (group.expanded) {
1914
- const items = recursiveItems(group.items);
1915
- items.forEach((item, itemIndex) => {
1916
- const y = (groupNum + itemNum + itemIndex) * lineHeight + item.refs.y + barHeight / 2;
1917
- this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
1918
- x: item.refs.x,
1919
- y
1920
- }, after: {
1921
- x: item.refs.x + item.refs.width,
1922
- y
1923
- } }));
1924
- });
1925
- itemNum += items.length;
2305
+ // if (this.groups.length > 0) {
2306
+ // let itemNum = 0;
2307
+ // let groupNum = 0;
2308
+ // this.groups.forEach((group) => {
2309
+ // groupNum++;
2310
+ // if (group.expanded) {
2311
+ // const items = recursiveItems(group.items);
2312
+ // items.forEach((item, itemIndex) => {
2313
+ // const y = (groupNum + itemNum + itemIndex) * lineHeight + item.refs.y + barHeight / 2;
2314
+ // this.linkItems.push({
2315
+ // ...item,
2316
+ // before: {
2317
+ // x: item.refs.x,
2318
+ // y
2319
+ // },
2320
+ // after: {
2321
+ // x: item.refs.x + item.refs.width,
2322
+ // y
2323
+ // }
2324
+ // });
2325
+ // });
2326
+ // itemNum += items.length;
2327
+ // }
2328
+ // });
2329
+ // } else {
2330
+ // const items = recursiveItems(this.items);
2331
+ // items.forEach((item, itemIndex) => {
2332
+ // const y = itemIndex * lineHeight + item.refs.y + barHeight / 2;
2333
+ // this.linkItems.push({
2334
+ // ...item,
2335
+ // before: {
2336
+ // x: item.refs.x,
2337
+ // y
2338
+ // },
2339
+ // after: {
2340
+ // x: item.refs.x + item.refs.width,
2341
+ // y
2342
+ // }
2343
+ // });
2344
+ // });
2345
+ // }
2346
+ this.flatData.forEach((item, itemIndex) => {
2347
+ if (!item.hasOwnProperty('items')) {
2348
+ const ganttItem = item;
2349
+ if (ganttItem.refs) {
2350
+ const y = itemIndex * lineHeight + ganttItem.refs.y + barHeight / 2;
2351
+ this.linkItems.push(Object.assign(Object.assign({}, ganttItem), { before: {
2352
+ x: ganttItem.refs.x,
2353
+ y
2354
+ }, after: {
2355
+ x: ganttItem.refs.x + ganttItem.refs.width,
2356
+ y
2357
+ } }));
1926
2358
  }
1927
- });
1928
- }
1929
- else {
1930
- const items = recursiveItems(this.items);
1931
- items.forEach((item, itemIndex) => {
1932
- const y = itemIndex * lineHeight + item.refs.y + barHeight / 2;
1933
- this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
1934
- x: item.refs.x,
1935
- y
1936
- }, after: {
1937
- x: item.refs.x + item.refs.width,
1938
- y
1939
- } }));
1940
- });
1941
- }
2359
+ }
2360
+ });
1942
2361
  }
1943
2362
  buildLinks() {
1944
2363
  this.computeItemPosition();
@@ -2003,8 +2422,8 @@ class GanttLinksComponent {
2003
2422
  this.unsubscribe$.complete();
2004
2423
  }
2005
2424
  }
2006
- GanttLinksComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLinksComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: GanttDragContainer }], target: i0.ɵɵFactoryTarget.Component });
2007
- GanttLinksComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { groups: "groups", items: "items" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path\n [attr.d]=\"link.path\"\n fill=\"transparent\"\n stroke-width=\"2\"\n [attr.stroke]=\"link.color\"\n pointer-events=\"none\"\n [attr.style]=\"link.type === ganttLinkTypes.sf ? 'marker-start: url(#triangle' + i + ')' : 'marker-end: url(#triangle' + i + ')'\"\n ></path>\n\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n [attr.d]=\"link.path\"\n (mouseenter)=\"mouseEnterPath(link, i)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n <defs *ngIf=\"showArrow\">\n <marker\n *ngIf=\"link.type === ganttLinkTypes.sf; else markerEnd\"\n [id]=\"'triangle' + i\"\n markerUnits=\"strokeWidth\"\n markerWidth=\"5\"\n markerHeight=\"4\"\n refX=\"5\"\n refY=\"2\"\n orient=\"180\"\n >\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n\n <ng-template #markerEnd>\n <marker [id]=\"'triangle' + i\" markerUnits=\"strokeWidth\" markerWidth=\"5\" markerHeight=\"4\" refX=\"5\" refY=\"2\" orient=\"auto\">\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n </ng-template>\n </defs>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\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"] }] });
2425
+ GanttLinksComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLinksComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: GanttDragContainer }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
2426
+ GanttLinksComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { flatData: "flatData" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path\n [attr.d]=\"link.path\"\n fill=\"transparent\"\n stroke-width=\"2\"\n [attr.stroke]=\"link.color\"\n pointer-events=\"none\"\n [attr.style]=\"link.type === ganttLinkTypes.sf ? 'marker-start: url(#triangle' + i + ')' : 'marker-end: url(#triangle' + i + ')'\"\n ></path>\n\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n [attr.d]=\"link.path\"\n (mouseenter)=\"mouseEnterPath(link, i)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n <defs *ngIf=\"showArrow\">\n <marker\n *ngIf=\"link.type === ganttLinkTypes.sf; else markerEnd\"\n [id]=\"'triangle' + i\"\n markerUnits=\"strokeWidth\"\n markerWidth=\"5\"\n markerHeight=\"4\"\n refX=\"5\"\n refY=\"2\"\n orient=\"180\"\n >\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n\n <ng-template #markerEnd>\n <marker [id]=\"'triangle' + i\" markerUnits=\"strokeWidth\" markerWidth=\"5\" markerHeight=\"4\" refX=\"5\" refY=\"2\" orient=\"auto\">\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n </ng-template>\n </defs>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\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"] }] });
2008
2427
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLinksComponent, decorators: [{
2009
2428
  type: Component,
2010
2429
  args: [{ selector: 'gantt-links-overlay', template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path\n [attr.d]=\"link.path\"\n fill=\"transparent\"\n stroke-width=\"2\"\n [attr.stroke]=\"link.color\"\n pointer-events=\"none\"\n [attr.style]=\"link.type === ganttLinkTypes.sf ? 'marker-start: url(#triangle' + i + ')' : 'marker-end: url(#triangle' + i + ')'\"\n ></path>\n\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n [attr.d]=\"link.path\"\n (mouseenter)=\"mouseEnterPath(link, i)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n <defs *ngIf=\"showArrow\">\n <marker\n *ngIf=\"link.type === ganttLinkTypes.sf; else markerEnd\"\n [id]=\"'triangle' + i\"\n markerUnits=\"strokeWidth\"\n markerWidth=\"5\"\n markerHeight=\"4\"\n refX=\"5\"\n refY=\"2\"\n orient=\"180\"\n >\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n\n <ng-template #markerEnd>\n <marker [id]=\"'triangle' + i\" markerUnits=\"strokeWidth\" markerWidth=\"5\" markerHeight=\"4\" refX=\"5\" refY=\"2\" orient=\"auto\">\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n </ng-template>\n </defs>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n" }]
@@ -2012,10 +2431,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2012
2431
  return [{ type: GanttUpper, decorators: [{
2013
2432
  type: Inject,
2014
2433
  args: [GANTT_UPPER_TOKEN]
2015
- }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: GanttDragContainer }];
2016
- }, propDecorators: { groups: [{
2017
- type: Input
2018
- }], items: [{
2434
+ }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: GanttDragContainer }, { type: i0.NgZone }];
2435
+ }, propDecorators: { flatData: [{
2019
2436
  type: Input
2020
2437
  }], lineClick: [{
2021
2438
  type: Output
@@ -2073,18 +2490,10 @@ class GanttDomService {
2073
2490
  .subscribe((event) => {
2074
2491
  this.syncScroll(event);
2075
2492
  }));
2076
- // fromEvent(this.mainContainer, 'scroll')
2077
- // .pipe(startWith(), takeUntil(this.unsubscribe$))
2078
- // .subscribe((event) => {
2079
- // // if (this.mainContainer.scrollLeft > 0) {
2080
- // // this.side.classList.add('gantt-side-has-shadow');
2081
- // // } else {
2082
- // // this.side.classList.remove('gantt-side-has-shadow');
2083
- // // }
2084
- // });
2085
2493
  }
2086
2494
  syncScroll(event) {
2087
2495
  const target = event.currentTarget;
2496
+ this.calendarHeader.scrollLeft = this.mainContainer.scrollLeft;
2088
2497
  this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
2089
2498
  this.sideContainer.scrollTop = target.scrollTop;
2090
2499
  this.mainContainer.scrollTop = target.scrollTop;
@@ -2110,8 +2519,11 @@ class GanttDomService {
2110
2519
  this.container = this.root.getElementsByClassName('gantt-container')[0];
2111
2520
  this.sideContainer = this.root.getElementsByClassName('gantt-side-container')[0];
2112
2521
  this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
2113
- this.mainItems = this.root.getElementsByClassName('gantt-main-items')[0];
2114
- this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-overlay')[0];
2522
+ const mainItems = this.mainContainer.getElementsByClassName('gantt-main-items')[0];
2523
+ const mainGroups = this.mainContainer.getElementsByClassName('gantt-main-groups')[0];
2524
+ this.mainItems = mainItems || mainGroups;
2525
+ this.calendarHeader = this.root.getElementsByClassName('gantt-calendar-header')[0];
2526
+ this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-grid')[0];
2115
2527
  this.monitorScrollChange();
2116
2528
  this.disableBrowserWheelEvent();
2117
2529
  }
@@ -2148,6 +2560,7 @@ class GanttDomService {
2148
2560
  if (isNumber(left)) {
2149
2561
  const scrollLeft = left - this.mainContainer.clientWidth / 2;
2150
2562
  this.mainContainer.scrollLeft = scrollLeft > scrollThreshold ? scrollLeft : 0;
2563
+ this.calendarHeader.scrollLeft = this.mainContainer.scrollLeft;
2151
2564
  this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
2152
2565
  }
2153
2566
  }
@@ -2178,102 +2591,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2178
2591
  }, 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" }]
2179
2592
  }] });
2180
2593
 
2181
- class GanttPrintService {
2182
- constructor() { }
2183
- setInlineStyles(targetElem) {
2184
- const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
2185
- for (const svgElement of svgElements) {
2186
- this.recursElementChildren(svgElement);
2187
- }
2188
- }
2189
- recursElementChildren(node) {
2190
- const transformProperties = [
2191
- 'fill',
2192
- 'color',
2193
- 'font-size',
2194
- 'stroke',
2195
- 'font',
2196
- 'text-anchor',
2197
- 'stroke-dasharray',
2198
- 'shape-rendering',
2199
- 'stroke-width'
2200
- ];
2201
- if (!node.style) {
2202
- return;
2203
- }
2204
- const styles = getComputedStyle(node);
2205
- for (const transformProperty of transformProperties) {
2206
- node.style[transformProperty] = styles[transformProperty];
2207
- }
2208
- for (const child of Array.from(node.childNodes)) {
2209
- this.recursElementChildren(child);
2210
- }
2594
+ class GanttCalendarHeaderComponent {
2595
+ get view() {
2596
+ return this.ganttUpper.view;
2211
2597
  }
2212
- register(root) {
2213
- this.root = root.nativeElement;
2214
- this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
2598
+ constructor(ganttUpper, ngZone, elementRef) {
2599
+ this.ganttUpper = ganttUpper;
2600
+ this.ngZone = ngZone;
2601
+ this.elementRef = elementRef;
2602
+ this.unsubscribe$ = new Subject();
2603
+ this.headerHeight = headerHeight;
2604
+ this.viewTypes = GanttViewType;
2605
+ this.className = `gantt-calendar gantt-calendar-header`;
2215
2606
  }
2216
- print(name = 'download', ignoreElementClass) {
2217
- return __awaiter(this, void 0, void 0, function* () {
2218
- const root = this.root;
2219
- const mainContainer = this.mainContainer;
2220
- // set print width
2221
- const printWidth = root.offsetWidth;
2222
- // set print height
2223
- const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
2224
- const html2canvas = (yield import(/* webpackChunkName: 'html2canvas' */ 'html2canvas')).default;
2225
- html2canvas(root, {
2226
- logging: false,
2227
- allowTaint: true,
2228
- useCORS: true,
2229
- width: printWidth,
2230
- height: printHeight,
2231
- ignoreElements: (element) => {
2232
- if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
2233
- return true;
2234
- }
2235
- if (element.classList.contains('gantt-calendar-today-overlay')) {
2236
- return true;
2237
- }
2238
- },
2239
- onclone: (cloneDocument) => {
2240
- const ganttClass = root.className;
2241
- const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
2242
- const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
2243
- const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
2244
- const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
2245
- // change targetDom width
2246
- cloneGanttDom.style.width = `${printWidth}px`;
2247
- cloneGanttDom.style.height = `${printHeight}px`;
2248
- cloneGanttDom.style.overflow = `unset`;
2249
- cloneGanttContainerDom.style.backgroundColor = '#fff';
2250
- cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
2251
- cloneCalendarOverlay.setAttribute('style', `background: transparent`);
2252
- if (cloneLinksOverlay) {
2253
- cloneLinksOverlay.setAttribute('height', `${printHeight}`);
2254
- cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
2255
- }
2256
- // setInlineStyles for svg
2257
- this.setInlineStyles(cloneGanttDom);
2258
- }
2259
- }).then((canvas) => {
2260
- const link = document.createElement('a');
2261
- const dataUrl = canvas.toDataURL('image/png');
2262
- link.download = `${name}.png`;
2263
- link.href = dataUrl;
2264
- link.click();
2607
+ ngOnInit() {
2608
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2609
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2610
+ .pipe(takeUntil(this.unsubscribe$))
2611
+ .subscribe(() => {
2612
+ if (this.ganttUpper.viewType === GanttViewType.day)
2613
+ this.setTodayPoint();
2265
2614
  });
2266
2615
  });
2267
2616
  }
2617
+ setTodayPoint() {
2618
+ const x = this.view.getTodayXPoint();
2619
+ const today = new GanttDate().getDate();
2620
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
2621
+ const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
2622
+ if (isNumber(x)) {
2623
+ if (rect) {
2624
+ rect.style.left = `${x - todayWidth / 2}px`;
2625
+ rect.style.top = `${headerHeight - todayHeight}px`;
2626
+ rect.innerHTML = today.toString();
2627
+ }
2628
+ }
2629
+ else {
2630
+ todayEle.style.display = 'none';
2631
+ }
2632
+ }
2633
+ trackBy(point, index) {
2634
+ return point.text || index;
2635
+ }
2268
2636
  }
2269
- GanttPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttPrintService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2270
- GanttPrintServiceprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttPrintService });
2271
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttPrintService, decorators: [{
2272
- type: Injectable
2273
- }], ctorParameters: function () { return []; } });
2637
+ 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 });
2638
+ GanttCalendarHeaderComponentcmp = 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"] }] });
2639
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
2640
+ type: Component,
2641
+ 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" }]
2642
+ }], ctorParameters: function () {
2643
+ return [{ type: GanttUpper, decorators: [{
2644
+ type: Inject,
2645
+ args: [GANTT_UPPER_TOKEN]
2646
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }];
2647
+ }, propDecorators: { className: [{
2648
+ type: HostBinding,
2649
+ args: ['class']
2650
+ }] } });
2274
2651
 
2275
2652
  const mainHeight = 5000;
2276
- class GanttCalendarComponent {
2653
+ class GanttCalendarGridComponent {
2277
2654
  get view() {
2278
2655
  return this.ganttUpper.view;
2279
2656
  }
@@ -2281,30 +2658,21 @@ class GanttCalendarComponent {
2281
2658
  this.ganttUpper = ganttUpper;
2282
2659
  this.ngZone = ngZone;
2283
2660
  this.elementRef = elementRef;
2661
+ this.unsubscribe$ = new Subject();
2284
2662
  this.headerHeight = headerHeight;
2285
2663
  this.mainHeight = mainHeight;
2286
- this.todayHeight = todayHeight;
2287
- this.todayWidth = todayWidth;
2288
2664
  this.todayBorderRadius = todayBorderRadius;
2289
2665
  this.viewTypes = GanttViewType;
2290
- this.className = true;
2291
- this.unsubscribe$ = new Subject();
2666
+ this.className = `gantt-calendar gantt-calendar-grid`;
2292
2667
  }
2293
2668
  setTodayPoint() {
2294
2669
  const x = this.view.getTodayXPoint();
2295
- const today = new GanttDate().getDate();
2296
2670
  const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
2297
- const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
2298
2671
  const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
2299
2672
  if (isNumber(x)) {
2300
- if (rect) {
2301
- rect.style.left = `${x - todayWidth / 2}px`;
2302
- rect.style.top = `${headerHeight - todayHeight}px`;
2303
- rect.innerHTML = today.toString();
2304
- }
2305
2673
  if (line) {
2306
2674
  line.style.left = `${x}px`;
2307
- line.style.top = `${headerHeight}px`;
2675
+ line.style.top = `0px`;
2308
2676
  line.style.bottom = `${-mainHeight}px`;
2309
2677
  }
2310
2678
  }
@@ -2313,22 +2681,15 @@ class GanttCalendarComponent {
2313
2681
  }
2314
2682
  }
2315
2683
  ngOnInit() {
2316
- // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
2317
- // the `onStable` will never emit any value.
2318
- const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
2319
- // Normally this isn't in the zone, but it can cause performance regressions for apps
2320
- // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
2321
- this.ngZone.runOutsideAngular(() => {
2322
- onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2323
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2324
- .pipe(takeUntil(this.unsubscribe$))
2325
- .subscribe(() => {
2326
- this.setTodayPoint();
2327
- });
2684
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2685
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2686
+ .pipe(takeUntil(this.unsubscribe$))
2687
+ .subscribe(() => {
2688
+ this.setTodayPoint();
2328
2689
  });
2329
2690
  });
2330
2691
  }
2331
- trackBy(index, point) {
2692
+ trackBy(point, index) {
2332
2693
  return point.text || index;
2333
2694
  }
2334
2695
  ngOnDestroy() {
@@ -2336,11 +2697,11 @@ class GanttCalendarComponent {
2336
2697
  this.unsubscribe$.complete();
2337
2698
  }
2338
2699
  }
2339
- GanttCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
2340
- GanttCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttCalendarComponent, selector: "gantt-calendar-overlay", host: { properties: { "class.gantt-calendar-overlay": "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 <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\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]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", 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.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
2341
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarComponent, decorators: [{
2700
+ 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 });
2701
+ 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"] }] });
2702
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
2342
2703
  type: Component,
2343
- args: [{ selector: 'gantt-calendar-overlay', template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\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]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n" }]
2704
+ 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" }]
2344
2705
  }], ctorParameters: function () {
2345
2706
  return [{ type: GanttUpper, decorators: [{
2346
2707
  type: Inject,
@@ -2348,7 +2709,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2348
2709
  }] }, { type: i0.NgZone }, { type: i0.ElementRef }];
2349
2710
  }, propDecorators: { className: [{
2350
2711
  type: HostBinding,
2351
- args: ['class.gantt-calendar-overlay']
2712
+ args: ['class']
2352
2713
  }] } });
2353
2714
 
2354
2715
  class NgxGanttToolbarComponent {
@@ -2409,7 +2770,7 @@ class NgxGanttRootComponent {
2409
2770
  this.setupViewScroll();
2410
2771
  // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
2411
2772
  this.elementRef.nativeElement.style.opacity = '1';
2412
- this.ganttUpper.viewChange.pipe(startWith(null), takeUntil(this.unsubscribe$)).subscribe(() => {
2773
+ this.ganttUpper.viewChange.pipe(startWith$1(null), takeUntil(this.unsubscribe$)).subscribe(() => {
2413
2774
  this.scrollToToday();
2414
2775
  });
2415
2776
  });
@@ -2478,12 +2839,12 @@ class NgxGanttRootComponent {
2478
2839
  }
2479
2840
  }
2480
2841
  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 });
2481
- 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\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\">\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\">\n <gantt-calendar-overlay></gantt-calendar-overlay>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n<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: "component", type: GanttCalendarComponent, selector: "gantt-calendar-overlay" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: ["template"] }] });
2842
+ 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"] }] });
2482
2843
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
2483
2844
  type: Component,
2484
2845
  args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
2485
2846
  class: 'gantt'
2486
- }, template: "<div class=\"gantt-side\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\">\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\">\n <gantt-calendar-overlay></gantt-calendar-overlay>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n<gantt-toolbar *ngIf=\"ganttUpper.showToolbar || ganttUpper.toolbarTemplate\" [template]=\"ganttUpper.toolbarTemplate\"> </gantt-toolbar>\n" }]
2847
+ }, 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" }]
2487
2848
  }], ctorParameters: function () {
2488
2849
  return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
2489
2850
  type: Inject,
@@ -2505,6 +2866,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2505
2866
  }] } });
2506
2867
 
2507
2868
  const dragMinWidth = 10;
2869
+ const autoScrollStep = 10;
2508
2870
  const activeClass = 'gantt-bar-active';
2509
2871
  const dropActiveClass = 'gantt-bar-drop-active';
2510
2872
  const singleDropActiveClass = 'gantt-bar-single-drop-active';
@@ -2527,6 +2889,16 @@ class GanttBarDrag {
2527
2889
  this.root = root;
2528
2890
  this.dragRefs = [];
2529
2891
  this.destroy$ = new Subject();
2892
+ // scrolling state when drag
2893
+ this.dragScrolling = false;
2894
+ }
2895
+ createDragRef(element) {
2896
+ const dragRef = this.dragDrop.createDrag(element);
2897
+ // dragRef.withPreviewContainer(this.dom.mainContainer as HTMLElement);
2898
+ return dragRef;
2899
+ }
2900
+ createDragScrollEvent(dragRef) {
2901
+ return fromEvent(this.dom.mainContainer, 'scroll', passiveListenerOptions).pipe(takeUntil(dragRef.ended));
2530
2902
  }
2531
2903
  createMouseEvents() {
2532
2904
  var _a, _b, _c;
@@ -2563,33 +2935,38 @@ class GanttBarDrag {
2563
2935
  });
2564
2936
  }
2565
2937
  createBarDrag() {
2566
- const dragRef = this.dragDrop.createDrag(this.barElement);
2938
+ const dragRef = this.createDragRef(this.barElement);
2567
2939
  dragRef.lockAxis = 'x';
2568
2940
  dragRef.withBoundaryElement(this.dom.mainItems);
2569
2941
  dragRef.started.subscribe(() => {
2570
2942
  this.setDraggingStyles();
2943
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2944
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2945
+ if (this.dropListRef.isDragging()) {
2946
+ this.dragScrolling = true;
2947
+ const scrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2948
+ this.barDragMove(dragRef, scrollDistance + this.barDragMoveDistance);
2949
+ }
2950
+ });
2571
2951
  this.dragContainer.dragStarted.emit({ item: this.item.origin });
2572
2952
  });
2573
2953
  dragRef.moved.subscribe((event) => {
2574
- const currentX = this.item.refs.x + event.distance.x;
2575
- const currentDate = this.ganttUpper.view.getDateByXPoint(currentX);
2576
- const currentStartX = this.ganttUpper.view.getXPointByDate(currentDate);
2577
- const dayWidth = this.ganttUpper.view.getDayOccupancyWidth(currentDate);
2578
- const diffDays = differenceInCalendarDays(this.item.end.value, this.item.start.value);
2579
- let start = currentDate;
2580
- let end = currentDate.addDays(diffDays);
2581
- if (currentX > currentStartX + dayWidth / 2) {
2582
- start = start.addDays(1);
2583
- end = end.addDays(1);
2954
+ this.barDragMove(dragRef, event.distance.x);
2955
+ if (!this.dragScrolling) {
2956
+ this.barDragMoveDistance = event.distance.x;
2584
2957
  }
2585
- this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
2586
- this.item.updateDate(start, end);
2587
- this.dragContainer.dragMoved.emit({ item: this.item.origin });
2588
2958
  });
2589
2959
  dragRef.ended.subscribe((event) => {
2960
+ this.item.updateRefs({
2961
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2962
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2963
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2964
+ });
2590
2965
  this.clearDraggingStyles();
2591
2966
  this.closeDragBackdrop();
2592
2967
  event.source.reset();
2968
+ this.dragScrolling = false;
2969
+ this.barDragMoveDistance = 0;
2593
2970
  this.dragContainer.dragEnded.emit({ item: this.item.origin });
2594
2971
  });
2595
2972
  this.barDragRef = dragRef;
@@ -2600,36 +2977,26 @@ class GanttBarDrag {
2600
2977
  const handles = this.barElement.querySelectorAll('.drag-handles .handle');
2601
2978
  handles.forEach((handle, index) => {
2602
2979
  const isBefore = index === 0;
2603
- const dragRef = this.dragDrop.createDrag(handle);
2980
+ const dragRef = this.createDragRef(handle);
2604
2981
  dragRef.lockAxis = 'x';
2605
2982
  dragRef.withBoundaryElement(this.dom.mainItems);
2606
2983
  dragRef.started.subscribe(() => {
2607
2984
  this.setDraggingStyles();
2985
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2986
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2987
+ if (this.dropListRef.isDragging()) {
2988
+ this.dragScrolling = true;
2989
+ const scrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2990
+ this.barHandleDragMove(scrollDistance + this.barHandleDragMoveDistance, isBefore);
2991
+ }
2992
+ });
2608
2993
  this.dragContainer.dragStarted.emit({ item: this.item.origin });
2609
2994
  });
2610
2995
  dragRef.moved.subscribe((event) => {
2611
- if (isBefore) {
2612
- const x = this.item.refs.x + event.distance.x;
2613
- const width = this.item.refs.width + event.distance.x * -1;
2614
- const start = this.ganttUpper.view.getDateByXPoint(x);
2615
- if (width > dragMinWidth) {
2616
- this.barElement.style.width = width + 'px';
2617
- this.barElement.style.left = x + 'px';
2618
- this.openDragBackdrop(this.barElement, start, this.item.end);
2619
- this.item.updateDate(start, this.item.end);
2620
- }
2996
+ this.barHandleDragMove(event.distance.x, isBefore);
2997
+ if (!this.dragScrolling) {
2998
+ this.barHandleDragMoveDistance = event.distance.x;
2621
2999
  }
2622
- else {
2623
- const width = this.item.refs.width + event.distance.x;
2624
- const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
2625
- if (width > dragMinWidth) {
2626
- this.barElement.style.width = width + 'px';
2627
- this.openDragBackdrop(this.barElement, this.item.start, end);
2628
- this.item.updateDate(this.item.start, end);
2629
- }
2630
- }
2631
- this.dragContainer.dragMoved.emit({ item: this.item.origin });
2632
- event.source.reset();
2633
3000
  });
2634
3001
  dragRef.ended.subscribe((event) => {
2635
3002
  if (isBefore) {
@@ -2644,8 +3011,16 @@ class GanttBarDrag {
2644
3011
  this.item.updateDate(this.item.start, this.item.start.endOfDay());
2645
3012
  }
2646
3013
  }
3014
+ this.item.updateRefs({
3015
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
3016
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
3017
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
3018
+ });
2647
3019
  this.clearDraggingStyles();
2648
3020
  this.closeDragBackdrop();
3021
+ event.source.reset();
3022
+ this.dragScrolling = false;
3023
+ this.barHandleDragMoveDistance = 0;
2649
3024
  this.dragContainer.dragEnded.emit({ item: this.item.origin });
2650
3025
  });
2651
3026
  dragRefs.push(dragRef);
@@ -2703,8 +3078,10 @@ class GanttBarDrag {
2703
3078
  return dragRefs;
2704
3079
  }
2705
3080
  openDragBackdrop(dragElement, start, end) {
2706
- const dragBackdropElement = this.root.backdrop.nativeElement;
2707
- const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask');
3081
+ // const dragBackdropElement = this.root.backdrop.nativeElement;
3082
+ // const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask') as HTMLElement;
3083
+ const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
3084
+ const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
2708
3085
  const rootRect = this.dom.root.getBoundingClientRect();
2709
3086
  const dragRect = dragElement.getBoundingClientRect();
2710
3087
  const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
@@ -2719,8 +3096,8 @@ class GanttBarDrag {
2719
3096
  dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
2720
3097
  }
2721
3098
  closeDragBackdrop() {
2722
- const dragBackdropElement = this.root.backdrop.nativeElement;
2723
- const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask');
3099
+ const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
3100
+ const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
2724
3101
  dragMaskElement.style.display = 'none';
2725
3102
  dragBackdropElement.style.display = 'none';
2726
3103
  }
@@ -2732,6 +3109,45 @@ class GanttBarDrag {
2732
3109
  this.barElement.style.pointerEvents = '';
2733
3110
  this.barElement.classList.remove('gantt-bar-draggable-drag');
2734
3111
  }
3112
+ barDragMove(dragRef, distance) {
3113
+ const currentX = this.item.refs.x + distance;
3114
+ const currentDate = this.ganttUpper.view.getDateByXPoint(currentX);
3115
+ const currentStartX = this.ganttUpper.view.getXPointByDate(currentDate);
3116
+ const dayWidth = this.ganttUpper.view.getDayOccupancyWidth(currentDate);
3117
+ const diffDays = differenceInCalendarDays(this.item.end.value, this.item.start.value);
3118
+ let start = currentDate;
3119
+ let end = currentDate.addDays(diffDays);
3120
+ if (currentX > currentStartX + dayWidth / 2) {
3121
+ start = start.addDays(1);
3122
+ end = end.addDays(1);
3123
+ }
3124
+ this.openDragBackdrop(dragRef['_preview'], this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
3125
+ this.item.updateDate(start, end);
3126
+ this.dragContainer.dragMoved.emit({ item: this.item.origin });
3127
+ }
3128
+ barHandleDragMove(distance, isBefore) {
3129
+ if (isBefore) {
3130
+ const x = this.item.refs.x + distance;
3131
+ const width = this.item.refs.width + distance * -1;
3132
+ const start = this.ganttUpper.view.getDateByXPoint(x);
3133
+ if (width > dragMinWidth) {
3134
+ this.barElement.style.width = width + 'px';
3135
+ this.barElement.style.left = x + 'px';
3136
+ this.openDragBackdrop(this.barElement, start, this.item.end);
3137
+ this.item.updateDate(start, this.item.end);
3138
+ }
3139
+ }
3140
+ else {
3141
+ const width = this.item.refs.width + distance;
3142
+ const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
3143
+ if (width > dragMinWidth) {
3144
+ this.barElement.style.width = width + 'px';
3145
+ this.openDragBackdrop(this.barElement, this.item.start, end);
3146
+ this.item.updateDate(this.item.start, end);
3147
+ }
3148
+ }
3149
+ this.dragContainer.dragMoved.emit({ item: this.item.origin });
3150
+ }
2735
3151
  calcLinkLinePositions(target, isBefore) {
2736
3152
  const rootRect = this.dom.root.getBoundingClientRect();
2737
3153
  const targetRect = target.getBoundingClientRect();
@@ -2763,7 +3179,6 @@ class GanttBarDrag {
2763
3179
  this.item = item;
2764
3180
  this.barElement = elementRef.nativeElement;
2765
3181
  this.ganttUpper = ganttUpper;
2766
- // if (!item.draggable || (this.dragDisabled && this.linkDragDisabled)) {
2767
3182
  if (this.dragDisabled && this.linkDragDisabled) {
2768
3183
  return;
2769
3184
  }
@@ -2773,6 +3188,13 @@ class GanttBarDrag {
2773
3188
  const dragRef = this.createBarDrag();
2774
3189
  const dragHandlesRefs = this.createBarHandleDrags();
2775
3190
  this.dragRefs.push(dragRef, ...dragHandlesRefs);
3191
+ // 创建拖拽容器并将所有元素添加到容器中,利用容器来实现自动滚动
3192
+ if (!this.dropListRef) {
3193
+ this.dropListRef = this.dragDrop.createDropList(this.dom.mainContainer);
3194
+ this.dropListRef.autoScrollStep = autoScrollStep;
3195
+ this.dropListRef.withOrientation('horizontal');
3196
+ }
3197
+ this.dropListRef.withItems([dragRef, ...dragHandlesRefs]);
2776
3198
  }
2777
3199
  if (!this.linkDragDisabled) {
2778
3200
  const linkDragRefs = this.createLinkHandleDrags();
@@ -2780,6 +3202,9 @@ class GanttBarDrag {
2780
3202
  }
2781
3203
  }
2782
3204
  }
3205
+ updateItem(item) {
3206
+ this.item = item;
3207
+ }
2783
3208
  ngOnDestroy() {
2784
3209
  this.closeDragBackdrop();
2785
3210
  this.dragRefs.forEach((dragRef) => dragRef.dispose());
@@ -2787,12 +3212,12 @@ class GanttBarDrag {
2787
3212
  this.destroy$.complete();
2788
3213
  }
2789
3214
  }
2790
- GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, deps: [{ token: i1$1.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
3215
+ GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, deps: [{ token: i2.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
2791
3216
  GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag });
2792
3217
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, decorators: [{
2793
3218
  type: Injectable
2794
3219
  }], ctorParameters: function () {
2795
- return [{ type: i1$1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: NgxGanttRootComponent, decorators: [{
3220
+ return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: NgxGanttRootComponent, decorators: [{
2796
3221
  type: SkipSelf
2797
3222
  }] }];
2798
3223
  } });
@@ -2810,16 +3235,26 @@ class GanttItemUpper {
2810
3235
  this.setPositions();
2811
3236
  });
2812
3237
  }
2813
- ngOnChanges() {
3238
+ ngOnChanges(changes) {
2814
3239
  if (!this.firstChange) {
2815
- this.setPositions();
3240
+ this.itemChange(changes.item.currentValue);
2816
3241
  }
2817
3242
  }
3243
+ itemChange(item) {
3244
+ this.unsubscribe$.next();
3245
+ this.unsubscribe$.complete();
3246
+ this.item = item;
3247
+ this.setPositions();
3248
+ this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3249
+ this.setPositions();
3250
+ });
3251
+ }
2818
3252
  setPositions() {
3253
+ var _a, _b, _c;
2819
3254
  const itemElement = this.elementRef.nativeElement;
2820
- itemElement.style.left = this.item.refs.x + 'px';
2821
- itemElement.style.top = this.item.refs.y + 'px';
2822
- itemElement.style.width = this.item.refs.width + 'px';
3255
+ itemElement.style.left = ((_a = this.item.refs) === null || _a === void 0 ? void 0 : _a.x) + 'px';
3256
+ itemElement.style.top = ((_b = this.item.refs) === null || _b === void 0 ? void 0 : _b.y) + 'px';
3257
+ itemElement.style.width = ((_c = this.item.refs) === null || _c === void 0 ? void 0 : _c.width) + 'px';
2823
3258
  if (this.item.type === GanttItemType.bar) {
2824
3259
  itemElement.style.height = this.ganttUpper.styles.barHeight + 'px';
2825
3260
  }
@@ -2866,6 +3301,12 @@ class NgxGanttBarComponent extends GanttItemUpper {
2866
3301
  this.setContentBackground();
2867
3302
  });
2868
3303
  }
3304
+ ngOnChanges(changes) {
3305
+ super.ngOnChanges(changes);
3306
+ if (!this.firstChange) {
3307
+ this.drag.updateItem(this.item);
3308
+ }
3309
+ }
2869
3310
  ngAfterViewInit() {
2870
3311
  // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
2871
3312
  // the `onStable` will never emit any value.
@@ -2879,7 +3320,7 @@ class NgxGanttBarComponent extends GanttItemUpper {
2879
3320
  });
2880
3321
  this.setContentBackground();
2881
3322
  this.handles.changes
2882
- .pipe(startWith(this.handles), switchMap(() =>
3323
+ .pipe(startWith$1(this.handles), switchMap(() =>
2883
3324
  // Note: we need to explicitly subscribe outside of the Angular zone since `addEventListener`
2884
3325
  // is called when the `fromEvent` is subscribed.
2885
3326
  new Observable((subscriber) => this.ngZone.runOutsideAngular(() => merge(...this.handles.toArray().map((handle) => fromEvent(handle.nativeElement, 'mousedown'))).subscribe(subscriber)))), takeUntil(this.unsubscribe$))
@@ -2923,7 +3364,7 @@ class NgxGanttBarComponent extends GanttItemUpper {
2923
3364
  }
2924
3365
  }
2925
3366
  NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
2926
- NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }, { propertyName: "handles", predicate: ["handle"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3367
+ NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }, { propertyName: "handles", predicate: ["handle"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
2927
3368
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
2928
3369
  type: Component,
2929
3370
  args: [{ selector: 'ngx-gantt-bar,gantt-bar', providers: [GanttBarDrag], template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n" }]
@@ -3014,18 +3455,18 @@ class GanttMainComponent {
3014
3455
  }
3015
3456
  }
3016
3457
  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 });
3017
- GanttMainComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttMainComponent, selector: "gantt-main", inputs: { groups: "groups", items: "items", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<gantt-links-overlay [groups]=\"groups\" [items]=\"items\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<!-- groups -->\n<div class=\"gantt-main-groups\" *ngIf=\"groups && groups.length > 0; else itemsTemplate\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"group.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: group }\"></ng-template>\n </div>\n <div *ngIf=\"group.expanded\" class=\"gantt-items\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: group.items }\"></ng-template>\n </div>\n </ng-container>\n</div>\n\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", 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: ["groups", "items"], 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" }] });
3458
+ 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" }] });
3018
3459
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, decorators: [{
3019
3460
  type: Component,
3020
- 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" }]
3461
+ 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" }]
3021
3462
  }], ctorParameters: function () {
3022
3463
  return [{ type: GanttUpper, decorators: [{
3023
3464
  type: Inject,
3024
3465
  args: [GANTT_UPPER_TOKEN]
3025
3466
  }] }];
3026
- }, propDecorators: { groups: [{
3467
+ }, propDecorators: { renderData: [{
3027
3468
  type: Input
3028
- }], items: [{
3469
+ }], flatData: [{
3029
3470
  type: Input
3030
3471
  }], groupHeaderTemplate: [{
3031
3472
  type: Input
@@ -3044,19 +3485,71 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3044
3485
  args: ['class.gantt-main-container']
3045
3486
  }] } });
3046
3487
 
3488
+ class GanttLoaderComponent {
3489
+ }
3490
+ GanttLoaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLoaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3491
+ GanttLoaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttLoaderComponent, selector: "gantt-loader", host: { classAttribute: "gantt-loader gantt-loader-overlay" }, ngImport: i0, template: `
3492
+ <div class="gantt-loader-wrapper">
3493
+ <div class="gantt-loader-loading">
3494
+ <span class="gantt-loader-loading-spot"></span>
3495
+ </div>
3496
+ </div>
3497
+ `, isInline: true });
3498
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLoaderComponent, decorators: [{
3499
+ type: Component,
3500
+ args: [{
3501
+ selector: 'gantt-loader',
3502
+ template: `
3503
+ <div class="gantt-loader-wrapper">
3504
+ <div class="gantt-loader-loading">
3505
+ <span class="gantt-loader-loading-spot"></span>
3506
+ </div>
3507
+ </div>
3508
+ `,
3509
+ host: {
3510
+ class: 'gantt-loader gantt-loader-overlay'
3511
+ }
3512
+ }]
3513
+ }] });
3514
+
3047
3515
  class NgxGanttComponent extends GanttUpper {
3048
- constructor(elementRef, cdr, ngZone, config) {
3516
+ set loading(loading) {
3517
+ if (loading) {
3518
+ if (this.loadingDelay > 0) {
3519
+ this.loadingTimer = setTimeout(() => {
3520
+ this._loading = loading;
3521
+ this.cdr.markForCheck();
3522
+ }, this.loadingDelay);
3523
+ }
3524
+ else {
3525
+ this._loading = loading;
3526
+ }
3527
+ }
3528
+ else {
3529
+ clearTimeout(this.loadingTimer);
3530
+ this._loading = loading;
3531
+ }
3532
+ }
3533
+ get loading() {
3534
+ return this._loading;
3535
+ }
3536
+ constructor(elementRef, cdr, ngZone, printService, config) {
3049
3537
  super(elementRef, cdr, ngZone, config);
3538
+ this.printService = printService;
3050
3539
  this.maxLevel = 2;
3540
+ this.loadingDelay = 0;
3051
3541
  this.linkDragStarted = new EventEmitter();
3052
3542
  this.linkDragEnded = new EventEmitter();
3053
3543
  this.lineClick = new EventEmitter();
3054
3544
  this.selectedChange = new EventEmitter();
3055
- this.ngUnsubscribe$ = new Subject();
3056
- this.sideTableWidth = sideWidth;
3545
+ this.flatData = [];
3546
+ this.renderData = [];
3547
+ this._loading = false;
3548
+ this.computeAllRefs = false;
3057
3549
  }
3058
3550
  ngOnInit() {
3059
3551
  super.ngOnInit();
3552
+ this.buildVirtualFlatData();
3060
3553
  // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
3061
3554
  // the `onStable` will never emit any value.
3062
3555
  const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
@@ -3064,24 +3557,84 @@ class NgxGanttComponent extends GanttUpper {
3064
3557
  // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
3065
3558
  this.ngZone.runOutsideAngular(() => {
3066
3559
  onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3067
- this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
3560
+ // this.dragContainer.dragEnded.subscribe((event) => {
3561
+ // this.computeTempDataRefs();
3562
+ // });
3563
+ this.dragContainer.linkDragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
3068
3564
  this.linkDragStarted.emit(event);
3069
3565
  });
3070
- this.dragContainer.linkDragEnded.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
3566
+ this.dragContainer.linkDragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
3071
3567
  this.linkDragEnded.emit(event);
3072
3568
  });
3073
3569
  });
3074
3570
  });
3571
+ this.view.start$.pipe(skip(1), takeUntil(this.unsubscribe$)).subscribe(() => {
3572
+ this.computeTempDataRefs();
3573
+ });
3574
+ }
3575
+ ngOnChanges(changes) {
3576
+ super.ngOnChanges(changes);
3577
+ if (!this.firstChange) {
3578
+ if (changes.viewType && changes.viewType.currentValue) {
3579
+ this.renderData = this.flatData.slice(this.rangeStart, this.rangeEnd);
3580
+ this.computeTempDataRefs();
3581
+ }
3582
+ if (changes.originItems || changes.originGroups) {
3583
+ this.buildVirtualFlatData();
3584
+ this.renderData = this.flatData.slice(this.rangeStart, this.rangeEnd);
3585
+ this.computeTempDataRefs();
3586
+ }
3587
+ }
3075
3588
  }
3076
3589
  ngAfterViewInit() {
3077
- this.columns.changes.pipe(startWith(true), takeUntil(this.ngUnsubscribe$)).subscribe(() => {
3078
- this.columns.forEach((column) => {
3079
- if (!column.columnWidth) {
3080
- column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
3590
+ this.virtualScroll.renderedRangeStream.pipe(takeUntil(this.unsubscribe$)).subscribe((range) => {
3591
+ const linksElement = this.elementRef.nativeElement.querySelector('.gantt-links-overlay');
3592
+ linksElement.style.top = `${-(this.styles.lineHeight * range.start)}px`;
3593
+ this.rangeStart = range.start;
3594
+ this.rangeEnd = range.end;
3595
+ this.renderData = this.flatData.slice(range.start, range.end);
3596
+ this.computeTempDataRefs();
3597
+ });
3598
+ }
3599
+ buildVirtualFlatData() {
3600
+ const virtualData = [];
3601
+ if (this.groups.length) {
3602
+ this.groups.forEach((group) => {
3603
+ virtualData.push(group);
3604
+ if (group.expanded) {
3605
+ const items = recursiveItems(group.items);
3606
+ virtualData.push(...items);
3081
3607
  }
3082
3608
  });
3083
- this.cdr.detectChanges();
3609
+ }
3610
+ if (this.items.length) {
3611
+ virtualData.push(...recursiveItems(this.items));
3612
+ }
3613
+ this.flatData = [...virtualData];
3614
+ this.flatDataMap = keyBy(this.flatData, 'id');
3615
+ }
3616
+ afterExpand() {
3617
+ this.buildVirtualFlatData();
3618
+ this.renderData = this.flatData.slice(this.rangeStart, this.rangeEnd);
3619
+ }
3620
+ computeTempDataRefs() {
3621
+ const tempItemData = [];
3622
+ this.renderData.forEach((data) => {
3623
+ if (!data.hasOwnProperty('items')) {
3624
+ const item = data;
3625
+ if (item.links) {
3626
+ item.links.forEach((link) => {
3627
+ if (this.flatDataMap[link.link]) {
3628
+ tempItemData.push(this.flatDataMap[link.link]);
3629
+ }
3630
+ });
3631
+ }
3632
+ tempItemData.push(data);
3633
+ }
3084
3634
  });
3635
+ this.computeItemsRefs(...uniqBy(tempItemData, 'id'));
3636
+ this.flatData = [...this.flatData];
3637
+ this.renderData = [...this.renderData];
3085
3638
  }
3086
3639
  expandChildren(item) {
3087
3640
  if (!item.expanded) {
@@ -3091,6 +3644,7 @@ class NgxGanttComponent extends GanttUpper {
3091
3644
  this.childrenResolve(item.origin)
3092
3645
  .pipe(take(1), finalize(() => {
3093
3646
  item.loading = false;
3647
+ this.afterExpand();
3094
3648
  this.expandChange.emit(item);
3095
3649
  this.cdr.detectChanges();
3096
3650
  }))
@@ -3101,11 +3655,13 @@ class NgxGanttComponent extends GanttUpper {
3101
3655
  }
3102
3656
  else {
3103
3657
  this.computeItemsRefs(...item.children);
3658
+ this.afterExpand();
3104
3659
  this.expandChange.emit(item);
3105
3660
  }
3106
3661
  }
3107
3662
  else {
3108
3663
  item.setExpand(false);
3664
+ this.afterExpand();
3109
3665
  this.expandChange.emit(item);
3110
3666
  }
3111
3667
  }
@@ -3132,9 +3688,23 @@ class NgxGanttComponent extends GanttUpper {
3132
3688
  scrollToDate(date) {
3133
3689
  this.ganttRoot.scrollToDate(date);
3134
3690
  }
3691
+ expandGroups(expanded) {
3692
+ this.groups.forEach((group) => {
3693
+ group.setExpand(expanded);
3694
+ });
3695
+ this.afterExpand();
3696
+ this.expandChange.next(null);
3697
+ this.cdr.detectChanges();
3698
+ }
3699
+ expandGroup(group) {
3700
+ group.setExpand(!group.expanded);
3701
+ this.afterExpand();
3702
+ this.expandChange.emit();
3703
+ this.cdr.detectChanges();
3704
+ }
3135
3705
  }
3136
- NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
3137
- NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
3706
+ NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GanttPrintService, optional: true }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
3707
+ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable", loading: "loading", loadingDelay: "loadingDelay" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
3138
3708
  {
3139
3709
  provide: GANTT_UPPER_TOKEN,
3140
3710
  useExisting: NgxGanttComponent
@@ -3143,7 +3713,7 @@ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
3143
3713
  provide: GANTT_ABSTRACT_TOKEN,
3144
3714
  useExisting: forwardRef(() => NgxGanttComponent)
3145
3715
  }
3146
- ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], viewQueries: [{ propertyName: "ganttRoot", first: true, predicate: ["ganttRoot"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<ngx-gantt-root #ganttRoot>\n <ng-template #sideTemplate>\n <gantt-table\n [groups]=\"groups\"\n [items]=\"items\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table>\n </ng-template>\n <ng-template #mainTemplate>\n <gantt-main\n [groups]=\"groups\"\n [items]=\"items\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </ng-template>\n</ngx-gantt-root>\n", dependencies: [{ kind: "component", type: GanttTableComponent, selector: "gantt-table", inputs: ["groups", "items", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate"], outputs: ["itemClick"] }, { kind: "component", type: GanttMainComponent, selector: "gantt-main", inputs: ["groups", "items", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }, { kind: "component", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3716
+ ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], viewQueries: [{ propertyName: "ganttRoot", first: true, predicate: ["ganttRoot"], descendants: true }, { propertyName: "virtualScroll", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n <gantt-loader *ngIf=\"loading\"></gantt-loader>\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\" [style.width.px]=\"tableHeader.tableWidth + 1\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i3.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i3.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: GanttTableHeaderComponent, selector: "gantt-table-header", inputs: ["columns"] }, { kind: "component", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: ["renderData", "flatData", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate", "draggable", "dropEnterPredicate"], outputs: ["dragDropped", "itemClick"] }, { kind: "component", type: GanttMainComponent, selector: "gantt-main", inputs: ["renderData", "flatData", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttLoaderComponent, selector: "gantt-loader" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3147
3717
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttComponent, decorators: [{
3148
3718
  type: Component,
3149
3719
  args: [{ selector: 'ngx-gantt', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
@@ -3155,9 +3725,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3155
3725
  provide: GANTT_ABSTRACT_TOKEN,
3156
3726
  useExisting: forwardRef(() => NgxGanttComponent)
3157
3727
  }
3158
- ], template: "<ngx-gantt-root #ganttRoot>\n <ng-template #sideTemplate>\n <gantt-table\n [groups]=\"groups\"\n [items]=\"items\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table>\n </ng-template>\n <ng-template #mainTemplate>\n <gantt-main\n [groups]=\"groups\"\n [items]=\"items\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </ng-template>\n</ngx-gantt-root>\n" }]
3728
+ ], template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n <gantt-loader *ngIf=\"loading\"></gantt-loader>\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\" [style.width.px]=\"tableHeader.tableWidth + 1\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n" }]
3159
3729
  }], ctorParameters: function () {
3160
- return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
3730
+ return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: GanttPrintService, decorators: [{
3731
+ type: Optional
3732
+ }] }, { type: undefined, decorators: [{
3161
3733
  type: Inject,
3162
3734
  args: [GANTT_GLOBAL_CONFIG]
3163
3735
  }] }];
@@ -3169,6 +3741,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3169
3741
  type: Input
3170
3742
  }], linkable: [{
3171
3743
  type: Input
3744
+ }], loading: [{
3745
+ type: Input
3746
+ }], loadingDelay: [{
3747
+ type: Input
3172
3748
  }], linkDragStarted: [{
3173
3749
  type: Output
3174
3750
  }], linkDragEnded: [{
@@ -3189,6 +3765,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3189
3765
  }], ganttRoot: [{
3190
3766
  type: ViewChild,
3191
3767
  args: ['ganttRoot']
3768
+ }], virtualScroll: [{
3769
+ type: ViewChild,
3770
+ args: [CdkVirtualScrollViewport]
3192
3771
  }] } });
3193
3772
 
3194
3773
  class NgxGanttModule {
@@ -3197,10 +3776,15 @@ NgxGanttModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version:
3197
3776
  NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttModule, declarations: [NgxGanttComponent,
3198
3777
  NgxGanttTableComponent,
3199
3778
  NgxGanttTableColumnComponent,
3200
- GanttTableComponent,
3779
+ // GanttTableComponent,
3780
+ GanttTableHeaderComponent,
3781
+ GanttTableBodyComponent,
3201
3782
  GanttMainComponent,
3202
- GanttCalendarComponent,
3783
+ // GanttCalendarComponent,
3784
+ GanttCalendarHeaderComponent,
3785
+ GanttCalendarGridComponent,
3203
3786
  GanttLinksComponent,
3787
+ GanttLoaderComponent,
3204
3788
  NgxGanttBarComponent,
3205
3789
  GanttIconComponent,
3206
3790
  GanttDragBackdropComponent,
@@ -3210,7 +3794,7 @@ NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
3210
3794
  NgxGanttToolbarComponent,
3211
3795
  IsGanttRangeItemPipe,
3212
3796
  IsGanttBarItemPipe,
3213
- IsGanttCustomItemPipe], imports: [CommonModule, DragDropModule], exports: [NgxGanttComponent,
3797
+ IsGanttCustomItemPipe], imports: [CommonModule, DragDropModule, ScrollingModule], exports: [NgxGanttComponent,
3214
3798
  NgxGanttTableComponent,
3215
3799
  NgxGanttTableColumnComponent,
3216
3800
  NgxGanttRootComponent,
@@ -3219,15 +3803,16 @@ NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
3219
3803
  NgxGanttBaselineComponent,
3220
3804
  NgxGanttToolbarComponent] });
3221
3805
  NgxGanttModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttModule, providers: [
3806
+ CdkVirtualScrollViewport,
3222
3807
  {
3223
3808
  provide: GANTT_GLOBAL_CONFIG,
3224
3809
  useValue: defaultConfig
3225
3810
  }
3226
- ], imports: [CommonModule, DragDropModule] });
3811
+ ], imports: [CommonModule, DragDropModule, ScrollingModule] });
3227
3812
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttModule, decorators: [{
3228
3813
  type: NgModule,
3229
3814
  args: [{
3230
- imports: [CommonModule, DragDropModule],
3815
+ imports: [CommonModule, DragDropModule, ScrollingModule],
3231
3816
  exports: [
3232
3817
  NgxGanttComponent,
3233
3818
  NgxGanttTableComponent,
@@ -3242,10 +3827,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3242
3827
  NgxGanttComponent,
3243
3828
  NgxGanttTableComponent,
3244
3829
  NgxGanttTableColumnComponent,
3245
- GanttTableComponent,
3830
+ // GanttTableComponent,
3831
+ GanttTableHeaderComponent,
3832
+ GanttTableBodyComponent,
3246
3833
  GanttMainComponent,
3247
- GanttCalendarComponent,
3834
+ // GanttCalendarComponent,
3835
+ GanttCalendarHeaderComponent,
3836
+ GanttCalendarGridComponent,
3248
3837
  GanttLinksComponent,
3838
+ GanttLoaderComponent,
3249
3839
  NgxGanttBarComponent,
3250
3840
  GanttIconComponent,
3251
3841
  GanttDragBackdropComponent,
@@ -3258,6 +3848,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3258
3848
  IsGanttCustomItemPipe
3259
3849
  ],
3260
3850
  providers: [
3851
+ CdkVirtualScrollViewport,
3261
3852
  {
3262
3853
  provide: GANTT_GLOBAL_CONFIG,
3263
3854
  useValue: defaultConfig
@@ -3274,5 +3865,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3274
3865
  * Generated bundle index. Do not edit.
3275
3866
  */
3276
3867
 
3277
- export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttBaselineItemInternal, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLinkLineType, GanttLinkType, GanttLoadOnScrollEvent, GanttPrintService, GanttSelectedEvent, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, LinkColors, NgxGanttBarComponent, NgxGanttBaselineComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, NgxGanttToolbarComponent, defaultConfig, ganttViews, primaryDatePointTop, registerView, secondaryDatePointTop };
3868
+ export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttBaselineItemInternal, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLinkLineType, GanttLinkType, GanttLoadOnScrollEvent, GanttLoaderComponent, GanttPrintService, GanttSelectedEvent, GanttTableDragDroppedEvent, GanttTableDragEnterPredicateContext, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, LinkColors, NgxGanttBarComponent, NgxGanttBaselineComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, NgxGanttToolbarComponent, defaultConfig, ganttViews, primaryDatePointTop, registerView, secondaryDatePointTop };
3278
3869
  //# sourceMappingURL=worktile-gantt.mjs.map