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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Injectable, ViewChild, Pipe, ViewChildren, PLATFORM_ID, ElementRef, Optional, SkipSelf, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
2
+ import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Injectable, ViewChild, Pipe, ViewChildren, PLATFORM_ID, ElementRef, Optional, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { DOCUMENT, isPlatformServer, CommonModule } from '@angular/common';
5
5
  import { take, takeUntil, skip, switchMap, debounceTime, map, pairwise, auditTime as auditTime$1, startWith as startWith$1, finalize } from 'rxjs/operators';
6
- import { BehaviorSubject, Subject, from, takeUntil as takeUntil$1, startWith, auditTime, filter, merge, EMPTY, fromEvent, Observable } from 'rxjs';
6
+ import { BehaviorSubject, Subject, from, takeUntil as takeUntil$1, startWith, auditTime, filter, merge, EMPTY, fromEvent, Observable, interval, animationFrameScheduler } from 'rxjs';
7
7
  import { fromUnixTime, getWeek, getDaysInMonth, differenceInCalendarDays, setDate, addSeconds, addMinutes, addHours, addDays, addWeeks, addMonths, addQuarters, addYears, startOfDay, startOfWeek, startOfMonth, startOfQuarter, startOfYear, endOfDay, endOfWeek, endOfMonth, endOfQuarter, endOfYear, getUnixTime, format, isWeekend, isToday, differenceInDays, differenceInCalendarQuarters, eachMonthOfInterval, eachYearOfInterval, eachWeekOfInterval, eachDayOfInterval, differenceInCalendarYears } from 'date-fns';
8
8
  export { addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarQuarters, differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, endOfDay, endOfMonth, endOfQuarter, endOfWeek, endOfYear, format, fromUnixTime, getDaysInMonth, getUnixTime, getWeek, isToday, isWeekend, setDate, startOfDay, startOfMonth, startOfQuarter, startOfWeek, startOfYear } from 'date-fns';
9
9
  import { SelectionModel } from '@angular/cdk/collections';
@@ -1052,16 +1052,17 @@ class GanttUpper {
1052
1052
  this.ngZone.runOutsideAngular(() => {
1053
1053
  onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1054
1054
  this.element.style.opacity = '1';
1055
+ const disabledLoadOnScroll = this.disabledLoadOnScroll;
1055
1056
  this.dragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1057
+ this.disabledLoadOnScroll = true;
1056
1058
  this.dragStarted.emit(event);
1057
1059
  });
1058
1060
  this.dragContainer.dragMoved.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1059
1061
  this.dragMoved.emit(event);
1060
1062
  });
1061
1063
  this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
1064
+ this.disabledLoadOnScroll = disabledLoadOnScroll;
1062
1065
  this.dragEnded.emit(event);
1063
- // this.computeRefs();
1064
- // this.detectChanges();
1065
1066
  });
1066
1067
  });
1067
1068
  });
@@ -1831,6 +1832,7 @@ class GanttTableBodyComponent {
1831
1832
  }
1832
1833
  else {
1833
1834
  this.itemDropTarget = null;
1835
+ this.cleanupDragArtifacts(false);
1834
1836
  }
1835
1837
  }
1836
1838
  else {
@@ -2490,6 +2492,41 @@ function normalizePassiveListenerOptions(options) {
2490
2492
  /** Options used to bind passive event listeners. */
2491
2493
  const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
2492
2494
 
2495
+ /**
2496
+ * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
2497
+ * viewport. The value comes from trying it out manually until it feels right.
2498
+ */
2499
+ const SCROLL_PROXIMITY_THRESHOLD = 0.05;
2500
+ /**
2501
+ * Gets whether the horizontal auto-scroll direction of a node.
2502
+ * @param clientRect Dimensions of the node.
2503
+ * @param pointerX Position of the user's pointer along the x axis.
2504
+ */
2505
+ function getHorizontalScrollDirection(clientRect, pointerX) {
2506
+ const { left, right, width } = clientRect;
2507
+ const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
2508
+ if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
2509
+ return 1 /* AutoScrollHorizontalDirection.LEFT */;
2510
+ }
2511
+ else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
2512
+ return 2 /* AutoScrollHorizontalDirection.RIGHT */;
2513
+ }
2514
+ return 0 /* AutoScrollHorizontalDirection.NONE */;
2515
+ }
2516
+ /**
2517
+ * Checks whether the pointer coordinates are close to a ClientRect.
2518
+ * @param rect ClientRect to check against.
2519
+ * @param threshold Threshold around the ClientRect.
2520
+ * @param pointerX Coordinates along the X axis.
2521
+ * @param pointerY Coordinates along the Y axis.
2522
+ */
2523
+ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
2524
+ const { top, right, bottom, left, width, height } = rect;
2525
+ const xThreshold = width * threshold;
2526
+ const yThreshold = height * threshold;
2527
+ return pointerY > top - yThreshold && pointerY < bottom + yThreshold && pointerX > left - xThreshold && pointerX < right + xThreshold;
2528
+ }
2529
+
2493
2530
  const scrollThreshold = 50;
2494
2531
  var ScrollDirection;
2495
2532
  (function (ScrollDirection) {
@@ -2599,461 +2636,192 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2599
2636
  }] }];
2600
2637
  } });
2601
2638
 
