gantt-task-react-powern 0.6.21 → 0.6.23

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.
package/dist/index.js CHANGED
@@ -106,9 +106,23 @@ var startOfDate = function startOfDate(date, scale) {
106
106
  var newDate = new Date(date.getFullYear(), shouldReset("year") ? 0 : date.getMonth(), shouldReset("month") ? 1 : date.getDate(), shouldReset("day") ? 0 : date.getHours(), shouldReset("hour") ? 0 : date.getMinutes(), shouldReset("minute") ? 0 : date.getSeconds(), shouldReset("second") ? 0 : date.getMilliseconds());
107
107
  return newDate;
108
108
  };
109
- var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount) {
109
+
110
+ var getFiscalQuarterStartDate = function getFiscalQuarterStartDate(date, quarterStart) {
111
+ var month = date.getMonth();
112
+ var offset = (month - quarterStart + 12) % 12;
113
+ var qStartMonth = (quarterStart + Math.floor(offset / 3) * 3) % 12;
114
+ var year = date.getFullYear();
115
+ if (qStartMonth > month) year -= 1;
116
+ return new Date(year, qStartMonth, 1);
117
+ };
118
+
119
+ var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount, quarterStart) {
110
120
  var _tasks$, _tasks$2, _tasks$3, _tasks$4;
111
121
 
122
+ if (quarterStart === void 0) {
123
+ quarterStart = 0;
124
+ }
125
+
112
126
  var newStartDate = ((_tasks$ = tasks[0]) === null || _tasks$ === void 0 ? void 0 : _tasks$.start.getTime()) !== 0 ? ((_tasks$2 = tasks[0]) === null || _tasks$2 === void 0 ? void 0 : _tasks$2.start) || new Date() : new Date();
113
127
  var newEndDate = ((_tasks$3 = tasks[0]) === null || _tasks$3 === void 0 ? void 0 : _tasks$3.end.getTime()) !== 0 ? ((_tasks$4 = tasks[0]) === null || _tasks$4 === void 0 ? void 0 : _tasks$4.end) || new Date() : new Date();
114
128
 
@@ -141,11 +155,14 @@ var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount) {
141
155
  break;
142
156
 
143
157
  case exports.ViewMode.Quarter:
144
- newStartDate = addToDate(newStartDate, -1 * preStepsCount, "year");
145
- newStartDate = startOfDate(newStartDate, "year");
146
- newEndDate = addToDate(newEndDate, 1, "year");
147
- newEndDate = startOfDate(newEndDate, "quarter");
148
- break;
158
+ {
159
+ newStartDate = addToDate(newStartDate, -1 * preStepsCount, "year");
160
+ newStartDate = getFiscalQuarterStartDate(newStartDate, quarterStart);
161
+ newEndDate = addToDate(newEndDate, 1, "year");
162
+ var endQStart = getFiscalQuarterStartDate(newEndDate, quarterStart);
163
+ newEndDate = endQStart < newEndDate ? addToDate(endQStart, 3, "month") : endQStart;
164
+ break;
165
+ }
149
166
 
150
167
  case exports.ViewMode.Month:
151
168
  newStartDate = addToDate(newStartDate, -1 * preStepsCount, "month");
@@ -236,13 +253,6 @@ var seedDates = function seedDates(startDate, endDate, viewMode) {
236
253
 
237
254
  return dates;
238
255
  };
239
- var getLocaleMonth = function getLocaleMonth(date, locale) {
240
- var bottomValue = getCachedDateTimeFormat(locale, {
241
- month: "long"
242
- }).format(date);
243
- bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
244
- return bottomValue;
245
- };
246
256
  var getLocalDayOfWeek = function getLocalDayOfWeek(date, locale, format) {
247
257
  var bottomValue = getCachedDateTimeFormat(locale, {
248
258
  weekday: format
@@ -257,26 +267,6 @@ var getMonday = function getMonday(date) {
257
267
  return new Date(date.setDate(diff));
258
268
  };
259
269
 
260
- var getWeekNumberISO8601 = function getWeekNumberISO8601(date) {
261
- var tmpDate = new Date(date.valueOf());
262
- var dayNumber = (tmpDate.getDay() + 6) % 7;
263
- tmpDate.setDate(tmpDate.getDate() - dayNumber + 3);
264
- var firstThursday = tmpDate.valueOf();
265
- tmpDate.setMonth(0, 1);
266
-
267
- if (tmpDate.getDay() !== 4) {
268
- tmpDate.setMonth(0, 1 + (4 - tmpDate.getDay() + 7) % 7);
269
- }
270
-
271
- var weekNumber = (1 + Math.ceil((firstThursday - tmpDate.valueOf()) / 604800000)).toString();
272
-
273
- if (weekNumber.length === 1) {
274
- return "0" + weekNumber;
275
- } else {
276
- return weekNumber;
277
- }
278
- };
279
-
280
270
  var styles = {"ganttTable":"_3_ygE","ganttTable_Header":"_1nBOt","ganttTable_HeaderSeparator":"_2eZzQ","ganttTable_HeaderItem":"_WuQ0f"};
281
271
 
282
272
  var TaskListHeaderDefault = function TaskListHeaderDefault(_ref) {
@@ -732,7 +722,8 @@ var Tooltip = function Tooltip(_ref) {
732
722
  fontFamily = _ref.fontFamily,
733
723
  headerHeight = _ref.headerHeight,
734
724
  taskListWidth = _ref.taskListWidth,
735
- TooltipContent = _ref.TooltipContent;
725
+ TooltipContent = _ref.TooltipContent,
726
+ isDragging = _ref.isDragging;
736
727
  var tooltipRef = React.useRef(null);
737
728
 
738
729
  var _useState = React.useState(0),
@@ -750,6 +741,14 @@ var Tooltip = function Tooltip(_ref) {
750
741
  var newRelatedY = task.index * rowHeight - scrollY + headerHeight;
751
742
  var newRelatedX;
752
743
 
744
+ if (isDragging) {
745
+ newRelatedX = taskListWidth + svgContainerWidth - tooltipWidth - 10;
746
+ newRelatedY = headerHeight + 5;
747
+ setRelatedY(newRelatedY);
748
+ setRelatedX(newRelatedX);
749
+ return;
750
+ }
751
+
753
752
  if (rtl) {
754
753
  newRelatedX = task.x1 - arrowIndent * 1.5 - tooltipWidth - scrollX;
755
754
 
@@ -789,7 +788,7 @@ var Tooltip = function Tooltip(_ref) {
789
788
  setRelatedY(newRelatedY);
790
789
  setRelatedX(newRelatedX);
791
790
  }
792
- }, [tooltipRef, task, arrowIndent, scrollX, scrollY, headerHeight, taskListWidth, rowHeight, svgContainerHeight, svgContainerWidth, rtl]);
791
+ }, [tooltipRef, task, arrowIndent, scrollX, scrollY, headerHeight, taskListWidth, rowHeight, svgContainerHeight, svgContainerWidth, rtl, isDragging]);
793
792
  return React__default.createElement("div", {
794
793
  ref: tooltipRef,
795
794
  className: relatedX ? styles$2.tooltipDetailsContainer : styles$2.tooltipDetailsContainerHidden,
@@ -805,6 +804,8 @@ var Tooltip = function Tooltip(_ref) {
805
804
  }));
806
805
  };
807
806
  var StandardTooltipContent = function StandardTooltipContent(_ref2) {
807
+ var _task$plannedDuration, _task$actualDuration;
808
+
808
809
  var task = _ref2.task,
809
810
  fontSize = _ref2.fontSize,
810
811
  fontFamily = _ref2.fontFamily,
@@ -813,6 +814,8 @@ var StandardTooltipContent = function StandardTooltipContent(_ref2) {
813
814
  fontSize: fontSize,
814
815
  fontFamily: fontFamily
815
816
  };
817
+ var computedPlannedDuration = task.start && task.end && task.end.getTime() - task.start.getTime() > 0 ? Math.max(1, Math.round((task.end.getTime() - task.start.getTime()) / (1000 * 60 * 60 * 24))) : (_task$plannedDuration = task.plannedDuration) != null ? _task$plannedDuration : 0;
818
+ var computedActualDuration = task.actualStart && task.actualEnd && task.actualEnd.getTime() - task.actualStart.getTime() > 0 ? Math.max(1, Math.round((task.actualEnd.getTime() - task.actualStart.getTime()) / (1000 * 60 * 60 * 24))) : (_task$actualDuration = task.actualDuration) != null ? _task$actualDuration : 0;
816
819
  if (type == "planned") return React__default.createElement("div", {
817
820
  className: styles$2.tooltipDefaultContainer,
818
821
  style: style
@@ -822,7 +825,7 @@ var StandardTooltipContent = function StandardTooltipContent(_ref2) {
822
825
  }
823
826
  }, task.name + ": Planned dates: "), React__default.createElement("b", null, task.start.getMonth() + 1 + "/" + task.start.getDate() + "/" + task.start.getFullYear() + " - " + (task.end.getMonth() + 1) + "/" + task.end.getDate() + "/" + task.end.getFullYear()), task.end.getTime() - task.start.getTime() !== 0 && React__default.createElement("p", {
824
827
  className: styles$2.tooltipDefaultContainerParagraph
825
- }, "Duration: " + task.plannedDuration + " day(s)"), React__default.createElement("p", {
828
+ }, "Duration: " + computedPlannedDuration + " day(s)"), React__default.createElement("p", {
826
829
  className: styles$2.tooltipDefaultContainerParagraph
827
830
  }, !!task.progress && "Progress: " + task.progress + " %"));else return React__default.createElement("div", {
828
831
  className: styles$2.tooltipDefaultContainer,
@@ -833,7 +836,7 @@ var StandardTooltipContent = function StandardTooltipContent(_ref2) {
833
836
  }
834
837
  }, task.name + ": Actual dates: "), React__default.createElement("b", null, task.actualStart.getMonth() + 1 + "/" + task.actualStart.getDate() + "/" + task.actualStart.getFullYear() + " - " + (task.actualEnd.getMonth() + 1) + "/" + task.actualEnd.getDate() + "/" + task.actualEnd.getFullYear()), task.actualEnd.getTime() - task.actualStart.getTime() !== 0 && React__default.createElement("p", {
835
838
  className: styles$2.tooltipDefaultContainerParagraph
836
- }, "Duration: " + task.actualDuration + " day(s)"), React__default.createElement("p", {
839
+ }, "Duration: " + computedActualDuration + " day(s)"), React__default.createElement("p", {
837
840
  className: styles$2.tooltipDefaultContainerParagraph
838
841
  }, !!task.progress && "Progress: " + task.progress + " %"));
839
842
  };
@@ -1100,9 +1103,133 @@ var TaskList = function TaskList(_ref) {
1100
1103
  }, React__default.createElement(TaskListTable, Object.assign({}, tableProps))))));
1101
1104
  };
1102
1105
 
