@worktile/gantt 12.2.1 → 12.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/bundles/worktile-gantt.umd.js +305 -210
  2. package/bundles/worktile-gantt.umd.js.map +1 -1
  3. package/components/bar/bar-drag.d.ts +4 -2
  4. package/components/bar/bar.component.d.ts +4 -4
  5. package/components/calendar/calendar.component.d.ts +3 -5
  6. package/components/drag-backdrop/drag-backdrop.component.d.ts +1 -5
  7. package/components/icon/icon.component.d.ts +2 -4
  8. package/components/main/gantt-main.component.d.ts +2 -3
  9. package/components/range/range.component.d.ts +2 -5
  10. package/components/table/gantt-table.component.d.ts +2 -3
  11. package/esm2015/components/bar/bar-drag.js +24 -17
  12. package/esm2015/components/bar/bar.component.js +21 -14
  13. package/esm2015/components/calendar/calendar.component.js +16 -11
  14. package/esm2015/components/drag-backdrop/drag-backdrop.component.js +8 -12
  15. package/esm2015/components/icon/icon.component.js +1 -3
  16. package/esm2015/components/links/links.component.js +2 -2
  17. package/esm2015/components/main/gantt-main.component.js +1 -2
  18. package/esm2015/components/range/range.component.js +2 -11
  19. package/esm2015/components/table/gantt-table.component.js +7 -3
  20. package/esm2015/gantt-dom.service.js +39 -25
  21. package/esm2015/gantt-item-upper.js +5 -5
  22. package/esm2015/gantt-print.service.js +50 -47
  23. package/esm2015/gantt-upper.js +27 -18
  24. package/esm2015/gantt.component.js +17 -16
  25. package/esm2015/root.component.js +41 -29
  26. package/esm2015/table/gantt-column.component.js +1 -2
  27. package/esm2015/table/gantt-table.component.js +2 -3
  28. package/esm2015/utils/passive-listeners.js +30 -0
  29. package/esm2015/utils/set-style-with-vendor-prefix.js +15 -0
  30. package/esm2015/views/day.js +1 -1
  31. package/fesm2015/worktile-gantt.js +285 -205
  32. package/fesm2015/worktile-gantt.js.map +1 -1
  33. package/gantt-dom.service.d.ts +11 -4
  34. package/gantt-item-upper.d.ts +5 -5
  35. package/gantt-print.service.d.ts +1 -1
  36. package/gantt-upper.d.ts +5 -5
  37. package/gantt.component.d.ts +2 -4
  38. package/main.bundle.scss +3 -2
  39. package/package.json +1 -1
  40. package/root.component.d.ts +5 -3
  41. package/table/gantt-column.component.d.ts +2 -3
  42. package/table/gantt-table.component.d.ts +2 -4
  43. package/utils/passive-listeners.d.ts +13 -0
  44. package/utils/set-style-with-vendor-prefix.d.ts +12 -0
  45. package/README.md +0 -24
@@ -1,17 +1,16 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Pipe, ViewChild, Injectable, Optional, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
2
+ import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Pipe, ViewChild, PLATFORM_ID, Injectable, ElementRef, Optional, SkipSelf, ViewChildren, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
3
  import * as i2 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
5
- import { take, skip, takeUntil, startWith, map, pairwise, auditTime, debounceTime, finalize } from 'rxjs/operators';
6
- import { BehaviorSubject, Subject, merge, fromEvent } from 'rxjs';
4
+ import { isPlatformServer, CommonModule } from '@angular/common';
5
+ import { take, takeUntil, skip, map, pairwise, auditTime, startWith, debounceTime, switchMap, finalize } from 'rxjs/operators';
6
+ import { BehaviorSubject, Subject, from, merge, fromEvent, Observable, EMPTY } 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
11
  import * as i1 from '@angular/cdk/drag-drop';
12
12
  import { DragDropModule } from '@angular/cdk/drag-drop';
13
- import html2canvas from 'html2canvas';
14
- import { __decorate, __param } from 'tslib';
13
+ import { __awaiter, __decorate, __param } from 'tslib';
15
14
 
16
15
  class GanttDatePoint {
17
16
  constructor(start, text, x, y, additions) {
@@ -792,7 +791,9 @@ class GanttUpper {
792
791
  this.cdr = cdr;
793
792
  this.ngZone = ngZone;
794
793
  this.config = config;
794
+ // eslint-disable-next-line @angular-eslint/no-input-rename
795
795
  this.originItems = [];
796
+ // eslint-disable-next-line @angular-eslint/no-input-rename
796
797
  this.originGroups = [];
797
798
  this.viewType = GanttViewType.month;
798
799
  this.showTodayLine = true;
@@ -941,7 +942,7 @@ class GanttUpper {
941
942
  initSelectionModel() {
942
943
  return new SelectionModel(this.multiple, []);
943
944
  }
944
- onInit() {
945
+ ngOnInit() {
945
946
  this.styles = Object.assign({}, defaultStyles, this.styles);
946
947
  this.viewOptions.dateFormat = Object.assign({}, defaultConfig.dateFormat, this.config.dateFormat, this.viewOptions.dateFormat);
947
948
  this.createView();
@@ -950,25 +951,32 @@ class GanttUpper {
950
951
  this.computeRefs();
951
952
  this.initSelectionModel();
952
953
  this.firstChange = false;
953
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
954
- this.element.style.opacity = '1';
955
- this.dragContainer.dragStarted.subscribe((event) => {
956
- this.dragStarted.emit(event);
957
- });
958
- this.dragContainer.dragMoved.subscribe((event) => {
959
- this.dragMoved.emit(event);
960
- });
961
- this.dragContainer.dragEnded.subscribe((event) => {
962
- this.dragEnded.emit(event);
963
- this.computeRefs();
964
- this.detectChanges();
954
+ // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
955
+ // the `onStable` will never emit any value.
956
+ const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
957
+ // Normally this isn't in the zone, but it can cause performance regressions for apps
958
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
959
+ this.ngZone.runOutsideAngular(() => {
960
+ onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
961
+ this.element.style.opacity = '1';
962
+ this.dragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
963
+ this.dragStarted.emit(event);
964
+ });
965
+ this.dragContainer.dragMoved.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
966
+ this.dragMoved.emit(event);
967
+ });
968
+ this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
969
+ this.dragEnded.emit(event);
970
+ this.computeRefs();
971
+ this.detectChanges();
972
+ });
965
973
  });
966
974
  });
967
975
  this.view.start$.pipe(skip(1), takeUntil(this.unsubscribe$)).subscribe(() => {
968
976
  this.computeRefs();
969
977
  });
970
978
  }