2602
- class GanttDragBackdropComponent {
2639
+ /**
2640
+ * Proximity, as a ratio to width/height, at which a
2641
+ * dragged item will affect the drop container.
2642
+ */
2643
+ const DROP_PROXIMITY_THRESHOLD = 0.05;
2644
+ const dragMinWidth = 10;
2645
+ const autoScrollStep = 5;
2646
+ const activeClass = 'gantt-bar-active';
2647
+ const dropActiveClass = 'gantt-bar-drop-active';
2648
+ const singleDropActiveClass = 'gantt-bar-single-drop-active';
2649
+ function createSvgElement(qualifiedName, className) {
2650
+ const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2651
+ element.classList.add(className);
2652
+ return element;
2603
2653
  }
2604
- GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2605
- GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { classAttribute: "gantt-drag-backdrop" }, ngImport: i0, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" });
2606
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
2607
- type: Component,
2608
- args: [{ selector: 'gantt-drag-backdrop', host: {
2609
- class: 'gantt-drag-backdrop'
2610
- }, 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" }]
2611
- }] });
2612
-
2613
- class GanttCalendarHeaderComponent {
2614
- get view() {
2615
- return this.ganttUpper.view;
2654
+ class GanttBarDrag {
2655
+ get dragDisabled() {
2656
+ return !this.item.draggable || !this.ganttUpper.draggable;
2616
2657
  }
2617
- constructor(ganttUpper, ngZone, elementRef) {
2618
- this.ganttUpper = ganttUpper;
2619
- this.ngZone = ngZone;
2620
- this.elementRef = elementRef;
2621
- this.unsubscribe$ = new Subject();
2622
- this.headerHeight = headerHeight;
2623
- this.viewTypes = GanttViewType;
2624
- this.className = `gantt-calendar gantt-calendar-header`;
2658
+ get linkDragDisabled() {
2659
+ return !this.item.linkable || !this.ganttUpper.linkable;
2625
2660
  }
2626
- ngOnInit() {
2627
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2628
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2629
- .pipe(takeUntil(this.unsubscribe$))
2661
+ constructor(dragDrop, dom, dragContainer, _ngZone) {
2662
+ this.dragDrop = dragDrop;
2663
+ this.dom = dom;
2664
+ this.dragContainer = dragContainer;
2665
+ this._ngZone = _ngZone;
2666
+ this.dragRefs = [];
2667
+ this.destroy$ = new Subject();
2668
+ /** Used to signal to the current auto-scroll sequence when to stop. */
2669
+ this.stopScrollTimers$ = new Subject();
2670
+ /** move distance when drag bar */
2671
+ this.barDragMoveDistance = 0;
2672
+ /** move distance when drag bar handle */
2673
+ this.barHandleDragMoveDistance = 0;
2674
+ /** scrolling state when drag */
2675
+ this.dragScrolling = false;
2676
+ /** dragScrollDistance */
2677
+ this.dragScrollDistance = 0;
2678
+ /** Horizontal direction in which the list is currently scrolling. */
2679
+ this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
2680
+ this.startScrollInterval = () => {
2681
+ this.stopScrolling();
2682
+ interval(0, animationFrameScheduler)
2683
+ .pipe(takeUntil(this.stopScrollTimers$))
2630
2684
  .subscribe(() => {
2631
- if (this.ganttUpper.viewType === GanttViewType.day)
2632
- this.setTodayPoint();
2685
+ const node = this.dom.mainContainer;
2686
+ const scrollStep = autoScrollStep;
2687
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2688
+ node.scrollBy(-scrollStep, 0);
2689
+ }
2690
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2691
+ node.scrollBy(scrollStep, 0);
2692
+ }
2633
2693
  });
2634
- });
2635
- }
2636
- setTodayPoint() {
2637
- const x = this.view.getTodayXPoint();
2638
- const today = new GanttDate().getDate();
2639
- const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
2640
- const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
2641
- if (isNumber(x)) {
2642
- if (rect) {
2643
- rect.style.left = `${x - todayWidth / 2}px`;
2644
- rect.style.top = `${headerHeight - todayHeight}px`;
2645
- rect.innerHTML = today.toString();
2646
- }
2647
- }
2648
- else {
2649
- todayEle.style.display = 'none';
2650
- }
2651
- }
2652
- trackBy(point, index) {
2653
- return point.text || index;
2694
+ };
2654
2695
  }
2655
- }
2656
- 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 });
2657
- GanttCalendarHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header", host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n</div>\n<svg [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\n class=\"primary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text\n class=\"secondary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"headerHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n</svg>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
2658
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
2659
- type: Component,
2660
- 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" }]
2661
- }], ctorParameters: function () {
2662
- return [{ type: GanttUpper, decorators: [{
2663
- type: Inject,
2664
- args: [GANTT_UPPER_TOKEN]
2665
- }] }, { type: i0.NgZone }, { type: i0.ElementRef }];
2666
- }, propDecorators: { className: [{
2667
- type: HostBinding,
2668
- args: ['class']
2669
- }] } });
2670
-
2671
- const mainHeight = 5000;
2672
- class GanttCalendarGridComponent {
2673
- get view() {
2674
- return this.ganttUpper.view;
2696
+ createDragRef(element) {
2697
+ const dragRef = this.dragDrop.createDrag(element);
2698
+ return dragRef;
2675
2699
  }
2676
- constructor(ganttUpper, ngZone, elementRef) {
2677
- this.ganttUpper = ganttUpper;
2678
- this.ngZone = ngZone;
2679
- this.elementRef = elementRef;
2680
- this.unsubscribe$ = new Subject();
2681
- this.headerHeight = headerHeight;
2682
- this.mainHeight = mainHeight;
2683
- this.todayBorderRadius = todayBorderRadius;
2684
- this.viewTypes = GanttViewType;
2685
- this.className = `gantt-calendar gantt-calendar-grid`;
2700
+ createDragScrollEvent(dragRef) {
2701
+ return fromEvent(this.dom.mainContainer, 'scroll', passiveListenerOptions).pipe(takeUntil(dragRef.ended));
2686
2702
  }
2687
- setTodayPoint() {
2688
- const x = this.view.getTodayXPoint();
2689
- const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
2690
- const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
2691
- if (isNumber(x)) {
2692
- if (line) {
2693
- line.style.left = `${x}px`;
2694
- line.style.top = `0px`;
2695
- line.style.bottom = `${-mainHeight}px`;
2703
+ createMouseEvents() {
2704
+ var _a, _b, _c;
2705
+ const dropClass = ((_b = (_a = this.ganttUpper.config.linkOptions) === null || _a === void 0 ? void 0 : _a.dependencyTypes) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
2706
+ ((_c = this.ganttUpper.config.linkOptions) === null || _c === void 0 ? void 0 : _c.dependencyTypes[0]) === GanttLinkType.fs
2707
+ ? singleDropActiveClass
2708
+ : dropActiveClass;
2709
+ fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
2710
+ .pipe(takeUntil(this.destroy$))
2711
+ .subscribe(() => {
2712
+ if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2713
+ if (this.item.linkable) {
2714
+ this.barElement.classList.add(dropClass);
2715
+ this.dragContainer.emitLinkDragEntered({
2716
+ item: this.item,
2717
+ element: this.barElement
2718
+ });
2719
+ }
2696
2720
  }
2697
- }
2698
- else {
2699
- todayEle.style.display = 'none';
2700
- }
2721
+ else {
2722
+ this.barElement.classList.add(activeClass);
2723
+ }
2724
+ });
2725
+ fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
2726
+ .pipe(takeUntil(this.destroy$))
2727
+ .subscribe(() => {
2728
+ if (!this.dragContainer.linkDraggingId) {
2729
+ this.barElement.classList.remove(activeClass);
2730
+ }
2731
+ else {
2732
+ this.dragContainer.emitLinkDragLeaved();
2733
+ }
2734
+ this.barElement.classList.remove(dropClass);
2735
+ });
2701
2736
  }
2702
- ngOnInit() {
2703
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2704
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2705
- .pipe(takeUntil(this.unsubscribe$))
2706
- .subscribe(() => {
2707
- this.setTodayPoint();
2737
+ createBarDrag() {
2738
+ const dragRef = this.createDragRef(this.barElement);
2739
+ dragRef.lockAxis = 'x';
2740
+ dragRef.withBoundaryElement(this.dom.mainItems);
2741
+ dragRef.started.subscribe(() => {
2742
+ this.setDraggingStyles();
2743
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2744
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2745
+ if (dragRef.isDragging()) {
2746
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2747
+ this.dragScrollDistance = dragScrollDistance;
2748
+ dragRef['_boundaryRect'] = this.dom.mainItems.getBoundingClientRect();
2749
+ this.barDragMove();
2750
+ }
2751
+ });
2752
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2753
+ });
2754
+ dragRef.moved.subscribe((event) => {
2755
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2756
+ this.barDragMoveDistance = event.distance.x;
2757
+ if (!this.dragScrolling) {
2758
+ this.barDragMove();
2759
+ }
2760
+ });
2761
+ dragRef.ended.subscribe((event) => {
2762
+ this.clearDraggingStyles();
2763
+ this.closeDragBackdrop();
2764
+ event.source.reset();
2765
+ this.stopScrolling();
2766
+ this.dragScrolling = false;
2767
+ this.dragScrollDistance = 0;
2768
+ this.barDragMoveDistance = 0;
2769
+ this.item.updateRefs({
2770
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2771
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2772
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2708
2773
  });
2774
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2709
2775
  });
2776
+ this.barDragRef = dragRef;
2777
+ return dragRef;
2710
2778
  }
2711
- trackBy(point, index) {
2712
- return point.text || index;
2713
- }
2714
- ngOnDestroy() {
2715
- this.unsubscribe$.next();
2716
- this.unsubscribe$.complete();
2717
- }
2718
- }
2719
- 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 });
2720
- 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"] }] });
2721
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
2722
- type: Component,
2723
- 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" }]
2724
- }], ctorParameters: function () {
2725
- return [{ type: GanttUpper, decorators: [{
2726
- type: Inject,
2727
- args: [GANTT_UPPER_TOKEN]
2728
- }] }, { type: i0.NgZone }, { type: i0.ElementRef }];
2729
- }, propDecorators: { className: [{
2730
- type: HostBinding,
2731
- args: ['class']
2732
- }] } });
2733
-
2734
- class NgxGanttToolbarComponent {
2735
- constructor(ganttUpper) {
2736
- this.ganttUpper = ganttUpper;
2737
- this.ganttItemClass = true;
2738
- this.ganttViewsMap = keyBy(ganttViews, 'value');
2739
- }
2740
- selectView(view) {
2741
- this.ganttUpper.changeView(view);
2742
- }
2743
- }
2744
- NgxGanttToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2745
- NgxGanttToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: { template: "template" }, host: { properties: { "class.gantt-toolbar": "this.ganttItemClass" } }, ngImport: i0, template: "<div class=\"toolbar-container\">\n <ng-container *ngIf=\"!template\">\n <div class=\"toolbar-views\" *ngIf=\"this.ganttUpper.toolbarOptions?.viewTypes?.length\">\n <ng-container *ngFor=\"let view of this.ganttUpper.toolbarOptions?.viewTypes\">\n <div class=\"toolbar-view\" *ngIf=\"ganttViewsMap[view]\" [class.active]=\"view === this.ganttUpper.viewType\" (click)=\"selectView(view)\">\n {{ ganttViewsMap[view].name }}\n </div>\n </ng-container>\n </div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
2746
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, decorators: [{
2747
- type: Component,
2748
- args: [{ selector: 'ngx-gantt-toolbar,gantt-toolbar', template: "<div class=\"toolbar-container\">\n <ng-container *ngIf=\"!template\">\n <div class=\"toolbar-views\" *ngIf=\"this.ganttUpper.toolbarOptions?.viewTypes?.length\">\n <ng-container *ngFor=\"let view of this.ganttUpper.toolbarOptions?.viewTypes\">\n <div class=\"toolbar-view\" *ngIf=\"ganttViewsMap[view]\" [class.active]=\"view === this.ganttUpper.viewType\" (click)=\"selectView(view)\">\n {{ ganttViewsMap[view].name }}\n </div>\n </ng-container>\n </div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n</div>\n" }]
2749
- }], ctorParameters: function () {
2750
- return [{ type: GanttUpper, decorators: [{
2751
- type: Inject,
2752
- args: [GANTT_UPPER_TOKEN]
2753
- }] }];
2754
- }, propDecorators: { template: [{
2755
- type: Input
2756
- }], ganttItemClass: [{
2757
- type: HostBinding,
2758
- args: ['class.gantt-toolbar']
2759
- }] } });
2760
-
2761
- class NgxGanttRootComponent {
2762
- get view() {
2763
- return this.ganttUpper.view;
2764
- }
2765
- constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
2766
- this.elementRef = elementRef;
2767
- this.ngZone = ngZone;
2768
- this.dom = dom;
2769
- this.dragContainer = dragContainer;
2770
- this.ganttUpper = ganttUpper;
2771
- this.printService = printService;
2772
- this.unsubscribe$ = new Subject();
2773
- this.ganttUpper.dragContainer = dragContainer;
2774
- }
2775
- ngOnInit() {
2776
- // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
2777
- // the `onStable` will never emit any value.
2778
- const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
2779
- // Normally this isn't in the zone, but it can cause performance regressions for apps
2780
- // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
2781
- this.ngZone.runOutsideAngular(() => {
2782
- onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2783
- this.dom.initialize(this.elementRef);
2784
- if (this.printService) {
2785
- this.printService.register(this.elementRef);
2786
- }
2787
- this.setupScrollClass();
2788
- this.setupResize();
2789
- this.setupViewScroll();
2790
- // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
2791
- this.elementRef.nativeElement.style.opacity = '1';
2792
- this.ganttUpper.viewChange.pipe(startWith$1(null), takeUntil(this.unsubscribe$)).subscribe(() => {
2793
- this.scrollToToday();
2794
- });
2795
- });
2796
- });
2797
- }
2798
- ngOnDestroy() {
2799
- this.unsubscribe$.next();
2800
- }
2801
- setupViewScroll() {
2802
- if (this.ganttUpper.disabledLoadOnScroll) {
2803
- return;
2804
- }
2805
- this.dom
2806
- .getViewerScroll(passiveListenerOptions)
2807
- .pipe(takeUntil(this.unsubscribe$))
2808
- .subscribe((event) => {
2809
- if (event.direction === ScrollDirection.LEFT) {
2810
- const dates = this.view.addStartDate();
2811
- if (dates) {
2812
- event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
2813
- if (this.ganttUpper.loadOnScroll.observers) {
2814
- this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
2815
- }
2816
- }
2817
- }
2818
- if (event.direction === ScrollDirection.RIGHT) {
2819
- const dates = this.view.addEndDate();
2820
- if (dates && this.ganttUpper.loadOnScroll.observers) {
2821
- this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
2822
- }
2823
- }
2824
- });
2825
- }
2826
- setupResize() {
2827
- this.dom
2828
- .getResize()
2829
- .pipe(takeUntil(this.unsubscribe$))
2830
- .subscribe(() => {
2831
- this.setupScrollClass();
2832
- });
2833
- }
2834
- setupScrollClass() {
2835
- const mainContainer = this.dom.mainContainer;
2836
- const height = mainContainer.offsetHeight;
2837
- const scrollHeight = mainContainer.scrollHeight;
2838
- if (scrollHeight > height) {
2839
- this.elementRef.nativeElement.className = 'gantt gantt-scroll';
2840
- }
2841
- else {
2842
- this.elementRef.nativeElement.className = 'gantt';
2843
- }
2844
- }
2845
- scrollToToday() {
2846
- const x = this.view.getTodayXPoint();
2847
- this.dom.scrollMainContainer(x);
2848
- }
2849
- scrollToDate(date) {
2850
- let x;
2851
- if (typeof date === 'number') {
2852
- x = this.view.getXPointByDate(new GanttDate(date));
2853
- }
2854
- else {
2855
- x = this.view.getXPointByDate(date);
2856
- }
2857
- this.dom.scrollMainContainer(x);
2858
- }
2859
- }
2860
- 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 });
2861
- 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"] }] });
2862
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
2863
- type: Component,
2864
- args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
2865
- class: 'gantt'
2866
- }, 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" }]
2867
- }], ctorParameters: function () {
2868
- return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
2869
- type: Inject,
2870
- args: [GANTT_UPPER_TOKEN]
2871
- }] }, { type: GanttPrintService, decorators: [{
2872
- type: Optional
2873
- }] }];
2874
- }, propDecorators: { sideWidth: [{
2875
- type: Input
2876
- }], sideTemplate: [{
2877
- type: ContentChild,
2878
- args: ['sideTemplate', { static: true }]
2879
- }], mainTemplate: [{
2880
- type: ContentChild,
2881
- args: ['mainTemplate', { static: true }]
2882
- }], backdrop: [{
2883
- type: ViewChild,
2884
- args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
2885
- }] } });
2886
-
2887
- /**
2888
- * Proximity, as a ratio to width/height, at which a
2889
- * dragged item will affect the drop container.
2890
- */
2891
- const DROP_PROXIMITY_THRESHOLD = 0.05;
2892
- const dragMinWidth = 10;
2893
- const autoScrollStep = 5;
2894
- const activeClass = 'gantt-bar-active';
2895
- const dropActiveClass = 'gantt-bar-drop-active';
2896
- const singleDropActiveClass = 'gantt-bar-single-drop-active';
2897
- function createSvgElement(qualifiedName, className) {
2898
- const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2899
- element.classList.add(className);
2900
- return element;
2901
- }
2902
- class GanttBarDrag {
2903
- get dragDisabled() {
2904
- return !this.item.draggable || !this.ganttUpper.draggable;
2905
- }
2906
- get linkDragDisabled() {
2907
- return !this.item.linkable || !this.ganttUpper.linkable;
2908
- }
2909
- constructor(dragDrop, dom, dragContainer, _ngZone, root) {
2910
- this.dragDrop = dragDrop;
2911
- this.dom = dom;
2912
- this.dragContainer = dragContainer;
2913
- this._ngZone = _ngZone;
2914
- this.root = root;
2915
- this.dragRefs = [];
2916
- this.destroy$ = new Subject();
2917
- /** Used to signal to the current auto-scroll sequence when to stop. */
2918
- this.stopScrollTimers$ = new Subject();
2919
- /** move distance when drag bar */
2920
- this.barDragMoveDistance = 0;
2921
- /** move distance when drag bar handle */
2922
- this.barHandleDragMoveDistance = 0;
2923
- /** scrolling state when drag */
2924
- this.dragScrolling = false;
2925
- /** dragScrollDistance */
2926
- this.dragScrollDistance = 0;
2927
- /** Horizontal direction in which the list is currently scrolling. */
2928
- this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
2929
- }
2930
- createDragRef(element) {
2931
- const dragRef = this.dragDrop.createDrag(element);
2932
- return dragRef;
2933
- }
2934
- createDragScrollEvent(dragRef) {
2935
- return fromEvent(this.dom.mainContainer, 'scroll', passiveListenerOptions).pipe(takeUntil(dragRef.ended));
2936
- }
2937
- createMouseEvents() {
2938
- var _a, _b, _c;
2939
- const dropClass = ((_b = (_a = this.ganttUpper.config.linkOptions) === null || _a === void 0 ? void 0 : _a.dependencyTypes) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
2940
- ((_c = this.ganttUpper.config.linkOptions) === null || _c === void 0 ? void 0 : _c.dependencyTypes[0]) === GanttLinkType.fs
2941
- ? singleDropActiveClass
2942
- : dropActiveClass;
2943
- fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
2944
- .pipe(takeUntil(this.destroy$))
2945
- .subscribe(() => {
2946
- if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2947
- if (this.item.linkable) {
2948
- this.barElement.classList.add(dropClass);
2949
- this.dragContainer.emitLinkDragEntered({
2950
- item: this.item,
2951
- element: this.barElement
2952
- });
2953
- }
2954
- }
2955
- else {
2956
- this.barElement.classList.add(activeClass);
2957
- }
2958
- });
2959
- fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
2960
- .pipe(takeUntil(this.destroy$))
2961
- .subscribe(() => {
2962
- if (!this.dragContainer.linkDraggingId) {
2963
- this.barElement.classList.remove(activeClass);
2964
- }
2965
- else {
2966
- this.dragContainer.emitLinkDragLeaved();
2967
- }
2968
- this.barElement.classList.remove(dropClass);
2969
- });
2970
- }
2971
- createBarDrag() {
2972
- const dragRef = this.createDragRef(this.barElement);
2973
- dragRef.lockAxis = 'x';
2974
- dragRef.withBoundaryElement(this.dom.mainItems);
2975
- dragRef.started.subscribe(() => {
2976
- this.setDraggingStyles();
2977
- // this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2978
- // this.createDragScrollEvent(dragRef).subscribe(() => {
2979
- // if (dragRef.isDragging()) {
2980
- // const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2981
- // this.dragScrollDistance = dragScrollDistance;
2982
- // this.barDragMove();
2983
- // }
2984
- // });
2985
- this.dragContainer.dragStarted.emit({ item: this.item.origin });
2986
- });
2987
- dragRef.moved.subscribe((event) => {
2988
- // this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2989
- this.barDragMoveDistance = event.distance.x;
2990
- if (!this.dragScrolling) {
2991
- this.barDragMove();
2992
- }
2993
- });
2994
- dragRef.ended.subscribe((event) => {
2995
- this.clearDraggingStyles();
2996
- this.closeDragBackdrop();
2997
- event.source.reset();
2998
- // this.stopScrolling();
2999
- // this.dragScrolling = false;
3000
- // this.dragScrollDistance = 0;
3001
- this.barDragMoveDistance = 0;
3002
- this.item.updateRefs({
3003
- width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
3004
- x: this.ganttUpper.view.getXPointByDate(this.item.start),
3005
- y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
3006
- });
3007
- this.dragContainer.dragEnded.emit({ item: this.item.origin });
3008
- });
3009
- this.barDragRef = dragRef;
3010
- return dragRef;
3011
- }
3012
- createBarHandleDrags() {
3013
- const dragRefs = [];
3014
- const handles = this.barElement.querySelectorAll('.drag-handles .handle');
3015
- handles.forEach((handle, index) => {
3016
- const isBefore = index === 0;
3017
- const dragRef = this.createDragRef(handle);
3018
- dragRef.lockAxis = 'x';
3019
- dragRef.withBoundaryElement(this.dom.mainItems);
3020
- dragRef.started.subscribe(() => {
3021
- this.setDraggingStyles();
3022
- // this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
3023
- // this.createDragScrollEvent(dragRef).subscribe(() => {
3024
- // if (dragRef.isDragging()) {
3025
- // const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
3026
- // this.dragScrollDistance = dragScrollDistance;
3027
- // this.barHandleDragMove(isBefore);
3028
- // }
3029
- // });
3030
- this.dragContainer.dragStarted.emit({ item: this.item.origin });
3031
- });
3032
- dragRef.moved.subscribe((event) => {
3033
- // this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
3034
- this.barHandleDragMoveDistance = event.distance.x;
3035
- if (!this.dragScrolling) {
3036
- this.barHandleDragMove(isBefore);
3037
- }
3038
- });
3039
- dragRef.ended.subscribe((event) => {
3040
- this.clearDraggingStyles();
3041
- this.closeDragBackdrop();
3042
- event.source.reset();
3043
- // this.stopScrolling();
3044
- // this.dragScrolling = false;
3045
- // this.dragScrollDistance = 0;
3046
- this.barHandleDragMoveDistance = 0;
3047
- this.item.updateRefs({
3048
- width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
3049
- x: this.ganttUpper.view.getXPointByDate(this.item.start),
3050
- y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
3051
- });
3052
- this.dragContainer.dragEnded.emit({ item: this.item.origin });
3053
- });
3054
- dragRefs.push(dragRef);
3055
- });
3056
- return dragRefs;
2779
+ createBarHandleDrags() {
2780
+ const dragRefs = [];
2781
+ const handles = this.barElement.querySelectorAll('.drag-handles .handle');
2782
+ handles.forEach((handle, index) => {
2783
+ const isBefore = index === 0;
2784
+ const dragRef = this.createDragRef(handle);
2785
+ dragRef.lockAxis = 'x';
2786
+ dragRef.withBoundaryElement(this.dom.mainItems);
2787
+ dragRef.started.subscribe(() => {
2788
+ this.setDraggingStyles();
2789
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2790
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2791
+ if (dragRef.isDragging()) {
2792
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2793
+ this.dragScrollDistance = dragScrollDistance;
2794
+ dragRef['_boundaryRect'] = this.dom.mainItems.getBoundingClientRect();
2795
+ this.barHandleDragMove(isBefore);
2796
+ }
2797
+ });
2798
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2799
+ });
2800
+ dragRef.moved.subscribe((event) => {
2801
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2802
+ this.barHandleDragMoveDistance = event.distance.x;
2803
+ if (!this.dragScrolling) {
2804
+ this.barHandleDragMove(isBefore);
2805
+ }
2806
+ });
2807
+ dragRef.ended.subscribe((event) => {
2808
+ this.clearDraggingStyles();
2809
+ this.closeDragBackdrop();
2810
+ event.source.reset();
2811
+ this.stopScrolling();
2812
+ this.dragScrolling = false;
2813
+ this.dragScrollDistance = 0;
2814
+ this.barHandleDragMoveDistance = 0;
2815
+ this.item.updateRefs({
2816
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2817
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2818
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2819
+ });
2820
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2821
+ });
2822
+ dragRefs.push(dragRef);
2823
+ });
2824
+ return dragRefs;
3057
2825
  }
