@worktile/gantt 12.2.0-next.1 → 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.
Files changed (39) hide show
  1. package/bundles/worktile-gantt.umd.js +175 -145
  2. package/bundles/worktile-gantt.umd.js.map +1 -1
  3. package/class/event.d.ts +2 -0
  4. package/class/index.d.ts +1 -0
  5. package/class/item.d.ts +1 -1
  6. package/class/link.d.ts +5 -5
  7. package/components/links/{paths → lines}/curve.d.ts +2 -3
  8. package/components/links/lines/factory.d.ts +5 -0
  9. package/components/links/{paths/path.d.ts → lines/line.d.ts} +1 -4
  10. package/components/links/{paths/line.d.ts → lines/straight.d.ts} +2 -2
  11. package/components/links/links.component.d.ts +1 -1
  12. package/esm2015/class/event.js +1 -1
  13. package/esm2015/class/index.js +2 -1
  14. package/esm2015/class/item.js +4 -3
  15. package/esm2015/class/link.js +6 -6
  16. package/esm2015/components/bar/bar-drag.js +35 -12
  17. package/esm2015/components/bar/bar.component.js +1 -1
  18. package/esm2015/components/links/lines/curve.js +96 -0
  19. package/esm2015/components/links/lines/factory.js +14 -0
  20. package/esm2015/components/links/lines/line.js +24 -0
  21. package/esm2015/components/links/lines/straight.js +58 -0
  22. package/esm2015/components/links/links.component.js +4 -4
  23. package/esm2015/gantt-drag-container.js +55 -38
  24. package/esm2015/gantt-upper.js +10 -2
  25. package/esm2015/gantt.component.js +7 -11
  26. package/esm2015/gantt.config.js +3 -3
  27. package/fesm2015/worktile-gantt.js +136 -124
  28. package/fesm2015/worktile-gantt.js.map +1 -1
  29. package/gantt-drag-container.d.ts +20 -8
  30. package/gantt-upper.d.ts +5 -3
  31. package/gantt.component.d.ts +1 -3
  32. package/gantt.config.d.ts +2 -2
  33. package/main.bundle.scss +31 -1
  34. package/package.json +1 -1
  35. package/components/links/paths/factory.d.ts +0 -5
  36. package/esm2015/components/links/paths/curve.js +0 -118
  37. package/esm2015/components/links/paths/factory.js +0 -14
  38. package/esm2015/components/links/paths/line.js +0 -59
  39. package/esm2015/components/links/paths/path.js +0 -31
@@ -564,24 +564,24 @@
564
564
  GanttViewType["week"] = "week";
565
565
  })(exports.GanttViewType || (exports.GanttViewType = {}));
566
566
 
567
- var GanttLinkType;
567
+ exports.GanttLinkType = void 0;
568
568
  (function (GanttLinkType) {
569
569
  GanttLinkType[GanttLinkType["fs"] = 1] = "fs";
570
570
  GanttLinkType[GanttLinkType["ff"] = 2] = "ff";
571
571
  GanttLinkType[GanttLinkType["ss"] = 3] = "ss";
572
572
  GanttLinkType[GanttLinkType["sf"] = 4] = "sf";
573
- })(GanttLinkType || (GanttLinkType = {}));
574
- var GanttLinkPathType;
575
- (function (GanttLinkPathType) {
576
- GanttLinkPathType["curve"] = "curve";
577
- GanttLinkPathType["line"] = "line";
578
- })(GanttLinkPathType || (GanttLinkPathType = {}));
579
- var LinkColors;
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
580
  (function (LinkColors) {
581
581
  LinkColors["default"] = "#cacaca";
582
582
  LinkColors["blocked"] = "#FF7575";
583
583
  LinkColors["active"] = "#348FE4";
584
- })(LinkColors || (LinkColors = {}));
584
+ })(exports.LinkColors || (exports.LinkColors = {}));
585
585
 
586
586
  exports.GanttItemType = void 0;
