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