3058
2826
  createLinkHandleDrags() {
3059
2827
  const dragRefs = [];
@@ -3106,13 +2874,19 @@ class GanttBarDrag {
3106
2874
  return dragRefs;
3107
2875
  }
3108
2876
  openDragBackdrop(dragElement, start, end) {
3109
- // const dragBackdropElement = this.root.backdrop.nativeElement;
3110
- // const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask') as HTMLElement;
3111
2877
  const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
3112
2878
  const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
3113
2879
  const rootRect = this.dom.root.getBoundingClientRect();
3114
2880
  const dragRect = dragElement.getBoundingClientRect();
3115
- const left = dragRect.left - rootRect.left - (this.dom.side.clientWidth + 1);
2881
+ let left = dragRect.left - rootRect.left - (this.dom.side.clientWidth + 1);
2882
+ if (this.dragScrolling) {
2883
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2884
+ left += autoScrollStep;
2885
+ }
2886
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2887
+ left -= autoScrollStep;
2888
+ }
2889
+ }
3116
2890
  const width = dragRect.right - dragRect.left;
3117
2891
  // Note: updating styles will cause re-layout so we have to place them consistently one by one.
3118
2892
  dragMaskElement.style.left = left + 'px';
@@ -3150,7 +2924,8 @@ class GanttBarDrag {
3150
2924
  end = end.addDays(1);
3151
2925
  }