587
587
  (function (GanttItemType) {
@@ -598,7 +598,7 @@
598
598
  this.links = (this.origin.links || []).map(function (link) {
599
599
  if (typeof link === 'string') {
600
600
  return {
601
- type: GanttLinkType.fs,
601
+ type: exports.GanttLinkType.fs,
602
602
  link: link
603
603
  };
604
604
  }
@@ -668,8 +668,9 @@
668
668
  this.expanded = expanded;
669
669
  this.origin.expanded = expanded;
670
670
  };
671
- GanttItemInternal.prototype.addLink = function (linkId) {
672
- this.links = __spreadArray(__spreadArray([], __read(this.links)), [{ type: GanttLinkType.fs, link: linkId }]);
671
+ GanttItemInternal.prototype.addLink = function (link) {
672
+ console.log(link);
673
+ this.links = __spreadArray(__spreadArray([], __read(this.links)), [link]);
673
674
  this.origin.links = this.links;
674
675
  };
675
676
  return GanttItemInternal;
@@ -703,9 +704,9 @@
703
704
  yearQuarter: 'yyyy年QQQ'
704
705
  },
705
706
  linkOptions: {
706
- dependencyTypes: [GanttLinkType.fs],
707
+ dependencyTypes: [exports.GanttLinkType.fs],
707
708
  showArrow: false,
708
- linkPathType: GanttLinkPathType.curve
709
+ lineType: exports.GanttLinkLineType.curve
709
710
  }
710
711
  };
711
712
  var GANTT_GLOBAL_CONFIG = new i0.InjectionToken('GANTT_GLOBAL_CONFIG');
@@ -1200,6 +1201,16 @@
1200
1201
  this._multiple = false;
1201
1202
  this.ganttClass = true;
1202
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
+ });
1203
1214
  Object.defineProperty(GanttUpper.prototype, "selectable", {
1204
1215
  get: function () {
1205
1216
  return this._selectable;
@@ -1444,7 +1455,7 @@
1444
1455
  return GanttUpper;
1445
1456
  }());
1446
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 });
1447
- 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 });
1448
1459
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttUpper, decorators: [{
1449
1460
  type: i0.Directive
1450
1461
  }], ctorParameters: function () {
@@ -1472,6 +1483,8 @@
1472
1483
  type: i0.Input
1473
1484
  }], viewOptions: [{
1474
1485
  type: i0.Input
1486
+ }], linkOptions: [{
1487
+ type: i0.Input
1475
1488
  }], disabledLoadOnScroll: [{
1476
1489
  type: i0.Input
1477
1490
  }], selectable: [{
@@ -1941,64 +1954,80 @@
1941
1954
  type: i0.Injectable
1942
1955
  }], ctorParameters: function () { return []; } });
1943
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 = {}));
1944
1974
  var GanttDragContainer = /** @class */ (function () {
1945
- function GanttDragContainer() {
1975
+ function GanttDragContainer(ganttUpper) {
1976
+ this.ganttUpper = ganttUpper;
1946
1977
  this.dragStarted = new i0.EventEmitter();
1947
1978
  this.dragMoved = new i0.EventEmitter();
1948
1979
  this.dragEnded = new i0.EventEmitter();
1949
1980
  this.linkDragStarted = new i0.EventEmitter();
1950
1981
  this.linkDragEntered = new i0.EventEmitter();
1951
1982
  this.linkDragEnded = new i0.EventEmitter();
1983
+ this.linkDragPath = { from: null, to: null };
1952
1984
  }
1953
- GanttDragContainer.prototype.emitLinkDragStarted = function (from, item) {
1954
- this.linkDraggingId = item.id;
1955
- this.linkDragFrom = from;
1956
- this.linkDragSource = this.linkDragFrom === 'source' ? item : null;
1957
- this.linkDragTarget = this.linkDragFrom === 'target' ? item : null;
1985
+ GanttDragContainer.prototype.emitLinkDragStarted = function (from) {
1986
+ this.linkDraggingId = from.item.id;
1987
+ this.linkDragPath.from = from;
1958
1988
  this.linkDragStarted.emit({
1959
- source: this.linkDragSource && this.linkDragSource.origin,
1960
- target: this.linkDragTarget && this.linkDragTarget.origin
1989
+ source: from.item.origin,
1990
+ target: null
1961
1991
  });
1962
1992
  };
1963
- GanttDragContainer.prototype.emitLinkDragEntered = function (item) {
1964
- if (this.linkDragFrom === 'source') {
1965
- this.linkDragTarget = item;
1966
- }
1967
- else {
1968
- this.linkDragSource = item;
1969
- }
1993
+ GanttDragContainer.prototype.emitLinkDragEntered = function (to) {
1994
+ this.linkDragPath.to = to;
1970
1995
  this.linkDragEntered.emit({
1971
- source: this.linkDragSource.origin,
1972
- target: this.linkDragTarget.origin
1996
+ source: this.linkDragPath.from.item.origin,
1997
+ target: to.item.origin
1973
1998
  });
1974
1999
  };
1975
2000
  GanttDragContainer.prototype.emitLinkDragLeaved = function () {
1976
- if (this.linkDragFrom === 'source') {
1977
- this.linkDragTarget = null;
1978
- }
1979
- else {
1980
- this.linkDragSource = null;
1981
- }
2001
+ this.linkDragPath.to = null;
1982
2002
  };
1983
- 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
+ });
1984
2016
  this.linkDraggingId = null;
1985
- if (this.linkDragSource && this.linkDragTarget) {
1986
- this.linkDragSource.addLink(this.linkDragTarget.id);
1987
- this.linkDragEnded.emit({
1988
- source: this.linkDragSource.origin,
1989
- target: this.linkDragTarget.origin
1990
- });
1991
- }
1992
- this.linkDragSource = null;
1993
- this.linkDragTarget = null;
2017
+ this.linkDragPath = { from: null, to: null };
1994
2018
  };
1995
2019
  return GanttDragContainer;
1996
2020
  }());