971
- onChanges(changes) {
979
+ ngOnChanges(changes) {
972
980
  if (!this.firstChange) {
973
981
  if (changes.viewType && changes.viewType.currentValue) {
974
982
  this.createView();
@@ -985,7 +993,7 @@ class GanttUpper {
985
993
  }
986
994
  }
987
995
  }
988
- onDestroy() {
996
+ ngOnDestroy() {
989
997
  this.unsubscribe$.next();
990
998
  this.unsubscribe$.complete();
991
999
  }
@@ -1040,7 +1048,7 @@ class GanttUpper {
1040
1048
  }
1041
1049
  }
1042
1050
  GanttUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttUpper, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Directive });
1043
- GanttUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.5", type: GanttUpper, inputs: { originItems: ["items", "originItems"], originGroups: ["groups", "originGroups"], viewType: "viewType", start: "start", end: "end", showTodayLine: "showTodayLine", draggable: "draggable", styles: "styles", viewOptions: "viewOptions", linkOptions: "linkOptions", disabledLoadOnScroll: "disabledLoadOnScroll", selectable: "selectable", multiple: "multiple" }, outputs: { loadOnScroll: "loadOnScroll", dragStarted: "dragStarted", dragMoved: "dragMoved", dragEnded: "dragEnded", barClick: "barClick" }, host: { properties: { "class.gantt": "this.ganttClass" } }, queries: [{ propertyName: "barTemplate", first: true, predicate: ["bar"], descendants: true, static: true }, { propertyName: "rangeTemplate", first: true, predicate: ["range"], descendants: true, static: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, static: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true, static: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ["groupHeader"], descendants: true, static: true }], ngImport: i0 });
1051
+ GanttUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.5", type: GanttUpper, inputs: { originItems: ["items", "originItems"], originGroups: ["groups", "originGroups"], viewType: "viewType", start: "start", end: "end", showTodayLine: "showTodayLine", draggable: "draggable", styles: "styles", viewOptions: "viewOptions", linkOptions: "linkOptions", disabledLoadOnScroll: "disabledLoadOnScroll", selectable: "selectable", multiple: "multiple" }, outputs: { loadOnScroll: "loadOnScroll", dragStarted: "dragStarted", dragMoved: "dragMoved", dragEnded: "dragEnded", barClick: "barClick" }, host: { properties: { "class.gantt": "this.ganttClass" } }, queries: [{ propertyName: "barTemplate", first: true, predicate: ["bar"], descendants: true, static: true }, { propertyName: "rangeTemplate", first: true, predicate: ["range"], descendants: true, static: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, static: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true, static: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ["groupHeader"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0 });
1044
1052
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttUpper, decorators: [{
1045
1053
  type: Directive
1046
1054
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
@@ -1112,7 +1120,6 @@ class NgxGanttTableColumnComponent {
1112
1120
  set width(width) {
1113
1121
  this.columnWidth = coerceCssPixelValue(width);
1114
1122
  }
1115
- ngOnInit() { }
1116
1123
  }
1117
1124
  NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
1118
1125
  NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
@@ -1141,7 +1148,6 @@ class NgxGanttTableComponent {
1141
1148
  constructor() {
1142
1149
  this.columnChanges = new EventEmitter();
1143
1150
  }
1144
- ngOnInit() { }
1145
1151
  }
1146
1152
  NgxGanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1147
1153
  NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", 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 });
@@ -1151,7 +1157,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImpor
1151
1157
  selector: 'ngx-gantt-table',
1152
1158
  template: ''
1153
1159
  }]