3152
2926
  if (this.dragScrolling) {
3153
- this.barElement.style.left = currentX - this.barDragMoveDistance + 'px';
2927
+ const left = currentX - this.barDragMoveDistance;
2928
+ this.barElement.style.left = left + 'px';
3154
2929
  }
3155
2930
  this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
3156
2931
  if (!this.isStartOrEndInsideView(start, end)) {
@@ -3166,13 +2941,13 @@ class GanttBarDrag {
3166
2941
  const width = this.item.refs.width + distance * -1;
3167
2942
  const start = this.ganttUpper.view.getDateByXPoint(x);
3168
2943
  const days = differenceInDays(this.item.end.value, start.value);
3169
- if (!this.isStartOrEndInsideView(start, this.item.end)) {
3170
- return;
3171
- }
3172
2944
  if (width > dragMinWidth && days > 0) {
3173
2945
  this.barElement.style.width = width + 'px';
3174
2946
  this.barElement.style.left = x + 'px';
3175
2947
  this.openDragBackdrop(this.barElement, start, this.item.end);
2948
+ if (!this.isStartOrEndInsideView(start, this.item.end)) {
2949
+ return;
2950
+ }
3176
2951
  this.item.updateDate(start, this.item.end);
3177
2952
  }
3178
2953
  else {
@@ -3184,12 +2959,12 @@ class GanttBarDrag {
3184
2959
  const width = this.item.refs.width + distance;
3185
2960
  const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
3186
2961
  const days = differenceInDays(end.value, this.item.start.value);
3187
- if (!this.isStartOrEndInsideView(this.item.start, end)) {
3188
- return;
3189
- }
3190
2962
  if (width > dragMinWidth && days > 0) {
3191
2963
  this.barElement.style.width = width + 'px';
3192
2964
  this.openDragBackdrop(this.barElement, this.item.start, end);
2965
+ if (!this.isStartOrEndInsideView(this.item.start, end)) {
2966
+ return;
2967
+ }
3193
2968
  this.item.updateDate(this.item.start, end);
3194
2969
  }
3195
2970
  else {
@@ -3226,37 +3001,27 @@ class GanttBarDrag {
3226
3001
  this.linkDraggingLine = null;
3227
3002
  }
3228
3003
  }
3229
- // private startScrollInterval = () => {
3230
- // this.stopScrolling();
3231
- // interval(0, animationFrameScheduler)
3232
- // .pipe(takeUntil(this.stopScrollTimers$))
3233
- // .subscribe(() => {
3234
- // const node = this.dom.mainContainer;
3235
- // const scrollStep = autoScrollStep;
3236
- // if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.LEFT) {
3237
- // node.scrollBy(-scrollStep, 0);
3238
- // } else if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.RIGHT) {
3239
- // node.scrollBy(scrollStep, 0);
3240
- // }
3241
- // });
3242
- // };
3243
- // private startScrollingIfNecessary(pointerX: number, pointerY: number) {
3244
- // const clientRect = this.dom.mainContainer.getBoundingClientRect();
3245
- // if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
3246
- // const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
3247
- // if (horizontalScrollDirection) {
3248
- // this._horizontalScrollDirection = horizontalScrollDirection;
3249
- // this.dragScrolling = true;
3250
- // this._ngZone.runOutsideAngular(this.startScrollInterval);
3251
- // } else {
3252
- // this.dragScrolling = false;
3253
- // this.stopScrolling();
3254
- // }
3255
- // }
3256
- // }
3257
- // private stopScrolling() {
3258
- // this.stopScrollTimers$.next();
3259
- // }
3004
+ startScrollingIfNecessary(pointerX, pointerY) {
3005
+ const clientRect = this.dom.mainContainer.getBoundingClientRect();
3006
+ const scrollLeft = this.dom.mainContainer.scrollLeft;
3007
+ if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
3008
+ const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
3009
+ if ((horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */ && scrollLeft > 0) ||
3010
+ (horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */ &&
3011
+ scrollLeft < this.ganttUpper.view.width - clientRect.width)) {
3012
+ this._horizontalScrollDirection = horizontalScrollDirection;
3013
+ this.dragScrolling = true;
3014
+ this._ngZone.runOutsideAngular(this.startScrollInterval);
3015
+ }
3016
+ else {
3017
+ this.dragScrolling = false;
3018
+ this.stopScrolling();
3019
+ }
3020
+ }
3021
+ }
3022
+ stopScrolling() {
3023
+ this.stopScrollTimers$.next();
3024
+ }
3260
3025
  isStartOrEndInsideView(start, end) {
3261
3026
  const itemStart = start.getUnixTime();
3262
3027
  const itemEnd = end.getUnixTime();
@@ -3297,19 +3062,15 @@ class GanttBarDrag {
3297
3062
  this.dragRefs.forEach((dragRef) => dragRef.dispose());
3298
3063
  this.destroy$.next();
3299
3064
  this.destroy$.complete();
3300
- // this.stopScrolling();
3065
+ this.stopScrolling();
3301
3066
  this.stopScrollTimers$.complete();
3302
3067
  }
3303
3068
  }
3304
- GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, deps: [{ token: i2.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: i0.NgZone }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
3069
+ GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, deps: [{ token: i2.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
3305
3070
  GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag });
3306
3071
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, decorators: [{
3307
3072
  type: Injectable
3308
- }], ctorParameters: function () {
3309
- return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: i0.NgZone }, { type: NgxGanttRootComponent, decorators: [{
3310
- type: SkipSelf
3311
- }] }];
3312
- } });
3073
+ }], ctorParameters: function () { return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: i0.NgZone }]; } });
3313
3074
 