1997
- 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 });
1998
2022
  GanttDragContainer.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttDragContainer });
1999
2023
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttDragContainer, decorators: [{
2000
2024
  type: i0.Injectable
2001
- }], ctorParameters: function () { return []; } });
2025
+ }], ctorParameters: function () {
2026
+ return [{ type: GanttUpper, decorators: [{
2027
+ type: i0.Inject,
2028
+ args: [GANTT_UPPER_TOKEN]
2029
+ }] }];
2030
+ } });
2002
2031
 
2003
2032
  var GanttPrintService = /** @class */ (function () {
2004
2033
  function GanttPrintService() {
@@ -2349,20 +2378,20 @@
2349
2378
  args: ['mainTemplate', { static: true }]
2350
2379
  }] } });
2351
2380
 
2352
- var GanttLinkPath = /** @class */ (function () {
2353
- function GanttLinkPath() {
2381
+ var GanttLinkLine = /** @class */ (function () {
2382
+ function GanttLinkLine() {
2354
2383
  }
2355
- GanttLinkPath.prototype.generatePath = function (source, target, type) {
2384
+ GanttLinkLine.prototype.generatePath = function (source, target, type) {
2356
2385
  if (source.before && source.after && target.before && target.after) {
2357
2386
  var path = '';
2358
2387
  switch (type) {
2359
- case GanttLinkType.ss:
2388
+ case exports.GanttLinkType.ss:
2360
2389
  path = this.generateSSPath(source, target);
2361
2390
  break;
2362
- case GanttLinkType.ff:
2391
+ case exports.GanttLinkType.ff:
2363
2392
  path = this.generateFFPath(source, target);
2364
2393
  break;
2365
- case GanttLinkType.sf:
2394
+ case exports.GanttLinkType.sf:
2366
2395
  path = this.generateFSAndSFPath(source, target, type);
2367
2396
  break;
2368
2397
  default:
@@ -2371,23 +2400,17 @@
2371
2400
  return path;
2372
2401
  }
2373
2402
  };
2374
- return GanttLinkPath;
2403
+ return GanttLinkLine;
2375
2404
  }());
2376
- GanttLinkPath.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttLinkPath, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2377
- GanttLinkPath.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttLinkPath });
2378
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: GanttLinkPath, decorators: [{
2379
- type: i0.Injectable
2380
- }], ctorParameters: function () { return []; } });
2381
2405
 
2382
- var GanttLinkPathCurve = /** @class */ (function (_super) {
2383
- __extends(GanttLinkPathCurve, _super);
2384
- function GanttLinkPathCurve(ganttUpper) {
2406
+ var GanttLinkLineCurve = /** @class */ (function (_super) {
2407
+ __extends(GanttLinkLineCurve, _super);
2408
+ function GanttLinkLineCurve(ganttUpper) {
2385
2409
  var _this = _super.call(this) || this;
2386
2410
  _this.ganttUpper = ganttUpper;
2387
- _this.bezierWeight = -0.5;
2388
2411
  return _this;
2389
2412
  }
2390
- GanttLinkPathCurve.prototype.generateSSPath = function (source, target) {
2413
+ GanttLinkLineCurve.prototype.generateSSPath = function (source, target) {
2391
2414
  var x1 = source.before.x;
2392
2415
  var y1 = source.before.y;
2393
2416
  var x4 = target.before.x;
@@ -2401,7 +2424,7 @@
2401
2424
  return "M " + x1 + " " + y1 + "\n L " + x4 + " " + y1 + "\n A " + radius + " " + radius + " 0 1 " + isMirror + " " + x4 + " " + y4;
2402
2425
  }
2403
2426
  };
2404
- GanttLinkPathCurve.prototype.generateFFPath = function (source, target) {
2427
+ GanttLinkLineCurve.prototype.generateFFPath = function (source, target) {
2405
2428
  var x1 = source.after.x;
2406
2429
  var y1 = source.after.y;
2407
2430
  var x4 = target.after.x;
@@ -2415,75 +2438,65 @@
2415
2438
  return "M " + x1 + " " + y1 + "\n A " + radius + " " + radius + " 0 1 " + isMirror + " " + x1 + " " + y4 + "\n L " + x4 + " " + y4;
2416
2439
  }
2417
2440
  };
2418
- GanttLinkPathCurve.prototype.generateFSAndSFPath = function (source, target, type) {
2441
+ GanttLinkLineCurve.prototype.generateFSAndSFPath = function (source, target, type) {
2442
+ var _a;
2419
2443
  var x1 = source.after.x;
2420
2444
  var y1 = source.after.y;
2421
2445
  var x4 = target.before.x;
2422
2446
  var y4 = target.before.y;
2423
- if (type === GanttLinkType.sf) {
2447
+ var bezierWeight = 0.5;
2448
+ if (type === exports.GanttLinkType.sf) {
2424
2449
  x1 = target.after.x;
2425
2450
  y1 = target.after.y;
2426
2451
  x4 = source.before.x;
2427
2452
  y4 = source.before.y;
2428
2453
  }
2429
- var dx = Math.abs(x4 - x1) * this.bezierWeight;
2430
- var x2 = x1 - dx;
2431
- var x3 = x4 + dx;
2454
+ var dx = Math.abs(x4 - x1) * bezierWeight;
2455
+ var x2 = x1 + dx;
2456
+ var x3 = x4 - dx;
2432
2457
  var centerX = (x1 + x4) / 2;
2433
2458
  var centerY = (y1 + y4) / 2;
2434
2459
  var controlX = this.ganttUpper.styles.lineHeight / 2;
2435
2460
  var controlY = this.ganttUpper.styles.lineHeight / 2;
2436
2461
  if (x1 >= x4) {
2437
- if (y4 > y1) {
2438
- if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
2439
- return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y1 + controlX) + " " + x1 + " " + (y1 + controlY) + "\n L " + x4 + " " + (y4 - controlY) + "\n C " + (x4 - controlY) + " " + (y4 - controlY) + " " + (x4 - controlX) + " " + y4 + " " + x4 + " " + y4;
2440
- }
2441
- else {
2442
- controlX = this.ganttUpper.styles.lineHeight;
2443
- return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y1 + controlX) + " " + centerX + " " + centerY + "\n C " + (x4 - controlX) + " " + (y4 - controlX) + " " + (x4 - controlX) + " " + y4 + " " + x4 + " " + y4 + "\n ";
2444
- }
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 ";
2445
2464
  }
2446
2465
  else {
2447
- if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
2448
- return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y1 - controlX) + " " + x1 + " " + (y1 - controlY) + "\n L " + x4 + " " + (y4 + controlY) + "\n C " + (x4 - controlY) + " " + (y4 + controlY) + " " + (x4 - controlX) + " " + y4 + " " + x4 + " " + y4 + "\n ";
2449
- }
2450
- else {
2451
- controlX = this.ganttUpper.styles.lineHeight;
2452
- return "M " + x1 + " " + y1 + "\n C " + (x1 + controlX) + " " + y1 + " " + (x1 + controlX) + " " + (y1 - controlX) + " " + centerX + " " + centerY + "\n C " + (x4 - controlX) + " " + (y4 + controlX) + " " + (x4 - controlX) + " " + y4 + " " + x4 + " " + y4 + "\n ";
2453
- }
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 ";
2454
2468
  }
2455
2469
  }
2456
- else if (x4 - x1 < 100) {
2457
- var radius = Math.abs(y4 - y1) / 4;
2458
- var lindWidth = x4 - x1 - radius;
2459
- lindWidth = Math.max(lindWidth, radius);
2460
- return "M " + x1 + " " + y1 + "\n L " + (x1 + lindWidth) + " " + y1 + "\n A " + radius + " " + radius + " 0 1 " + (y4 > y1 ? 1 : 0) + " " + (x1 + lindWidth) + " " + (y4 > y1 ? y1 + 2 * radius : y1 - 2 * radius) + "\n L " + (x4 - lindWidth) + " " + (y4 > y1 ? y1 + 2 * radius : y1 - 2 * radius) + "\n A " + radius + " " + radius + " 0 1 " + (y4 > y1 ? 0 : 1) + " " + (x4 - lindWidth) + " " + y4 + "\n L " + x4 + " " + y4 + "\n ";
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;
2461
2475
  }
2462
2476
  return "M " + x1 + " " + y1 + " C " + x2 + " " + y1 + " " + x3 + " " + y4 + " " + x4 + " " + y4;
2463
2477
  };
2464
- return GanttLinkPathCurve;
2465
- }(GanttLinkPath));
2466
- GanttLinkPathCurve = __decorate([
2478
+ return GanttLinkLineCurve;
2479
+ }(GanttLinkLine));
2480
+ GanttLinkLineCurve = __decorate([
2467
2481
  __param(0, i0.Inject(GANTT_UPPER_TOKEN))
2468
- ], GanttLinkPathCurve);
2482
+ ], GanttLinkLineCurve);
2469
2483
 