1103
- var styles$5 = {"gridRow":"_2dZTy","gridRowLookAhead":"_2RRca","gridRowLine":"_3rUKi","gridTick":"_RuwuK","darkerGridRow":"_2M-tt"};
1106
+ function parseTimeToMinutes(t) {
1107
+ var parts = t.split(":").map(Number);
1108
+ return parts[0] * 60 + parts[1] + (parts[2] ? parts[2] / 60 : 0);
1109
+ }
1110
+
1111
+ function toDateString(date) {
1112
+ var y = date.getFullYear();
1113
+ var m = String(date.getMonth() + 1).padStart(2, "0");
1114
+ var d = String(date.getDate()).padStart(2, "0");
1115
+ return y + "-" + m + "-" + d;
1116
+ }
1117
+
1118
+ function isHoliday(date, cal) {
1119
+ return cal.holidays.includes(toDateString(date));
1120
+ }
1121
+ function isOffDay(date, cal) {
1122
+ return cal.off_days.includes(date.getDay()) || isHoliday(date, cal);
1123
+ }
1124
+ function getShiftsForDay(date, cal) {
1125
+ if (isOffDay(date, cal)) return [];
1126
+ return cal.shifts.map(function (_ref) {
1127
+ var s = _ref[0],
1128
+ e = _ref[1];
1129
+ return {
1130
+ start: parseTimeToMinutes(s),
1131
+ end: parseTimeToMinutes(e)
1132
+ };
1133
+ });
1134
+ }
1135
+ function getWorkingIntervals(start, end, cal) {
1136
+ if (start >= end) return [];
1137
+ var intervals = [];
1138
+ var cursor = new Date(start);
1139
+ cursor.setHours(0, 0, 0, 0);
1140
+
1141
+ while (cursor <= end) {
1142
+ var shifts = getShiftsForDay(cursor, cal);
1143
+
1144
+ for (var _iterator = _createForOfIteratorHelperLoose(shifts), _step; !(_step = _iterator()).done;) {
1145
+ var shift = _step.value;
1146
+ var shiftStart = new Date(cursor);
1147
+ shiftStart.setHours(Math.floor(shift.start / 60), Math.floor(shift.start % 60), Math.round(shift.start % 1 * 60), 0);
1148
+ var shiftEnd = new Date(cursor);
1149
+ shiftEnd.setHours(Math.floor(shift.end / 60), Math.floor(shift.end % 60), Math.round(shift.end % 1 * 60), 0);
1150
+ var intervalStart = shiftStart < start ? start : shiftStart;
1151
+ var intervalEnd = shiftEnd > end ? end : shiftEnd;
1152
+
1153
+ if (intervalStart < intervalEnd) {
1154
+ intervals.push({
1155
+ start: intervalStart,
1156
+ end: intervalEnd
1157
+ });
1158
+ }
1159
+ }
1160
+
1161
+ cursor.setDate(cursor.getDate() + 1);
1162
+ }
1163
+
1164
+ return intervals;
1165
+ }
1166
+ function snapToWorkingTime(date, cal, direction) {
1167
+ var MAX_DAYS = 60;
1168
+ var result = new Date(date);
1169
+
1170
+ for (var attempt = 0; attempt < MAX_DAYS * 24 * 60; attempt++) {
1171
+ var dayStart = new Date(result);
1172
+ dayStart.setHours(0, 0, 0, 0);
1173
+ var shifts = getShiftsForDay(dayStart, cal);
1174
+
1175
+ if (shifts.length > 0) {
1176
+ if (direction === "forward") {
1177
+ var currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
1178
+
1179
+ for (var _iterator2 = _createForOfIteratorHelperLoose(shifts), _step2; !(_step2 = _iterator2()).done;) {
1180
+ var shift = _step2.value;
1181
+
1182
+ if (currentMins <= shift.end) {
1183
+ if (currentMins < shift.start) {
1184
+ result.setHours(Math.floor(shift.start / 60), Math.round(shift.start % 60), 0, 0);
1185
+ }
1186
+
1187
+ return result;
1188
+ }
1189
+ }
1190
+
1191
+ result.setDate(result.getDate() + 1);
1192
+ result.setHours(0, 0, 0, 0);
1193
+ } else {
1194
+ var _currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
1195
+
1196
+ for (var i = shifts.length - 1; i >= 0; i--) {
1197
+ if (_currentMins >= shifts[i].start) {
1198
+ if (_currentMins > shifts[i].end) {
1199
+ result.setHours(Math.floor(shifts[i].end / 60), Math.round(shifts[i].end % 60), 0, 0);
1200
+ }
1201
+
1202
+ return result;
1203
+ }
1204
+ }
1205
+
1206
+ result.setDate(result.getDate() - 1);
1207
+ result.setHours(23, 59, 59, 0);
1208
+ }
1209
+ } else {
1210
+ if (direction === "forward") {
1211
+ result.setDate(result.getDate() + 1);
1212
+ result.setHours(0, 0, 0, 0);
1213
+ } else {
1214
+ result.setDate(result.getDate() - 1);
1215
+ result.setHours(23, 59, 59, 0);
1216
+ }
1217
+ }
1218
+ }
1219
+
1220
+ return date;
1221
+ }
1222
+ function getQuarterNumber(date, quarterStart) {
1223
+ var month = date.getMonth();
1224
+ var offset = (month - quarterStart + 12) % 12;
1225
+ return Math.floor(offset / 3) + 1;
1226
+ }
1227
+
1228
+ var styles$5 = {"gridRow":"_2dZTy","gridRowLookAhead":"_2RRca","gridRowLine":"_3rUKi","gridTick":"_RuwuK","gridTickDashed":"_Zh9jh","darkerGridRow":"_2M-tt"};
1104
1229
 
1105
1230
  var GridBody = function GridBody(_ref) {
1231
+ var _projectCalendar$week;
1232
+
1106
1233
  var tasks = _ref.tasks,
1107
1234
  scheduleType = _ref.scheduleType,
1108
1235
  dates = _ref.dates,
@@ -1115,7 +1242,9 @@ var GridBody = function GridBody(_ref) {
1115
1242
  _ref$virtualItems = _ref.virtualItems,
1116
1243
  virtualItems = _ref$virtualItems === void 0 ? [] : _ref$virtualItems,
1117
1244
  visibleStartY = _ref.visibleStartY,
1118
- visibleEndY = _ref.visibleEndY;
1245
+ visibleEndY = _ref.visibleEndY,
1246
+ projectCalendar = _ref.projectCalendar,
1247
+ viewMode = _ref.viewMode;
1119
1248
  var visibleHeight = visibleEndY - visibleStartY;
1120
1249
  var now = new Date();
1121
1250
  var items = virtualItems.length > 0 ? virtualItems : tasks.map(function (_, i) {
@@ -1128,7 +1257,8 @@ var GridBody = function GridBody(_ref) {
1128
1257
  };
1129
1258
  });
1130
1259
 
1131
- var isWeekend = function isWeekend(date) {
1260
+ var isDayOff = function isDayOff(date) {
1261
+ if (projectCalendar) return isOffDay(date, projectCalendar);
1132
1262
  var d = date.getDay();
1133
1263
  return d === 0 || d === 6;
1134
1264
  };
@@ -1148,7 +1278,8 @@ var GridBody = function GridBody(_ref) {
1148
1278
  };
1149
1279
 
1150
1280
  var todayRects = [];
1151
- var weekendRects = [];
1281
+ var offDayRects = [];
1282
+ var weekStartDay = (_projectCalendar$week = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) != null ? _projectCalendar$week : 1;
1152
1283
 
1153
1284
  for (var i = 0, x = 0; i < dates.length; i++, x += columnWidth) {
1154
1285
  if (isTodayColumn(i)) {
@@ -1162,26 +1293,57 @@ var GridBody = function GridBody(_ref) {
1162
1293
  }));
1163
1294
  }
1164
1295
 
1165
- if (isWeekend(dates[i])) {
1166
- weekendRects.push(React__default.createElement("rect", {
1167
- key: "weekend-" + i,
1168
- x: x,
1169
- y: visibleStartY,
1170
- width: columnWidth,
1171
- height: visibleHeight,
1172
- fill: weekendColor
1173
- }));
1296
+ if (viewMode !== exports.ViewMode.Month && viewMode !== exports.ViewMode.Quarter) {
1297
+ var _dates;
1298
+
1299
+ var pEnd = (_dates = dates[i + 1]) != null ? _dates : addToDate(dates[i], 1, "day");
1300
+ var periodMs = pEnd.getTime() - dates[i].getTime();
1301
+
1302
+ if (periodMs > 0) {
1303
+ var cursor = new Date(dates[i]);
1304
+ cursor.setHours(0, 0, 0, 0);
1305
+
1306
+ while (cursor.getTime() < pEnd.getTime()) {
1307
+ if (isDayOff(cursor)) {
1308
+ var ds = cursor.getTime() - dates[i].getTime();
1309
+ var de = ds + 86400000;
1310
+ var startFrac = Math.max(0, ds) / periodMs;
1311
+ var endFrac = Math.min(periodMs, de) / periodMs;
1312
+ var rw = (endFrac - startFrac) * columnWidth;
1313
+
1314
+ if (rw > 0.5) {
1315
+ offDayRects.push(React__default.createElement("rect", {
1316
+ key: "offday-" + i + "-" + cursor.getTime(),
1317
+ x: x + startFrac * columnWidth,
1318
+ y: visibleStartY,
1319
+ width: rw,
1320
+ height: visibleHeight,
1321
+ fill: weekendColor
1322
+ }));
1323
+ }
1324
+ }
1325
+
1326
+ cursor.setDate(cursor.getDate() + 1);
1327
+ }
1328
+ }
1174
1329
  }
1175
1330
  }
1176
1331
 
1177
- var tickLines = dates.map(function (_, i) {
1332
+ var isDayView = viewMode === exports.ViewMode.Day;
1333
+ var tickLines = dates.map(function (date, i) {
1334
+ var tickClass = styles$5.gridTick;
1335
+
1336
+ if (isDayView) {
1337
+ tickClass = date.getDay() === weekStartDay ? styles$5.gridTick : styles$5.gridTickDashed;
1338
+ }
1339
+
1178
1340
  return React__default.createElement("line", {
1179
1341
  key: "tick-" + i,
1180
1342
  x1: i * columnWidth,
1181
1343
  y1: visibleStartY,
1182
1344
  x2: i * columnWidth,
1183
1345
  y2: visibleEndY,
1184
- className: styles$5.gridTick
1346
+ className: tickClass
1185
1347
  });
1186
1348
  });
1187
1349
  var rowBackgrounds = [];
@@ -1227,10 +1389,10 @@ var GridBody = function GridBody(_ref) {
1227
1389
  }, rowBackgrounds), React__default.createElement("g", {
1228
1390
  className: "rowLines"
1229
1391
  }, rowLines), React__default.createElement("g", {
1392
+ className: "offdays"
1393
+ }, offDayRects), React__default.createElement("g", {
1230
1394
  className: "ticks"
1231
- }, tickLines), scheduleType === "lookAhead" && React__default.createElement("g", {
1232
- className: "weekend"
1233
- }, weekendRects), React__default.createElement("g", {
1395
+ }, tickLines), React__default.createElement("g", {
1234
1396
  className: "today"
1235
1397
  }, todayRects));
1236
1398
  };
@@ -1241,7 +1403,7 @@ var Grid = function Grid(props) {
1241
1403
  }, React__default.createElement(GridBody, Object.assign({}, props)));
