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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Injectable, ViewChild, Pipe, ViewChildren, PLATFORM_ID, ElementRef, Optional, SkipSelf, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
2
+ import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Injectable, ViewChild, Pipe, ViewChildren, PLATFORM_ID, ElementRef, Optional, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { DOCUMENT, isPlatformServer, CommonModule } from '@angular/common';
5
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
  });
@@ -2490,6 +2491,41 @@ function normalizePassiveListenerOptions(options) {
2490
2491
  /** Options used to bind passive event listeners. */
2491
2492
  const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
2492
2493
 
2494
+ /**
2495
+ * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
2496
+ * viewport. The value comes from trying it out manually until it feels right.
2497
+ */
2498
+ const SCROLL_PROXIMITY_THRESHOLD = 0.05;
2499
+ /**
2500
+ * Gets whether the horizontal auto-scroll direction of a node.
2501
+ * @param clientRect Dimensions of the node.
2502
+ * @param pointerX Position of the user's pointer along the x axis.
2503
+ */
2504
+ function getHorizontalScrollDirection(clientRect, pointerX) {
2505
+ const { left, right, width } = clientRect;
2506
+ const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
2507
+ if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
2508
+ return 1 /* AutoScrollHorizontalDirection.LEFT */;
2509
+ }
2510
+ else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
2511
+ return 2 /* AutoScrollHorizontalDirection.RIGHT */;
2512
+ }
2513
+ return 0 /* AutoScrollHorizontalDirection.NONE */;
2514
+ }
2515
+ /**
2516
+ * Checks whether the pointer coordinates are close to a ClientRect.
2517
+ * @param rect ClientRect to check against.
2518
+ * @param threshold Threshold around the ClientRect.
2519
+ * @param pointerX Coordinates along the X axis.
2520
+ * @param pointerY Coordinates along the Y axis.
2521
+ */
2522
+ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
2523
+ const { top, right, bottom, left, width, height } = rect;
2524
+ const xThreshold = width * threshold;
2525
+ const yThreshold = height * threshold;
2526
+ return pointerY > top - yThreshold && pointerY < bottom + yThreshold && pointerX > left - xThreshold && pointerX < right + xThreshold;
2527
+ }
2528
+
2493
2529
  const scrollThreshold = 50;
2494
2530
  var ScrollDirection;
2495
2531
  (function (ScrollDirection) {
@@ -2599,461 +2635,192 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2599
2635
  }] }];
2600
2636
  } });
2601
2637
 