2470
- var GanttLinkPathLine = /** @class */ (function (_super) {
2471
- __extends(GanttLinkPathLine, _super);
2472
- function GanttLinkPathLine() {
2484
+ var GanttLinkLineStraight = /** @class */ (function (_super) {
2485
+ __extends(GanttLinkLineStraight, _super);
2486
+ function GanttLinkLineStraight() {
2473
2487
  var _this = _super.call(this) || this;
2474
2488
  _this.pathControl = 20;
2475
2489
  return _this;
2476
2490
  }
2477
- GanttLinkPathLine.prototype.generateSSPath = function (source, target) {
2491
+ GanttLinkLineStraight.prototype.generateSSPath = function (source, target) {
2478
2492
  var x1 = source.before.x;
2479
2493
  var y1 = source.before.y;
2480
2494
  var x4 = target.before.x;
2481
2495
  var y4 = target.before.y;
2482
2496
  var control = this.pathControl;
2483
- var centerY = (y1 + y4) / 2;
2484
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;
2485
2498
  };
2486
- GanttLinkPathLine.prototype.generateFFPath = function (source, target) {
2499
+ GanttLinkLineStraight.prototype.generateFFPath = function (source, target) {
2487
2500
  var x1 = source.after.x;
2488
2501
  var y1 = source.after.y;
2489
2502
  var x4 = target.after.x;
@@ -2491,13 +2504,13 @@
2491
2504
  var control = this.pathControl;
2492
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;
2493
2506
  };
2494
- GanttLinkPathLine.prototype.generateFSAndSFPath = function (source, target, type) {
2507
+ GanttLinkLineStraight.prototype.generateFSAndSFPath = function (source, target, type) {
2495
2508
  var x1 = source.after.x;
2496
2509
  var y1 = source.after.y;
2497
2510
  var x4 = target.before.x;
2498
2511
  var y4 = target.before.y;
2499
2512
  var control = this.pathControl;
2500
- if (type === GanttLinkType.sf) {
2513
+ if (type === exports.GanttLinkType.sf) {
2501
2514
  x1 = target.after.x;
2502
2515
  y1 = target.after.y;
2503
2516
  x4 = source.before.x;
@@ -2510,15 +2523,15 @@
2510
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;
2511
2524
  }
2512
2525
  };
2513
- return GanttLinkPathLine;
2514
- }(GanttLinkPath));
2526
+ return GanttLinkLineStraight;
2527
+ }(GanttLinkLine));
2515
2528
 
2516
- function generatePathFactory(type, ganttUpper) {
2529
+ function createLineGenerator(type, ganttUpper) {
2517
2530
  switch (type) {
2518
- case GanttLinkPathType.curve:
2519
- return new GanttLinkPathCurve(ganttUpper);
2520
- case GanttLinkPathType.line:
2521
- return new GanttLinkPathLine();
2531
+ case exports.GanttLinkLineType.curve:
2532
+ return new GanttLinkLineCurve(ganttUpper);
2533
+ case exports.GanttLinkLineType.straight:
2534
+ return new GanttLinkLineStraight();
2522
2535
  default:
2523
2536
  throw new Error('gantt link path type invalid');
2524
2537
  }
@@ -2534,7 +2547,7 @@
2534
2547
  this.items = [];
2535
2548
  this.lineClick = new i0.EventEmitter();
2536
2549
  this.links = [];
2537
- this.ganttLinkTypes = GanttLinkType;
2550
+ this.ganttLinkTypes = exports.GanttLinkType;
2538
2551
  this.showArrow = false;
2539
2552
  this.linkItems = [];
2540
2553
  this.firstChange = true;
@@ -2543,7 +2556,7 @@
2543
2556
  }
2544
2557
  GanttLinksComponent.prototype.ngOnInit = function () {
2545
2558
  var _this = this;
2546
- this.linkPath = generatePathFactory(this.ganttUpper.linkOptions.linkPathType, this.ganttUpper);
2559
+ this.linkLine = createLineGenerator(this.ganttUpper.linkOptions.lineType, this.ganttUpper);
2547
2560
  this.showArrow = this.ganttUpper.linkOptions.showArrow;
2548
2561
  this.buildLinks();
2549
2562
  this.firstChange = false;
@@ -2612,12 +2625,12 @@
2612
2625
  source.links.forEach(function (link) {
2613
2626
  var target = _this.linkItems.find(function (item) { return item.id === link.link; });
2614
2627
  if (target && (target.origin.start || target.origin.end)) {
2615
- var color = LinkColors.default;
2616
- if (link.type === GanttLinkType.fs && source.end.getTime() > target.start.getTime()) {
2617
- color = LinkColors.blocked;
2628
+ var color = exports.LinkColors.default;
2629
+ if (link.type === exports.GanttLinkType.fs && source.end.getTime() > target.start.getTime()) {
2630
+ color = exports.LinkColors.blocked;
2618
2631
  }
2619
2632
  _this.links.push({
2620
- path: _this.linkPath.generatePath(source, target, link.type),
2633
+ path: _this.linkLine.generatePath(source, target, link.type),
2621
2634
  source: source.origin,
2622
2635
  target: target.origin,
2623
2636
  type: link.type,
@@ -2639,13 +2652,13 @@
2639
2652
  });
2640
2653
  };
2641
2654
  GanttLinksComponent.prototype.mouseEnterPath = function (link) {
2642
- if (link.color === LinkColors.default) {
2643
- link.color = LinkColors.active;
2655
+ if (link.color === exports.LinkColors.default) {
2656
+ link.color = exports.LinkColors.active;
2644
2657
  }
2645
2658
  };
2646
2659
  GanttLinksComponent.prototype.mouseLeavePath = function (link) {
2647
- if (link.color === LinkColors.active) {
2648
- link.color = LinkColors.default;
2660
+ if (link.color === exports.LinkColors.active) {
2661
+ link.color = exports.LinkColors.default;
2649
2662
  }
2650
2663
  };
2651
2664
  GanttLinksComponent.prototype.ngOnDestroy = function () {
@@ -2770,7 +2783,8 @@
2770
2783
 
2771
2784
  var dragMinWidth = 10;
2772
2785
  var activeClass = 'gantt-bar-active';
2773
- var linkDropClass = 'gantt-bar-link-drop';
2786
+ var dropActiveClass = 'gantt-bar-drop-active';
2787
+ var singleDropActiveClass = 'gantt-bar-single-drop-active';
2774
2788
  function createSvgElement(qualifiedName, className) {
2775
2789
  var element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2776
2790
  element.classList.add(className);
@@ -2800,13 +2814,21 @@
2800
2814
  });
2801
2815
  GanttBarDrag.prototype.createMouseEvents = function () {
2802
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;
2803
2822
  rxjs.fromEvent(this.barElement, 'mouseenter')
2804
2823
  .pipe(operators.takeUntil(this.destroy$))
2805
- .subscribe(function () {
2824
+ .subscribe(function (event) {
2806
2825
  if (_this.dragContainer.linkDraggingId && _this.dragContainer.linkDraggingId !== _this.item.id) {
2807
2826
  if (_this.item.linkable) {
2808
- _this.barElement.classList.add(linkDropClass);
2809
- _this.dragContainer.emitLinkDragEntered(_this.item);
2827
+ _this.barElement.classList.add(dropClass);
2828
+ _this.dragContainer.emitLinkDragEntered({
2829
+ item: _this.item,
2830
+ element: _this.barElement
2831
+ });
2810
2832
  }
2811
2833
  }
2812
2834
  else {
@@ -2815,14 +2837,14 @@
2815
2837
  });
2816
2838
  rxjs.fromEvent(this.barElement, 'mouseleave')
2817
2839
  .pipe(operators.takeUntil(this.destroy$))
2818
- .subscribe(function () {
2840
+ .subscribe(function (event) {
2819
2841
  if (!_this.dragContainer.linkDraggingId) {
2820
2842
  _this.barElement.classList.remove(activeClass);
2821
2843
  }
2822
2844
  else {
2823
2845
  _this.dragContainer.emitLinkDragLeaved();
2824
2846
  }
2825
- _this.barElement.classList.remove(linkDropClass);
2847
+ _this.barElement.classList.remove(dropClass);
2826
2848
  });
2827
2849
  };
2828
2850
  GanttBarDrag.prototype.createBarDrag = function () {
@@ -2925,7 +2947,7 @@
2925
2947
  var dragRefs = [];
2926
2948
  var handles = this.barElement.querySelectorAll('.link-handles .handle');
2927
2949
  handles.forEach(function (handle, index) {
2928
- var isBefore = index === 0;
2950
+ var isBegin = index === 0;
2929
2951
  var dragRef = _this.dragDrop.createDrag(handle);
2930
2952
  dragRef.withBoundaryElement(_this.dom.root);
2931
2953
  dragRef.beforeStarted.subscribe(function () {
@@ -2934,24 +2956,35 @@
2934
2956
  _this.barDragRef.disabled = true;
2935
2957
  }
2936
2958
  _this.createLinkDraggingLine();
2937
- _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
+ });
2938
2964
  });
2939
2965
  dragRef.moved.subscribe(function () {
2940
- var positions = _this.calcLinkLinePositions(handle, isBefore);
2966
+ var positions = _this.calcLinkLinePositions(handle, isBegin);
2941
2967
  _this.linkDraggingLine.setAttribute('x1', positions.x1.toString());
2942
2968
  _this.linkDraggingLine.setAttribute('y1', positions.y1.toString());
2943
2969
  _this.linkDraggingLine.setAttribute('x2', positions.x2.toString());
2944
2970
  _this.linkDraggingLine.setAttribute('y2', positions.y2.toString());
2945
2971
  });
2946
2972
  dragRef.ended.subscribe(function (event) {
2947
- event.source.reset();
2948
2973
  handle.style.pointerEvents = '';
2949
2974
  if (_this.barDragRef) {
2950
2975
  _this.barDragRef.disabled = false;
2951
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();
2952
2986
  _this.barElement.classList.remove(activeClass);
2953
2987
  _this.destroyLinkDraggingLine();
2954
- _this.dragContainer.emitLinkDragEnded();
2955
2988
  });
2956
2989
  dragRefs.push(dragRef);
2957
2990
  });
@@ -3000,6 +3033,7 @@
3000
3033
  if (!this.linkDraggingLine) {
3001
3034
  var svgElement = createSvgElement('svg', 'gantt-link-drag-container');
3002
3035
  var linElement = createSvgElement('line', 'link-dragging-line');
3036
+ linElement.style.pointerEvents = 'none';
3003
3037
  svgElement.appendChild(linElement);
3004
3038
  this.dom.root.appendChild(svgElement);
3005
3039
  this.linkDraggingLine = linElement;
@@ -3012,7 +3046,7 @@
3012
3046
  }
3013
3047
  };
3014
3048
  GanttBarDrag.prototype.createDrags = function (elementRef, item, ganttUpper) {
3015
- var _a, _b;
3049
+ var _d, _e;
3016
3050
  this.item = item;
3017
3051
  this.barElement = elementRef.nativeElement;
3018
3052
  this.ganttUpper = ganttUpper;
@@ -3024,11 +3058,11 @@
3024
3058
  if (!this.dragDisabled) {
3025
3059
  var dragRef = this.createBarDrag();
3026
3060
  var dragHandlesRefs = this.createBarHandleDrags();
3027
- (_a = this.dragRefs).push.apply(_a, __spreadArray([dragRef], __read(dragHandlesRefs)));
3061
+ (_d = this.dragRefs).push.apply(_d, __spreadArray([dragRef], __read(dragHandlesRefs)));
3028
3062
  }
3029
3063
  if (!this.linkDragDisabled) {
3030
3064
  var linkDragRefs = this.createLinkHandleDrags();
3031
- (_b = this.dragRefs).push.apply(_b, __spreadArray([], __read(linkDragRefs)));
3065
+ (_e = this.dragRefs).push.apply(_e, __spreadArray([], __read(linkDragRefs)));
3032
3066
  }
3033
3067
  }
3034
3068
  };
@@ -3200,9 +3234,7 @@
3200
3234
  }
3201
3235
  NgxGanttComponent.prototype.ngOnInit = function () {
3202
3236
  var _this = this;
3203
- var _a;
3204
3237
  _super.prototype.onInit.call(this);
3205
- this.linkOptions = Object.assign({}, defaultConfig.linkOptions, (_a = this.config) === null || _a === void 0 ? void 0 : _a.linkOptions, this.linkOptions);
3206
3238
  this.ngZone.onStable.pipe(operators.take(1)).subscribe(function () {
3207
3239
  _this.dragContainer.linkDragStarted.pipe(operators.takeUntil(_this.ngUnsubscribe$)).subscribe(function (event) {
3208
3240
  _this.linkDragStarted.emit(event);
@@ -3262,12 +3294,12 @@
3262
3294
  this.selectionModel.toggle(selectedValue.id);
3263
3295
  var selectedIds = this.selectionModel.selected;
3264
3296
  if (this.multiple) {
3265
- var selectedValue_1 = this.getGanttItems(selectedIds).map(function (item) { return item.origin; });
3266
- 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 });
3267
3299
  }
3268
3300
  else {
3269
- var selectedValue_2 = (_a = this.getGanttItem(selectedIds[0])) === null || _a === void 0 ? void 0 : _a.origin;
3270
- 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 });
3271
3303
  }
3272
3304
  };
3273
3305
  NgxGanttComponent.prototype.ngOnDestroy = function () {
@@ -3276,7 +3308,7 @@
3276
3308
  return NgxGanttComponent;
3277
3309
  }(GanttUpper));
3278
3310
  NgxGanttComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: NgxGanttComponent, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }, { token: i0__namespace.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0__namespace.ɵɵFactoryTarget.Component });
3279
- NgxGanttComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable", linkOptions: "linkOptions" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
3311
+ NgxGanttComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
3280
3312
  {
3281
3313
  provide: GANTT_UPPER_TOKEN,
3282
3314
  useExisting: NgxGanttComponent
@@ -3316,8 +3348,6 @@
3316
3348
  type: i0.Input
3317
3349
  }], linkable: [{
3318
3350
  type: i0.Input
3319
- }], linkOptions: [{
3320
- type: i0.Input
3321
3351
  }], linkDragStarted: [{
3322
3352
  type: i0.Output
3323
3353
  }], linkDragEnded: [{