1242
1404
  };
1243
1405
 
1244
- var styles$6 = {"calendarBottomText":"_9w8d5","calendarTopTick":"_1rLuZ","calendarTopText":"_2q1Kt","calendarHeader":"_35nLX","textAnchorStart":"_2Shd-","textAnchorMiddle":"_2XXW4","textAnchorEnd":"_3GdnC"};
1406
+ var styles$6 = {"calendarBottomText":"_9w8d5","calendarTopTick":"_1rLuZ","calendarTickSolid":"_2X-yN","calendarTickDashed":"_2BaXZ","calendarOffDayHeader":"_24p-y","calendarTopText":"_2q1Kt","calendarHeader":"_35nLX","textAnchorStart":"_2Shd-","textAnchorMiddle":"_2XXW4","textAnchorEnd":"_3GdnC"};
1245
1407
 
1246
1408
  var TopPartOfCalendar = function TopPartOfCalendar(_ref) {
1247
1409
  var value = _ref.value,
@@ -1278,7 +1440,14 @@ var Calendar = function Calendar(_ref) {
1278
1440
  headerHeight = _ref.headerHeight,
1279
1441
  columnWidth = _ref.columnWidth,
1280
1442
  fontFamily = _ref.fontFamily,
1281
- fontSize = _ref.fontSize;
1443
+ fontSize = _ref.fontSize,
1444
+ projectCalendar = _ref.projectCalendar;
1445
+
1446
+ var shortMonth = function shortMonth(date) {
1447
+ return date.toLocaleString(locale, {
1448
+ month: "short"
1449
+ });
1450
+ };
1282
1451
 
1283
1452
  var getCalendarValuesForYear = function getCalendarValuesForYear() {
1284
1453
  var topValues = [];
@@ -1321,93 +1490,150 @@ var Calendar = function Calendar(_ref) {
1321
1490
  };
1322
1491
 
1323
1492
  var getCalendarValuesForQuarter = function getCalendarValuesForQuarter() {
1493
+ var _projectCalendar$quar;
1494
+
1324
1495
  var topValues = [];
1325
1496
  var bottomValues = [];
1326
- var topDefaultHeight = headerHeight * 0.5;
1497
+ var offDayRects = [];
1498
+ var quarterStart = (_projectCalendar$quar = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar : 0;
1499
+ var rowH = headerHeight / 3;
1327
1500
 
1328
1501
  for (var i = 0; i < dateSetup.dates.length; i++) {
1329
1502
  var date = dateSetup.dates[i];
1330
- var quarter = Math.floor(date.getMonth() / 3) + 1;
1331
- var bottomValue = "Q" + quarter;
1503
+ var qNum = getQuarterNumber(date, quarterStart);
1504
+
1505
+ for (var m = 0; m < 3; m++) {
1506
+ var monthDate = addToDate(date, m, "month");
1507
+ bottomValues.push(React__default.createElement("text", {
1508
+ key: "qmonth-" + i + "-" + m,
1509
+ y: headerHeight * 0.9,
1510
+ x: columnWidth * i + columnWidth * (m * 2 + 1) / 6,
1511
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
1512
+ }, shortMonth(monthDate)));
1513
+ }
1514
+
1332
1515
  bottomValues.push(React__default.createElement("text", {
1333
- key: bottomValue + "-" + date.getFullYear(),
1334
- y: headerHeight * 0.8,
1516
+ key: "qlabel-" + i,
1517
+ y: rowH * 1.6,
1335
1518
  x: columnWidth * i + columnWidth * 0.5,
1336
- className: styles$6.calendarBottomText
1337
- }, bottomValue));
1519
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
1520
+ }, "Qtr " + qNum));
1521
+ bottomValues.push(React__default.createElement("line", {
1522
+ key: "qsep-" + i,
1523
+ x1: columnWidth * i,
1524
+ y1: rowH,
1525
+ x2: columnWidth * i,
1526
+ y2: headerHeight,
1527
+ className: styles$6.calendarTopTick
1528
+ }));
1529
+
1530
+ if (i === 0) {
1531
+ bottomValues.push(React__default.createElement("line", {
1532
+ key: "qhsep1",
1533
+ x1: 0,
1534
+ y1: rowH,
1535
+ x2: columnWidth * dateSetup.dates.length,
1536
+ y2: rowH,
1537
+ className: styles$6.calendarTopTick
1538
+ }));
1539
+ bottomValues.push(React__default.createElement("line", {
1540
+ key: "qhsep2",
1541
+ x1: 0,
1542
+ y1: rowH * 2,
1543
+ x2: columnWidth * dateSetup.dates.length,
1544
+ y2: rowH * 2,
1545
+ className: styles$6.calendarTopTick
1546
+ }));
1547
+ }
1338
1548
 
1339
1549
  if (i === 0 || date.getFullYear() !== dateSetup.dates[i - 1].getFullYear()) {
1340
1550
  var topValue = date.getFullYear().toString();
1341
- var xText = void 0;
1551
+ var span = 0;
1342
1552
 
1343
- if (rtl) {
1344
- xText = (3 + i + quarter) * columnWidth;
1345
- } else {
1346
- xText = (3 + i - quarter) * columnWidth;
1553
+ for (var j = i; j < dateSetup.dates.length && dateSetup.dates[j].getFullYear() === date.getFullYear(); j++) {
1554
+ span++;
1347
1555
  }
1348
1556
 
1557
+ var xText = columnWidth * i + columnWidth * span / 2;
1349
1558
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1350
- key: topValue,
1559
+ key: topValue + i,
1351
1560
  value: topValue,
1352
1561
  x1Line: columnWidth * i,
1353
1562
  y1Line: 0,
1354
- y2Line: headerHeight,
1563
+ y2Line: rowH,
1355
1564
  xText: xText,
1356
- yText: topDefaultHeight * 0.9
1565
+ yText: rowH * 0.7,
1566
+ textAnchor: "middle"
1357
1567
  }));
1358
1568
  }
1359
1569
  }
1360
1570
 
1361
- return [topValues, bottomValues];
1571
+ return [topValues, bottomValues, offDayRects];
1362
1572
  };
1363
1573
 
1364
1574
  var getCalendarValuesForMonth = function getCalendarValuesForMonth() {
1575
+ var _projectCalendar$quar2;
1576
+
1365
1577
  var topValues = [];
1366
1578
  var bottomValues = [];
1579
+ var offDayRects = [];
1367
1580
  var topDefaultHeight = headerHeight * 0.5;
1581
+ var quarterStart = (_projectCalendar$quar2 = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar2 : 0;
1368
1582
 
1369
1583
  for (var i = 0; i < dateSetup.dates.length; i++) {
1370
1584
  var date = dateSetup.dates[i];
1371
- var bottomValue = date.toLocaleString(locale, {
1372
- month: "short"
1373
- });
1585
+ var bottomValue = shortMonth(date);
1374
1586
  bottomValues.push(React__default.createElement("text", {
1375
- key: bottomValue + date.getFullYear(),
1587
+ key: bottomValue + date.getFullYear() + i,
1376
1588
  y: headerHeight * 0.8,
1377
1589
  x: columnWidth * i + columnWidth * 0.5,
1378
- className: styles$6.calendarTopText + " " + styles$6.textAnchorEnd
1590
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
1379
1591
  }, bottomValue));
1592
+ var qNum = getQuarterNumber(date, quarterStart);
1593
+ var prevDate = i > 0 ? dateSetup.dates[i - 1] : null;
1594
+ var prevQNum = prevDate ? getQuarterNumber(prevDate, quarterStart) : -1;
1595
+ var isNewQuarter = i === 0 || qNum !== prevQNum || date.getFullYear() !== (prevDate ? prevDate.getFullYear() : -1);
1380
1596
 
1381
- if (i === 0 || date.getFullYear() !== dateSetup.dates[i - 1].getFullYear()) {
1382
- var topValue = date.getFullYear().toString();
1383
- var xText = void 0;
1597
+ if (isNewQuarter) {
1598
+ var topValue = "Qtr " + qNum + ", " + date.getFullYear();
1599
+ var span = 0;
1384
1600
 
1385
- if (rtl) {
1386
- xText = (6 + i + date.getMonth() + 1) * columnWidth;
1387
- } else {
1388
- xText = (6 + i - date.getMonth()) * columnWidth;
1601
+ for (var j = i; j < dateSetup.dates.length && getQuarterNumber(dateSetup.dates[j], quarterStart) === qNum && dateSetup.dates[j].getFullYear() === date.getFullYear(); j++) {
1602
+ span++;
1389
1603
  }
1390
1604
 
1391
- console.log(xText);
1605
+ var xText = rtl ? columnWidth * i + columnWidth * span * 0.5 + columnWidth : columnWidth * i + columnWidth * span / 2;
1392
1606
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1393
- key: topValue,
1607
+ key: topValue + i,
1394
1608
  value: topValue,
1395
1609
  x1Line: columnWidth * i,
1396
1610
  y1Line: 0,
1397
1611
  y2Line: topDefaultHeight,
1398
1612
  xText: xText,
1399
- yText: topDefaultHeight * 0.9,
1400
- textAnchor: "end"
1613
+ yText: topDefaultHeight * 0.7,
1614
+ textAnchor: "middle"
1401
1615
  }));
1616
+
1617
+ if (i > 0) {
1618
+ bottomValues.push(React__default.createElement("line", {
1619
+ key: "qbound-" + i,
1620
+ x1: columnWidth * i,
1621
+ y1: topDefaultHeight,
1622
+ x2: columnWidth * i,
1623
+ y2: headerHeight,
1624
+ className: styles$6.calendarTopTick
1625
+ }));
1626
+ }
1402
1627
  }
1403
1628
  }
1404
1629
 
1405
- return [topValues, bottomValues];
1630
+ return [topValues, bottomValues, offDayRects];
1406
1631
  };
1407
1632
 