3314
3075
  class GanttItemUpper {
3315
3076
  constructor(elementRef, ganttUpper) {
@@ -3530,57 +3291,178 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3530
3291
  type: Component,
3531
3292
  args: [{ selector: 'ngx-gantt-baseline,gantt-baseline', template: "<div #content *ngIf=\"baselineItem\" class=\"baseline-content\"></div>\n" }]
3532
3293
  }], ctorParameters: function () {
3533
- return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3294
+ return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3295
+ type: Inject,
3296
+ args: [GANTT_UPPER_TOKEN]
3297
+ }] }];
3298
+ }, propDecorators: { baselineItem: [{
3299
+ type: Input
3300
+ }], ganttBaselineClass: [{
3301
+ type: HostBinding,
3302
+ args: ['class.gantt-baseline']
3303
+ }] } });
3304
+
3305
+ class GanttMainComponent {
3306
+ constructor(ganttUpper) {
3307
+ this.ganttUpper = ganttUpper;
3308
+ this.barClick = new EventEmitter();
3309
+ this.lineClick = new EventEmitter();
3310
+ this.ganttMainClass = true;
3311
+ }
3312
+ trackBy(index, item) {
3313
+ return item.id || index;
3314
+ }
3315
+ }
3316
+ 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 });
3317
+ 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" }] });
3318
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, decorators: [{
3319
+ type: Component,
3320
+ 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" }]
3321
+ }], ctorParameters: function () {
3322
+ return [{ type: GanttUpper, decorators: [{
3323
+ type: Inject,
3324
+ args: [GANTT_UPPER_TOKEN]
3325
+ }] }];
3326
+ }, propDecorators: { renderData: [{
3327
+ type: Input
3328
+ }], flatData: [{
3329
+ type: Input
3330
+ }], groupHeaderTemplate: [{
3331
+ type: Input
3332
+ }], itemTemplate: [{
3333
+ type: Input
3334
+ }], barTemplate: [{
3335
+ type: Input
3336
+ }], rangeTemplate: [{
3337
+ type: Input
3338
+ }], barClick: [{
3339
+ type: Output
3340
+ }], lineClick: [{
3341
+ type: Output
3342
+ }], ganttMainClass: [{
3343
+ type: HostBinding,
3344
+ args: ['class.gantt-main-container']
3345
+ }] } });
3346
+
3347
+ class GanttCalendarHeaderComponent {
3348
+ get view() {
3349
+ return this.ganttUpper.view;
3350
+ }
3351
+ constructor(ganttUpper, ngZone, elementRef) {
3352
+ this.ganttUpper = ganttUpper;
3353
+ this.ngZone = ngZone;
3354
+ this.elementRef = elementRef;
3355
+ this.unsubscribe$ = new Subject();
3356
+ this.headerHeight = headerHeight;
3357
+ this.viewTypes = GanttViewType;
3358
+ this.className = `gantt-calendar gantt-calendar-header`;
3359
+ }
3360
+ ngOnInit() {
3361
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
3362
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
3363
+ .pipe(takeUntil(this.unsubscribe$))
3364
+ .subscribe(() => {
3365
+ if (this.ganttUpper.viewType === GanttViewType.day)
3366
+ this.setTodayPoint();
3367
+ });
3368
+ });
3369
+ }
3370
+ setTodayPoint() {
3371
+ const x = this.view.getTodayXPoint();
3372
+ const today = new GanttDate().getDate();
3373
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
3374
+ const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
3375
+ if (isNumber(x)) {
3376
+ if (rect) {
3377
+ rect.style.left = `${x - todayWidth / 2}px`;
3378
+ rect.style.top = `${headerHeight - todayHeight}px`;
3379
+ rect.innerHTML = today.toString();
3380
+ }
3381
+ }
3382
+ else {
3383
+ todayEle.style.display = 'none';
3384
+ }
3385
+ }
3386
+ trackBy(point, index) {
3387
+ return point.text || index;
3388
+ }
3389
+ }
3390
+ 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 });
3391
+ GanttCalendarHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header", host: { properties: { "class": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n</div>\n<svg [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text\n class=\"primary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text\n class=\"secondary-text\"\n [ngStyle]=\"point.style\"\n [class.today]=\"point.additions?.isToday\"\n [class.weekend]=\"point.additions?.isWeekend\"\n [attr.x]=\"point.x\"\n [attr.y]=\"point.y\"\n >\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"headerHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n</svg>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
3392
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
3393
+ type: Component,
3394
+ 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" }]
3395
+ }], ctorParameters: function () {
3396
+ return [{ type: GanttUpper, decorators: [{
3534
3397
  type: Inject,
3535
3398
  args: [GANTT_UPPER_TOKEN]
3536
- }] }];
3537
- }, propDecorators: { baselineItem: [{
3538
- type: Input
3539
- }], ganttBaselineClass: [{
3399
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }];
3400
+ }, propDecorators: { className: [{
3540
3401
  type: HostBinding,
3541
- args: ['class.gantt-baseline']
3402
+ args: ['class']
3542
3403
  }] } });
