@worktile/gantt 12.1.3 → 12.2.0

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.
@@ -564,6 +564,25 @@
564
564
  GanttViewType["week"] = "week";
565
565
  })(exports.GanttViewType || (exports.GanttViewType = {}));
566
566
 
567
+ exports.GanttLinkType = void 0;
568
+ (function (GanttLinkType) {
569
+ GanttLinkType[GanttLinkType["fs"] = 1] = "fs";
570
+ GanttLinkType[GanttLinkType["ff"] = 2] = "ff";
571
+ GanttLinkType[GanttLinkType["ss"] = 3] = "ss";
572
+ GanttLinkType[GanttLinkType["sf"] = 4] = "sf";
573
+ })(exports.GanttLinkType || (exports.GanttLinkType = {}));
574
+ exports.GanttLinkLineType = void 0;
575
+ (function (GanttLinkLineType) {
576
+ GanttLinkLineType["curve"] = "curve";
577
+ GanttLinkLineType["straight"] = "straight";
578
+ })(exports.GanttLinkLineType || (exports.GanttLinkLineType = {}));
579
+ exports.LinkColors = void 0;
580
+ (function (LinkColors) {
581
+ LinkColors["default"] = "#cacaca";
582
+ LinkColors["blocked"] = "#FF7575";
583
+ LinkColors["active"] = "#348FE4";
584
+ })(exports.LinkColors || (exports.LinkColors = {}));
585
+
567
586
  exports.GanttItemType = void 0;
568
587
  (function (GanttItemType) {
569
588
  GanttItemType["bar"] = "bar";
@@ -576,7 +595,17 @@
576
595
  this.refs$ = new rxjs.BehaviorSubject(null);
577
596
  this.origin = item;
578
597
  this.id = this.origin.id;
579
- this.links = this.origin.links || [];
598
+ this.links = (this.origin.links || []).map(function (link) {
599
+ if (typeof link === 'string') {
600
+ return {
601
+ type: exports.GanttLinkType.fs,
602
+ link: link
603
+ };
604
+ }
605
+ else {
606
+ return link;
607
+ }
608
+ });
580
609
  this.color = this.origin.color;
581
610
  this.barStyle = this.origin.barStyle;
582
611
  this.linkable = this.origin.linkable === undefined ? true : this.origin.linkable;
@@ -639,8 +668,9 @@
639
668
  this.expanded = expanded;
640
669
  this.origin.expanded = expanded;
641
670
  };
642
- GanttItemInternal.prototype.addLink = function (linkId) {
643
- this.links = __spreadArray(__spreadArray([], __read(this.links)), [linkId]);
671
+ GanttItemInternal.prototype.addLink = function (link) {
672
+ console.log(link);
673
+ this.links = __spreadArray(__spreadArray([], __read(this.links)), [link]);
644
674
  this.origin.links = this.links;
645
675
  };
646
676
  return GanttItemInternal;
@@ -671,7 +701,12 @@
671
701
  quarter: 'QQQ',
672
702
  year: 'yyyy年',
673
703
  yearMonth: 'yyyy年MM月',
674
- yearQuarter: 'yyyy年QQQ',
704
+ yearQuarter: 'yyyy年QQQ'
705
+ },
706
+ linkOptions: {
707
+ dependencyTypes: [exports.GanttLinkType.fs],
708
+ showArrow: false,
709
+ lineType: exports.GanttLinkLineType.curve
675
710
  }
676
711
  };
677
712
  var GANTT_GLOBAL_CONFIG = new i0.InjectionToken('GANTT_GLOBAL_CONFIG');
@@ -1166,6 +1201,16 @@
1166
1201
  this._multiple = false;
1167
1202
  this.ganttClass = true;
1168
1203
  }
1204
+ Object.defineProperty(GanttUpper.prototype, "linkOptions", {
1205
+ get: function () {
1206
+ return Object.assign({}, defaultConfig.linkOptions, this.config.linkOptions, this._linkOptions);
1207
+ },
1208
+ set: function (options) {
1209
+ this._linkOptions = options;
1210
+ },
1211
+ enumerable: false,
1212
+ configurable: true
1213
+ });
1169
1214
  Object.defineProperty(GanttUpper.prototype, "selectable", {
1170
1215
  get: function () {
1171
1216
  return this._selectable;
@@ -1410,7 +1455,7 @@
1410
1455
  return GanttUpper;
1411
1456
  }());
1412
1457
  GanttUpper.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttUpper, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }, { token: i0__namespace.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1413
- GanttUpper.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.2", type: GanttUpper, inputs: { originItems: ["items", "originItems"], originGroups: ["groups", "originGroups"], viewType: "viewType", start: "start", end: "end", showTodayLine: "showTodayLine", draggable: "draggable", styles: "styles", viewOptions: "viewOptions", disabledLoadOnScroll: "disabledLoadOnScroll", selectable: "selectable", multiple: "multiple" }, outputs: { loadOnScroll: "loadOnScroll", dragStarted: "dragStarted", dragMoved: "dragMoved", dragEnded: "dragEnded", barClick: "barClick" }, host: { properties: { "class.gantt": "this.ganttClass" } }, queries: [{ propertyName: "barTemplate", first: true, predicate: ["bar"], descendants: true, static: true }, { propertyName: "rangeTemplate", first: true, predicate: ["range"], descendants: true, static: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, static: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true, static: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ["groupHeader"], descendants: true, static: true }], ngImport: i0__namespace });
1458
+ GanttUpper.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.2", type: GanttUpper, inputs: { originItems: ["items", "originItems"], originGroups: ["groups", "originGroups"], viewType: "viewType", start: "start", end: "end", showTodayLine: "showTodayLine", draggable: "draggable", styles: "styles", viewOptions: "viewOptions", linkOptions: "linkOptions", disabledLoadOnScroll: "disabledLoadOnScroll", selectable: "selectable", multiple: "multiple" }, outputs: { loadOnScroll: "loadOnScroll", dragStarted: "dragStarted", dragMoved: "dragMoved", dragEnded: "dragEnded", barClick: "barClick" }, host: { properties: { "class.gantt": "this.ganttClass" } }, queries: [{ propertyName: "barTemplate", first: true, predicate: ["bar"], descendants: true, static: true }, { propertyName: "rangeTemplate", first: true, predicate: ["range"], descendants: true, static: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, static: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true, static: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ["groupHeader"], descendants: true, static: true }], ngImport: i0__namespace });
1414
1459
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttUpper, decorators: [{
1415
1460
  type: i0.Directive
1416
1461
  }], ctorParameters: function () {
@@ -1438,6 +1483,8 @@
1438
1483
  type: i0.Input
1439
1484
  }], viewOptions: [{
1440
1485
  type: i0.Input
1486
+ }], linkOptions: [{
1487
+ type: i0.Input
1441
1488
  }], disabledLoadOnScroll: [{
1442
1489
  type: i0.Input
1443
1490
  }], selectable: [{
@@ -1907,64 +1954,80 @@
1907
1954
  type: i0.Injectable
1908
1955
  }], ctorParameters: function () { return []; } });