2602
- class GanttDragBackdropComponent {
2638
+ /**
2639
+ * Proximity, as a ratio to width/height, at which a
2640
+ * dragged item will affect the drop container.
2641
+ */
2642
+ const DROP_PROXIMITY_THRESHOLD = 0.05;
2643
+ const dragMinWidth = 10;
2644
+ const autoScrollStep = 5;
2645
+ const activeClass = 'gantt-bar-active';
2646
+ const dropActiveClass = 'gantt-bar-drop-active';
2647
+ const singleDropActiveClass = 'gantt-bar-single-drop-active';
2648
+ function createSvgElement(qualifiedName, className) {
2649
+ const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2650
+ element.classList.add(className);
2651
+ return element;
2603
2652
  }
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;
2653
+ class GanttBarDrag {
2654
+ get dragDisabled() {
2655
+ return !this.item.draggable || !this.ganttUpper.draggable;
2616
2656
  }
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`;
2657
+ get linkDragDisabled() {
2658
+ return !this.item.linkable || !this.ganttUpper.linkable;
2625
2659
  }
2626
- ngOnInit() {
2627
- this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2628
- merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
2629
- .pipe(takeUntil(this.unsubscribe$))
2660
+ constructor(dragDrop, dom, dragContainer, _ngZone) {
2661
+ this.dragDrop = dragDrop;
2662
+ this.dom = dom;
2663
+ this.dragContainer = dragContainer;
2664
+ this._ngZone = _ngZone;
2665
+ this.dragRefs = [];
2666
+ this.destroy$ = new Subject();
2667
+ /** Used to signal to the current auto-scroll sequence when to stop. */
2668
+ this.stopScrollTimers$ = new Subject();
2669
+ /** move distance when drag bar */
2670
+ this.barDragMoveDistance = 0;
2671
+ /** move distance when drag bar handle */
2672
+ this.barHandleDragMoveDistance = 0;
2673
+ /** scrolling state when drag */
2674
+ this.dragScrolling = false;
2675
+ /** dragScrollDistance */
2676
+ this.dragScrollDistance = 0;
2677
+ /** Horizontal direction in which the list is currently scrolling. */
2678
+ this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
2679
+ this.startScrollInterval = () => {
2680
+ this.stopScrolling();
2681
+ interval(0, animationFrameScheduler)
2682
+ .pipe(takeUntil(this.stopScrollTimers$))
2630
2683
  .subscribe(() => {
2631
- if (this.ganttUpper.viewType === GanttViewType.day)
2632
- this.setTodayPoint();
2684
+ const node = this.dom.mainContainer;
2685
+ const scrollStep = autoScrollStep;
2686
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2687
+ node.scrollBy(-scrollStep, 0);
2688
+ }
2689
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2690
+ node.scrollBy(scrollStep, 0);
2691
+ }
2633
2692
  });
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;
2693
+ };
2654
2694
  }
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;
2695
+ createDragRef(element) {
2696
+ const dragRef = this.dragDrop.createDrag(element);
2697
+ return dragRef;
2675
2698
  }
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`;
2699
+ createDragScrollEvent(dragRef) {
2700
+ return fromEvent(this.dom.mainContainer, 'scroll', passiveListenerOptions).pipe(takeUntil(dragRef.ended));
2686
2701
  }
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`;
2702
+ createMouseEvents() {
2703
+ var _a, _b, _c;
2704
+ 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 &&
2705
+ ((_c = this.ganttUpper.config.linkOptions) === null || _c === void 0 ? void 0 : _c.dependencyTypes[0]) === GanttLinkType.fs
2706
+ ? singleDropActiveClass
2707
+ : dropActiveClass;
2708
+ fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
2709
+ .pipe(takeUntil(this.destroy$))
2710
+ .subscribe(() => {
2711
+ if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2712
+ if (this.item.linkable) {
2713
+ this.barElement.classList.add(dropClass);
2714
+ this.dragContainer.emitLinkDragEntered({
2715
+ item: this.item,
2716
+ element: this.barElement
2717
+ });
2718
+ }
2696
2719
  }
2697
- }
2698
- else {
2699
- todayEle.style.display = 'none';
2700
- }
2720
+ else {
2721
+ this.barElement.classList.add(activeClass);
2722
+ }
2723
+ });
2724
+ fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
2725
+ .pipe(takeUntil(this.destroy$))
2726
+ .subscribe(() => {
2727
+ if (!this.dragContainer.linkDraggingId) {
2728
+ this.barElement.classList.remove(activeClass);
2729
+ }
2730
+ else {
2731
+ this.dragContainer.emitLinkDragLeaved();
2732
+ }
2733
+ this.barElement.classList.remove(dropClass);
2734
+ });
2701
2735
  }
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();
2736
+ createBarDrag() {
2737
+ const dragRef = this.createDragRef(this.barElement);
2738
+ dragRef.lockAxis = 'x';
2739
+ dragRef.withBoundaryElement(this.dom.mainItems);
2740
+ dragRef.started.subscribe(() => {
2741
+ this.setDraggingStyles();
2742
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2743
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2744
+ if (dragRef.isDragging()) {
2745
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2746
+ this.dragScrollDistance = dragScrollDistance;
2747
+ dragRef['_boundaryRect'] = this.dom.mainItems.getBoundingClientRect();
2748
+ this.barDragMove();
2749
+ }
2750
+ });
2751
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2752
+ });
2753
+ dragRef.moved.subscribe((event) => {
2754
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2755
+ this.barDragMoveDistance = event.distance.x;
2756
+ if (!this.dragScrolling) {
2757
+ this.barDragMove();
2758
+ }
2759
+ });
2760
+ dragRef.ended.subscribe((event) => {
2761
+ this.clearDraggingStyles();
2762
+ this.closeDragBackdrop();
2763
+ event.source.reset();
2764
+ this.stopScrolling();
2765
+ this.dragScrolling = false;
2766
+ this.dragScrollDistance = 0;
2767
+ this.barDragMoveDistance = 0;
2768
+ this.item.updateRefs({
2769
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2770
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2771
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2708
2772
  });
2773
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2709
2774
  });
2775
+ this.barDragRef = dragRef;
2776
+ return dragRef;
2710
2777
  }
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;
2778
+ createBarHandleDrags() {
2779
+ const dragRefs = [];
2780
+ const handles = this.barElement.querySelectorAll('.drag-handles .handle');
2781
+ handles.forEach((handle, index) => {
2782
+ const isBefore = index === 0;
2783
+ const dragRef = this.createDragRef(handle);
2784
+ dragRef.lockAxis = 'x';
2785
+ dragRef.withBoundaryElement(this.dom.mainItems);
2786
+ dragRef.started.subscribe(() => {
2787
+ this.setDraggingStyles();
2788
+ this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2789
+ this.createDragScrollEvent(dragRef).subscribe(() => {
2790
+ if (dragRef.isDragging()) {
2791
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2792
+ this.dragScrollDistance = dragScrollDistance;
2793
+ dragRef['_boundaryRect'] = this.dom.mainItems.getBoundingClientRect();
2794
+ this.barHandleDragMove(isBefore);
2795
+ }
2796
+ });
2797
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2798
+ });
2799
+ dragRef.moved.subscribe((event) => {
2800
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2801
+ this.barHandleDragMoveDistance = event.distance.x;
2802
+ if (!this.dragScrolling) {
2803
+ this.barHandleDragMove(isBefore);
2804
+ }
2805
+ });
2806
+ dragRef.ended.subscribe((event) => {
2807
+ this.clearDraggingStyles();
2808
+ this.closeDragBackdrop();
2809
+ event.source.reset();
2810
+ this.stopScrolling();
2811
+ this.dragScrolling = false;
2812
+ this.dragScrollDistance = 0;
2813
+ this.barHandleDragMoveDistance = 0;
2814
+ this.item.updateRefs({
2815
+ width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
2816
+ x: this.ganttUpper.view.getXPointByDate(this.item.start),
2817
+ y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
2818
+ });
2819
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2820
+ });
2821
+ dragRefs.push(dragRef);
2822
+ });
2823
+ return dragRefs;
3057
2824
  }
3058
2825
  createLinkHandleDrags() {
3059
2826
  const dragRefs = [];
@@ -3106,13 +2873,19 @@ class GanttBarDrag {
3106
2873
  return dragRefs;
3107
2874
  }
3108
2875
  openDragBackdrop(dragElement, start, end) {
3109
- // const dragBackdropElement = this.root.backdrop.nativeElement;
3110
- // const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask') as HTMLElement;
3111
2876
  const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
3112
2877
  const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
3113
2878
  const rootRect = this.dom.root.getBoundingClientRect();
3114
2879
  const dragRect = dragElement.getBoundingClientRect();
3115
- const left = dragRect.left - rootRect.left - (this.dom.side.clientWidth + 1);
2880
+ let left = dragRect.left - rootRect.left - (this.dom.side.clientWidth + 1);
2881
+ if (this.dragScrolling) {
2882
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2883
+ left += autoScrollStep;
2884
+ }
2885
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2886
+ left -= autoScrollStep;
2887
+ }
2888
+ }
3116
2889
  const width = dragRect.right - dragRect.left;
3117
2890
  // Note: updating styles will cause re-layout so we have to place them consistently one by one.
3118
2891
  dragMaskElement.style.left = left + 'px';
@@ -3150,7 +2923,8 @@ class GanttBarDrag {
3150
2923
  end = end.addDays(1);
3151
2924
  }
3152
2925
  if (this.dragScrolling) {
3153
- this.barElement.style.left = currentX - this.barDragMoveDistance + 'px';
2926
+ const left = currentX - this.barDragMoveDistance;
2927
+ this.barElement.style.left = left + 'px';
3154
2928
  }
3155
2929
  this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
3156
2930
  if (!this.isStartOrEndInsideView(start, end)) {
@@ -3166,13 +2940,13 @@ class GanttBarDrag {
3166
2940
  const width = this.item.refs.width + distance * -1;
3167
2941
  const start = this.ganttUpper.view.getDateByXPoint(x);
3168
2942
  const days = differenceInDays(this.item.end.value, start.value);
3169
- if (!this.isStartOrEndInsideView(start, this.item.end)) {
3170
- return;
3171
- }
3172
2943
  if (width > dragMinWidth && days > 0) {
3173
2944
  this.barElement.style.width = width + 'px';
3174
2945
  this.barElement.style.left = x + 'px';
3175
2946
  this.openDragBackdrop(this.barElement, start, this.item.end);
2947
+ if (!this.isStartOrEndInsideView(start, this.item.end)) {
2948
+ return;
2949
+ }
3176
2950
  this.item.updateDate(start, this.item.end);
3177
2951
  }
3178
2952
  else {
@@ -3184,12 +2958,12 @@ class GanttBarDrag {
3184
2958
  const width = this.item.refs.width + distance;
3185
2959
  const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
3186
2960
  const days = differenceInDays(end.value, this.item.start.value);
3187
- if (!this.isStartOrEndInsideView(this.item.start, end)) {
3188
- return;
3189
- }
3190
2961
  if (width > dragMinWidth && days > 0) {
3191
2962
  this.barElement.style.width = width + 'px';
3192
2963
  this.openDragBackdrop(this.barElement, this.item.start, end);
2964
+ if (!this.isStartOrEndInsideView(this.item.start, end)) {
2965
+ return;
2966
+ }
3193
2967
  this.item.updateDate(this.item.start, end);
3194
2968
  }
3195
2969
  else {
@@ -3226,37 +3000,27 @@ class GanttBarDrag {
3226
3000
  this.linkDraggingLine = null;
3227
3001
  }
3228
3002
  }
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
- // }
3003
+ startScrollingIfNecessary(pointerX, pointerY) {
3004
+ const clientRect = this.dom.mainContainer.getBoundingClientRect();
3005
+ const scrollLeft = this.dom.mainContainer.scrollLeft;
3006
+ if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
3007
+ const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
3008
+ if ((horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */ && scrollLeft > 0) ||
3009
+ (horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */ &&
3010
+ scrollLeft < this.ganttUpper.view.width - clientRect.width)) {
3011
+ this._horizontalScrollDirection = horizontalScrollDirection;
3012
+ this.dragScrolling = true;
3013
+ this._ngZone.runOutsideAngular(this.startScrollInterval);
3014
+ }
3015
+ else {
3016
+ this.dragScrolling = false;
3017
+ this.stopScrolling();
3018
+ }
3019
+ }
3020
+ }
3021
+ stopScrolling() {
3022
+ this.stopScrollTimers$.next();
3023
+ }
3260
3024
  isStartOrEndInsideView(start, end) {
3261
3025
  const itemStart = start.getUnixTime();
3262
3026
  const itemEnd = end.getUnixTime();
@@ -3297,19 +3061,15 @@ class GanttBarDrag {
3297
3061
  this.dragRefs.forEach((dragRef) => dragRef.dispose());
3298
3062
  this.destroy$.next();
3299
3063
  this.destroy$.complete();
3300
- // this.stopScrolling();
3064
+ this.stopScrolling();
3301
3065
  this.stopScrollTimers$.complete();
3302
3066
  }
3303
3067
  }
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 });
3068
+ 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
3069
  GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag });
3306
3070
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, decorators: [{
3307
3071
  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
- } });
3072
+ }], ctorParameters: function () { return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: i0.NgZone }]; } });
3313
3073
 
3314
3074
  class GanttItemUpper {
3315
3075
  constructor(elementRef, ganttUpper) {
@@ -3530,57 +3290,178 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3530
3290
  type: Component,
3531
3291
  args: [{ selector: 'ngx-gantt-baseline,gantt-baseline', template: "<div #content *ngIf=\"baselineItem\" class=\"baseline-content\"></div>\n" }]
3532
3292
  }], ctorParameters: function () {
3533
- return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3293
+ return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3294
+ type: Inject,
3295
+ args: [GANTT_UPPER_TOKEN]
3296
+ }] }];
3297
+ }, propDecorators: { baselineItem: [{
3298
+ type: Input
3299
+ }], ganttBaselineClass: [{
3300
+ type: HostBinding,
3301
+ args: ['class.gantt-baseline']
3302
+ }] } });
3303
+
3304
+ class GanttMainComponent {
3305
+ constructor(ganttUpper) {
3306
+ this.ganttUpper = ganttUpper;
3307
+ this.barClick = new EventEmitter();
3308
+ this.lineClick = new EventEmitter();
3309
+ this.ganttMainClass = true;
3310
+ }
3311
+ trackBy(index, item) {
3312
+ return item.id || index;
3313
+ }
3314
+ }
3315
+ 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 });
3316
+ 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" }] });
3317
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttMainComponent, decorators: [{
3318
+ type: Component,
3319
+ 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" }]
3320
+ }], ctorParameters: function () {
3321
+ return [{ type: GanttUpper, decorators: [{
3322
+ type: Inject,
3323
+ args: [GANTT_UPPER_TOKEN]
3324
+ }] }];
3325
+ }, propDecorators: { renderData: [{
3326
+ type: Input
3327
+ }], flatData: [{
3328
+ type: Input
3329
+ }], groupHeaderTemplate: [{
3330
+ type: Input
3331
+ }], itemTemplate: [{
3332
+ type: Input
3333
+ }], barTemplate: [{
3334
+ type: Input
3335
+ }], rangeTemplate: [{
3336
+ type: Input
3337
+ }], barClick: [{
3338
+ type: Output
3339
+ }], lineClick: [{
3340
+ type: Output
3341
+ }], ganttMainClass: [{
3342
+ type: HostBinding,
3343
+ args: ['class.gantt-main-container']
3344
+ }] } });
3345
+
3346
+ class GanttCalendarHeaderComponent {
3347
+ get view() {
3348
+ return this.ganttUpper.view;
3349
+ }
3350
+ constructor(ganttUpper, ngZone, elementRef) {
3351
+ this.ganttUpper = ganttUpper;
3352
+ this.ngZone = ngZone;
3353
+ this.elementRef = elementRef;
3354
+ this.unsubscribe$ = new Subject();
3355
+ this.headerHeight = headerHeight;
3356
+ this.viewTypes = GanttViewType;
3357
+ this.className = `gantt-calendar gantt-calendar-header`;
3358
+ }
3359
+ ngOnInit() {
3360
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
3361
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
3362
+ .pipe(takeUntil(this.unsubscribe$))
3363
+ .subscribe(() => {
3364
+ if (this.ganttUpper.viewType === GanttViewType.day)
3365
+ this.setTodayPoint();
3366
+ });
3367
+ });
3368
+ }
3369
+ setTodayPoint() {
3370
+ const x = this.view.getTodayXPoint();
3371
+ const today = new GanttDate().getDate();
3372
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
3373
+ const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
3374
+ if (isNumber(x)) {
3375
+ if (rect) {
3376
+ rect.style.left = `${x - todayWidth / 2}px`;
3377
+ rect.style.top = `${headerHeight - todayHeight}px`;
3378
+ rect.innerHTML = today.toString();
3379
+ }
3380
+ }
3381
+ else {
3382
+ todayEle.style.display = 'none';
3383
+ }
3384
+ }
3385
+ trackBy(point, index) {
3386
+ return point.text || index;
3387
+ }
3388
+ }
3389
+ 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 });
3390
+ 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"] }] });
3391
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarHeaderComponent, decorators: [{
3392
+ type: Component,
3393
+ 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" }]
3394
+ }], ctorParameters: function () {
3395
+ return [{ type: GanttUpper, decorators: [{
3534
3396
  type: Inject,
3535
3397
  args: [GANTT_UPPER_TOKEN]
3536
- }] }];
3537
- }, propDecorators: { baselineItem: [{
3538
- type: Input
3539
- }], ganttBaselineClass: [{
3398
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }];
3399
+ }, propDecorators: { className: [{
3540
3400
  type: HostBinding,
3541
- args: ['class.gantt-baseline']
3401
+ args: ['class']
3542
3402
  }] } });
3543
3403
 
3544
- class GanttMainComponent {
3545
- constructor(ganttUpper) {
3404
+ const mainHeight = 5000;
3405
+ class GanttCalendarGridComponent {
3406
+ get view() {
3407
+ return this.ganttUpper.view;
3408
+ }
3409
+ constructor(ganttUpper, ngZone, elementRef) {
3546
3410
  this.ganttUpper = ganttUpper;
3547
- this.barClick = new EventEmitter();
3548
- this.lineClick = new EventEmitter();
3549
- this.ganttMainClass = true;
3411
+ this.ngZone = ngZone;
3412
+ this.elementRef = elementRef;
3413
+ this.unsubscribe$ = new Subject();
3414
+ this.headerHeight = headerHeight;
3415
+ this.mainHeight = mainHeight;
3416
+ this.todayBorderRadius = todayBorderRadius;
3417
+ this.viewTypes = GanttViewType;
3418
+ this.className = `gantt-calendar gantt-calendar-grid`;
3550
3419
  }
3551
- trackBy(index, item) {
3552
- return item.id || index;
3420
+ setTodayPoint() {
3421
+ const x = this.view.getTodayXPoint();
3422
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
3423
+ const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
3424
+ if (isNumber(x)) {
3425
+ if (line) {
3426
+ line.style.left = `${x}px`;
3427
+ line.style.top = `0px`;
3428
+ line.style.bottom = `${-mainHeight}px`;
3429
+ }
3430
+ }
3431
+ else {
3432
+ todayEle.style.display = 'none';
3433
+ }
3434
+ }
3435
+ ngOnInit() {
3436
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
3437
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
3438
+ .pipe(takeUntil(this.unsubscribe$))
3439
+ .subscribe(() => {
3440
+ this.setTodayPoint();
3441
+ });
3442
+ });
3443
+ }
3444
+ trackBy(point, index) {
3445
+ return point.text || index;
3446
+ }
3447
+ ngOnDestroy() {
3448
+ this.unsubscribe$.next();
3449
+ this.unsubscribe$.complete();
3553
3450
  }
3554
3451
  }
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: [{
3452
+ 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 });
3453
+ 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"] }] });
3454
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttCalendarGridComponent, decorators: [{
3558
3455
  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" }]
3456
+ 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
3457
  }], ctorParameters: function () {
3561
3458
  return [{ type: GanttUpper, decorators: [{
3562
3459
  type: Inject,
3563
3460
  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: [{
3461
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }];
3462
+ }, propDecorators: { className: [{
3582
3463
  type: HostBinding,
3583
- args: ['class.gantt-main-container']
3464
+ args: ['class']
3584
3465
  }] } });
3585
3466
 
3586
3467
  class GanttLoaderComponent {
@@ -3610,6 +3491,170 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3610
3491
  }]
3611
3492
  }] });
3612
3493
 
3494
+ class GanttDragBackdropComponent {
3495
+ }
3496
+ GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3497
+ 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" });
3498
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
3499
+ type: Component,
3500
+ args: [{ selector: 'gantt-drag-backdrop', host: {
3501
+ class: 'gantt-drag-backdrop'
3502
+ }, 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" }]
3503
+ }] });
3504
+
3505
+ class NgxGanttToolbarComponent {
3506
+ constructor(ganttUpper) {
3507
+ this.ganttUpper = ganttUpper;
3508
+ this.ganttItemClass = true;
3509
+ this.ganttViewsMap = keyBy(ganttViews, 'value');
3510
+ }
3511
+ selectView(view) {
3512
+ this.ganttUpper.changeView(view);
3513
+ }
3514
+ }
3515
+ 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 });
3516
+ 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"] }] });
3517
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttToolbarComponent, decorators: [{
3518
+ type: Component,
3519
+ 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" }]
3520
+ }], ctorParameters: function () {
3521
+ return [{ type: GanttUpper, decorators: [{
3522
+ type: Inject,
3523
+ args: [GANTT_UPPER_TOKEN]
3524
+ }] }];
3525
+ }, propDecorators: { template: [{
3526
+ type: Input
3527
+ }], ganttItemClass: [{
3528
+ type: HostBinding,
3529
+ args: ['class.gantt-toolbar']
3530
+ }] } });
3531
+
3532
+ class NgxGanttRootComponent {
3533
+ get view() {
3534
+ return this.ganttUpper.view;
3535
+ }
3536
+ constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
3537
+ this.elementRef = elementRef;
3538
+ this.ngZone = ngZone;
3539
+ this.dom = dom;
3540
+ this.dragContainer = dragContainer;
3541
+ this.ganttUpper = ganttUpper;
3542
+ this.printService = printService;
3543
+ this.unsubscribe$ = new Subject();
3544
+ this.ganttUpper.dragContainer = dragContainer;
3545
+ }
3546
+ ngOnInit() {
3547
+ // Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
3548
+ // the `onStable` will never emit any value.
3549
+ const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
3550
+ // Normally this isn't in the zone, but it can cause performance regressions for apps
3551
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
3552
+ this.ngZone.runOutsideAngular(() => {
3553
+ onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3554
+ this.dom.initialize(this.elementRef);
3555
+ if (this.printService) {
3556
+ this.printService.register(this.elementRef);
3557
+ }
3558
+ this.setupScrollClass();
3559
+ this.setupResize();
3560
+ this.setupViewScroll();
3561
+ // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
3562
+ this.elementRef.nativeElement.style.opacity = '1';
3563
+ this.ganttUpper.viewChange.pipe(startWith$1(null), takeUntil(this.unsubscribe$)).subscribe(() => {
3564
+ this.scrollToToday();
3565
+ });
3566
+ });
3567
+ });
3568
+ }
3569
+ ngOnDestroy() {
3570
+ this.unsubscribe$.next();
3571
+ }
3572
+ setupViewScroll() {
3573
+ if (this.ganttUpper.disabledLoadOnScroll) {
3574
+ return;
3575
+ }
3576
+ this.dom
3577
+ .getViewerScroll(passiveListenerOptions)
3578
+ .pipe(takeUntil(this.unsubscribe$))
3579
+ .subscribe((event) => {
3580
+ if (event.direction === ScrollDirection.LEFT) {
3581
+ const dates = this.view.addStartDate();
3582
+ if (dates) {
3583
+ event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
3584
+ if (this.ganttUpper.loadOnScroll.observers) {
3585
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
3586
+ }
3587
+ }
3588
+ }
3589
+ if (event.direction === ScrollDirection.RIGHT) {
3590
+ const dates = this.view.addEndDate();
3591
+ if (dates && this.ganttUpper.loadOnScroll.observers) {
3592
+ this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
3593
+ }
3594
+ }
3595
+ });
3596
+ }
3597
+ setupResize() {
3598
+ this.dom
3599
+ .getResize()
3600
+ .pipe(takeUntil(this.unsubscribe$))
3601
+ .subscribe(() => {
3602
+ this.setupScrollClass();
3603
+ });
3604
+ }
3605
+ setupScrollClass() {
3606
+ const mainContainer = this.dom.mainContainer;
3607
+ const height = mainContainer.offsetHeight;
3608
+ const scrollHeight = mainContainer.scrollHeight;
3609
+ if (scrollHeight > height) {
3610
+ this.elementRef.nativeElement.className = 'gantt gantt-scroll';
3611
+ }
3612
+ else {
3613
+ this.elementRef.nativeElement.className = 'gantt';
3614
+ }
3615
+ }
3616
+ scrollToToday() {
3617
+ const x = this.view.getTodayXPoint();
3618
+ this.dom.scrollMainContainer(x);
3619
+ }
3620
+ scrollToDate(date) {
3621
+ let x;
3622
+ if (typeof date === 'number') {
3623
+ x = this.view.getXPointByDate(new GanttDate(date));
3624
+ }
3625
+ else {
3626
+ x = this.view.getXPointByDate(date);
3627
+ }
3628
+ this.dom.scrollMainContainer(x);
3629
+ }
3630
+ }
3631
+ 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 });
3632
+ 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"] }] });
3633
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
3634
+ type: Component,
3635
+ args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
3636
+ class: 'gantt'
3637
+ }, 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" }]
3638
+ }], ctorParameters: function () {
3639
+ return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
3640
+ type: Inject,
3641
+ args: [GANTT_UPPER_TOKEN]
3642
+ }] }, { type: GanttPrintService, decorators: [{
3643
+ type: Optional
3644
+ }] }];
3645
+ }, propDecorators: { sideWidth: [{
3646
+ type: Input
3647
+ }], sideTemplate: [{
3648
+ type: ContentChild,
3649
+ args: ['sideTemplate', { static: true }]
3650
+ }], mainTemplate: [{
3651
+ type: ContentChild,
3652
+ args: ['mainTemplate', { static: true }]
3653
+ }], backdrop: [{
3654
+ type: ViewChild,
3655
+ args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
3656
+ }] } });
3657
+
3613
3658
  class NgxGanttComponent extends GanttUpper {
3614
3659
  set loading(loading) {
3615
3660
  if (loading) {