3543
3404
 
3544
- class GanttMainComponent {
3545
- constructor(ganttUpper) {
3405
+ const mainHeight = 5000;
3406
+ class GanttCalendarGridComponent {
3407
+ get view() {
3408
+ return this.ganttUpper.view;
3409
+ }
3410
+ constructor(ganttUpper, ngZone, elementRef) {
3546
3411
  this.ganttUpper = ganttUpper;
3547
- this.barClick = new EventEmitter();
3548
- this.lineClick = new EventEmitter();
3549
- this.ganttMainClass = true;
3412
+ this.ngZone = ngZone;
3413
+ this.elementRef = elementRef;
3414
+ this.unsubscribe$ = new Subject();
3415
+ this.headerHeight = headerHeight;
3416
+ this.mainHeight = mainHeight;
3417
+ this.todayBorderRadius = todayBorderRadius;
3418
+ this.viewTypes = GanttViewType;
3419
+ this.className = `gantt-calendar gantt-calendar-grid`;
3550
3420
  }
3551
- trackBy(index, item) {
3552
- return item.id || index;
3421
+ setTodayPoint() {
3422
+ const x = this.view.getTodayXPoint();
3423
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
3424
+ const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
3425
+ if (isNumber(x)) {
3426
+ if (line) {
3427
+ line.style.left = `${x}px`;
3428
+ line.style.top = `0px`;
3429
+ line.style.bottom = `${-mainHeight}px`;
3430
+ }
3431
+ }
3432
+ else {
3433
+ todayEle.style.display = 'none';
3434
+ }
3435
+ }
3436
+ ngOnInit() {
3437
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
3438
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
3439
+ .pipe(takeUntil(this.unsubscribe$))
3440
+ .subscribe(() => {
3441
+ this.setTodayPoint();
3442
+ });
3443
+ });
3444
+ }
3445
+ trackBy(point, index) {
3446
+ return point.text || index;
3447
+ }
3448
+ ngOnDestroy() {
3449
+ this.unsubscribe$.next();
3450
+ this.unsubscribe$.complete();
3553
3451
  }
3554
3452
  }
3555
- 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 });
3556
- 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" }] });
3557
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, decorators: [{
3453
+ 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 });
3454
+ 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"] }] });
3455
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
3558
3456
  type: Component,