1909
1956
 
1957
+ function getDependencyType(path, dependencyTypes) {
1958
+ if (dependencyTypes.includes(exports.GanttLinkType.ss) && path.from.pos === InBarPosition.start && path.to.pos === InBarPosition.start) {
1959
+ return exports.GanttLinkType.ss;
1960
+ }
1961
+ if (dependencyTypes.includes(exports.GanttLinkType.ff) && path.from.pos === InBarPosition.finish && path.to.pos === InBarPosition.finish) {
1962
+ return exports.GanttLinkType.ff;
1963
+ }
1964
+ if (dependencyTypes.includes(exports.GanttLinkType.sf) && path.from.pos === InBarPosition.start && path.to.pos === InBarPosition.finish) {
1965
+ return exports.GanttLinkType.sf;
1966
+ }
1967
+ return exports.GanttLinkType.fs;
1968
+ }
1969
+ var InBarPosition;
1970
+ (function (InBarPosition) {
1971
+ InBarPosition["start"] = "start";
1972
+ InBarPosition["finish"] = "finish";
1973
+ })(InBarPosition || (InBarPosition = {}));
1910
1974
  var GanttDragContainer = /** @class */ (function () {
1911
- function GanttDragContainer() {
1975
+ function GanttDragContainer(ganttUpper) {
1976
+ this.ganttUpper = ganttUpper;
1912
1977
  this.dragStarted = new i0.EventEmitter();
1913
1978
  this.dragMoved = new i0.EventEmitter();
1914
1979
  this.dragEnded = new i0.EventEmitter();
1915
1980
  this.linkDragStarted = new i0.EventEmitter();
1916
1981
  this.linkDragEntered = new i0.EventEmitter();
1917
1982
  this.linkDragEnded = new i0.EventEmitter();
1983
+ this.linkDragPath = { from: null, to: null };
1918
1984
  }
1919
- GanttDragContainer.prototype.emitLinkDragStarted = function (from, item) {
1920
- this.linkDraggingId = item.id;
1921
- this.linkDragFrom = from;
1922
- this.linkDragSource = this.linkDragFrom === 'source' ? item : null;
1923
- this.linkDragTarget = this.linkDragFrom === 'target' ? item : null;
1985
+ GanttDragContainer.prototype.emitLinkDragStarted = function (from) {
1986
+ this.linkDraggingId = from.item.id;
1987
+ this.linkDragPath.from = from;
1924
1988
  this.linkDragStarted.emit({
1925
- source: this.linkDragSource && this.linkDragSource.origin,
1926
- target: this.linkDragTarget && this.linkDragTarget.origin
1989
+ source: from.item.origin,
1990
+ target: null
1927
1991
  });
1928
1992
  };
1929
- GanttDragContainer.prototype.emitLinkDragEntered = function (item) {
1930
- if (this.linkDragFrom === 'source') {
1931
- this.linkDragTarget = item;
1932
- }
1933
- else {
1934
- this.linkDragSource = item;
1935
- }
1993
+ GanttDragContainer.prototype.emitLinkDragEntered = function (to) {
1994
+ this.linkDragPath.to = to;
1936
1995
  this.linkDragEntered.emit({
1937
- source: this.linkDragSource.origin,
1938
- target: this.linkDragTarget.origin
1996
+ source: this.linkDragPath.from.item.origin,
1997
+ target: to.item.origin
1939
1998
  });
1940
1999
  };
1941
2000
  GanttDragContainer.prototype.emitLinkDragLeaved = function () {
1942
- if (this.linkDragFrom === 'source') {
1943
- this.linkDragTarget = null;
1944
- }
1945
- else {
1946
- this.linkDragSource = null;
1947
- }
2001
+ this.linkDragPath.to = null;
1948
2002
  };
1949
- GanttDragContainer.prototype.emitLinkDragEnded = function () {
2003
+ GanttDragContainer.prototype.emitLinkDragEnded = function (to) {
2004
+ var _a;
2005
+ this.linkDragPath.to = to;
2006
+ var dependencyType = getDependencyType(this.linkDragPath, (_a = this.ganttUpper.linkOptions) === null || _a === void 0 ? void 0 : _a.dependencyTypes);
2007
+ this.linkDragPath.from.item.addLink({
2008
+ link: this.linkDragPath.to.item.id,
2009
+ type: dependencyType
2010
+ });
2011
+ this.linkDragEnded.emit({
2012
+ source: this.linkDragPath.from.item.origin,
2013
+ target: this.linkDragPath.to.item.origin,
2014
+ type: dependencyType
2015
+ });
1950
2016
  this.linkDraggingId = null;
1951
- if (this.linkDragSource && this.linkDragTarget) {
1952
- this.linkDragSource.addLink(this.linkDragTarget.id);
1953
- this.linkDragEnded.emit({
1954
- source: this.linkDragSource.origin,
1955
- target: this.linkDragTarget.origin
1956
- });
1957
- }
1958
- this.linkDragSource = null;
1959
- this.linkDragTarget = null;
2017
+ this.linkDragPath = { from: null, to: null };
1960
2018
  };
1961
2019
  return GanttDragContainer;
1962
2020
  }());
1963
- GanttDragContainer.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttDragContainer, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2021
+ GanttDragContainer.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttDragContainer, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1964
2022
  GanttDragContainer.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttDragContainer });
1965
2023
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttDragContainer, decorators: [{
1966
2024
  type: i0.Injectable
1967
- }], ctorParameters: function () { return []; } });
2025
+ }], ctorParameters: function () {
2026
+ return [{ type: GanttUpper, decorators: [{
2027
+ type: i0.Inject,
2028
+ args: [GANTT_UPPER_TOKEN]
2029
+ }] }];
2030
+ } });
1968
2031
 
