@worktile/gantt 15.1.0-next.3 → 15.1.0-next.5

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.
@@ -3,7 +3,7 @@ import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, Content
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 as debounceTime$1, map, pairwise, auditTime, startWith as startWith$1, finalize } from 'rxjs/operators';
6
- import { BehaviorSubject, Subject, from, takeUntil as takeUntil$1, startWith, debounceTime, filter, merge, EMPTY, fromEvent, Observable, interval, animationFrameScheduler } from 'rxjs';
6
+ import { BehaviorSubject, Subject, from, takeUntil as takeUntil$1, startWith, debounceTime, filter, merge, EMPTY, fromEvent, Observable } from 'rxjs';
7
7
  import { fromUnixTime, getWeek, getDaysInMonth, differenceInCalendarDays, setDate, addSeconds, addMinutes, addHours, addDays, addWeeks, addMonths, addQuarters, addYears, startOfDay, startOfWeek, startOfMonth, startOfQuarter, startOfYear, endOfDay, endOfWeek, endOfMonth, endOfQuarter, endOfYear, getUnixTime, format, isWeekend, isToday, differenceInDays, differenceInCalendarQuarters, eachMonthOfInterval, eachYearOfInterval, eachWeekOfInterval, eachDayOfInterval, differenceInCalendarYears } from 'date-fns';
8
8
  export { addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarQuarters, differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, endOfDay, endOfMonth, endOfQuarter, endOfWeek, endOfYear, format, fromUnixTime, getDaysInMonth, getUnixTime, getWeek, isToday, isWeekend, setDate, startOfDay, startOfMonth, startOfQuarter, startOfWeek, startOfYear } from 'date-fns';
9
9
  import { SelectionModel } from '@angular/cdk/collections';
@@ -1246,12 +1246,15 @@ class NgxGanttTableColumnComponent {
1246
1246
  }
1247
1247
  }
1248
1248
  NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1249
- NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name", showExpandIcon: "showExpandIcon" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1249
+ NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name", showExpandIcon: "showExpandIcon" }, host: { classAttribute: "gantt-table-column" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1250
1250
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, decorators: [{
1251
1251
  type: Component,
1252
1252
  args: [{
1253
1253
  selector: 'ngx-gantt-column',
1254
- template: ''
1254
+ template: '',
1255
+ host: {
1256
+ class: 'gantt-table-column'
1257
+ }
1255
1258
  }]
1256
1259
  }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1257
1260
  type: Inject,
@@ -1737,7 +1740,6 @@ class GanttTableBodyComponent {
1737
1740
  this.columns.changes.pipe(startWith(this.columns), takeUntil$1(this.destroy$)).subscribe(() => {
1738
1741
  this.hasExpandIcon = false;
1739
1742
  this.columns.forEach((column) => {
1740
- column.classList.add('gantt-table-column');
1741
1743
  if (!column.columnWidth) {
1742
1744
  column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1743
1745
  }
@@ -2458,41 +2460,6 @@ function normalizePassiveListenerOptions(options) {
2458
2460
  /** Options used to bind passive event listeners. */
2459
2461
  const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
2460
2462
 
2461
- /**
2462
- * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
2463
- * viewport. The value comes from trying it out manually until it feels right.
2464
- */
2465
- const SCROLL_PROXIMITY_THRESHOLD = 0.05;
2466
- /**
2467
- * Gets whether the horizontal auto-scroll direction of a node.
2468
- * @param clientRect Dimensions of the node.
2469
- * @param pointerX Position of the user's pointer along the x axis.
2470
- */
2471
- function getHorizontalScrollDirection(clientRect, pointerX) {
2472
- const { left, right, width } = clientRect;
2473
- const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
2474
- if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
2475
- return 1 /* AutoScrollHorizontalDirection.LEFT */;
2476
- }
2477
- else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
2478
- return 2 /* AutoScrollHorizontalDirection.RIGHT */;
2479
- }
2480
- return 0 /* AutoScrollHorizontalDirection.NONE */;
2481
- }
2482
- /**
2483
- * Checks whether the pointer coordinates are close to a ClientRect.
2484
- * @param rect ClientRect to check against.
2485
- * @param threshold Threshold around the ClientRect.
2486
- * @param pointerX Coordinates along the X axis.
2487
- * @param pointerY Coordinates along the Y axis.
2488
- */
2489
- function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
2490
- const { top, right, bottom, left, width, height } = rect;
2491
- const xThreshold = width * threshold;
2492
- const yThreshold = height * threshold;
2493
- return pointerY > top - yThreshold && pointerY < bottom + yThreshold && pointerX > left - xThreshold && pointerX < right + xThreshold;
2494
- }
2495
-
2496
2463
  const scrollThreshold = 50;
2497
2464
  var ScrollDirection;
2498
2465
  (function (ScrollDirection) {
@@ -2919,21 +2886,6 @@ class GanttBarDrag {
2919
2886
  this.dragScrollDistance = 0;
2920
2887
  /** Horizontal direction in which the list is currently scrolling. */
2921
2888
  this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
2922
- this.startScrollInterval = () => {
2923
- this.stopScrolling();
2924
- interval(0, animationFrameScheduler)
2925
- .pipe(takeUntil(this.stopScrollTimers$))
2926
- .subscribe(() => {
2927
- const node = this.dom.mainContainer;
2928
- const scrollStep = autoScrollStep;
2929
- if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2930
- node.scrollBy(-scrollStep, 0);
2931
- }
2932
- else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2933
- node.scrollBy(scrollStep, 0);
2934
- }
2935
- });
2936
- };
2937
2889
  }
2938
2890
  createDragRef(element) {
2939
2891
  const dragRef = this.dragDrop.createDrag(element);
@@ -2981,36 +2933,36 @@ class GanttBarDrag {
2981
2933
  dragRef.withBoundaryElement(this.dom.mainItems);
2982
2934
  dragRef.started.subscribe(() => {
2983
2935
  this.setDraggingStyles();
2984
- this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2985
- this.createDragScrollEvent(dragRef).subscribe(() => {
2986
- if (dragRef.isDragging()) {
2987
- const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2988
- this.dragScrollDistance = dragScrollDistance;
2989
- this.barDragMove();
2990
- }
2991
- });
2936
+ // this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2937
+ // this.createDragScrollEvent(dragRef).subscribe(() => {
2938
+ // if (dragRef.isDragging()) {
2939
+ // const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2940
+ // this.dragScrollDistance = dragScrollDistance;
2941
+ // this.barDragMove();
2942
+ // }
2943
+ // });
2992
2944
  this.dragContainer.dragStarted.emit({ item: this.item.origin });
2993
2945
  });
2994
2946
  dragRef.moved.subscribe((event) => {
2995
- this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2947
+ // this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2996
2948
  this.barDragMoveDistance = event.distance.x;
2997
2949
  if (!this.dragScrolling) {
2998
2950
  this.barDragMove();
2999
2951
  }
3000
2952
  });
3001
2953
  dragRef.ended.subscribe((event) => {
2954
+ this.clearDraggingStyles();
2955
+ this.closeDragBackdrop();
2956
+ event.source.reset();
2957
+ // this.stopScrolling();
2958
+ // this.dragScrolling = false;
2959
+ // this.dragScrollDistance = 0;
2960
+ this.barDragMoveDistance = 0;
3002
2961
  this.item.updateRefs({
3003
2962
  width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
3004
2963
  x: this.ganttUpper.view.getXPointByDate(this.item.start),
3005
2964
  y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
3006
2965
  });
3007
- this.clearDraggingStyles();
3008
- this.closeDragBackdrop();
3009
- event.source.reset();
3010
- this.stopScrolling();
3011
- this.dragScrolling = false;
3012
- this.dragScrollDistance = 0;
3013
- this.barDragMoveDistance = 0;
3014
2966
  this.dragContainer.dragEnded.emit({ item: this.item.origin });
3015
2967
  });
3016
2968
  this.barDragRef = dragRef;
@@ -3026,48 +2978,36 @@ class GanttBarDrag {
3026
2978
  dragRef.withBoundaryElement(this.dom.mainItems);
3027
2979
  dragRef.started.subscribe(() => {
3028
2980
  this.setDraggingStyles();
3029
- this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
3030
- this.createDragScrollEvent(dragRef).subscribe(() => {
3031
- if (dragRef.isDragging()) {
3032
- const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
3033
- this.dragScrollDistance = dragScrollDistance;
3034
- this.barHandleDragMove(isBefore);
3035
- }
3036
- });
2981
+ // this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2982
+ // this.createDragScrollEvent(dragRef).subscribe(() => {
2983
+ // if (dragRef.isDragging()) {
2984
+ // const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2985
+ // this.dragScrollDistance = dragScrollDistance;
2986
+ // this.barHandleDragMove(isBefore);
2987
+ // }
2988
+ // });
3037
2989
  this.dragContainer.dragStarted.emit({ item: this.item.origin });
3038
2990
  });
3039
2991
  dragRef.moved.subscribe((event) => {
3040
- this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
2992
+ // this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
3041
2993
  this.barHandleDragMoveDistance = event.distance.x;
3042
2994
  if (!this.dragScrolling) {
3043
2995
  this.barHandleDragMove(isBefore);
3044
2996
  }
3045
2997
  });
3046
2998
  dragRef.ended.subscribe((event) => {
3047
- if (isBefore) {
3048
- const width = this.item.refs.width + event.distance.x * -1;
3049
- if (width <= dragMinWidth) {
3050
- this.item.updateDate(this.item.end.startOfDay(), this.item.end);
3051
- }
3052
- }
3053
- else {
3054
- const width = this.item.refs.width + event.distance.x;
3055
- if (width <= dragMinWidth) {
3056
- this.item.updateDate(this.item.start, this.item.start.endOfDay());
3057
- }
3058
- }
2999
+ this.clearDraggingStyles();
3000
+ this.closeDragBackdrop();
3001
+ event.source.reset();
3002
+ // this.stopScrolling();
3003
+ // this.dragScrolling = false;
3004
+ // this.dragScrollDistance = 0;
3005
+ this.barHandleDragMoveDistance = 0;
3059
3006
  this.item.updateRefs({
3060
3007
  width: this.ganttUpper.view.getDateRangeWidth(this.item.start.startOfDay(), this.item.end.endOfDay()),
3061
3008
  x: this.ganttUpper.view.getXPointByDate(this.item.start),
3062
3009
  y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
3063
3010
  });
3064
- this.clearDraggingStyles();
3065
- this.closeDragBackdrop();
3066
- event.source.reset();
3067
- this.stopScrolling();
3068
- this.dragScrolling = false;
3069
- this.dragScrollDistance = 0;
3070
- this.barHandleDragMoveDistance = 0;
3071
3011
  this.dragContainer.dragEnded.emit({ item: this.item.origin });
3072
3012
  });
3073
3013
  dragRefs.push(dragRef);
@@ -3134,7 +3074,7 @@ class GanttBarDrag {
3134
3074
  const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
3135
3075
  const rootRect = this.dom.root.getBoundingClientRect();
3136
3076
  const dragRect = dragElement.getBoundingClientRect();
3137
- const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
3077
+ const left = dragRect.left - rootRect.left - (this.dom.side.clientWidth + 1);
3138
3078
  const width = dragRect.right - dragRect.left;
3139
3079
  // Note: updating styles will cause re-layout so we have to place them consistently one by one.
3140
3080
  dragMaskElement.style.left = left + 'px';
@@ -3187,27 +3127,37 @@ class GanttBarDrag {
3187
3127
  const x = this.item.refs.x + distance;
3188
3128
  const width = this.item.refs.width + distance * -1;
3189
3129
  const start = this.ganttUpper.view.getDateByXPoint(x);
3190
- if (width > dragMinWidth) {
3130
+ const days = differenceInDays(this.item.end.value, start.value);
3131
+ if (!this.isStartOrEndInsideView(start, this.item.end)) {
3132
+ return;
3133
+ }
3134
+ if (width > dragMinWidth && days > 0) {
3191
3135
  this.barElement.style.width = width + 'px';
3192
3136
  this.barElement.style.left = x + 'px';
3193
3137
  this.openDragBackdrop(this.barElement, start, this.item.end);
3194
- if (!this.isStartOrEndInsideView(start, this.item.end)) {
3195
- return;
3196
- }
3197
3138
  this.item.updateDate(start, this.item.end);
3198
3139
  }
3140
+ else {
3141
+ this.openDragBackdrop(this.barElement, this.item.end.startOfDay(), this.item.end);
3142
+ this.item.updateDate(this.item.end.startOfDay(), this.item.end);
3143
+ }
3199
3144
  }
3200
3145
  else {
3201
3146
  const width = this.item.refs.width + distance;
3202
3147
  const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
3203
- if (width > dragMinWidth) {
3148
+ const days = differenceInDays(end.value, this.item.start.value);
3149
+ if (!this.isStartOrEndInsideView(this.item.start, end)) {
3150
+ return;
3151
+ }
3152
+ if (width > dragMinWidth && days > 0) {
3204
3153
  this.barElement.style.width = width + 'px';
3205
3154
  this.openDragBackdrop(this.barElement, this.item.start, end);
3206
- if (!this.isStartOrEndInsideView(this.item.start, end)) {
3207
- return;
3208
- }
3209
3155
  this.item.updateDate(this.item.start, end);
3210
3156
  }
3157
+ else {
3158
+ this.openDragBackdrop(this.barElement, this.item.start, this.item.start.endOfDay());
3159
+ this.item.updateDate(this.item.start, this.item.start.endOfDay());
3160
+ }
3211
3161
  }
3212
3162
  this.dragContainer.dragMoved.emit({ item: this.item.origin });
3213
3163
  }
@@ -3238,24 +3188,37 @@ class GanttBarDrag {
3238
3188
  this.linkDraggingLine = null;
3239
3189
  }
3240
3190
  }
3241
- startScrollingIfNecessary(pointerX, pointerY) {
3242
- const clientRect = this.dom.mainContainer.getBoundingClientRect();
3243
- if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
3244
- const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
3245
- if (horizontalScrollDirection) {
3246
- this._horizontalScrollDirection = horizontalScrollDirection;
3247
- this.dragScrolling = true;
3248
- this._ngZone.runOutsideAngular(this.startScrollInterval);
3249
- }
3250
- else {
3251
- this.dragScrolling = false;
3252
- this.stopScrolling();
3253
- }
3254
- }
3255
- }
3256
- stopScrolling() {
3257
- this.stopScrollTimers$.next();
3258
- }
3191
+ // private startScrollInterval = () => {
3192
+ // this.stopScrolling();
3193
+ // interval(0, animationFrameScheduler)
3194
+ // .pipe(takeUntil(this.stopScrollTimers$))
3195
+ // .subscribe(() => {
3196
+ // const node = this.dom.mainContainer;
3197
+ // const scrollStep = autoScrollStep;
3198
+ // if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.LEFT) {
3199
+ // node.scrollBy(-scrollStep, 0);
3200
+ // } else if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.RIGHT) {
3201
+ // node.scrollBy(scrollStep, 0);
3202
+ // }
3203
+ // });
3204
+ // };
3205
+ // private startScrollingIfNecessary(pointerX: number, pointerY: number) {
3206
+ // const clientRect = this.dom.mainContainer.getBoundingClientRect();
3207
+ // if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
3208
+ // const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
3209
+ // if (horizontalScrollDirection) {
3210
+ // this._horizontalScrollDirection = horizontalScrollDirection;
3211
+ // this.dragScrolling = true;
3212
+ // this._ngZone.runOutsideAngular(this.startScrollInterval);
3213
+ // } else {
3214
+ // this.dragScrolling = false;
3215
+ // this.stopScrolling();
3216
+ // }
3217
+ // }
3218
+ // }
3219
+ // private stopScrolling() {
3220
+ // this.stopScrollTimers$.next();
3221
+ // }
3259
3222
  isStartOrEndInsideView(start, end) {
3260
3223
  const itemStart = start.getUnixTime();
3261
3224
  const itemEnd = end.getUnixTime();
@@ -3296,7 +3259,7 @@ class GanttBarDrag {
3296
3259
  this.dragRefs.forEach((dragRef) => dragRef.dispose());
3297
3260
  this.destroy$.next();
3298
3261
  this.destroy$.complete();
3299
- this.stopScrolling();
3262
+ // this.stopScrolling();
3300
3263
  this.stopScrollTimers$.complete();
3301
3264
  }
3302
3265
  }
@@ -3331,7 +3294,6 @@ class GanttItemUpper {
3331
3294
  this.refsUnsubscribe$.next();
3332
3295
  this.refsUnsubscribe$.complete();
3333
3296
  this.item = item;
3334
- this.setPositions();
3335
3297
  this.item.refs$.pipe(takeUntil(this.refsUnsubscribe$)).subscribe(() => {
3336
3298
  this.setPositions();
3337
3299
  });