3559
- 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" }]
3457
+ 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" }]
3560
3458
  }], ctorParameters: function () {
3561
3459
  return [{ type: GanttUpper, decorators: [{
3562
3460
  type: Inject,
3563
3461
  args: [GANTT_UPPER_TOKEN]
3564
- }] }];
3565
- }, propDecorators: { renderData: [{
3566
- type: Input
3567
- }], flatData: [{
3568
- type: Input
3569
- }], groupHeaderTemplate: [{
3570
- type: Input
3571
- }], itemTemplate: [{
3572
- type: Input
3573
- }], barTemplate: [{
3574
- type: Input
3575
- }], rangeTemplate: [{
3576
- type: Input
3577
- }], barClick: [{
3578
- type: Output
3579
- }], lineClick: [{
3580
- type: Output
3581
- }], ganttMainClass: [{
3462
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }];
3463
+ }, propDecorators: { className: [{
3582
3464
  type: HostBinding,
3583
- args: ['class.gantt-main-container']
3465
+ args: ['class']
3584
3466
  }] } });
3585
3467
 
3586
3468
  class GanttLoaderComponent {
@@ -3610,6 +3492,170 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3610
3492
  }]
3611
3493
  }] });
3612
3494
 
3495
+ class GanttDragBackdropComponent {
3496
+ }
3497
+ GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3498
+ GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { classAttribute: "gantt-drag-backdrop" }, ngImport: i0, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" });
3499
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
3500
+ type: Component,
3501
+ args: [{ selector: 'gantt-drag-backdrop', host: {
3502
+ class: 'gantt-drag-backdrop'
3503
+ }, 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" }]
3504
+ }] });
3505
+
3506
+ class NgxGanttToolbarComponent {
3507
+ constructor(ganttUpper) {
3508
+ this.ganttUpper = ganttUpper;
3509
+ this.ganttItemClass = true;
3510
+ this.ganttViewsMap = keyBy(ganttViews, 'value');
3511
+ }
3512
+ selectView(view) {
3513
+ this.ganttUpper.changeView(view);
3514
+ }
3515
+ }
3516
+ NgxGanttToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
3517
+ NgxGanttToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: { template: "template" }, host: { properties: { "class.gantt-toolbar": "this.ganttItemClass" } }, ngImport: i0, template: "<div class=\"toolbar-container\">\n <ng-container *ngIf=\"!template\">\n <div class=\"toolbar-views\" *ngIf=\"this.ganttUpper.toolbarOptions?.viewTypes?.length\">\n <ng-container *ngFor=\"let view of this.ganttUpper.toolbarOptions?.viewTypes\">\n <div class=\"toolbar-view\" *ngIf=\"ganttViewsMap[view]\" [class.active]=\"view === this.ganttUpper.viewType\" (click)=\"selectView(view)\">\n {{ ganttViewsMap[view].name }}\n </div>\n </ng-container>\n </div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3518
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, decorators: [{
3519
+ type: Component,
3520
+ args: [{ selector: 'ngx-gantt-toolbar,gantt-toolbar', template: "<div class=\"toolbar-container\">\n <ng-container *ngIf=\"!template\">\n <div class=\"toolbar-views\" *ngIf=\"this.ganttUpper.toolbarOptions?.viewTypes?.length\">\n <ng-container *ngFor=\"let view of this.ganttUpper.toolbarOptions?.viewTypes\">\n <div class=\"toolbar-view\" *ngIf=\"ganttViewsMap[view]\" [class.active]=\"view === this.ganttUpper.viewType\" (click)=\"selectView(view)\">\n {{ ganttViewsMap[view].name }}\n </div>\n </ng-container>\n </div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n</div>\n" }]
3521
+ }], ctorParameters: function () {
3522
+ return [{ type: GanttUpper, decorators: [{
3523
+ type: Inject,
3524
+ args: [GANTT_UPPER_TOKEN]
3525
+ }] }];
3526
+ }, propDecorators: { template: [{
3527
+ type: Input
3528
+ }], ganttItemClass: [{
3529
+ type: HostBinding,
3530
+ args: ['class.gantt-toolbar']
3531
+ }] } });
3532
+
3533
+ class NgxGanttRootComponent {
3534
+ get view() {
3535
+ return this.ganttUpper.view;
3536
+ }
3537
+ constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
3538
+ this.elementRef = elementRef;
3539
+ this.ngZone = ngZone;
3540
+ this.dom = dom;
3541
+ this.dragContainer = dragContainer;
3542
+ this.ganttUpper = ganttUpper;
3543
+ this.printService = printService;
3544
+ this.unsubscribe$ = new Subject();
3545
+ this.ganttUpper.dragContainer = dragContainer;
3546
+ }
3547
+ ngOnInit() {
3548
+ // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
3549
+ // the `onStable` will never emit any value.
3550
+ const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
3551
+ // Normally this isn't in the zone, but it can cause performance regressions for apps
3552
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
3553
+ this.ngZone.runOutsideAngular(() => {
3554
+ onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3555
+ this.dom.initialize(this.elementRef);
3556
+ if (this.printService) {
3557
+ this.printService.register(this.elementRef);
3558
+ }
3559
+ this.setupScrollClass();
3560
+ this.setupResize();
3561
+ this.setupViewScroll();
3562
+ // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
3563
+ this.elementRef.nativeElement.style.opacity = '1';
3564
+ this.ganttUpper.viewChange.pipe(startWith$1(null), takeUntil(this.unsubscribe$)).subscribe(() => {
3565
+ this.scrollToToday();
3566
+ });
3567
+ });
3568
+ });
3569
+ }
3570
+ ngOnDestroy() {
3571
+ this.unsubscribe$.next();
3572
+ }
3573
+ setupViewScroll() {
3574
+ if (this.ganttUpper.disabledLoadOnScroll) {
3575
+ return;
3576
+ }
3577
+ this.dom
3578
+ .getViewerScroll(passiveListenerOptions)
3579
+ .pipe(takeUntil(this.unsubscribe$))
3580
+ .subscribe((event) => {
3581
+ if (event.direction === ScrollDirection.LEFT) {
3582
+ const dates = this.view.addStartDate();
3583
+ if (dates) {
3584
+ event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
3585
+ if (this.ganttUpper.loadOnScroll.observers) {
3586
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
3587
+ }
3588
+ }
3589
+ }
3590
+ if (event.direction === ScrollDirection.RIGHT) {
3591
+ const dates = this.view.addEndDate();
3592
+ if (dates && this.ganttUpper.loadOnScroll.observers) {
3593
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
3594
+ }
3595
+ }
3596
+ });
3597
+ }
3598
+ setupResize() {
3599
+ this.dom
3600
+ .getResize()
3601
+ .pipe(takeUntil(this.unsubscribe$))
3602
+ .subscribe(() => {
3603
+ this.setupScrollClass();
3604
+ });
3605
+ }
3606
+ setupScrollClass() {
3607
+ const mainContainer = this.dom.mainContainer;
3608
+ const height = mainContainer.offsetHeight;
3609
+ const scrollHeight = mainContainer.scrollHeight;
3610
+ if (scrollHeight > height) {
3611
+ this.elementRef.nativeElement.className = 'gantt gantt-scroll';
3612
+ }
3613
+ else {
3614
+ this.elementRef.nativeElement.className = 'gantt';
3615
+ }
3616
+ }
3617
+ scrollToToday() {
3618
+ const x = this.view.getTodayXPoint();
3619
+ this.dom.scrollMainContainer(x);
3620
+ }
3621
+ scrollToDate(date) {
3622
+ let x;
3623
+ if (typeof date === 'number') {
3624
+ x = this.view.getXPointByDate(new GanttDate(date));
3625
+ }
3626
+ else {
3627
+ x = this.view.getXPointByDate(date);
3628
+ }
3629
+ this.dom.scrollMainContainer(x);
3630
+ }
3631
+ }
3632
+ 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 });
3633
+ 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"] }] });
3634
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
3635
+ type: Component,
3636
+ args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
3637
+ class: 'gantt'
3638
+ }, 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" }]
3639
+ }], ctorParameters: function () {
3640
+ return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
3641
+ type: Inject,
3642
+ args: [GANTT_UPPER_TOKEN]
3643
+ }] }, { type: GanttPrintService, decorators: [{
3644
+ type: Optional
3645
+ }] }];
3646
+ }, propDecorators: { sideWidth: [{
3647
+ type: Input
3648
+ }], sideTemplate: [{
3649
+ type: ContentChild,
3650
+ args: ['sideTemplate', { static: true }]
3651
+ }], mainTemplate: [{
3652
+ type: ContentChild,
3653
+ args: ['mainTemplate', { static: true }]
3654
+ }], backdrop: [{
3655
+ type: ViewChild,
3656
+ args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
3657
+ }] } });
3658
+
3613
3659
  class NgxGanttComponent extends GanttUpper {
3614
3660
  set loading(loading) {
3615
3661
  if (loading) {