1969
2032
  var GanttPrintService = /** @class */ (function () {
1970
2033
  function GanttPrintService() {
@@ -2315,12 +2378,165 @@
2315
2378
  args: ['mainTemplate', { static: true }]
2316
2379
  }] } });
2317
2380
 
2318
- var LinkColors;
2319
- (function (LinkColors) {
2320
- LinkColors["default"] = "#cacaca";
2321
- LinkColors["blocked"] = "#FF7575";
2322
- LinkColors["active"] = "#348FE4";
2323
- })(LinkColors || (LinkColors = {}));
2381
+ var GanttLinkLine = /** @class */ (function () {
2382
+ function GanttLinkLine() {
2383
+ }
2384
+ GanttLinkLine.prototype.generatePath = function (source, target, type) {
2385
+ if (source.before && source.after && target.before && target.after) {
2386
+ var path = '';
2387
+ switch (type) {
2388
+ case exports.GanttLinkType.ss:
2389
+ path = this.generateSSPath(source, target);
2390
+ break;
2391
+ case exports.GanttLinkType.ff:
2392
+ path = this.generateFFPath(source, target);
2393
+ break;
2394
+ case exports.GanttLinkType.sf:
2395
+ path = this.generateFSAndSFPath(source, target, type);
2396
+ break;
2397
+ default:
2398
+ path = this.generateFSAndSFPath(source, target);
2399
+ }
2400
+ return path;
2401
+ }
2402
+ };
2403
+ return GanttLinkLine;
2404
+ }());
2405
+
2406
+ var GanttLinkLineCurve = /** @class */ (function (_super) {
2407
+ __extends(GanttLinkLineCurve, _super);
2408
+ function GanttLinkLineCurve(ganttUpper) {
2409
+ var _this = _super.call(this) || this;
2410
+ _this.ganttUpper = ganttUpper;
2411
+ return _this;
2412
+ }
2413
+ GanttLinkLineCurve.prototype.generateSSPath = function (source, target) {
2414
+ var x1 = source.before.x;
2415
+ var y1 = source.before.y;
2416
+ var x4 = target.before.x;
2417
+ var y4 = target.before.y;
2418
+ var isMirror = y4 > y1 ? 0 : 1;
2419
+ var radius = Math.abs(y4 - y1) / 2;
2420
+ if (x4 > x1) {
2421
+ return "M " + x1 + " " + y1 + "\n A " + radius + " " + radius + " 0 1 " + isMirror + " " + x1 + " " + y4 + "\n L " + x4 + " " + y4;
2422
+ }
2423
+ else {
2424
+ return "M " + x1 + " " + y1 + "\n L " + x4 + " " + y1 + "\n A " + radius + " " + radius + " 0 1 " + isMirror + " " + x4 + " " + y4;
2425
+ }
2426
+ };
2427
+ GanttLinkLineCurve.prototype.generateFFPath = function (source, target) {
2428
+ var x1 = source.after.x;
2429
+ var y1 = source.after.y;
2430
+ var x4 = target.after.x;
2431
+ var y4 = target.after.y;
2432
+ var isMirror = y4 > y1 ? 1 : 0;
2433
+ var radius = Math.abs(y4 - y1) / 2;
2434
+ if (x4 > x1) {
2435
+ return "M " + x1 + " " + y1 + "\n L " + x4 + " " + y1 + "\n A " + radius + " " + radius + " 0 1 " + isMirror + " " + x4 + " " + y4;
2436
+ }
2437
+ else {
2438
+ return "M " + x1 + " " + y1 + "\n A " + radius + " " + radius + " 0 1 " + isMirror + " " + x1 + " " + y4 + "\n L " + x4 + " " + y4;
2439
+ }
2440
+ };
2441
+ GanttLinkLineCurve.prototype.generateFSAndSFPath = function (source, target, type) {
2442
+ var _a;
2443
+ var x1 = source.after.x;
2444
+ var y1 = source.after.y;
2445
+ var x4 = target.before.x;
2446
+ var y4 = target.before.y;
2447
+ var bezierWeight = 0.5;
2448
+ if (type === exports.GanttLinkType.sf) {
2449
+ x1 = target.after.x;
2450
+ y1 = target.after.y;
2451
+ x4 = source.before.x;
2452
+ y4 = source.before.y;
2453
+ }
2454
+ var dx = Math.abs(x4 - x1) * bezierWeight;
2455
+ var x2 = x1 + dx;
2456
+ var x3 = x4 - dx;
2457
+ var centerX = (x1 + x4) / 2;
2458
+ var centerY = (y1 + y4) / 2;
2459
+ var controlX = this.ganttUpper.styles.lineHeight / 2;
2460
+ var controlY = this.ganttUpper.styles.lineHeight / 2;
2461
+ if (x1 >= x4) {
2462
+ if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
2463
+ return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y4 > y1 ? y1 + controlX : y1 - controlX) + " " + x1 + " " + (y4 > y1 ? y1 + controlY : y1 - controlY) + "\n L " + x4 + " " + (y4 > y1 ? y4 - controlY : y4 + controlY) + "\n C " + (x4 - controlY) + " " + (y4 > y1 ? y4 - controlY : y4 + controlY) + " " + (x4 - controlX) + " " + y4 + " " + x4 + " " + y4 + "\n ";
2464
+ }
2465
+ else {
2466
+ controlX = this.ganttUpper.styles.lineHeight;
2467
+ return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y4 > y1 ? y1 + controlX : y1 - controlX) + " " + centerX + " " + centerY + "\n C " + (x4 - controlX) + " " + (y4 > y1 ? y4 - controlX : y4 + controlX) + " " + (x4 - controlX) + " " + y4 + " " + x4 + " " + y4 + "\n ";
2468
+ }
2469
+ }
2470
+ else if (((_a = this.ganttUpper.linkOptions) === null || _a === void 0 ? void 0 : _a.showArrow) && x4 - x1 < 200) {
2471
+ dx = Math.max(Math.abs(y4 - y1) * bezierWeight, 60);
2472
+ x2 = x1 + dx;
2473
+ x3 = x4 - dx;
2474
+ return "M " + x1 + " " + y1 + " C " + x2 + " " + y1 + " " + x3 + " " + y4 + " " + x4 + " " + y4;
2475
+ }
2476
+ return "M " + x1 + " " + y1 + " C " + x2 + " " + y1 + " " + x3 + " " + y4 + " " + x4 + " " + y4;
2477
+ };
2478
+ return GanttLinkLineCurve;
2479
+ }(GanttLinkLine));
2480
+ GanttLinkLineCurve = __decorate([
2481
+ __param(0, i0.Inject(GANTT_UPPER_TOKEN))
2482
+ ], GanttLinkLineCurve);
2483
+
2484
+ var GanttLinkLineStraight = /** @class */ (function (_super) {
2485
+ __extends(GanttLinkLineStraight, _super);
2486
+ function GanttLinkLineStraight() {
2487
+ var _this = _super.call(this) || this;
2488
+ _this.pathControl = 20;
2489
+ return _this;
2490
+ }
2491
+ GanttLinkLineStraight.prototype.generateSSPath = function (source, target) {
2492
+ var x1 = source.before.x;
2493
+ var y1 = source.before.y;
2494
+ var x4 = target.before.x;
2495
+ var y4 = target.before.y;
2496
+ var control = this.pathControl;
2497
+ return "M " + x1 + " " + y1 + "\n L " + (x4 > x1 ? x1 - control : x4 - control) + " " + y1 + "\n L " + (x4 > x1 ? x1 - control : x4 - control) + " " + y4 + "\n L " + x4 + " " + y4;
2498
+ };
2499
+ GanttLinkLineStraight.prototype.generateFFPath = function (source, target) {
2500
+ var x1 = source.after.x;
2501
+ var y1 = source.after.y;
2502
+ var x4 = target.after.x;
2503
+ var y4 = target.after.y;
2504
+ var control = this.pathControl;
2505
+ return "M " + x1 + " " + y1 + "\n L " + (x4 > x1 ? x4 + control : x1 + control) + " " + y1 + "\n L " + (x4 > x1 ? x4 + control : x1 + control) + " " + y4 + "\n L " + x4 + " " + y4;
2506
+ };
2507
+ GanttLinkLineStraight.prototype.generateFSAndSFPath = function (source, target, type) {
2508
+ var x1 = source.after.x;
2509
+ var y1 = source.after.y;
2510
+ var x4 = target.before.x;
2511
+ var y4 = target.before.y;
2512
+ var control = this.pathControl;
2513
+ if (type === exports.GanttLinkType.sf) {
2514
+ x1 = target.after.x;
2515
+ y1 = target.after.y;
2516
+ x4 = source.before.x;
2517
+ y4 = source.before.y;
2518
+ }
2519
+ if (x4 - x1 >= 40) {
2520
+ return "M " + x1 + " " + y1 + "\n L " + (x1 + control) + " " + y1 + "\n L " + (x1 + control) + " " + y4 + "\n L " + x4 + " " + y4;
2521
+ }
2522
+ else {
2523
+ return "M " + x1 + " " + y1 + "\n L " + (x1 + control) + " " + y1 + "\n L " + (x1 + control) + " " + (y4 > y1 ? y1 + control : y1 - control) + "\n L " + (x4 - control) + " " + (y4 > y1 ? y1 + control : y1 - control) + "\n L " + (x4 - control) + " " + y4 + "\n L " + x4 + " " + y4;
2524
+ }
2525
+ };
2526
+ return GanttLinkLineStraight;
2527
+ }(GanttLinkLine));
2528
+
2529
+ function createLineGenerator(type, ganttUpper) {
2530
+ switch (type) {
2531
+ case exports.GanttLinkLineType.curve:
2532
+ return new GanttLinkLineCurve(ganttUpper);
2533
+ case exports.GanttLinkLineType.straight:
2534
+ return new GanttLinkLineStraight();
2535
+ default:
2536
+ throw new Error('gantt link path type invalid');
2537
+ }
2538
+ }
2539
+
2324
2540
  var GanttLinksComponent = /** @class */ (function () {
2325
2541
  function GanttLinksComponent(ganttUpper, cdr, elementRef, ganttDragContainer) {
2326
2542
  this.ganttUpper = ganttUpper;
@@ -2331,21 +2547,24 @@
2331
2547
  this.items = [];
2332
2548
  this.lineClick = new i0.EventEmitter();
2333
2549
  this.links = [];
2550
+ this.ganttLinkTypes = exports.GanttLinkType;
2551
+ this.showArrow = false;
2334
2552
  this.linkItems = [];
2335
- this.bezierWeight = -0.5;
2336
2553
  this.firstChange = true;
2337
2554
  this.unsubscribe$ = new rxjs.Subject();
2338
2555
  this.ganttLinksOverlay = true;
2339
2556
  }
2340
2557
  GanttLinksComponent.prototype.ngOnInit = function () {
2341
2558
  var _this = this;
2559
+ this.linkLine = createLineGenerator(this.ganttUpper.linkOptions.lineType, this.ganttUpper);
2560
+ this.showArrow = this.ganttUpper.linkOptions.showArrow;
2342
2561
  this.buildLinks();
2343
2562
  this.firstChange = false;
2344
2563
  this.ganttDragContainer.dragStarted.pipe(operators.takeUntil(this.unsubscribe$)).subscribe(function () {
2345
2564
  _this.elementRef.nativeElement.style.visibility = 'hidden';
2346
2565
  });
2347
2566
  rxjs.merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded)
2348
- .pipe(operators.takeUntil(this.unsubscribe$), operators.skip(1))
2567
+ .pipe(operators.takeUntil(this.unsubscribe$), operators.skip(1), operators.debounceTime(0))
2349
2568
  .subscribe(function () {
2350
2569
  _this.elementRef.nativeElement.style.visibility = 'visible';
2351
2570
  _this.buildLinks();
@@ -2397,56 +2616,25 @@
2397
2616
  });
2398
2617
  }
2399
2618
  };