1154
- }], ctorParameters: function () { return []; }, propDecorators: { columnChanges: [{
1160
+ }], propDecorators: { columnChanges: [{
1155
1161
  type: Output
1156
1162
  }], rowBeforeTemplate: [{
1157
1163
  type: ContentChild,
@@ -1163,6 +1169,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImpor
1163
1169
 
1164
1170
  const GANTT_ABSTRACT_TOKEN = new InjectionToken('gantt-abstract-token');
1165
1171
 
1172
+ const supports = (typeof window !== 'undefined' && !!window.CSS && CSS.supports) || (() => false);
1173
+ /**
1174
+ * Note: we don't need to add vendor prefixes within `.scss` files since they're added automatically.
1175
+ * This function is necessary when the `element.style` is updated directly through the JavaScript.
1176
+ * This is not required to be used with CSS properties that don't require vendor prefixes (e.g. `opacity`).
1177
+ */
1178
+ function setStyleWithVendorPrefix({ element, style, value }) {
1179
+ element.style[style] = value;
1180
+ if (supports(`-webkit-${style}: ${value}`)) {
1181
+ // Note: some browsers still require setting `-webkit` vendor prefix. E.g. Mozilla 49 has implemented
1182
+ // the 3D support for `transform`, but it requires setting `-webkit-` prefix.
1183
+ element.style[`-webkit-${style}`] = value;
1184
+ }
1185
+ }
1186
+
1166
1187
  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>`;
1167
1188
  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>`;
1168
1189
  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>`;
@@ -1258,8 +1279,6 @@ class GanttIconComponent {
1258
1279
  set iconName(name) {
1259
1280
  this.setSvg(name);
1260
1281
  }
1261
- ngOnInit() { }
1262
- ngAfterViewInit() { }
1263
1282
  setSvg(name) {
1264
1283
  const iconSvg = icons[name];
1265
1284
  if (iconSvg) {
@@ -1344,7 +1363,6 @@ class GanttTableComponent {
1344
1363
  });
1345
1364
  this.columnList = columns;
1346
1365
  }
1347
- ngOnInit() { }
1348
1366
  ngOnChanges(changes) {
1349
1367
  var _a, _b;
1350
1368
  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)) {
@@ -1356,7 +1374,11 @@ class GanttTableComponent {
1356
1374
  }
1357
1375
  dragFixed(config) {
1358
1376
  if (config.movedWidth < config.minWidth) {
1359
- config.target.style.transform = `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`;
1377
+ setStyleWithVendorPrefix({
1378
+ element: config.target,
1379
+ style: 'transform',
1380
+ value: `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`
1381
+ });
1360
1382
  }
1361
1383
  }
1362
1384
  expandGroup(group) {
@@ -1478,6 +1500,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImpor
1478
1500
  args: ['class.gantt-table-empty']
1479
1501
  }] } });
1480
1502
 
1503
+ /** Cached result of whether the user's browser supports passive event listeners. */
1504
+ let supportsPassiveEvents;
1505
+ /**
1506
+ * Checks whether the user's browser supports passive event listeners.
1507
+ * See: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
1508
+ */
1509
+ function supportsPassiveEventListeners() {
1510
+ if (supportsPassiveEvents == null && typeof window !== 'undefined') {
1511
+ try {
1512
+ window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
1513
+ get: () => (supportsPassiveEvents = true)
1514
+ }));
1515
+ }
1516
+ finally {
1517
+ supportsPassiveEvents = supportsPassiveEvents || false;
1518
+ }
1519
+ }
1520
+ return supportsPassiveEvents;
1521
+ }
1522
+ /**
1523
+ * Normalizes an `AddEventListener` object to something that can be passed
1524
+ * to `addEventListener` on any browser, no matter whether it supports the
1525
+ * `options` parameter.
1526
+ */
1527
+ function normalizePassiveListenerOptions(options) {
1528
+ return supportsPassiveEventListeners() ? options : !!options.capture;
1529
+ }
1530
+ /** Options used to bind passive event listeners. */
1531
+ const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
1532
+
1481
1533
  const scrollThreshold = 50;
1482
1534
  var ScrollDirection;
1483
1535
  (function (ScrollDirection) {
@@ -1486,24 +1538,26 @@ var ScrollDirection;
1486
1538
  ScrollDirection[ScrollDirection["RIGHT"] = 2] = "RIGHT";
1487
1539
  })(ScrollDirection || (ScrollDirection = {}));
1488
1540
  class GanttDomService {
1489
- constructor() {
1541
+ constructor(ngZone, platformId) {
1542
+ this.ngZone = ngZone;
1543
+ this.platformId = platformId;
1490
1544
  this.unsubscribe$ = new Subject();
1491
1545
  }
1492
1546
  monitorScrollChange() {
1493
- merge(fromEvent(this.mainContainer, 'scroll'), fromEvent(this.sideContainer, 'scroll'))
1547
+ this.ngZone.runOutsideAngular(() => merge(fromEvent(this.mainContainer, 'scroll', passiveListenerOptions), fromEvent(this.sideContainer, 'scroll', passiveListenerOptions))
1494
1548
  .pipe(takeUntil(this.unsubscribe$))
1495
1549
  .subscribe((event) => {
1496
1550
  this.syncScroll(event);
1497
- });
1498
- fromEvent(this.mainContainer, 'scroll')
1499
- .pipe(startWith(), takeUntil(this.unsubscribe$))
1500
- .subscribe((event) => {
1501
- // if (this.mainContainer.scrollLeft > 0) {
1502
- // this.side.classList.add('gantt-side-has-shadow');
1503
- // } else {
1504
- // this.side.classList.remove('gantt-side-has-shadow');
1505
- // }
1506
- });
1551
+ }));
1552
+ // fromEvent(this.mainContainer, 'scroll')
1553
+ // .pipe(startWith(), takeUntil(this.unsubscribe$))
1554
+ // .subscribe((event) => {
1555
+ // // if (this.mainContainer.scrollLeft > 0) {
1556
+ // // this.side.classList.add('gantt-side-has-shadow');
1557
+ // // } else {
1558
+ // // this.side.classList.remove('gantt-side-has-shadow');
1559
+ // // }
1560
+ // });
1507
1561
  }
1508
1562
  syncScroll(event) {
1509
1563
  const target = event.currentTarget;
@@ -1513,7 +1567,7 @@ class GanttDomService {
1513
1567
  }
1514
1568
  disableBrowserWheelEvent() {
1515
1569
  const container = this.mainContainer;
1516
- fromEvent(container, 'wheel')
1570
+ this.ngZone.runOutsideAngular(() => fromEvent(container, 'wheel')
1517
1571
  .pipe(takeUntil(this.unsubscribe$))
1518
1572
  .subscribe((event) => {
1519
1573
  const delta = event.deltaX;
@@ -1524,7 +1578,7 @@ class GanttDomService {
1524
1578
  (container.scrollLeft === 0 && delta < 0)) {
1525
1579
  event.preventDefault();
1526
1580
  }
1527
- });
1581
+ }));
1528
1582
  }
1529
1583
  initialize(root) {
1530
1584
  this.root = root.nativeElement;
@@ -1536,8 +1590,13 @@ class GanttDomService {
1536
1590
  this.monitorScrollChange();
1537
1591
  this.disableBrowserWheelEvent();
1538
1592
  }
1539
- getViewerScroll() {
1540
- return fromEvent(this.mainContainer, 'scroll').pipe(map(() => this.mainContainer.scrollLeft), pairwise(), map(([previous, current]) => {
1593
+ /**
1594
+ * @returns An observable that will emit outside the Angular zone. Note, consumers should re-enter the Angular zone
1595
+ * to run the change detection if needed.
1596
+ */
1597
+ getViewerScroll(options) {
1598
+ return new Observable((subscriber) => this.ngZone.runOutsideAngular(() => fromEvent(this.mainContainer, 'scroll', options)
1599
+ .pipe(map(() => this.mainContainer.scrollLeft), pairwise(), map(([previous, current]) => {
1541
1600
  const event = {
1542
1601
  target: this.mainContainer,
1543
1602
  direction: ScrollDirection.NONE
@@ -1548,15 +1607,17 @@ class GanttDomService {
1548
1607
  }
1549
1608
  }
1550
1609
  if (current - previous > 0) {
1551
- if (this.mainContainer.scrollWidth - this.mainContainer.clientWidth - this.mainContainer.scrollLeft < scrollThreshold) {
1610
+ if (this.mainContainer.scrollWidth - this.mainContainer.clientWidth - this.mainContainer.scrollLeft <
1611
+ scrollThreshold) {
1552
1612
  event.direction = ScrollDirection.RIGHT;
1553
1613
  }
1554
1614
  }
1555
1615
  return event;
1556
- }));
1616
+ }))
1617
+ .subscribe(subscriber)));
1557
1618
  }
1558
1619
  getResize() {
1559
- return fromEvent(window, 'resize').pipe(auditTime(150));
1620
+ return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime(150));
1560
1621
  }
1561
1622
  scrollMainContainer(left) {
1562
1623
  if (isNumber(left)) {
@@ -1570,11 +1631,14 @@ class GanttDomService {
1570
1631
  this.unsubscribe$.complete();
1571
1632
  }
1572
1633
  }
1573
- GanttDomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttDomService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1634
+ GanttDomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttDomService, deps: [{ token: i0.NgZone }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
1574
1635
  GanttDomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttDomService });
1575
1636
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttDomService, decorators: [{
1576
1637
  type: Injectable
1577
- }], ctorParameters: function () { return []; } });
1638
+ }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: undefined, decorators: [{
1639
+ type: Inject,
1640
+ args: [PLATFORM_ID]
1641
+ }] }]; } });
1578
1642
 
1579
1643
  function getDependencyType(path, dependencyTypes) {
1580
1644
  if (dependencyTypes.includes(GanttLinkType.ss) && path.from.pos === InBarPosition.start && path.to.pos === InBarPosition.start) {
@@ -1648,6 +1712,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImpor
1648
1712
  args: [GANTT_UPPER_TOKEN]
1649
1713
  }] }]; } });
1650
1714
 
1715
+ class GanttDragBackdropComponent {
1716
+ }
1717
+ GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1718
+ GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { classAttribute: "gantt-drag-backdrop" }, ngImport: i0, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" });
1719
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
1720
+ type: Component,
1721
+ args: [{
1722
+ selector: 'gantt-drag-backdrop',
1723
+ templateUrl: `./drag-backdrop.component.html`,
1724
+ host: {
1725
+ class: 'gantt-drag-backdrop'
1726
+ }
1727
+ }]
1728
+ }] });
1729
+
1651
1730
  class GanttPrintService {
1652
1731
  constructor() { }
1653
1732
  setInlineStyles(targetElem) {
@@ -1684,52 +1763,55 @@ class GanttPrintService {
1684
1763
  this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
1685
1764
  }
1686
1765
  print(name = 'download', ignoreElementClass) {
1687
- const root = this.root;
1688
- const mainContainer = this.mainContainer;
1689
- // set print width
1690
- const printWidth = root.offsetWidth;
1691
- // set print height
1692
- const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
1693
- html2canvas(root, {
1694
- logging: false,
1695
- allowTaint: true,
1696
- useCORS: true,
1697
- width: printWidth,
1698
- height: printHeight,
1699
- ignoreElements: (element) => {
1700
- if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
1701
- return true;
1702
- }
1703
- if (element.classList.contains('gantt-calendar-today-overlay')) {
1704
- return true;
1705
- }
1706
- },
1707
- onclone: (cloneDocument) => {
1708
- const ganttClass = root.className;
1709
- const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
1710
- const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
1711
- const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
1712
- const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
1713
- // change targetDom width
1714
- cloneGanttDom.style.width = `${printWidth}px`;
1715
- cloneGanttDom.style.height = `${printHeight}px`;
1716
- cloneGanttDom.style.overflow = `unset`;
1717
- cloneGanttContainerDom.style.backgroundColor = '#fff';
1718
- cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
1719
- cloneCalendarOverlay.setAttribute('style', `background: transparent`);
1720
- if (cloneLinksOverlay) {
1721
- cloneLinksOverlay.setAttribute('height', `${printHeight}`);
1722
- cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
1766
+ return __awaiter(this, void 0, void 0, function* () {
1767
+ const root = this.root;
1768
+ const mainContainer = this.mainContainer;
1769
+ // set print width
1770
+ const printWidth = root.offsetWidth;
1771
+ // set print height
1772
+ const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
1773
+ const html2canvas = (yield import(/* webpackChunkName: 'html2canvas' */ 'html2canvas')).default;
1774
+ html2canvas(root, {
1775
+ logging: false,
1776
+ allowTaint: true,
1777
+ useCORS: true,
1778
+ width: printWidth,
1779
+ height: printHeight,
1780
+ ignoreElements: (element) => {
1781
+ if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
1782
+ return true;
1783
+ }
1784
+ if (element.classList.contains('gantt-calendar-today-overlay')) {
1785
+ return true;
1786
+ }
1787
+ },
1788
+ onclone: (cloneDocument) => {
1789
+ const ganttClass = root.className;
1790
+ const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
1791
+ const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
1792
+ const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
1793
+ const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
1794
+ // change targetDom width
1795
+ cloneGanttDom.style.width = `${printWidth}px`;
1796
+ cloneGanttDom.style.height = `${printHeight}px`;
1797
+ cloneGanttDom.style.overflow = `unset`;
1798
+ cloneGanttContainerDom.style.backgroundColor = '#fff';
1799
+ cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
1800
+ cloneCalendarOverlay.setAttribute('style', `background: transparent`);
1801
+ if (cloneLinksOverlay) {
1802
+ cloneLinksOverlay.setAttribute('height', `${printHeight}`);
1803
+ cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
1804
+ }
1805
+ // setInlineStyles for svg
1806
+ this.setInlineStyles(cloneGanttDom);
1723
1807
  }
1724
- // setInlineStyles for svg
1725
- this.setInlineStyles(cloneGanttDom);
1726
- }
1727
- }).then((canvas) => {
1728
- const link = document.createElement('a');
1729
- const dataUrl = canvas.toDataURL('image/png');
1730
- link.download = `${name}.png`;
1731
- link.href = dataUrl;
1732
- link.click();
1808
+ }).then((canvas) => {
1809
+ const link = document.createElement('a');
1810
+ const dataUrl = canvas.toDataURL('image/png');
1811
+ link.download = `${name}.png`;
1812
+ link.href = dataUrl;
1813
+ link.click();
1814
+ });
1733
1815
  });
1734
1816
  }
1735
1817
  }
@@ -1745,7 +1827,6 @@ class GanttCalendarComponent {
1745
1827
  this.ganttUpper = ganttUpper;
1746
1828
  this.ngZone = ngZone;
1747
1829
  this.elementRef = elementRef;
1748
- this.unsubscribe$ = new Subject();
1749
1830
  this.headerHeight = headerHeight;
1750
1831
  this.mainHeight = mainHeight;
1751
1832
  this.todayHeight = todayHeight;
@@ -1753,6 +1834,7 @@ class GanttCalendarComponent {
1753
1834
  this.todayBorderRadius = todayBorderRadius;
1754
1835
  this.viewTypes = GanttViewType;
1755
1836
  this.className = true;
1837
+ this.unsubscribe$ = new Subject();
1756
1838
  }
1757
1839
  get view() {
1758
1840
  return this.ganttUpper.view;
@@ -1780,16 +1862,21 @@ class GanttCalendarComponent {
1780
1862
  }
1781
1863
  }
1782
1864
  ngOnInit() {
1783
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1784
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
1785
- .pipe(takeUntil(this.unsubscribe$))
1786
- .subscribe(() => {
1787
- this.setTodayPoint();
1865
+ // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
1866
+ // the `onStable` will never emit any value.
1867
+ const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
1868
+ // Normally this isn't in the zone, but it can cause performance regressions for apps
1869
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
1870
+ this.ngZone.runOutsideAngular(() => {
1871
+ onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1872
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
1873
+ .pipe(takeUntil(this.unsubscribe$))
1874
+ .subscribe(() => {
1875
+ this.setTodayPoint();
1876
+ });
1788
1877
  });
1789
1878
  });
1790
1879
  }
1791
- ngAfterViewInit() { }
1792
- ngOnChanges(changes) { }
1793
1880
  trackBy(index, point) {
1794
1881
  return point.text || index;
1795
1882
  }
@@ -1799,7 +1886,7 @@ class GanttCalendarComponent {
1799
1886
  }
1800
1887
  }
1801
1888
  GanttCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttCalendarComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1802
- GanttCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: GanttCalendarComponent, selector: "gantt-calendar-overlay", host: { properties: { "class.gantt-calendar-overlay": "this.className" } }, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1889
+ GanttCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", 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 class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1803
1890
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttCalendarComponent, decorators: [{
1804
1891
  type: Component,
1805
1892
  args: [{
@@ -1814,25 +1901,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImpor
1814
1901
  args: ['class.gantt-calendar-overlay']
1815
1902
  }] } });
1816
1903
 
1817
- class GanttDragBackdropComponent {
1818
- constructor() {
1819
- this.backdropClass = true;
1820
- }
1821
- ngOnInit() { }
1822
- }
1823
- GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1824
- GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { properties: { "class.gantt-drag-backdrop": "this.backdropClass" } }, ngImport: i0, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" });
1825
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
1826
- type: Component,
1827
- args: [{
1828
- selector: 'gantt-drag-backdrop',
1829
- templateUrl: `./drag-backdrop.component.html`
1830
- }]
1831
- }], ctorParameters: function () { return []; }, propDecorators: { backdropClass: [{
1832
- type: HostBinding,
1833
- args: ['class.gantt-drag-backdrop']
1834
- }] } });
1835
-
1836
1904
  class NgxGanttRootComponent {
1837
1905
  constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
1838
1906
  this.elementRef = elementRef;
@@ -1841,7 +1909,6 @@ class NgxGanttRootComponent {
1841
1909
  this.dragContainer = dragContainer;
1842
1910
  this.ganttUpper = ganttUpper;
1843
1911
  this.printService = printService;
1844
- this.ganttClass = true;
1845
1912
  this.unsubscribe$ = new Subject();
1846
1913
  this.ganttUpper.dragContainer = dragContainer;
1847
1914
  }
@@ -1849,44 +1916,52 @@ class NgxGanttRootComponent {
1849
1916
  return this.ganttUpper.view;
1850
1917
  }
1851
1918
  ngOnInit() {
1852
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1853
- this.dom.initialize(this.elementRef);
1854
- if (this.printService) {
1855
- this.printService.register(this.elementRef);
1856
- }
1857
- this.setupScrollClass();
1858
- this.setupResize();
1859
- this.setupViewScroll();
1860
- // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
1861
- this.elementRef.nativeElement.style.opacity = '1';
1862
- this.ganttUpper.viewChange.pipe(startWith(null)).subscribe(() => {
1863
- this.scrollToToday();
1919
+ // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
1920
+ // the `onStable` will never emit any value.
1921
+ const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
1922
+ // Normally this isn't in the zone, but it can cause performance regressions for apps
1923
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
1924
+ this.ngZone.runOutsideAngular(() => {
1925
+ onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1926
+ this.dom.initialize(this.elementRef);
1927
+ if (this.printService) {
1928
+ this.printService.register(this.elementRef);
1929
+ }
1930
+ this.setupScrollClass();
1931
+ this.setupResize();
1932
+ this.setupViewScroll();
1933
+ // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
1934
+ this.elementRef.nativeElement.style.opacity = '1';
1935
+ this.ganttUpper.viewChange.pipe(startWith(null), takeUntil(this.unsubscribe$)).subscribe(() => {
1936
+ this.scrollToToday();
1937
+ });
1864
1938
  });
1865
1939
  });
1866
1940
  }
1941
+ ngOnDestroy() {
1942
+ this.unsubscribe$.next();
1943
+ }
1867
1944
  setupViewScroll() {
1868
1945
  if (this.ganttUpper.disabledLoadOnScroll) {
1869
1946
  return;
1870
1947
  }
1871
1948
  this.dom
1872
- .getViewerScroll()
1949
+ .getViewerScroll(passiveListenerOptions)
1873
1950
  .pipe(takeUntil(this.unsubscribe$))
1874
1951
  .subscribe((event) => {
1875
1952
  if (event.direction === ScrollDirection.LEFT) {
1876
1953
  const dates = this.view.addStartDate();
1877
1954
  if (dates) {
1878
1955
  event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
1879
- this.ngZone.run(() => {
1880
- this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
1881
- });
1956
+ if (this.ganttUpper.loadOnScroll.observers) {
1957
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
1958
+ }
1882
1959
  }
1883
1960
  }
1884
1961
  if (event.direction === ScrollDirection.RIGHT) {
1885
1962
  const dates = this.view.addEndDate();
1886
- if (dates) {
1887
- this.ngZone.run(() => {
1888
- this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
1889
- });
1963
+ if (dates && this.ganttUpper.loadOnScroll.observers) {
1964
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
1890
1965
  }
1891
1966
  }
1892
1967
  });
@@ -1916,13 +1991,16 @@ class NgxGanttRootComponent {
1916
1991
  }
1917
1992
  }
1918
1993
  NgxGanttRootComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", 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 });
1919
- NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { properties: { "class.gantt": "this.ganttClass" } }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\">\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\">\n <gantt-calendar-overlay></gantt-calendar-overlay>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n", components: [{ type: GanttCalendarComponent, selector: "gantt-calendar-overlay" }, { type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }], directives: [{ type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
1994
+ NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", 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", components: [{ type: GanttCalendarComponent, selector: "gantt-calendar-overlay" }, { type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }], directives: [{ type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
1920
1995
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
1921
1996
  type: Component,
1922
1997
  args: [{
1923
1998
  selector: 'ngx-gantt-root',
1924
1999
  templateUrl: './root.component.html',
1925
- providers: [GanttDomService, GanttDragContainer]
2000
+ providers: [GanttDomService, GanttDragContainer],
2001
+ host: {
2002
+ class: 'gantt'
2003
+ }
1926
2004
  }]
1927
2005
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
1928
2006
  type: Inject,
@@ -1931,15 +2009,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImpor
1931
2009
  type: Optional
1932
2010
  }] }]; }, propDecorators: { sideWidth: [{
1933
2011
  type: Input
1934
- }], ganttClass: [{
1935
- type: HostBinding,
1936
- args: ['class.gantt']
1937
2012
  }], sideTemplate: [{
1938
2013
  type: ContentChild,
1939
2014
  args: ['sideTemplate', { static: true }]
1940
2015
  }], mainTemplate: [{
1941
2016
  type: ContentChild,
1942
2017
  args: ['mainTemplate', { static: true }]
2018
+ }], backdrop: [{
2019
+ type: ViewChild,
2020
+ args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
1943
2021
  }] } });
1944
2022
 
1945
2023
  class GanttLinkLine {
@@ -2148,7 +2226,7 @@ class GanttLinksComponent {
2148
2226
  this.elementRef.nativeElement.style.visibility = 'hidden';
2149
2227
  });
2150
2228
  merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded)
2151
- .pipe(takeUntil(this.unsubscribe$), skip(1), debounceTime(0))
2229
+ .pipe(skip(1), debounceTime(0), takeUntil(this.unsubscribe$))
2152
2230
  .subscribe(() => {
2153
2231
  this.elementRef.nativeElement.style.visibility = 'visible';
2154
2232
  this.buildLinks();
@@ -2291,13 +2369,13 @@ class GanttItemUpper {
2291
2369
  this.firstChange = true;
2292
2370
  this.unsubscribe$ = new Subject();
2293
2371
  }
2294
- onInit() {
2372
+ ngOnInit() {
2295
2373
  this.firstChange = false;
2296
2374
  this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2297
2375
  this.setPositions();
2298
2376
  });
2299
2377
  }
2300
- onChanges() {
2378
+ ngOnChanges() {
2301
2379
  if (!this.firstChange) {
2302
2380
  this.setPositions();
2303
2381
  }
@@ -2316,13 +2394,13 @@ class GanttItemUpper {
2316
2394
  else {
2317
2395
  }
2318
2396
  }
2319
- onDestroy() {
2397
+ ngOnDestroy() {
2320
2398
  this.unsubscribe$.next();
2321
2399
  this.unsubscribe$.complete();
2322
2400
  }
2323
2401
  }
2324
2402
  GanttItemUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttItemUpper, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Directive });
2325
- GanttItemUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.5", type: GanttItemUpper, inputs: { template: "template", item: "item" }, ngImport: i0 });
2403
+ GanttItemUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.5", type: GanttItemUpper, inputs: { template: "template", item: "item" }, usesOnChanges: true, ngImport: i0 });
2326
2404
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttItemUpper, decorators: [{
2327
2405
  type: Directive
2328
2406
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
@@ -2339,18 +2417,9 @@ class NgxGanttRangeComponent extends GanttItemUpper {
2339
2417
  super(elementRef, ganttUpper);
2340
2418
  this.ganttRangeClass = true;
2341
2419
  }
2342
- ngOnInit() {
2343
- super.onInit();
2344
- }
2345
- ngOnChanges() {
2346
- super.onChanges();
2347
- }
2348
- ngOnDestroy() {
2349
- super.onDestroy();
2350
- }
2351
2420
  }
2352
2421
  NgxGanttRangeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttRangeComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2353
- NgxGanttRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range", host: { properties: { "class.gantt-range": "this.ganttRangeClass" } }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"item.start && item.end\">\n <div class=\"gantt-range-main\">\n <div class=\"gantt-range-main-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n </div>\n <div class=\"gantt-range-triangle left\"></div>\n <div class=\"gantt-range-triangle right\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</ng-container>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2422
+ NgxGanttRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range", host: { properties: { "class.gantt-range": "this.ganttRangeClass" } }, usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"item.start && item.end\">\n <div class=\"gantt-range-main\">\n <div class=\"gantt-range-main-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n </div>\n <div class=\"gantt-range-triangle left\"></div>\n <div class=\"gantt-range-triangle right\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</ng-container>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2354
2423
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttRangeComponent, decorators: [{
2355
2424
  type: Component,
2356
2425
  args: [{
@@ -2375,10 +2444,11 @@ function createSvgElement(qualifiedName, className) {
2375
2444
  return element;
2376
2445
  }
2377
2446
  class GanttBarDrag {
2378
- constructor(dragDrop, dom, dragContainer) {
2447
+ constructor(dragDrop, dom, dragContainer, root) {
2379
2448
  this.dragDrop = dragDrop;
2380
2449
  this.dom = dom;
2381
2450
  this.dragContainer = dragContainer;
2451
+ this.root = root;
2382
2452
  this.dragRefs = [];
2383
2453
  this.destroy$ = new Subject();
2384
2454
  }
@@ -2394,9 +2464,9 @@ class GanttBarDrag {
2394
2464
  ((_c = this.ganttUpper.config.linkOptions) === null || _c === void 0 ? void 0 : _c.dependencyTypes[0]) === GanttLinkType.fs
2395
2465
  ? singleDropActiveClass
2396
2466
  : dropActiveClass;
2397
- fromEvent(this.barElement, 'mouseenter')
2467
+ fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
2398
2468
  .pipe(takeUntil(this.destroy$))
2399
- .subscribe((event) => {
2469
+ .subscribe(() => {
2400
2470
  if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2401
2471
  if (this.item.linkable) {
2402
2472
  this.barElement.classList.add(dropClass);
@@ -2410,9 +2480,9 @@ class GanttBarDrag {
2410
2480
  this.barElement.classList.add(activeClass);
2411
2481
  }
2412
2482
  });
2413
- fromEvent(this.barElement, 'mouseleave')
2483
+ fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
2414
2484
  .pipe(takeUntil(this.destroy$))
2415
- .subscribe((event) => {
2485
+ .subscribe(() => {
2416
2486
  if (!this.dragContainer.linkDraggingId) {
2417
2487
  this.barElement.classList.remove(activeClass);
2418
2488
  }
@@ -2473,7 +2543,7 @@ class GanttBarDrag {
2473
2543
  if (width > dragMinWidth) {
2474
2544
  this.barElement.style.width = width + 'px';
2475
2545
  this.barElement.style.left = x + 'px';
2476
- this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), this.ganttUpper.view.getDateByXPoint(x + width));
2546
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), this.item.end);
2477
2547
  this.item.updateDate(this.ganttUpper.view.getDateByXPoint(x), this.item.end);
2478
2548
  }
2479
2549
  }
@@ -2481,7 +2551,7 @@ class GanttBarDrag {
2481
2551
  const width = this.item.refs.width + event.distance.x;
2482
2552
  if (width > dragMinWidth) {
2483
2553
  this.barElement.style.width = width + 'px';
2484
- this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(this.item.refs.x), this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
2554
+ this.openDragBackdrop(this.barElement, this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
2485
2555
  }
2486
2556
  this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
2487
2557
  }
@@ -2563,22 +2633,24 @@ class GanttBarDrag {
2563
2633
  return dragRefs;
2564
2634
  }
2565
2635
  openDragBackdrop(dragElement, start, end) {
2566
- const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
2567
- const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
2636
+ const dragBackdropElement = this.root.backdrop.nativeElement;
2637
+ const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask');
2568
2638
  const rootRect = this.dom.root.getBoundingClientRect();
2569
2639
  const dragRect = dragElement.getBoundingClientRect();
2570
2640
  const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
2571
2641
  const width = dragRect.right - dragRect.left;
2642
+ // Note: updating styles will cause re-layout so we have to place them consistently one by one.
2572
2643
  dragMaskElement.style.left = left + 'px';
2573
2644
  dragMaskElement.style.width = width + 'px';
2574
- dragMaskElement.querySelector('.start').innerHTML = start.format('MM-dd');
2575
- dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
2576
2645
  dragMaskElement.style.display = 'block';
2577
2646
  dragBackdropElement.style.display = 'block';
2647
+ // This will invalidate the layout, but we won't need re-layout, because we set styles previously.
2648
+ dragMaskElement.querySelector('.start').innerHTML = start.format('MM-dd');
2649
+ dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
2578
2650
  }
2579
2651
  closeDragBackdrop() {
2580
- const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
2581
- const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
2652
+ const dragBackdropElement = this.root.backdrop.nativeElement;
2653
+ const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask');
2582
2654
  dragMaskElement.style.display = 'none';
2583
2655
  dragBackdropElement.style.display = 'none';
2584
2656
  }
@@ -2644,27 +2716,30 @@ class GanttBarDrag {
2644
2716
  this.destroy$.complete();
2645
2717
  }
2646
2718
  }
2647
- GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttBarDrag, deps: [{ token: i1.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }], target: i0.ɵɵFactoryTarget.Injectable });
2719
+ GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttBarDrag, deps: [{ token: i1.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
2648
2720
  GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttBarDrag });
2649
2721
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: GanttBarDrag, decorators: [{
2650
2722
  type: Injectable
2651
- }], ctorParameters: function () { return [{ type: i1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }]; } });
2723
+ }], ctorParameters: function () { return [{ type: i1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: NgxGanttRootComponent, decorators: [{
2724
+ type: SkipSelf
2725
+ }] }]; } });
2652
2726
 
2653
2727
  function linearGradient(sideOrCorner, color, stop) {
2654
2728
  return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
2655
2729
  }
2656
2730
  class NgxGanttBarComponent extends GanttItemUpper {
2657
- constructor(dragContainer, drag, elementRef, ganttUpper) {
2731
+ constructor(dragContainer, drag, elementRef, ganttUpper, ngZone) {
2658
2732
  super(elementRef, ganttUpper);
2659
2733
  this.dragContainer = dragContainer;
2660
2734
  this.drag = drag;
2661
2735
  this.ganttUpper = ganttUpper;
2736
+ this.ngZone = ngZone;
2662
2737
  this.barClick = new EventEmitter();
2663
2738
  this.ganttItemClass = true;
2664
2739
  this.color = 'red';
2665
2740
  }
2666
2741
  ngOnInit() {
2667
- super.onInit();
2742
+ super.ngOnInit();
2668
2743
  this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2669
2744
  this.setContentBackground();
2670
2745
  });
@@ -2672,9 +2747,14 @@ class NgxGanttBarComponent extends GanttItemUpper {
2672
2747
  ngAfterViewInit() {
2673
2748
  this.drag.createDrags(this.elementRef, this.item, this.ganttUpper);
2674
2749
  this.setContentBackground();
2675
- }
2676
- ngOnChanges() {
2677
- super.onChanges();
2750
+ this.handles.changes
2751
+ .pipe(startWith(this.handles), switchMap(() =>
2752
+ // Note: we need to explicitly subscribe outside of the Angular zone since `addEventListener`
2753
+ // is called when the `fromEvent` is subscribed.
2754
+ new Observable((subscriber) => this.ngZone.runOutsideAngular(() => merge(...this.handles.toArray().map((handle) => fromEvent(handle.nativeElement, 'mousedown'))).subscribe(subscriber)))), takeUntil(this.unsubscribe$))
2755
+ .subscribe((event) => {
2756
+ event.stopPropagation();
2757
+ });
2678
2758
  }
2679
2759
  onBarClick(event) {
2680
2760
  this.barClick.emit({ event, item: this.item.origin });
@@ -2710,12 +2790,9 @@ class NgxGanttBarComponent extends GanttItemUpper {
2710
2790
  stopPropagation(event) {
2711
2791
  event.stopPropagation();
2712
2792
  }
2713
- ngOnDestroy() {
2714
- super.onDestroy();
2715
- }
2716
2793
  }
2717
- NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2718
- NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div *ngIf=\"item.draggable && ganttUpper.draggable\" class=\"drag-handles\">\n <ng-container>\n <span class=\"handle\" (mousedown)=\"stopPropagation($event)\"></span>\n <span class=\"handle\" (mousedown)=\"stopPropagation($event)\"></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2794
+ NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
2795
+ NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", 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 *ngIf=\"item.draggable && ganttUpper.draggable\" class=\"drag-handles\">\n <ng-container>\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", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2719
2796
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
2720
2797
  type: Component,
2721
2798
  args: [{
@@ -2726,7 +2803,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImpor
2726
2803
  }], ctorParameters: function () { return [{ type: GanttDragContainer }, { type: GanttBarDrag }, { type: i0.ElementRef }, { type: GanttUpper, decorators: [{
2727
2804
  type: Inject,
2728
2805
  args: [GANTT_UPPER_TOKEN]
2729
- }] }]; }, propDecorators: { barClick: [{
2806
+ }] }, { type: i0.NgZone }]; }, propDecorators: { barClick: [{
2730
2807
  type: Output
2731
2808
  }], contentElementRef: [{
2732
2809
  type: ViewChild,
@@ -2734,6 +2811,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImpor
2734
2811
  }], ganttItemClass: [{
2735
2812
  type: HostBinding,
2736
2813
  args: ['class.gantt-bar']
2814
+ }], handles: [{
2815
+ type: ViewChildren,
2816
+ args: ['handle']
2737
2817
  }] } });
2738
2818
 
2739
2819
  class GanttMainComponent {
@@ -2743,7 +2823,6 @@ class GanttMainComponent {
2743
2823
  this.lineClick = new EventEmitter();
2744
2824
  this.ganttMainClass = true;
2745
2825
  }
2746
- ngOnInit() { }
2747
2826
  trackBy(index, item) {
2748
2827
  return item.id || index;
2749
2828
  }
@@ -2792,13 +2871,20 @@ class NgxGanttComponent extends GanttUpper {
2792
2871
  this.sideTableWidth = sideWidth;
2793
2872
  }
2794
2873
  ngOnInit() {
2795
- super.onInit();
2796
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2797
- this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2798
- this.linkDragStarted.emit(event);
2799
- });
2800
- this.dragContainer.linkDragEnded.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2801
- this.linkDragEnded.emit(event);
2874
+ super.ngOnInit();
2875
+ // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
2876
+ // the `onStable` will never emit any value.
2877
+ const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
2878
+ // Normally this isn't in the zone, but it can cause performance regressions for apps
2879
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
2880
+ this.ngZone.runOutsideAngular(() => {
2881
+ onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2882
+ this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2883
+ this.linkDragStarted.emit(event);
2884
+ });
2885
+ this.dragContainer.linkDragEnded.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2886
+ this.linkDragEnded.emit(event);
2887
+ });
2802
2888
  });
2803
2889
  });
2804
2890
  }
@@ -2812,9 +2898,6 @@ class NgxGanttComponent extends GanttUpper {
2812
2898
  this.cdr.detectChanges();
2813
2899
  });
2814
2900
  }
2815
- ngOnChanges(changes) {
2816
- super.onChanges(changes);
2817
- }
2818
2901
  expandChildren(item) {
2819
2902
  if (!item.expanded) {
2820
2903
  item.setExpand(true);
@@ -2858,9 +2941,6 @@ class NgxGanttComponent extends GanttUpper {
2858
2941
  this.selectedChange.emit({ event, selectedValue: _selectedValue });
2859
2942
  }
2860
2943
  }
2861
- ngOnDestroy() {
2862
- super.onDestroy();
2863
- }
2864
2944
  }
2865
2945
  NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
2866
2946
  NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
@@ -2872,7 +2952,7 @@ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
2872
2952
  provide: GANTT_ABSTRACT_TOKEN,
2873
2953
  useExisting: forwardRef(() => NgxGanttComponent)
2874
2954
  }
2875
- ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ngx-gantt-root>\n <ng-template #sideTemplate>\n <gantt-table\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", components: [{ type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }, { type: GanttTableComponent, selector: "gantt-table", inputs: ["groups", "items", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate"], outputs: ["itemClick"] }, { type: GanttMainComponent, selector: "gantt-main", inputs: ["groups", "items", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2955
+ ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], usesInheritance: true, ngImport: i0, template: "<ngx-gantt-root>\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", components: [{ type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }, { type: GanttTableComponent, selector: "gantt-table", inputs: ["groups", "items", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate"], outputs: ["itemClick"] }, { type: GanttMainComponent, selector: "gantt-main", inputs: ["groups", "items", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2876
2956
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxGanttComponent, decorators: [{
2877
2957
  type: Component,
2878
2958
  args: [{