1408
1633
  var getCalendarValuesForWeek = function getCalendarValuesForWeek() {
1409
1634
  var topValues = [];
1410
1635
  var bottomValues = [];
1636
+ var offDayRects = [];
1411
1637
  var weeksCount = 1;
1412
1638
  var topDefaultHeight = headerHeight * 0.5;
1413
1639
  var dates = dateSetup.dates;
@@ -1417,10 +1643,10 @@ var Calendar = function Calendar(_ref) {
1417
1643
  var topValue = "";
1418
1644
 
1419
1645
  if (i === 0 || date.getMonth() !== dates[i - 1].getMonth()) {
1420
- topValue = getLocaleMonth(date, locale) + ", " + date.getFullYear();
1646
+ topValue = shortMonth(date) + " " + date.getFullYear();
1421
1647
  }
1422
1648
 
1423
- var bottomValue = "W" + getWeekNumberISO8601(date);
1649
+ var bottomValue = date.getDate().toString();
1424
1650
  bottomValues.push(React__default.createElement("text", {
1425
1651
  key: date.getTime(),
1426
1652
  y: headerHeight * 0.8,
@@ -1431,7 +1657,7 @@ var Calendar = function Calendar(_ref) {
1431
1657
  if (topValue) {
1432
1658
  if (i !== dates.length - 1) {
1433
1659
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1434
- key: topValue,
1660
+ key: topValue + i,
1435
1661
  value: topValue,
1436
1662
  x1Line: columnWidth * i + weeksCount * columnWidth,
1437
1663
  y1Line: 0,
@@ -1448,18 +1674,32 @@ var Calendar = function Calendar(_ref) {
1448
1674
  weeksCount++;
1449
1675
  }
1450
1676
 
1451
- return [topValues, bottomValues];
1677
+ return [topValues, bottomValues, offDayRects];
1452
1678
  };
1453
1679
 
1454
1680
  var getCalendarValuesForDay = function getCalendarValuesForDay() {
1681
+ var _projectCalendar$week;
1682
+
1455
1683
  var topValues = [];
1456
1684
  var bottomValues = [];
1685
+ var offDayRects = [];
1686
+ var tickLines = [];
1457
1687
  var topDefaultHeight = headerHeight * 0.5;
1458
1688
  var dates = dateSetup.dates;
1689
+ var weekStartDay = (_projectCalendar$week = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) != null ? _projectCalendar$week : 1;
1459
1690
 
1460
1691
  for (var i = 0; i < dates.length; i++) {
1461
1692
  var date = dates[i];
1462
- var bottomValue = columnWidth > 55 ? getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate().toString() : getLocalDayOfWeek(date, locale, "narrow") + "," + date.getDate().toString();
1693
+ var isWeekStart = date.getDay() === weekStartDay;
1694
+ tickLines.push(React__default.createElement("line", {
1695
+ key: "tick-day-" + i,
1696
+ x1: columnWidth * i,
1697
+ y1: topDefaultHeight,
1698
+ x2: columnWidth * i,
1699
+ y2: headerHeight,
1700
+ className: isWeekStart ? styles$6.calendarTickSolid : styles$6.calendarTickDashed
1701
+ }));
1702
+ var bottomValue = columnWidth > 55 ? getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate() : getLocalDayOfWeek(date, locale, "narrow") + "," + date.getDate();
1463
1703
  bottomValues.push(React__default.createElement("text", {
1464
1704
  key: date.getTime(),
1465
1705
  y: headerHeight * 0.8,
@@ -1468,9 +1708,9 @@ var Calendar = function Calendar(_ref) {
1468
1708
  }, bottomValue));
1469
1709
 
1470
1710
  if (i + 1 !== dates.length && date.getMonth() !== dates[i + 1].getMonth()) {
1471
- var topValue = getLocaleMonth(date, locale) + " " + date.getFullYear();
1711
+ var topValue = shortMonth(date) + " " + date.getFullYear();
1472
1712
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1473
- key: topValue + date.getFullYear(),
1713
+ key: topValue + i,
1474
1714
  value: topValue,
1475
1715
  x1Line: columnWidth * (i + 1),
1476
1716
  y1Line: 0,
@@ -1481,10 +1721,10 @@ var Calendar = function Calendar(_ref) {
1481
1721
  }
1482
1722
 
1483
1723
  if (i + 1 === dates.length) {
1484
- var _topValue = getLocaleMonth(date, locale) + " " + date.getFullYear();
1724
+ var _topValue = shortMonth(date) + " " + date.getFullYear();
1485
1725
 
1486
1726
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1487
- key: _topValue + date.getFullYear(),
1727
+ key: _topValue + "last",
1488
1728
  value: _topValue,
1489
1729
  x1Line: columnWidth * (i + 1),
1490
1730
  y1Line: 0,
@@ -1495,7 +1735,7 @@ var Calendar = function Calendar(_ref) {
1495
1735
  }
1496
1736
  }
1497
1737
 
1498
- return [topValues, bottomValues];
1738
+ return [topValues, bottomValues, offDayRects, tickLines];
1499
1739
  };
1500
1740
 
1501
1741
  var getCalendarValuesForPartOfDay = function getCalendarValuesForPartOfDay() {
@@ -1519,7 +1759,7 @@ var Calendar = function Calendar(_ref) {
1519
1759
  }, bottomValue));
1520
1760
 
1521
1761
  if (i === 0 || date.getDate() !== dates[i - 1].getDate()) {
1522
- var topValue = getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate() + " " + getLocaleMonth(date, locale);
1762
+ var topValue = getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate() + " " + shortMonth(date);
1523
1763
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1524
1764
  key: topValue + date.getFullYear(),
1525
1765
  value: topValue,
@@ -1556,7 +1796,7 @@ var Calendar = function Calendar(_ref) {
1556
1796
 
1557
1797
  if (i !== 0 && date.getDate() !== dates[i - 1].getDate()) {
1558
1798
  var displayDate = dates[i - 1];
1559
- var topValue = getLocalDayOfWeek(displayDate, locale, "long") + ", " + displayDate.getDate() + " " + getLocaleMonth(displayDate, locale);
1799
+ var topValue = getLocalDayOfWeek(displayDate, locale, "long") + ", " + displayDate.getDate() + " " + shortMonth(displayDate);
1560
1800
  var topPosition = (date.getHours() - 24) / 2;
1561
1801
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1562
1802
  key: topValue + displayDate.getFullYear(),
@@ -1575,6 +1815,8 @@ var Calendar = function Calendar(_ref) {
1575
1815
 
1576
1816
  var topValues = [];
1577
1817
  var bottomValues = [];
1818
+ var extraValues = [];
1819
+ var tickLines = [];
1578
1820
 
1579
1821
  switch (dateSetup.viewMode) {
1580
1822
  case exports.ViewMode.Year:
@@ -1585,46 +1827,57 @@ var Calendar = function Calendar(_ref) {
1585
1827
  break;
1586
1828
 
1587
1829
  case exports.ViewMode.Quarter:
1588
- var _getCalendarValuesFor2 = getCalendarValuesForQuarter();
1589
-
1590
- topValues = _getCalendarValuesFor2[0];
1591
- bottomValues = _getCalendarValuesFor2[1];
1592
- break;
1830
+ {
1831
+ var r = getCalendarValuesForQuarter();
1832
+ topValues = r[0];
1833
+ bottomValues = r[1];
1834
+ extraValues = r[2] || [];
1835
+ break;
1836
+ }
1593
1837
 
1594
1838
  case exports.ViewMode.Month:
1595
- var _getCalendarValuesFor3 = getCalendarValuesForMonth();
1839
+ {
1840
+ var _r = getCalendarValuesForMonth();
1596
1841
 
1597
- topValues = _getCalendarValuesFor3[0];
1598
- bottomValues = _getCalendarValuesFor3[1];
1599
- break;
1842
+ topValues = _r[0];
1843
+ bottomValues = _r[1];
1844
+ extraValues = _r[2] || [];
1845
+ break;
1846
+ }
1600
1847
 
1601
1848
  case exports.ViewMode.Week:
1602
- var _getCalendarValuesFor4 = getCalendarValuesForWeek();
1849
+ {
1850
+ var _r2 = getCalendarValuesForWeek();
1603
1851
 
1604
- topValues = _getCalendarValuesFor4[0];
1605
- bottomValues = _getCalendarValuesFor4[1];
1606
- break;
1852
+ topValues = _r2[0];
1853
+ bottomValues = _r2[1];
1854
+ extraValues = _r2[2] || [];
1855
+ break;
1856
+ }
1607
1857
 
1608
1858
  case exports.ViewMode.Day:
1609
- var _getCalendarValuesFor5 = getCalendarValuesForDay();
1610
-
1611
- topValues = _getCalendarValuesFor5[0];
1612
- bottomValues = _getCalendarValuesFor5[1];
1613
- break;
1859
+ {
1860
+ var result = getCalendarValuesForDay();
1861
+ topValues = result[0];
1862
+ bottomValues = result[1];
1863
+ extraValues = result[2];
1864
+ tickLines = result[3];
1865
+ break;
1866
+ }
1614
1867
 
1615
1868
  case exports.ViewMode.QuarterDay:
1616
1869
  case exports.ViewMode.HalfDay:
1617
- var _getCalendarValuesFor6 = getCalendarValuesForPartOfDay();
1870
+ var _getCalendarValuesFor2 = getCalendarValuesForPartOfDay();
1618
1871
 
1619
- topValues = _getCalendarValuesFor6[0];
1620
- bottomValues = _getCalendarValuesFor6[1];
1872
+ topValues = _getCalendarValuesFor2[0];
1873
+ bottomValues = _getCalendarValuesFor2[1];
1621
1874
  break;
1622
1875
 
1623
1876
  case exports.ViewMode.Hour:
1624
- var _getCalendarValuesFor7 = getCalendarValuesForHour();
1877
+ var _getCalendarValuesFor3 = getCalendarValuesForHour();
1625
1878
 
1626
- topValues = _getCalendarValuesFor7[0];
1627
- bottomValues = _getCalendarValuesFor7[1];
1879
+ topValues = _getCalendarValuesFor3[0];
1880
+ bottomValues = _getCalendarValuesFor3[1];
1628
1881
  }
1629
1882
 
1630
1883
  return React__default.createElement("g", {
@@ -1638,7 +1891,7 @@ var Calendar = function Calendar(_ref) {
1638
1891
  width: columnWidth * dateSetup.dates.length,
1639
1892
  height: headerHeight,
1640
1893
  className: styles$6.calendarHeader
1641
- }), bottomValues, " ", topValues);
1894
+ }), extraValues, tickLines, bottomValues, topValues);
1642
1895
  };
1643
1896
 
1644
1897
  // A type of promise-like that resolves synchronously and supports only one observer
@@ -1692,19 +1945,31 @@ var drawPathAndTriangle = function drawPathAndTriangle(taskFrom, taskTo, rowHeig
1692
1945
  var verticalOffset = indexCompare * (rowHeight / 2);
1693
1946
 
1694
1947
  var minX = function minX(t) {
1695
- if (t.x1 && t.actualx1) {
1696
- return Math.min(t.x1, t.actualx1);
1697
- } else if (t.x1) {
1698
- return t.x1;
1699
- } else if (t.actualx1) {
1700
- return t.actualx1;
1701
- } else {
1702
- return 0;
1948
+ if (t.plannedSegments && t.plannedSegments.length > 0) {
1949
+ var p = t.plannedSegments[0].x1;
1950
+ if (t.actualSegments && t.actualSegments.length > 0) return Math.min(p, t.actualSegments[0].x1);
1951
+ return p;
1703
1952
  }
1953
+
1954
+ if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[0].x1;
1955
+ var candidates = [];
1956
+ if (t.x1 !== undefined && t.x1 >= 0) candidates.push(t.x1);
1957
+ if (t.actualx1 !== undefined && t.actualx1 >= 0) candidates.push(t.actualx1);
1958
+ return candidates.length > 0 ? Math.min.apply(Math, candidates) : 0;
1704
1959
  };
1705
1960
 
1706
1961
  var maxX = function maxX(t) {
1707
- return Math.max(t.x2 || 0, t.actualx2 || 0);
1962
+ if (t.plannedSegments && t.plannedSegments.length > 0) {
1963
+ var p = t.plannedSegments[t.plannedSegments.length - 1].x2;
1964
+ if (t.actualSegments && t.actualSegments.length > 0) return Math.max(p, t.actualSegments[t.actualSegments.length - 1].x2);
1965
+ return p;
1966
+ }
1967
+
1968
+ if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[t.actualSegments.length - 1].x2;
1969
+ var candidates = [];
1970
+ if (t.x2 !== undefined && t.x2 >= 0) candidates.push(t.x2);
1971
+ if (t.actualx2 !== undefined && t.actualx2 >= 0) candidates.push(t.actualx2);
1972
+ return candidates.length > 0 ? Math.max.apply(Math, candidates) : 0;
1708
1973
  };
1709
1974
 
1710
1975
  var fromPoint, toPoint;
@@ -1831,10 +2096,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1831
2096
  actualx1 = task.actualStart ? taskXCoordinateRTL(task.actualStart, dates, columnWidth) : -1;
1832
2097
  actualx2 = task.actualEnd ? taskXCoordinateRTL(task.actualEnd, dates, columnWidth) : -1;
1833
2098
  } else {
1834
- x1 = task.start ? taskXCoordinate(task.start, dates, columnWidth) : -1;
1835
- x2 = task.end ? taskXCoordinate(task.end, dates, columnWidth) : -1;
1836
- actualx1 = task.actualStart ? taskXCoordinate(task.actualStart, dates, columnWidth) : -1;
1837
- actualx2 = task.actualEnd ? taskXCoordinate(task.actualEnd, dates, columnWidth) : -1;
2099
+ x1 = task.start ? taskXCoordinate(startOfDate(task.start, "day"), dates, columnWidth) : -1;
2100
+ x2 = task.end ? taskXCoordinate(addToDate(startOfDate(task.end, "day"), 1, "day"), dates, columnWidth) : -1;
2101
+ actualx1 = task.actualStart ? taskXCoordinate(startOfDate(task.actualStart, "day"), dates, columnWidth) : -1;
2102
+ actualx2 = task.actualEnd ? taskXCoordinate(addToDate(startOfDate(task.actualEnd, "day"), 1, "day"), dates, columnWidth) : -1;
1838
2103
  }
1839
2104
 
1840
2105
  progressStartWidth = actualx1 && x1 ? Math.abs(actualx1 - x1) : -1;
@@ -1847,6 +2112,39 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1847
2112
 
1848
2113
  var y = taskYCoordinate(index, rowHeight, taskHeight);
1849
2114
  var hideChildren = task.hideChildren || false;
2115
+ var plannedSegments;
2116
+ var actualSegments;
2117
+
2118
+ if (task.calender && task.start && task.end && task.start.getTime() > 0) {
2119
+ var planEnd = addToDate(startOfDate(task.end, "day"), 1, "day");
2120
+ var intervals = getWorkingIntervals(task.start, planEnd, task.calender);
2121
+ var segs = intervals.map(function (iv) {
2122
+ return {
2123
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
2124
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
2125
+ };
2126
+ }).filter(function (s) {
2127
+ return s.x2 > s.x1;
2128
+ });
2129
+ if (segs.length > 0) plannedSegments = segs;
2130
+ }
2131
+
2132
+ if (task.calender && task.actualStart && task.actualEnd && task.actualStart.getTime() > 0) {
2133
+ var actEnd = addToDate(startOfDate(task.actualEnd, "day"), 1, "day");
2134
+
2135
+ var _intervals = getWorkingIntervals(task.actualStart, actEnd, task.calender);
2136
+
2137
+ var _segs = _intervals.map(function (iv) {
2138
+ return {
2139
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
2140
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
2141
+ };
2142
+ }).filter(function (s) {
2143
+ return s.x2 > s.x1;
2144
+ });
2145
+
2146
+ if (_segs.length > 0) actualSegments = _segs;
2147
+ }
1850
2148
 
1851
2149
  var styles = _extends({
1852
2150
  backgroundColor: barBackgroundColor,
@@ -1872,7 +2170,9 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1872
2170
  hideChildren: hideChildren,
1873
2171
  height: taskHeight,
1874
2172
  barChildren: [],
1875
- styles: styles
2173
+ styles: styles,
2174
+ plannedSegments: plannedSegments,
2175
+ actualSegments: actualSegments
1876
2176
  });
1877
2177
  };
1878
2178
 
@@ -2238,6 +2538,7 @@ var BarDisplay = function BarDisplay(_ref) {
2238
2538
  progressWidth = _ref.progressWidth,
2239
2539
  barCornerRadius = _ref.barCornerRadius,
2240
2540
  styles = _ref.styles,
2541
+ segments = _ref.segments,
2241
2542
  onMouseDown = _ref.onMouseDown;
2242
2543
 
2243
2544
  var getProcessColor = function getProcessColor() {
@@ -2248,45 +2549,121 @@ var BarDisplay = function BarDisplay(_ref) {
2248
2549
  return isSelected ? styles.backgroundSelectedColor : styles.backgroundColor;
2249
2550
  };
2250
2551
 
2251
- if (type == "planned") return React__default.createElement("g", {
2252
- onMouseDown: onMouseDown
2253
- }, React__default.createElement("rect", {
2254
- x: x,
2255
- width: width,
2256
- y: y,
2257
- height: height,
2258
- ry: barCornerRadius,
2259
- rx: barCornerRadius,
2260
- fill: getBarColor(),
2261
- strokeWidth: 2,
2262
- stroke: styles.criticalPathColor
2263
- }), React__default.createElement("rect", {
2264
- x: progressX,
2265
- width: progressWidth,
2266
- y: y,
2267
- height: height,
2268
- ry: barCornerRadius,
2269
- rx: barCornerRadius,
2270
- fill: getProcessColor()
2271
- }));else return React__default.createElement("g", {
2272
- onMouseDown: onMouseDown
2273
- }, React__default.createElement("rect", {
2274
- x: x,
2275
- width: width,
2276
- y: y,
2277
- height: height,
2278
- ry: barCornerRadius,
2279
- rx: barCornerRadius,
2280
- fill: styles.taskProgressColor
2281
- }), React__default.createElement("rect", {
2282
- x: progressX,
2283
- width: progressWidth,
2284
- y: y,
2285
- height: height,
2286
- ry: barCornerRadius,
2287
- rx: barCornerRadius,
2288
- fill: getProcessColor()
2289
- }));
2552
+ if (type === "planned") {
2553
+ if (segments && segments.length > 0) {
2554
+ var totalWidth = width;
2555
+ return React__default.createElement("g", {
2556
+ onMouseDown: onMouseDown
2557
+ }, segments.map(function (seg, idx) {
2558
+ return React__default.createElement("rect", {
2559
+ key: "seg-" + idx,
2560
+ x: seg.x1,
2561
+ width: seg.x2 - seg.x1,
2562
+ y: y,
2563
+ height: height,
2564
+ ry: barCornerRadius,
2565
+ rx: barCornerRadius,
2566
+ fill: getBarColor(),
2567
+ strokeWidth: 2,
2568
+ stroke: styles.criticalPathColor
2569
+ });
2570
+ }), progressWidth > 0 && function () {
2571
+ var rects = [];
2572
+ var remaining = progressWidth;
2573
+
2574
+ for (var _iterator = _createForOfIteratorHelperLoose(segments), _step; !(_step = _iterator()).done;) {
2575
+ var seg = _step.value;
2576
+ if (remaining <= 0) break;
2577
+ var segW = seg.x2 - seg.x1;
2578
+ var ratio = totalWidth > 0 ? segW / totalWidth : 0;
2579
+ var pw = Math.min(remaining, progressWidth * ratio);
2580
+
2581
+ if (pw > 0) {
2582
+ rects.push(React__default.createElement("rect", {
2583
+ key: "prog-" + seg.x1,
2584
+ x: seg.x1,
2585
+ width: pw,
2586
+ y: y,
2587
+ height: height,
2588
+ ry: barCornerRadius,
2589
+ rx: barCornerRadius,
2590
+ fill: getProcessColor()
2591
+ }));
2592
+ remaining -= pw;
2593
+ }
2594
+ }
2595
+
2596
+ return rects;
2597
+ }());
2598
+ }
2599
+
2600
+ return React__default.createElement("g", {
2601
+ onMouseDown: onMouseDown
2602
+ }, React__default.createElement("rect", {
2603
+ x: x,
2604
+ width: width,
2605
+ y: y,
2606
+ height: height,
2607
+ ry: barCornerRadius,
2608
+ rx: barCornerRadius,
2609
+ fill: getBarColor(),
2610
+ strokeWidth: 2,
2611
+ stroke: styles.criticalPathColor
2612
+ }), React__default.createElement("rect", {
2613
+ x: progressX,
2614
+ width: progressWidth,
2615
+ y: y,
2616
+ height: height,
2617
+ ry: barCornerRadius,
2618
+ rx: barCornerRadius,
2619
+ fill: getProcessColor()
2620
+ }));
2621
+ } else {
2622
+ if (segments && segments.length > 0) {
2623
+ return React__default.createElement("g", {
2624
+ onMouseDown: onMouseDown
2625
+ }, segments.map(function (seg, idx) {
2626
+ return React__default.createElement("rect", {
2627
+ key: "aseg-" + idx,
2628
+ x: seg.x1,
2629
+ width: seg.x2 - seg.x1,
2630
+ y: y,
2631
+ height: height,
2632
+ ry: barCornerRadius,
2633
+ rx: barCornerRadius,
2634
+ fill: styles.taskProgressColor
2635
+ });
2636
+ }), React__default.createElement("rect", {
2637
+ x: progressX,
2638
+ width: progressWidth,
2639
+ y: y,
2640
+ height: height,
2641
+ ry: barCornerRadius,
2642
+ rx: barCornerRadius,
2643
+ fill: getProcessColor()
2644
+ }));
2645
+ }
2646
+
2647
+ return React__default.createElement("g", {
2648
+ onMouseDown: onMouseDown
2649
+ }, React__default.createElement("rect", {
2650
+ x: x,
2651
+ width: width,
2652
+ y: y,
2653
+ height: height,
2654
+ ry: barCornerRadius,
2655
+ rx: barCornerRadius,
2656
+ fill: styles.taskProgressColor
2657
+ }), React__default.createElement("rect", {
2658
+ x: progressX,
2659
+ width: progressWidth,
2660
+ y: y,
2661
+ height: height,
2662
+ ry: barCornerRadius,
2663
+ rx: barCornerRadius,
2664
+ fill: getProcessColor()
2665
+ }));
2666
+ }
2290
2667
  };
2291
2668
 
2292
2669
  var styles$7 = {"barWrapper":"_KxSXS","barHandle":"_3w_5u","barBackground":"_31ERP"};
@@ -2326,12 +2703,24 @@ var Bar = function Bar(_ref) {
2326
2703
  isSelected = _ref.isSelected;
2327
2704
  var progressPoint = getProgressPoint(+!rtl * task.progressWidth + task.progressX, task.y, task.height);
2328
2705
  var handleHeight = task.height / 2 - 1;
2706
+ var plannedSegs = task.plannedSegments;
2707
+ var plannedLeftHandleX = plannedSegs !== null && plannedSegs !== void 0 && plannedSegs.length ? plannedSegs[0].x1 : task.x1;
2708
+ var plannedRightHandleX = plannedSegs !== null && plannedSegs !== void 0 && plannedSegs.length ? plannedSegs[plannedSegs.length - 1].x2 : task.x2;
2709
+ var actualSegs = task.actualSegments;
2710
+ var actualLeftHandleX = actualSegs !== null && actualSegs !== void 0 && actualSegs.length ? actualSegs[0].x1 : task.actualx1;
2711
+ var actualRightHandleX = actualSegs !== null && actualSegs !== void 0 && actualSegs.length ? actualSegs[actualSegs.length - 1].x2 : task.actualx2;
2329
2712
 
2330
2713
  if (type == "planned") {
2331
2714
  if ((task === null || task === void 0 ? void 0 : task.x1) >= 0 && (task === null || task === void 0 ? void 0 : task.x2) >= 0 && task.x2 - task.x1 >= 0) return React__default.createElement("g", {
2332
2715
  className: styles$7.barWrapper,
2333
2716
  tabIndex: 0
2334
- }, React__default.createElement(BarDisplay, {
2717
+ }, React__default.createElement("rect", {
2718
+ x: task.x1,
2719
+ y: task.y,
2720
+ width: task.x2 - task.x1,
2721
+ height: task.height / 2,
2722
+ fill: "transparent"
2723
+ }), React__default.createElement(BarDisplay, {
2335
2724
  x: task.x1,
2336
2725
  y: task.y,
2337
2726
  type: type,
@@ -2344,13 +2733,14 @@ var Bar = function Bar(_ref) {
2344
2733
  barCornerRadius: task.barCornerRadius,
2345
2734
  styles: task.styles,
2346
2735
  isSelected: isSelected,
2736
+ segments: task.plannedSegments,
2347
2737
  onMouseDown: function onMouseDown(e) {
2348
2738
  isDateChangeable && onEventStart("move", task, e, "planned");
2349
2739
  }
2350
2740
  }), React__default.createElement("g", {
2351
2741
  className: "handleGroup"
2352
2742
  }, isDateChangeable && React__default.createElement("g", null, React__default.createElement(BarDateHandle, {
2353
- x: task.x1 + 1,
2743
+ x: plannedLeftHandleX + 1,
2354
2744
  y: task.y + 1,
2355
2745
  width: task.handleWidth,
2356
2746
  height: handleHeight,
@@ -2359,7 +2749,7 @@ var Bar = function Bar(_ref) {
2359
2749
  onEventStart("start", task, e, "planned");
2360
2750
  }
2361
2751
  }), React__default.createElement(BarDateHandle, {
2362
- x: task.x2 - task.handleWidth - 1,
2752
+ x: plannedRightHandleX - task.handleWidth - 1,
2363
2753
  y: task.y + 1,
2364
2754
  width: task.handleWidth,
2365
2755
  height: handleHeight,
@@ -2380,7 +2770,13 @@ var Bar = function Bar(_ref) {
2380
2770
  return React__default.createElement("g", {
2381
2771
  className: styles$7.barWrapper,
2382
2772
  tabIndex: 0
2383
- }, React__default.createElement(BarDisplay, {
2773
+ }, React__default.createElement("rect", {
2774
+ x: task.actualx1,
2775
+ y: task.y + task.height / 2,
2776
+ width: task.actualx2 - task.actualx1,
2777
+ height: task.height / 2,
2778
+ fill: "transparent"
2779
+ }), React__default.createElement(BarDisplay, {
2384
2780
  x: task.actualx1,
2385
2781
  y: task.y + task.height / 2,
2386
2782
  type: type,
@@ -2393,13 +2789,14 @@ var Bar = function Bar(_ref) {
2393
2789
  barCornerRadius: task.barCornerRadius,
2394
2790
  styles: task.styles,
2395
2791
  isSelected: isSelected,
2792
+ segments: task.actualSegments,
2396
2793
  onMouseDown: function onMouseDown(e) {
2397
2794
  isDateChangeable && onEventStart("move", task, e, "actual");
2398
2795
  }
2399
2796
  }), React__default.createElement("g", {
2400
2797
  className: "handleGroup"
2401
2798
  }, isDateChangeable && React__default.createElement("g", null, React__default.createElement(BarDateHandle, {
2402
- x: task.actualx1 + 1,
2799
+ x: actualLeftHandleX + 1,
2403
2800
  y: task.y + task.height / 2 + 1,
2404
2801
  width: task.handleWidth,
2405
2802
  height: handleHeight,
@@ -2408,7 +2805,7 @@ var Bar = function Bar(_ref) {
2408
2805
  onEventStart("start", task, e, "actual");
2409
2806
  }
2410
2807
  }), React__default.createElement(BarDateHandle, {
2411
- x: task.actualx2 - task.handleWidth - 1,
2808
+ x: actualRightHandleX - task.handleWidth - 1,
2412
2809
  y: task.y + task.height / 2 + 1,
2413
2810
  width: task.handleWidth,
2414
2811
  height: handleHeight,
@@ -2670,11 +3067,14 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2670
3067
  setGanttEvent = _ref.setGanttEvent,
2671
3068
  setFailedTask = _ref.setFailedTask,
2672
3069
  setSelectedTask = _ref.setSelectedTask,
3070
+ onBarTasksUpdate = _ref.onBarTasksUpdate,
2673
3071
  onDateChange = _ref.onDateChange,
2674
3072
  onProgressChange = _ref.onProgressChange,
2675
3073
  onDoubleClick = _ref.onDoubleClick,
2676
3074
  onClick = _ref.onClick,
2677
3075
  onDelete = _ref.onDelete,
3076
+ onCalendarError = _ref.onCalendarError,
3077
+ projectCalendar = _ref.projectCalendar,
2678
3078
  visibleStartY = _ref.visibleStartY,
2679
3079
  visibleEndY = _ref.visibleEndY;
2680
3080
  var point = svg === null || svg === void 0 ? void 0 : (_svg$current = svg.current) === null || _svg$current === void 0 ? void 0 : _svg$current.createSVGPoint();
@@ -2711,9 +3111,98 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2711
3111
  changedTask = _handleTaskBySVGMouse.changedTask;
2712
3112
 
2713
3113
  if (isChanged) {
3114
+ var finalTask = _extends({}, changedTask);
3115
+
3116
+ var dragType = ganttEvent.type;
3117
+
3118
+ if (changedTask.calender && (ganttEvent.action === "end" || ganttEvent.action === "start" || ganttEvent.action === "move")) {
3119
+ var cal = finalTask.calender;
3120
+
3121
+ if (dragType === "actual") {
3122
+ if (ganttEvent.action === "end") {
3123
+ var snapped = snapToWorkingTime(finalTask.actualEnd, cal, "forward");
3124
+ finalTask.actualEnd = snapped;
3125
+ finalTask.actualx2 = taskXCoordinate(snapped, dates, columnWidth);
3126
+ } else if (ganttEvent.action === "start") {
3127
+ var _snapped = snapToWorkingTime(finalTask.actualStart, cal, "forward");
3128
+
3129
+ finalTask.actualStart = _snapped;
3130
+ finalTask.actualx1 = taskXCoordinate(_snapped, dates, columnWidth);
3131
+ } else {
3132
+ var _snapped2 = snapToWorkingTime(finalTask.actualStart, cal, "forward");
3133
+
3134
+ var delta = _snapped2.getTime() - finalTask.actualStart.getTime();
3135
+ finalTask.actualStart = _snapped2;
3136
+ finalTask.actualEnd = new Date(finalTask.actualEnd.getTime() + delta);
3137
+ finalTask.actualx1 = taskXCoordinate(finalTask.actualStart, dates, columnWidth);
3138
+ finalTask.actualx2 = taskXCoordinate(finalTask.actualEnd, dates, columnWidth);
3139
+ }
3140
+
3141
+ var actEnd = addToDate(startOfDate(finalTask.actualEnd, "day"), 1, "day");
3142
+ var actIntervals = getWorkingIntervals(finalTask.actualStart, actEnd, cal);
3143
+ var actSegs = actIntervals.map(function (iv) {
3144
+ return {
3145
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
3146
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
3147
+ };
3148
+ }).filter(function (s) {
3149
+ return s.x2 > s.x1;
3150
+ });
3151
+ finalTask.actualSegments = actSegs.length > 0 ? actSegs : undefined;
3152
+ var actDays = Math.max(1, Math.round((finalTask.actualEnd.getTime() - finalTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3153
+ finalTask.actualDuration = actDays;
3154
+ } else {
3155
+ if (ganttEvent.action === "end") {
3156
+ var _snapped3 = snapToWorkingTime(finalTask.end, cal, "forward");
3157
+
3158
+ finalTask.end = _snapped3;
3159
+ finalTask.x2 = taskXCoordinate(_snapped3, dates, columnWidth);
3160
+ } else if (ganttEvent.action === "start") {
3161
+ var _snapped4 = snapToWorkingTime(finalTask.start, cal, "forward");
3162
+
3163
+ finalTask.start = _snapped4;
3164
+ finalTask.x1 = taskXCoordinate(_snapped4, dates, columnWidth);
3165
+ } else {
3166
+ var _snapped5 = snapToWorkingTime(finalTask.start, cal, "forward");
3167
+
3168
+ var _delta = _snapped5.getTime() - finalTask.start.getTime();
3169
+
3170
+ finalTask.start = _snapped5;
3171
+ finalTask.end = new Date(finalTask.end.getTime() + _delta);
3172
+ finalTask.x1 = taskXCoordinate(finalTask.start, dates, columnWidth);
3173
+ finalTask.x2 = taskXCoordinate(finalTask.end, dates, columnWidth);
3174
+ }
3175
+
3176
+ var planEnd = addToDate(startOfDate(finalTask.end, "day"), 1, "day");
3177
+ var planIntervals = getWorkingIntervals(finalTask.start, planEnd, cal);
3178
+ var planSegs = planIntervals.map(function (iv) {
3179
+ return {
3180
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
3181
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
3182
+ };
3183
+ }).filter(function (s) {
3184
+ return s.x2 > s.x1;
3185
+ });
3186
+ finalTask.plannedSegments = planSegs.length > 0 ? planSegs : undefined;
3187
+ var planDays = Math.max(1, Math.round((finalTask.end.getTime() - finalTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3188
+ finalTask.plannedDuration = planDays;
3189
+ }
3190
+ } else {
3191
+ if (dragType === "actual") {
3192
+ var _actDays = Math.max(1, Math.round((finalTask.actualEnd.getTime() - finalTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3193
+
3194
+ finalTask.actualDuration = _actDays;
3195
+ } else {
3196
+ var _planDays = Math.max(1, Math.round((finalTask.end.getTime() - finalTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3197
+
3198
+ finalTask.plannedDuration = _planDays;
3199
+ }
3200
+ }
3201
+
2714
3202
  setGanttEvent({
2715
3203
  action: ganttEvent.action,
2716
- changedTask: changedTask
3204
+ changedTask: finalTask,
3205
+ type: dragType
2717
3206
  });
2718
3207
  }
2719
3208
 
@@ -2746,8 +3235,123 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2746
3235
  newChangedTask = _handleTaskBySVGMouse2.changedTask;
2747
3236
 
2748
3237
  var isNotLikeOriginal = originalSelectedTask.start !== newChangedTask.start || originalSelectedTask.end !== newChangedTask.end || originalSelectedTask.actualStart !== newChangedTask.actualStart || originalSelectedTask.actualEnd !== newChangedTask.actualEnd || originalSelectedTask.progress !== newChangedTask.progress;
3238
+ var dropType = type;
3239
+
3240
+ if (newChangedTask.calender && (action === "move" || action === "end" || action === "start")) {
3241
+ var cal = newChangedTask.calender;
3242
+
3243
+ if (dropType === "actual") {
3244
+ if (action === "end") {
3245
+ var snappedEnd = snapToWorkingTime(newChangedTask.actualEnd, cal, "forward");
3246
+ newChangedTask.actualEnd = snappedEnd;
3247
+ newChangedTask.actualx2 = taskXCoordinate(snappedEnd, dates, columnWidth);
3248
+ } else if (action === "start") {
3249
+ var snappedStart = snapToWorkingTime(newChangedTask.actualStart, cal, "forward");
3250
+
3251
+ if (snappedStart >= newChangedTask.actualEnd) {
3252
+ setFailedTask(originalSelectedTask);
3253
+ onCalendarError === null || onCalendarError === void 0 ? void 0 : onCalendarError(newChangedTask, "No working time in selected range");
3254
+ setGanttEvent({
3255
+ action: ""
3256
+ });
3257
+ setIsMoving(false);
3258
+ svg.current.removeEventListener("mousemove", handleMouseMove);
3259
+ svg.current.removeEventListener("mouseup", handleMouseUp);
3260
+ return Promise.resolve();
3261
+ }
3262
+
3263
+ newChangedTask.actualStart = snappedStart;
3264
+ newChangedTask.actualx1 = taskXCoordinate(snappedStart, dates, columnWidth);
3265
+ } else {
3266
+ var _snappedStart = snapToWorkingTime(newChangedTask.actualStart, cal, "forward");
3267
+
3268
+ var delta = _snappedStart.getTime() - newChangedTask.actualStart.getTime();
3269
+ newChangedTask.actualStart = _snappedStart;
3270
+ newChangedTask.actualEnd = new Date(newChangedTask.actualEnd.getTime() + delta);
3271
+ newChangedTask.actualx1 = taskXCoordinate(_snappedStart, dates, columnWidth);
3272
+ newChangedTask.actualx2 = taskXCoordinate(newChangedTask.actualEnd, dates, columnWidth);
3273
+ }
3274
+
3275
+ var actEnd = addToDate(startOfDate(newChangedTask.actualEnd, "day"), 1, "day");
3276
+ var actIntervals = getWorkingIntervals(newChangedTask.actualStart, actEnd, cal);
3277
+ var actSegs = actIntervals.map(function (iv) {
3278
+ return {
3279
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
3280
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
3281
+ };
3282
+ }).filter(function (s) {
3283
+ return s.x2 > s.x1;
3284
+ });
3285
+ newChangedTask.actualSegments = actSegs.length > 0 ? actSegs : undefined;
3286
+ var actDays = Math.max(1, Math.round((newChangedTask.actualEnd.getTime() - newChangedTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3287
+ newChangedTask.actualDuration = actDays;
3288
+ } else {
3289
+ if (action === "end") {
3290
+ var _snappedEnd = snapToWorkingTime(newChangedTask.end, cal, "forward");
3291
+
3292
+ newChangedTask.end = _snappedEnd;
3293
+ newChangedTask.x2 = taskXCoordinate(_snappedEnd, dates, columnWidth);
3294
+ } else if (action === "start") {
3295
+ var _snappedStart2 = snapToWorkingTime(newChangedTask.start, cal, "forward");
3296
+
3297
+ if (_snappedStart2 >= newChangedTask.end) {
3298
+ setFailedTask(originalSelectedTask);
3299
+ onCalendarError === null || onCalendarError === void 0 ? void 0 : onCalendarError(newChangedTask, "No working time in selected range");
3300
+ setGanttEvent({
3301
+ action: ""
3302
+ });
3303
+ setIsMoving(false);
3304
+ svg.current.removeEventListener("mousemove", handleMouseMove);
3305
+ svg.current.removeEventListener("mouseup", handleMouseUp);
3306
+ return Promise.resolve();
3307
+ }
3308
+
3309
+ newChangedTask.start = _snappedStart2;
3310
+ newChangedTask.x1 = taskXCoordinate(_snappedStart2, dates, columnWidth);
3311
+ } else {
3312
+ var _snappedStart3 = snapToWorkingTime(newChangedTask.start, cal, "forward");
3313
+
3314
+ var _delta2 = _snappedStart3.getTime() - newChangedTask.start.getTime();
3315
+
3316
+ newChangedTask.start = _snappedStart3;
3317
+ newChangedTask.end = new Date(newChangedTask.end.getTime() + _delta2);
3318
+ newChangedTask.x1 = taskXCoordinate(_snappedStart3, dates, columnWidth);
3319
+ newChangedTask.x2 = taskXCoordinate(newChangedTask.end, dates, columnWidth);
3320
+ }
3321
+
3322
+ var planEnd = addToDate(startOfDate(newChangedTask.end, "day"), 1, "day");
3323
+ var planIntervals = getWorkingIntervals(newChangedTask.start, planEnd, cal);
3324
+ var planSegs = planIntervals.map(function (iv) {
3325
+ return {
3326
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
3327
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
3328
+ };
3329
+ }).filter(function (s) {
3330
+ return s.x2 > s.x1;
3331
+ });
3332
+ newChangedTask.plannedSegments = planSegs.length > 0 ? planSegs : undefined;
3333
+ var planDays = Math.max(1, Math.round((newChangedTask.end.getTime() - newChangedTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3334
+ newChangedTask.plannedDuration = planDays;
3335
+ }
3336
+ } else if (action === "move" || action === "end" || action === "start") {
3337
+ if (dropType === "actual") {
3338
+ var _actDays2 = Math.max(1, Math.round((newChangedTask.actualEnd.getTime() - newChangedTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3339
+
3340
+ newChangedTask.actualDuration = _actDays2;
3341
+ } else {
3342
+ var _planDays2 = Math.max(1, Math.round((newChangedTask.end.getTime() - newChangedTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3343
+
3344
+ newChangedTask.plannedDuration = _planDays2;
3345
+ }
3346
+ }
3347
+
2749
3348
  svg.current.removeEventListener("mousemove", handleMouseMove);
2750
3349
  svg.current.removeEventListener("mouseup", handleMouseUp);
3350
+
3351
+ if (onBarTasksUpdate && isNotLikeOriginal) {
3352
+ onBarTasksUpdate(newChangedTask);
3353
+ }
3354
+
2751
3355
  setGanttEvent({
2752
3356
  action: ""
2753
3357
  });
@@ -2799,7 +3403,7 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2799
3403
  svg.current.addEventListener("mouseup", handleMouseUp);
2800
3404
  setIsMoving(true);
2801
3405
  }
2802
- }, [ganttEvent, xStep, initEventX1Delta, onProgressChange, timeStep, onDateChange, svg, isMoving, point, rtl, setFailedTask, setGanttEvent]);
3406
+ }, [ganttEvent, xStep, initEventX1Delta, onProgressChange, timeStep, onDateChange, onCalendarError, projectCalendar, svg, isMoving, point, rtl, setFailedTask, setGanttEvent, onBarTasksUpdate, dates, columnWidth]);
2803
3407
 
2804
3408
  var handleBarEventStart = function handleBarEventStart(action, task, event, type) {
2805
3409
  try {
@@ -2885,7 +3489,9 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2885
3489
 
2886
3490
  var getArrows = function getArrows(isCritical, criticalPathType) {
2887
3491
  return tasks.flatMap(function (_task) {
2888
- var task = _task.start.getTime() > 0 && _task.end.getTime() > 0 ? _task : undefined;
3492
+ var _live = ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id ? ganttEvent.changedTask : _task;
3493
+
3494
+ var task = _live.start.getTime() > 0 && _live.end.getTime() > 0 ? _live : undefined;
2889
3495
 
2890
3496
  if (!task) {
2891
3497
  return [];
@@ -2937,8 +3543,9 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2937
3543
  fontSize: fontSize
2938
3544
  }, virtualItems.map(function (vi) {
2939
3545
  var _task = tasks[vi.index];
2940
-
2941
- var task = _extends({}, _task, {
3546
+ var task = ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id ? _extends({}, ganttEvent.changedTask, {
3547
+ y: 0
3548
+ }) : _extends({}, _task, {
2942
3549
  y: 0
2943
3550
  });
2944
3551
 
@@ -3094,6 +3701,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
3094
3701
  };
3095
3702
 
3096
3703
  var Gantt = function Gantt(_ref) {
3704
+ var _tasks$find$calender, _tasks$find;
3705
+
3097
3706
  var tasks = _ref.tasks,
3098
3707
  _ref$leafTasks = _ref.leafTasks,
3099
3708
  leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
@@ -3160,7 +3769,7 @@ var Gantt = function Gantt(_ref) {
3160
3769
  _ref$todayColor = _ref.todayColor,
3161
3770
  todayColor = _ref$todayColor === void 0 ? "rgba(252, 248, 227, 0.5)" : _ref$todayColor,
3162
3771
  _ref$weekendColor = _ref.weekendColor,
3163
- weekendColor = _ref$weekendColor === void 0 ? "#f5f5f5" : _ref$weekendColor,
3772
+ weekendColor = _ref$weekendColor === void 0 ? "#e6e4e4" : _ref$weekendColor,
3164
3773
  viewDate = _ref.viewDate,
3165
3774
  _ref$TooltipContent = _ref.TooltipContent,
3166
3775
  TooltipContent = _ref$TooltipContent === void 0 ? StandardTooltipContent : _ref$TooltipContent,
@@ -3180,7 +3789,12 @@ var Gantt = function Gantt(_ref) {
3180
3789
  _ref$delayToRender = _ref.delayToRender,
3181
3790
  delayToRender = _ref$delayToRender === void 0 ? 500 : _ref$delayToRender,
3182
3791
  _ref$shouldNotShowLoa = _ref.shouldNotShowLoadingOverlay,
3183
- shouldNotShowLoadingOverlay = _ref$shouldNotShowLoa === void 0 ? true : _ref$shouldNotShowLoa;
3792
+ shouldNotShowLoadingOverlay = _ref$shouldNotShowLoa === void 0 ? true : _ref$shouldNotShowLoa,
3793
+ projectCalendar = _ref.projectCalendar,
3794
+ onCalendarError = _ref.onCalendarError;
3795
+ var effectiveCalendar = (_tasks$find$calender = (_tasks$find = tasks.find(function (t) {
3796
+ return t.calender;
3797
+ })) === null || _tasks$find === void 0 ? void 0 : _tasks$find.calender) != null ? _tasks$find$calender : projectCalendar;
3184
3798
  var wrapperRef = React.useRef(null);
3185
3799
  var taskListRef = React.useRef(null);
3186
3800
  var isDraggingTable = React.useRef(false);
@@ -3283,6 +3897,14 @@ var Gantt = function Gantt(_ref) {
3283
3897
  ganttEvent = _useState9[0],
3284
3898
  setGanttEvent = _useState9[1];
3285
3899
 
3900
+ var handleBarTasksUpdate = function handleBarTasksUpdate(task) {
3901
+ setBarTasks(function (prev) {
3902
+ return prev.map(function (t) {
3903
+ return t.id === task.id ? task : t;
3904
+ });
3905
+ });
3906
+ };
3907
+
3286
3908
  var taskHeight = React.useMemo(function () {
3287
3909
  return rowHeight * barFill / 100;
3288
3910
  }, [rowHeight, barFill]);
@@ -3295,7 +3917,11 @@ var Gantt = function Gantt(_ref) {
3295
3917
  failedTask = _useState11[0],
3296
3918
  setFailedTask = _useState11[1];
3297
3919
 
3298
- var svgWidth = columnWidth < 55 ? (dateSetup.dates.length + 0.5) * columnWidth : dateSetup.dates.length * columnWidth;
3920
+ var effectiveColumnWidth = React.useMemo(function () {
3921
+ if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
3922
+ return Math.max(columnWidth, Math.ceil(svgContainerWidth / dateSetup.dates.length));
3923
+ }, [columnWidth, svgContainerWidth, dateSetup.dates.length]);
3924
+ var svgWidth = effectiveColumnWidth < 55 ? (dateSetup.dates.length + 0.5) * effectiveColumnWidth : dateSetup.dates.length * effectiveColumnWidth;
3299
3925
  var ganttFullHeight = React.useMemo(function () {
3300
3926
  return barTasks.length * rowHeight;
3301
3927
  }, [barTasks.length, rowHeight]);
@@ -3345,11 +3971,13 @@ var Gantt = function Gantt(_ref) {
3345
3971
  }
3346
3972
 
3347
3973
  debounceRef.current = setTimeout(function () {
3974
+ var _effectiveCalendar$qu;
3975
+
3348
3976
  var filteredTasks;
3349
3977
  filteredTasks = removeHiddenTasks(tasks);
3350
3978
  filteredTasks = filteredTasks.sort(sortTasks);
3351
3979
 
3352
- var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount),
3980
+ var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_effectiveCalendar$qu = effectiveCalendar === null || effectiveCalendar === void 0 ? void 0 : effectiveCalendar.quarter_start) != null ? _effectiveCalendar$qu : 0),
3353
3981
  startDateRange = _ganttDateRange2[0],
3354
3982
  endDateRange = _ganttDateRange2[1];
3355
3983
 
@@ -3363,7 +3991,7 @@ var Gantt = function Gantt(_ref) {
3363
3991
  newDates = newDates.reverse();
3364
3992
 
3365
3993
  if (scrollX === -1) {
3366
- setScrollX(newDates.length * columnWidth);
3994
+ setScrollX(newDates.length * effectiveColumnWidth);
3367
3995
  }
3368
3996
  }
3369
3997
 
@@ -3385,10 +4013,10 @@ var Gantt = function Gantt(_ref) {
3385
4013
  colorPath(primaryPath, "#ff0000", tasks, "primary");
3386
4014
  }
3387
4015
 
3388
- setBarTasks(convertToBarTasks(filteredTasks, newDates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
4016
+ setBarTasks(convertToBarTasks(filteredTasks, newDates, effectiveColumnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
3389
4017
  setIsProcessing(false);
3390
4018
  }, delayToRender);
3391
- }, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, columnWidth, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay]);
4019
+ }, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay, effectiveColumnWidth, effectiveCalendar]);
3392
4020
  React.useEffect(function () {
3393
4021
  return function () {
3394
4022
  clearTimeout(debounceRef.current);
@@ -3406,9 +4034,9 @@ var Gantt = function Gantt(_ref) {
3406
4034
  }
3407
4035
 
3408
4036
  setCurrentViewDate(viewDate);
3409
- setScrollX(columnWidth * index);
4037
+ setScrollX(effectiveColumnWidth * index);
3410
4038
  }
3411
- }, [viewDate, columnWidth, dateSetup.dates, dateSetup.viewMode, viewMode, currentViewDate, setCurrentViewDate]);
4039
+ }, [viewDate, effectiveColumnWidth, dateSetup.dates, dateSetup.viewMode, viewMode, currentViewDate, setCurrentViewDate]);
3412
4040
  React.useEffect(function () {
3413
4041
  var changedTask = ganttEvent.changedTask,
3414
4042
  action = ganttEvent.action;
@@ -3421,17 +4049,6 @@ var Gantt = function Gantt(_ref) {
3421
4049
  setBarTasks(barTasks.filter(function (t) {
3422
4050
  return t.id !== changedTask.id;
3423
4051
  }));
3424
- } else if (action === "move" || action === "end" || action === "start" || action === "progress") {
3425
- var prevStateTask = barTasks.find(function (t) {
3426
- return t.id === changedTask.id;
3427
- });
3428
-
3429
- if (prevStateTask && (prevStateTask.start.getTime() >= 0 && prevStateTask.start.getTime() !== changedTask.start.getTime() || prevStateTask.end.getTime() >= 0 && prevStateTask.end.getTime() !== changedTask.end.getTime() || (prevStateTask.actualStart.getTime() >= 0 && prevStateTask.actualStart.getTime()) !== changedTask.actualStart.getTime() || prevStateTask.actualEnd.getTime() >= 0 && prevStateTask.actualEnd.getTime() !== changedTask.actualEnd.getTime() || prevStateTask.progress !== changedTask.progress)) {
3430
- var newTaskList = barTasks.map(function (t) {
3431
- return t.id === changedTask.id ? changedTask : t;
3432
- });
3433
- setBarTasks(newTaskList);
3434
- }
3435
4052
  }
3436
4053
  }
3437
4054
  }, [ganttEvent, barTasks]);
@@ -3454,7 +4071,7 @@ var Gantt = function Gantt(_ref) {
3454
4071
  }, [taskListRef, listCellWidth]);
3455
4072
  React.useEffect(function () {
3456
4073
  if (wrapperRef.current) {
3457
- setSvgContainerWidth(wrapperRef.current.offsetWidth - taskListWidth);
4074
+ setSvgContainerWidth(wrapperRef.current.offsetWidth - taskListWidth - 20);
3458
4075
  }
3459
4076
  }, [wrapperRef, taskListWidth]);
3460
4077
  React.useEffect(function () {
@@ -3600,12 +4217,12 @@ var Gantt = function Gantt(_ref) {
3600
4217
 
3601
4218
  case "Left":
3602
4219
  case "ArrowLeft":
3603
- newScrollX -= columnWidth;
4220
+ newScrollX -= effectiveColumnWidth;
3604
4221
  break;
3605
4222
 
3606
4223
  case "Right":
3607
4224
  case "ArrowRight":
3608
- newScrollX += columnWidth;
4225
+ newScrollX += effectiveColumnWidth;
3609
4226
  break;
3610
4227
  }
3611
4228
 
@@ -3660,7 +4277,7 @@ var Gantt = function Gantt(_ref) {
3660
4277
  };
3661
4278
 
3662
4279
  var gridProps = {
3663
- columnWidth: columnWidth,
4280
+ columnWidth: effectiveColumnWidth,
3664
4281
  svgWidth: svgWidth,
3665
4282
  tasks: tasks,
3666
4283
  scheduleType: scheduleType,
@@ -3670,17 +4287,20 @@ var Gantt = function Gantt(_ref) {
3670
4287
  weekendColor: weekendColor,
3671
4288
  rtl: rtl,
3672
4289
  visibleStartY: visibleStartY,
3673
- visibleEndY: visibleEndY
4290
+ visibleEndY: visibleEndY,
4291
+ projectCalendar: effectiveCalendar,
4292
+ viewMode: viewMode
3674
4293
  };
3675
4294
  var calendarProps = {
3676
4295
  dateSetup: dateSetup,
3677
4296
  locale: locale,
3678
4297
  viewMode: viewMode,
3679
4298
  headerHeight: headerHeight,
3680
- columnWidth: columnWidth,
4299
+ columnWidth: effectiveColumnWidth,
3681
4300
  fontFamily: fontFamily,
3682
4301
  fontSize: fontSize,
3683
- rtl: rtl
4302
+ rtl: rtl,
4303
+ projectCalendar: effectiveCalendar
3684
4304
  };
3685
4305
  var barProps = {
3686
4306
  tasks: barTasks,
@@ -3689,7 +4309,7 @@ var Gantt = function Gantt(_ref) {
3689
4309
  selectedTask: selectedTask,
3690
4310
  rowHeight: rowHeight,
3691
4311
  taskHeight: taskHeight,
3692
- columnWidth: columnWidth,
4312
+ columnWidth: effectiveColumnWidth,
3693
4313
  arrowColor: arrowColor,
3694
4314
  timeStep: timeStep,
3695
4315
  fontFamily: fontFamily,
@@ -3700,20 +4320,28 @@ var Gantt = function Gantt(_ref) {
3700
4320
  setGanttEvent: setGanttEvent,
3701
4321
  setFailedTask: setFailedTask,
3702
4322
  setSelectedTask: handleSelectedTask,
4323
+ onBarTasksUpdate: handleBarTasksUpdate,
3703
4324
  onDateChange: onDateChange,
3704
4325
  onProgressChange: onProgressChange,
3705
4326
  onDoubleClick: onDoubleClick,
3706
4327
  onClick: onClick,
3707
4328
  onDelete: onDelete,
4329
+ onCalendarError: onCalendarError,
4330
+ projectCalendar: effectiveCalendar,
3708
4331
  visibleStartY: visibleStartY,
3709
4332
  visibleEndY: visibleEndY
3710
4333
  };
4334
+ var tableTasks = React.useMemo(function () {
4335
+ return ganttEvent.changedTask ? barTasks.map(function (t) {
4336
+ return t.id === ganttEvent.changedTask.id ? ganttEvent.changedTask : t;
4337
+ }) : barTasks;
4338
+ }, [barTasks, ganttEvent.changedTask]);
3711
4339
  var tableProps = {
3712
4340
  rowHeight: rowHeight,
3713
4341
  rowWidth: listCellWidth,
3714
4342
  fontFamily: fontFamily,
3715
4343
  fontSize: fontSize,
3716
- tasks: barTasks,
4344
+ tasks: tableTasks,
3717
4345
  leafTasks: leafTasks,
3718
4346
  scheduleType: scheduleType,
3719
4347
  locale: locale,
@@ -3781,7 +4409,8 @@ var Gantt = function Gantt(_ref) {
3781
4409
  taskListWidth: taskListWidth,
3782
4410
  TooltipContent: TooltipContent,
3783
4411
  rtl: rtl,
3784
- svgWidth: svgWidth
4412
+ svgWidth: svgWidth,
4413
+ isDragging: ganttEvent.action === "move" || ganttEvent.action === "start" || ganttEvent.action === "end" || ganttEvent.action === "progress"
3785
4414
  }), React__default.createElement(VerticalScroll, {
3786
4415
  ganttFullHeight: ganttFullHeight,
3787
4416
  ganttHeight: ganttHeight,