2400
- GanttLinksComponent.prototype.generatePath = function (source, target) {
2401
- if (source.before && source.after && target.before && target.after) {
2402
- var x1 = source.after.x;
2403
- var y1 = source.after.y;
2404
- var x4 = target.before.x;
2405
- var y4 = target.before.y;
2406
- var dx = Math.abs(x4 - x1) * this.bezierWeight;
2407
- var x2 = x1 - dx;
2408
- var x3 = x4 + dx;
2409
- var centerX = (x1 + x4) / 2;
2410
- var centerY = (y1 + y4) / 2;
2411
- var controlX = this.ganttUpper.styles.lineHeight / 2;
2412
- var controlY = this.ganttUpper.styles.lineHeight / 2;
2413
- if (x1 >= x4) {
2414
- if (y4 > y1) {
2415
- if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
2416
- return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y1 + controlX) + " " + x1 + " " + (y1 + controlY) + "\n L " + x1 + " " + (y1 + controlY) + " " + centerX + " " + centerY + "\n\n M " + x4 + " " + y4 + "\n C " + (x4 - controlX) + " " + y4 + " " + (x4 - controlX) + " " + (y4 - controlX) + " " + x4 + " " + (y4 - controlY) + "\n L " + x4 + " " + (y4 - controlY) + " " + centerX + " " + centerY;
2417
- }
2418
- else {
2419
- controlX = this.ganttUpper.styles.lineHeight;
2420
- return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y1 + controlX) + " " + centerX + " " + centerY + "\n\n\n M " + x4 + " " + y4 + "\n C " + (x4 - controlX) + " " + y4 + " " + (x4 - controlX) + " " + (y4 - controlX) + " " + centerX + " " + centerY;
2421
- }
2422
- }
2423
- else {
2424
- if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
2425
- return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y1 - controlX) + " " + x1 + " " + (y1 - controlY) + "\n L " + x1 + " " + (y1 - controlY) + " " + centerX + " " + centerY + "\n\n M " + x4 + " " + y4 + "\n C " + (x4 - controlX) + " " + y4 + " " + (x4 - controlX) + " " + (y4 + controlX) + " " + x4 + " " + (y4 + controlY) + "\n L " + x4 + " " + (y4 + controlY) + " " + centerX + " " + centerY + "\n ";
2426
- }
2427
- else {
2428
- controlX = this.ganttUpper.styles.lineHeight;
2429
- return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y1 - controlX) + " " + centerX + " " + centerY + "\n\n M " + x4 + " " + y4 + "\n C " + (x4 - controlX) + " " + y4 + " " + (x4 - controlX) + " " + (y4 + controlX) + " " + centerX + " " + centerY;
2430
- }
2431
- }
2432
- }
2433
- return "M " + x1 + " " + y1 + " C " + x2 + " " + y1 + " " + x3 + " " + y4 + " " + x4 + " " + y4;
2434
- }
2435
- };
2436
2619
  GanttLinksComponent.prototype.buildLinks = function () {
2437
2620
  var _this = this;
2438
2621
  this.computeItemPosition();
2439
2622
  this.links = [];
2440
2623
  this.linkItems.forEach(function (source) {
2441
2624
  if (source.origin.start || source.origin.end) {
2442
- source.links.forEach(function (linkId) {
2443
- var target = _this.linkItems.find(function (item) { return item.id === linkId; });
2625
+ source.links.forEach(function (link) {
2626
+ var target = _this.linkItems.find(function (item) { return item.id === link.link; });
2444
2627
  if (target && (target.origin.start || target.origin.end)) {
2628
+ var color = exports.LinkColors.default;
2629
+ if (link.type === exports.GanttLinkType.fs && source.end.getTime() > target.start.getTime()) {
2630
+ color = exports.LinkColors.blocked;
2631
+ }
2445
2632
  _this.links.push({
2446
- path: _this.generatePath(source, target),
2633
+ path: _this.linkLine.generatePath(source, target, link.type),
2447
2634
  source: source.origin,
2448
2635
  target: target.origin,
2449
- color: source.end.getTime() > target.start.getTime() ? LinkColors.blocked : LinkColors.default
2636
+ type: link.type,
2637
+ color: link.color || color
2450
2638
  });
2451
2639
  }
2452
2640
  });
@@ -2464,13 +2652,13 @@
2464
2652
  });
2465
2653
  };
2466
2654
  GanttLinksComponent.prototype.mouseEnterPath = function (link) {
2467
- if (link.color === LinkColors.default) {
2468
- link.color = LinkColors.active;
2655
+ if (link.color === exports.LinkColors.default) {
2656
+ link.color = exports.LinkColors.active;
2469
2657
  }
2470
2658
  };
2471
2659
  GanttLinksComponent.prototype.mouseLeavePath = function (link) {
2472
- if (link.color === LinkColors.active) {
2473
- link.color = LinkColors.default;
2660
+ if (link.color === exports.LinkColors.active) {
2661
+ link.color = exports.LinkColors.default;
2474
2662
  }
2475
2663
  };
2476
2664
  GanttLinksComponent.prototype.ngOnDestroy = function () {
@@ -2480,7 +2668,7 @@
2480
2668
  return GanttLinksComponent;
2481
2669
  }());
2482
2670
  GanttLinksComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttLinksComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0__namespace.ChangeDetectorRef }, { token: i0__namespace.ElementRef }, { token: GanttDragContainer }], target: i0__namespace.ɵɵFactoryTarget.Component });
2483
- GanttLinksComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { groups: "groups", items: "items" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0__namespace, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path [attr.d]=\"link.path\" fill=\"transparent\" stroke-width=\"2\" [attr.stroke]=\"link.color\" pointer-events=\"none\"></path>\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n (mouseenter)=\"mouseEnterPath(link)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n [attr.d]=\"link.path\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n", directives: [{ type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2671
+ GanttLinksComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { groups: "groups", items: "items" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0__namespace, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path\n [attr.d]=\"link.path\"\n fill=\"transparent\"\n stroke-width=\"2\"\n [attr.stroke]=\"link.color\"\n pointer-events=\"none\"\n [attr.style]=\"link.type === ganttLinkTypes.sf ? 'marker-start: url(#triangle' + i + ')' : 'marker-end: url(#triangle' + i + ')'\"\n ></path>\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n (mouseenter)=\"mouseEnterPath(link)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n [attr.d]=\"link.path\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n <defs *ngIf=\"showArrow\">\n <marker\n *ngIf=\"link.type === ganttLinkTypes.sf; else markerEnd\"\n [id]=\"'triangle' + i\"\n markerUnits=\"strokeWidth\"\n markerWidth=\"5\"\n markerHeight=\"4\"\n refX=\"5\"\n refY=\"2\"\n orient=\"180\"\n >\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n\n <ng-template #markerEnd>\n <marker [id]=\"'triangle' + i\" markerUnits=\"strokeWidth\" markerWidth=\"5\" markerHeight=\"4\" refX=\"5\" refY=\"2\" orient=\"auto\">\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n </ng-template>\n </defs>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n", directives: [{ type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2484
2672
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttLinksComponent, decorators: [{
2485
2673
  type: i0.Component,
2486
2674
  args: [{
@@ -2595,7 +2783,8 @@
2595
2783
 
2596
2784
  var dragMinWidth = 10;
2597
2785
  var activeClass = 'gantt-bar-active';
2598
- var linkDropClass = 'gantt-bar-link-drop';
2786
+ var dropActiveClass = 'gantt-bar-drop-active';
2787
+ var singleDropActiveClass = 'gantt-bar-single-drop-active';
2599
2788
  function createSvgElement(qualifiedName, className) {
2600
2789
  var element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2601
2790
  element.classList.add(className);
@@ -2625,13 +2814,21 @@
2625
2814
  });
2626
2815
  GanttBarDrag.prototype.createMouseEvents = function () {
2627
2816
  var _this = this;
2817
+ var _a, _b, _c;
2818
+ var dropClass = ((_b = (_a = this.ganttUpper.config.linkOptions) === null || _a === void 0 ? void 0 : _a.dependencyTypes) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
2819
+ ((_c = this.ganttUpper.config.linkOptions) === null || _c === void 0 ? void 0 : _c.dependencyTypes[0]) === exports.GanttLinkType.fs
2820
+ ? singleDropActiveClass
2821
+ : dropActiveClass;
2628
2822
  rxjs.fromEvent(this.barElement, 'mouseenter')
2629
2823
  .pipe(operators.takeUntil(this.destroy$))
2630
- .subscribe(function () {
2824
+ .subscribe(function (event) {
2631
2825
  if (_this.dragContainer.linkDraggingId && _this.dragContainer.linkDraggingId !== _this.item.id) {
2632
2826
  if (_this.item.linkable) {
2633
- _this.barElement.classList.add(linkDropClass);
2634
- _this.dragContainer.emitLinkDragEntered(_this.item);
2827
+ _this.barElement.classList.add(dropClass);
2828
+ _this.dragContainer.emitLinkDragEntered({
2829
+ item: _this.item,
2830
+ element: _this.barElement
2831
+ });
2635
2832
  }
2636
2833
  }
2637
2834
  else {
@@ -2640,14 +2837,14 @@
2640
2837
  });
2641
2838
  rxjs.fromEvent(this.barElement, 'mouseleave')
2642
2839
  .pipe(operators.takeUntil(this.destroy$))
2643
- .subscribe(function () {
2840
+ .subscribe(function (event) {
2644
2841
  if (!_this.dragContainer.linkDraggingId) {
2645
2842
  _this.barElement.classList.remove(activeClass);
2646
2843
  }
2647
2844
  else {
2648
2845
  _this.dragContainer.emitLinkDragLeaved();
2649
2846
  }
2650
- _this.barElement.classList.remove(linkDropClass);
2847
+ _this.barElement.classList.remove(dropClass);
2651
2848
  });
2652
2849
  };
2653
2850
  GanttBarDrag.prototype.createBarDrag = function () {
@@ -2659,19 +2856,22 @@
2659
2856
  _this.dragContainer.dragStarted.emit({ item: _this.item.origin });
2660
2857
  });
2661
2858
  dragRef.moved.subscribe(function (event) {
2662
- var x = _this.item.refs.x + event.distance.x;
2663
- var days = dateFns.differenceInCalendarDays(_this.item.end.value, _this.item.start.value);
2664
- var start = _this.ganttUpper.view.getDateByXPoint(x);
2665
- var end = start.addDays(days);
2666
- _this.openDragBackdrop(_this.barElement, _this.ganttUpper.view.getDateByXPoint(x), end);
2859
+ var currentX = _this.item.refs.x + event.distance.x;
2860
+ var currentDate = _this.ganttUpper.view.getDateByXPoint(currentX);
2861
+ var currentStartX = _this.ganttUpper.view.getXPointByDate(currentDate);
2862
+ var dayWidth = _this.ganttUpper.view.getDayOccupancyWidth(currentDate);
2863
+ var diffDays = dateFns.differenceInCalendarDays(_this.item.end.value, _this.item.start.value);
2864
+ var start = currentDate;
2865
+ var end = currentDate.addDays(diffDays);
2866
+ if (currentX > currentStartX + dayWidth / 2) {
2867
+ start = start.addDays(1);
2868
+ end = end.addDays(1);
2869
+ }
2870
+ _this.openDragBackdrop(_this.barElement, start, end);
2667
2871
  _this.item.updateDate(start, end);
2668
2872
  _this.dragContainer.dragMoved.emit({ item: _this.item.origin });
2669
2873
  });
2670
2874
  dragRef.ended.subscribe(function (event) {
2671
- var days = dateFns.differenceInCalendarDays(_this.item.end.value, _this.item.start.value);
2672
- var start = _this.ganttUpper.view.getDateByXPoint(_this.item.refs.x + event.distance.x);
2673
- var end = start.addDays(days);
2674
- _this.item.updateDate(start, end);
2675
2875
  _this.clearDraggingStyles();
2676
2876
  _this.closeDragBackdrop();
2677
2877
  event.source.reset();
@@ -2747,7 +2947,7 @@
2747
2947
  var dragRefs = [];
2748
2948
  var handles = this.barElement.querySelectorAll('.link-handles .handle');
2749
2949
  handles.forEach(function (handle, index) {
2750
- var isBefore = index === 0;
2950
+ var isBegin = index === 0;
2751
2951
  var dragRef = _this.dragDrop.createDrag(handle);
2752
2952
  dragRef.withBoundaryElement(_this.dom.root);
2753
2953
  dragRef.beforeStarted.subscribe(function () {
@@ -2756,24 +2956,35 @@
2756
2956
  _this.barDragRef.disabled = true;
2757
2957
  }
2758
2958
  _this.createLinkDraggingLine();
2759
- _this.dragContainer.emitLinkDragStarted(isBefore ? 'target' : 'source', _this.item);
2959
+ _this.dragContainer.emitLinkDragStarted({
2960
+ element: _this.barElement,
2961
+ item: _this.item,
2962
+ pos: isBegin ? InBarPosition.start : InBarPosition.finish
2963
+ });
2760
2964
  });
2761
2965
  dragRef.moved.subscribe(function () {
2762
- var positions = _this.calcLinkLinePositions(handle, isBefore);
2966
+ var positions = _this.calcLinkLinePositions(handle, isBegin);
2763
2967
  _this.linkDraggingLine.setAttribute('x1', positions.x1.toString());
2764
2968
  _this.linkDraggingLine.setAttribute('y1', positions.y1.toString());
2765
2969
  _this.linkDraggingLine.setAttribute('x2', positions.x2.toString());
2766
2970
  _this.linkDraggingLine.setAttribute('y2', positions.y2.toString());
2767
2971
  });
2768
2972
  dragRef.ended.subscribe(function (event) {
2769
- event.source.reset();
2770
2973
  handle.style.pointerEvents = '';
2771
2974
  if (_this.barDragRef) {
2772
2975
  _this.barDragRef.disabled = false;
2773
2976
  }
2977
+ // 计算line拖动的落点位于目标Bar的值,如果值大于Bar宽度的一半,说明是拖动到Begin位置,否则则为拖动到End位置
2978
+ if (_this.dragContainer.linkDragPath.to) {
2979
+ var placePointX = event.source.getRootElement().getBoundingClientRect().x -
2980
+ _this.dragContainer.linkDragPath.to.element.getBoundingClientRect().x;
2981
+ _this.dragContainer.emitLinkDragEnded(Object.assign(Object.assign({}, _this.dragContainer.linkDragPath.to), { pos: placePointX < _this.dragContainer.linkDragPath.to.item.refs.width / 2
2982
+ ? InBarPosition.start
2983
+ : InBarPosition.finish }));
2984
+ }
2985
+ event.source.reset();
2774
2986
  _this.barElement.classList.remove(activeClass);
2775
2987
  _this.destroyLinkDraggingLine();
2776
- _this.dragContainer.emitLinkDragEnded();
2777
2988
  });
2778
2989
  dragRefs.push(dragRef);
2779
2990
  });
@@ -2822,6 +3033,7 @@
2822
3033
  if (!this.linkDraggingLine) {
2823
3034
  var svgElement = createSvgElement('svg', 'gantt-link-drag-container');
2824
3035
  var linElement = createSvgElement('line', 'link-dragging-line');
3036
+ linElement.style.pointerEvents = 'none';
2825
3037
  svgElement.appendChild(linElement);
2826
3038
  this.dom.root.appendChild(svgElement);
2827
3039
  this.linkDraggingLine = linElement;
@@ -2834,7 +3046,7 @@
2834
3046
  }
2835
3047
  };
2836
3048
  GanttBarDrag.prototype.createDrags = function (elementRef, item, ganttUpper) {
2837
- var _a, _b;
3049
+ var _d, _e;
2838
3050
  this.item = item;
2839
3051
  this.barElement = elementRef.nativeElement;
2840
3052
  this.ganttUpper = ganttUpper;
@@ -2846,11 +3058,11 @@
2846
3058
  if (!this.dragDisabled) {
2847
3059
  var dragRef = this.createBarDrag();
2848
3060
  var dragHandlesRefs = this.createBarHandleDrags();
2849
- (_a = this.dragRefs).push.apply(_a, __spreadArray([dragRef], __read(dragHandlesRefs)));
3061
+ (_d = this.dragRefs).push.apply(_d, __spreadArray([dragRef], __read(dragHandlesRefs)));
2850
3062
  }
2851
3063
  if (!this.linkDragDisabled) {
2852
3064
  var linkDragRefs = this.createLinkHandleDrags();
2853
- (_b = this.dragRefs).push.apply(_b, __spreadArray([], __read(linkDragRefs)));
3065
+ (_e = this.dragRefs).push.apply(_e, __spreadArray([], __read(linkDragRefs)));
2854
3066
  }
2855
3067
  }
2856
3068
  };
@@ -3082,12 +3294,12 @@
3082
3294
  this.selectionModel.toggle(selectedValue.id);
3083
3295
  var selectedIds = this.selectionModel.selected;
3084
3296
  if (this.multiple) {
3085
- var selectedValue_1 = this.getGanttItems(selectedIds).map(function (item) { return item.origin; });
3086
- this.selectedChange.emit({ event: event, selectedValue: selectedValue_1 });
3297
+ var _selectedValue = this.getGanttItems(selectedIds).map(function (item) { return item.origin; });
3298
+ this.selectedChange.emit({ event: event, selectedValue: _selectedValue });
3087
3299
  }
3088
3300
  else {
3089
- var selectedValue_2 = (_a = this.getGanttItem(selectedIds[0])) === null || _a === void 0 ? void 0 : _a.origin;
3090
- this.selectedChange.emit({ event: event, selectedValue: selectedValue_2 });
3301
+ var _selectedValue = (_a = this.getGanttItem(selectedIds[0])) === null || _a === void 0 ? void 0 : _a.origin;
3302
+ this.selectedChange.emit({ event: event, selectedValue: _selectedValue });
3091
3303
  }
3092
3304
  };
3093
3305
  NgxGanttComponent.prototype.ngOnDestroy = function () {