gantt-task-react-powern 0.6.38 → 0.6.39

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
@@ -22,6 +22,10 @@ function _extends() {
22
22
  return _extends.apply(this, arguments);
23
23
  }
24
24
 
25
+ function _objectDestructuringEmpty(obj) {
26
+ if (obj == null) throw new TypeError("Cannot destructure undefined");
27
+ }
28
+
25
29
  function _unsupportedIterableToArray(o, minLen) {
26
30
  if (!o) return;
27
31
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -354,7 +358,7 @@ var TaskListHeaderDefault = function TaskListHeaderDefault(_ref) {
354
358
  }
355
359
  }), {
356
360
  resizable: false
357
- }), cell("id", 0.8, "ID"), cell("wbs", 0.8, "WBS Code / Activity ID"), cell("name", 1.8, "Task"), cell("plannedStart", 0.6, "Planned Start", {
361
+ }), cell("id", 0.8, "ID"), cell("wbs", 0.8, "WBS Code / Activity ID"), cell("name", 1.8, "IM TESTING"), cell("plannedStart", 0.6, "Planned Start", {
358
362
  title: "Planned Start"
359
363
  }), cell("plannedEnd", 0.6, "Planned End", {
360
364
  title: "Planned End"
@@ -746,6 +750,43 @@ var Tooltip = function Tooltip(_ref) {
746
750
  type: type
747
751
  }));
748
752
  };
753
+
754
+ function getOffTime(task, taskStart, taskEnd, _message) {
755
+ var start = taskStart.getTime();
756
+ var end = taskEnd.getTime();
757
+ var startWeek = Math.floor((start / 86400000 + 4) / 7);
758
+ var endWeek = Math.floor((end / 86400000 + 4) / 7);
759
+ var offTime = 0;
760
+
761
+ if (task.calendar) {
762
+ if (task.calendar.off_days && task.calendar.off_days.length) {
763
+ for (var d = 0; d < task.calendar.off_days.length || 0; d++) {
764
+ for (var w = startWeek; w <= endWeek; w++) {
765
+ var dayOfTheWeek = task.calendar.off_days[d];
766
+ var offDay = 86400000 * (7 * w - 4 + dayOfTheWeek);
767
+
768
+ if (offDay >= start && offDay <= end) {
769
+ offTime += 86400000;
770
+ }
771
+ }
772
+ }
773
+ }
774
+
775
+ if (task.calendar.holidays && task.calendar.holidays.length) {
776
+ for (var h = 0; h < task.calendar.holidays.length || 0; h++) {
777
+ var holiday = task.calendar.holidays[h];
778
+ var holiday_timestamp = new Date(holiday).getTime();
779
+
780
+ if (holiday_timestamp >= start && holiday_timestamp <= end) {
781
+ offTime += 86400000;
782
+ }
783
+ }
784
+ }
785
+ }
786
+
787
+ return offTime;
788
+ }
789
+
749
790
  var StandardTooltipContent = function StandardTooltipContent(_ref2) {
750
791
  var _task$plannedDuration, _task$actualDuration;
751
792
 
@@ -757,8 +798,8 @@ var StandardTooltipContent = function StandardTooltipContent(_ref2) {
757
798
  fontSize: fontSize,
758
799
  fontFamily: fontFamily
759
800
  };
760
- 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;
761
- 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;
801
+ var computedPlannedDuration = task.start && task.end && task.end.getTime() - task.start.getTime() > 0 ? Math.max(1, Math.round((task.end.getTime() - task.start.getTime() - getOffTime(task, task.start, task.end)) / (1000 * 60 * 60 * 24))) : (_task$plannedDuration = task.plannedDuration) != null ? _task$plannedDuration : 0;
802
+ var computedActualDuration = task.actualStart && task.actualEnd && task.actualEnd.getTime() - task.actualStart.getTime() > 0 ? Math.max(1, Math.round((task.actualEnd.getTime() - task.actualStart.getTime() - getOffTime(task, task.actualStart, task.actualEnd)) / (1000 * 60 * 60 * 24))) : (_task$actualDuration = task.actualDuration) != null ? _task$actualDuration : 0;
762
803
  if (type == "planned") return React__default.createElement("div", {
763
804
  className: styles$2.tooltipDefaultContainer,
764
805
  style: style
@@ -818,7 +859,7 @@ var VerticalScroll = function VerticalScroll(_ref) {
818
859
  };
819
860
 
820
861
  function getTaskListColumns(scheduleType, hasCheckbox) {
821
- const columns = [];
862
+ var columns = [];
822
863
  if (hasCheckbox) columns.push({
823
864
  id: "select",
824
865
  factor: 0.3
@@ -871,12 +912,13 @@ function getTaskListColumns(scheduleType, hasCheckbox) {
871
912
 
872
913
  return columns;
873
914
  }
874
- const MIN_COLUMN_WIDTH = 40;
915
+ var MIN_COLUMN_WIDTH = 40;
875
916
  function buildDefaultColumnWidths(scheduleType, hasCheckbox, rowWidth) {
876
- const base = parseInt(rowWidth) || 0;
877
- const widths = {};
917
+ var base = parseInt(rowWidth) || 0;
918
+ var widths = {};
878
919
 
879
- for (const col of getTaskListColumns(scheduleType, hasCheckbox)) {
920
+ for (var _iterator = _createForOfIteratorHelperLoose(getTaskListColumns(scheduleType, hasCheckbox)), _step; !(_step = _iterator()).done;) {
921
+ var col = _step.value;
880
922
  widths[col.id] = base * col.factor;
881
923
  }
882
924
 
@@ -979,21 +1021,44 @@ var TaskList = function TaskList(_ref) {
979
1021
  React.useEffect(function () {
980
1022
  onContentWidthChange === null || onContentWidthChange === void 0 ? void 0 : onContentWidthChange(contentWidth);
981
1023
  }, [contentWidth, onContentWidthChange]);
982
- var taskIdsKey = React.useMemo(function () {
983
- return tasks.map(function (t) {
984
- return t.id;
985
- }).join("|");
986
- }, [tasks]);
987
- var selectedTaskIds = React.useMemo(function () {
988
- return new Set(selectedTasks);
989
- }, [selectedTasks]);
990
1024
 
991
1025
  var _useState3 = React.useState([]),
992
1026
  pendingTaskSelect = _useState3[0],
993
1027
  setPendingTaskSelect = _useState3[1];
994
1028
 
995
1029
  var prevSelectedTasksRef = React.useRef([]);
996
- var expandedTasks = React.useRef([]);
1030
+ var expandedTasks = React.useRef(new Set());
1031
+ var taskIndex = React.useMemo(function () {
1032
+ var byId = new Map();
1033
+ var childrenOf = new Map();
1034
+ var roots = [];
1035
+ tasks.forEach(function (task) {
1036
+ return byId.set(task.id, task);
1037
+ });
1038
+ tasks.forEach(function (task) {
1039
+ var parent = getParentWbs(task.id);
1040
+
1041
+ if (parent === undefined) {
1042
+ roots.push(task.id);
1043
+ return;
1044
+ }
1045
+
1046
+ var siblings = childrenOf.get(parent);
1047
+ if (siblings) siblings.push(task.id);else childrenOf.set(parent, [task.id]);
1048
+ });
1049
+ return {
1050
+ byId: byId,
1051
+ childrenOf: childrenOf,
1052
+ roots: roots
1053
+ };
1054
+ }, [tasks]);
1055
+
1056
+ var sameIds = function sameIds(a, b) {
1057
+ return a.length === b.length && a.every(function (id, i) {
1058
+ return id === b[i];
1059
+ });
1060
+ };
1061
+
997
1062
  var virtualizer = reactVirtual.useVirtualizer({
998
1063
  count: tasks.length,
999
1064
  getScrollElement: function getScrollElement() {
@@ -1010,13 +1075,15 @@ var TaskList = function TaskList(_ref) {
1010
1075
  }
1011
1076
  }, [scrollY]);
1012
1077
  React.useEffect(function () {
1013
- if (onMultiSelect && JSON.stringify(prevSelectedTasksRef.current) !== JSON.stringify(selectedTasks)) {
1014
- var selectedTaskObjects = tasks.filter(function (task) {
1015
- return selectedTasks.includes(task.id);
1016
- });
1017
- prevSelectedTasksRef.current = [].concat(selectedTasks);
1018
- onMultiSelect(selectedTaskObjects);
1078
+ if (!onMultiSelect || sameIds(prevSelectedTasksRef.current, selectedTasks)) {
1079
+ return;
1019
1080
  }
1081
+
1082
+ var selected = new Set(selectedTasks);
1083
+ prevSelectedTasksRef.current = selectedTasks;
1084
+ onMultiSelect(tasks.filter(function (task) {
1085
+ return selected.has(task.id);
1086
+ }));
1020
1087
  }, [selectedTasks, tasks, onMultiSelect]);
1021
1088
  React.useEffect(function () {
1022
1089
  if (pendingTaskSelect.length === 0) return;
@@ -1026,19 +1093,19 @@ var TaskList = function TaskList(_ref) {
1026
1093
  selected = _ref2.selected;
1027
1094
 
1028
1095
  if (selected) {
1029
- recursiveOpen(taskId, tasks);
1030
- var descendants = getDescendants(taskId, tasks);
1096
+ recursiveOpen(taskId);
1097
+ var descendants = getDescendants(taskId);
1031
1098
  newSelected.add(taskId);
1032
1099
  descendants.forEach(function (d) {
1033
1100
  return newSelected.add(d);
1034
1101
  });
1035
1102
  } else {
1036
- var _descendants = getDescendants(taskId, tasks);
1103
+ var _descendants = getDescendants(taskId);
1037
1104
 
1038
- newSelected.delete(taskId);
1105
+ newSelected["delete"](taskId);
1039
1106
 
1040
1107
  _descendants.forEach(function (d) {
1041
- return newSelected.delete(d);
1108
+ return newSelected["delete"](d);
1042
1109
  });
1043
1110
  }
1044
1111
  });
@@ -1046,63 +1113,60 @@ var TaskList = function TaskList(_ref) {
1046
1113
  setPendingTaskSelect([]);
1047
1114
  }, [pendingTaskSelect]);
1048
1115
  React.useEffect(function () {
1049
- expandedTasks.current = expandedTasks.current.filter(function (id) {
1050
- var t = tasks.find(function (task) {
1051
- return task.id === id;
1052
- });
1053
- return t && !t.hideChildren;
1116
+ expandedTasks.current.forEach(function (id) {
1117
+ var task = taskIndex.byId.get(id);
1118
+ if (!task || task.hideChildren) expandedTasks.current["delete"](id);
1054
1119
  });
1055
1120
  if (selectedTasks.length === 0) return;
1056
1121
  var newSelected = new Set();
1057
1122
  selectedTasks.forEach(function (taskId) {
1058
- if (tasks.find(function (t) {
1059
- return t.id === taskId;
1060
- })) {
1061
- recursiveOpen(taskId, tasks);
1062
- newSelected.add(taskId);
1063
- var descendants = getDescendants(taskId, tasks);
1064
- descendants.forEach(function (d) {
1065
- return newSelected.add(d);
1066
- });
1067
- }
1123
+ if (!taskIndex.byId.has(taskId)) return;
1124
+ recursiveOpen(taskId);
1125
+ newSelected.add(taskId);
1126
+ getDescendants(taskId).forEach(function (d) {
1127
+ return newSelected.add(d);
1128
+ });
1068
1129
  });
1069
1130
  var newSelectedArray = Array.from(newSelected);
1070
1131
 
1071
- if (JSON.stringify(newSelectedArray) !== JSON.stringify(selectedTasks)) {
1132
+ if (!sameIds(newSelectedArray, selectedTasks)) {
1072
1133
  setSelectedTasks(newSelectedArray);
1073
1134
  }
1074
- }, [taskIdsKey]);
1135
+ }, [tasks.length]);
1075
1136
 
1076
- var getDescendants = function getDescendants(taskId, allTasks) {
1077
- var task = allTasks.find(function (t) {
1078
- return t.id === taskId;
1079
- });
1080
- if (!task) return [];
1081
- var children = allTasks.filter(function (t) {
1082
- return getParentWbs(t.id) === taskId;
1083
- });
1084
- return children.flatMap(function (child) {
1085
- return [child.id].concat(getDescendants(child.id, allTasks));
1086
- });
1087
- };
1137
+ var getDescendants = function getDescendants(taskId) {
1138
+ var _taskIndex$childrenOf;
1088
1139
 
1089
- var recursiveOpen = function recursiveOpen(taskId, allTasks) {
1090
- var task = allTasks.find(function (t) {
1091
- return t.id === taskId;
1092
- });
1093
- if (!task) return;
1140
+ if (!taskIndex.byId.has(taskId)) return [];
1141
+ var out = [];
1142
+ var stack = [].concat((_taskIndex$childrenOf = taskIndex.childrenOf.get(taskId)) != null ? _taskIndex$childrenOf : []).reverse();
1094
1143
 
1095
- if (!expandedTasks.current.includes(taskId) && task.hideChildren) {
1096
- onExpanderClick(task);
1097
- expandedTasks.current = [].concat(expandedTasks.current, [taskId]);
1144
+ while (stack.length) {
1145
+ var id = stack.pop();
1146
+ out.push(id);
1147
+ var children = taskIndex.childrenOf.get(id);
1148
+ if (children) stack.push.apply(stack, [].concat(children).reverse());
1098
1149
  }
1099
1150
 
1100
- var children = allTasks.filter(function (t) {
1101
- return getParentWbs(t.id) === taskId;
1102
- });
1103
- children.forEach(function (c) {
1104
- return recursiveOpen(c.id, allTasks);
1105
- });
1151
+ return out;
1152
+ };
1153
+
1154
+ var recursiveOpen = function recursiveOpen(taskId) {
1155
+ var stack = [taskId];
1156
+
1157
+ while (stack.length) {
1158
+ var id = stack.pop();
1159
+ var task = taskIndex.byId.get(id);
1160
+ var children = taskIndex.childrenOf.get(id);
1161
+ if (!task || !children) continue;
1162
+
1163
+ if (task.hideChildren && !expandedTasks.current.has(id)) {
1164
+ onExpanderClick(task);
1165
+ expandedTasks.current.add(id);
1166
+ }
1167
+
1168
+ stack.push.apply(stack, children);
1169
+ }
1106
1170
  };
1107
1171
 
1108
1172
  var handleTaskSelect = function handleTaskSelect(taskId, selected) {
@@ -1116,10 +1180,12 @@ var TaskList = function TaskList(_ref) {
1116
1180
 
1117
1181
  var handleSelectAll = function handleSelectAll(selected) {
1118
1182
  if (selected) {
1119
- setSelectedTasks(tasks.map(function (task) {
1120
- return task.id;
1183
+ setPendingTaskSelect(taskIndex.roots.map(function (taskId) {
1184
+ return {
1185
+ taskId: taskId,
1186
+ selected: true
1187
+ };
1121
1188
  }));
1122
- setPendingTaskSelect([]);
1123
1189
  } else {
1124
1190
  setSelectedTasks([]);
1125
1191
  setPendingTaskSelect([]);
@@ -1132,9 +1198,7 @@ var TaskList = function TaskList(_ref) {
1132
1198
  fontSize: fontSize,
1133
1199
  rowWidth: rowWidth,
1134
1200
  scheduleType: scheduleType,
1135
- allSelected: tasks.length > 0 && tasks.every(function (t) {
1136
- return selectedTaskIds.has(t.id);
1137
- }),
1201
+ allSelected: tasks.length > 0 && selectedTasks.length === tasks.length,
1138
1202
  onSelectAll: onMultiSelect ? handleSelectAll : undefined,
1139
1203
  columnWidths: columnWidths,
1140
1204
  onColumnResize: handleColumnResize
@@ -1195,15 +1259,15 @@ var TaskList = function TaskList(_ref) {
1195
1259
  };
1196
1260
 
1197
1261
  function parseTimeToMinutes(t) {
1198
- const parts = t.split(":").map(Number);
1262
+ var parts = t.split(":").map(Number);
1199
1263
  return parts[0] * 60 + parts[1] + (parts[2] ? parts[2] / 60 : 0);
1200
1264
  }
1201
1265
 
1202
1266
  function toDateString(date) {
1203
- const y = date.getFullYear();
1204
- const m = String(date.getMonth() + 1).padStart(2, "0");
1205
- const d = String(date.getDate()).padStart(2, "0");
1206
- return `${y}-${m}-${d}`;
1267
+ var y = date.getFullYear();
1268
+ var m = String(date.getMonth() + 1).padStart(2, "0");
1269
+ var d = String(date.getDate()).padStart(2, "0");
1270
+ return y + "-" + m + "-" + d;
1207
1271
  }
1208
1272
 
1209
1273
  function isHoliday(date, cal) {
@@ -1220,32 +1284,70 @@ function isOffDay(date, cal) {
1220
1284
  return false;
1221
1285
  }
1222
1286
  }
1287
+ var parsedShiftsCache = new WeakMap();
1288
+ var offDayCache = new WeakMap();
1289
+
1290
+ function parsedShifts(cal) {
1291
+ var shifts = parsedShiftsCache.get(cal);
1292
+
1293
+ if (!shifts) {
1294
+ var _cal$shifts;
1295
+
1296
+ shifts = ((_cal$shifts = cal.shifts) != null ? _cal$shifts : []).map(function (_ref) {
1297
+ var s = _ref[0],
1298
+ e = _ref[1];
1299
+ return {
1300
+ start: parseTimeToMinutes(s),
1301
+ end: parseTimeToMinutes(e)
1302
+ };
1303
+ });
1304
+ parsedShiftsCache.set(cal, shifts);
1305
+ }
1306
+
1307
+ return shifts;
1308
+ }
1309
+
1310
+ function isOffDayCached(date, cal) {
1311
+ var perCal = offDayCache.get(cal);
1312
+
1313
+ if (!perCal) {
1314
+ perCal = new Map();
1315
+ offDayCache.set(cal, perCal);
1316
+ }
1317
+
1318
+ var key = date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate();
1319
+ var off = perCal.get(key);
1320
+
1321
+ if (off === undefined) {
1322
+ off = isOffDay(date, cal);
1323
+ perCal.set(key, off);
1324
+ }
1325
+
1326
+ return off;
1327
+ }
1328
+
1329
+ var NO_SHIFTS = [];
1223
1330
  function getShiftsForDay(date, cal) {
1224
- if (isOffDay(date, cal) || !cal.shifts) return [];
1225
- return cal.shifts.map(_ref => {
1226
- let [s, e] = _ref;
1227
- return {
1228
- start: parseTimeToMinutes(s),
1229
- end: parseTimeToMinutes(e)
1230
- };
1231
- });
1331
+ if (!cal.shifts || isOffDayCached(date, cal)) return NO_SHIFTS;
1332
+ return parsedShifts(cal);
1232
1333
  }
1233
1334
  function getWorkingIntervals(start, end, cal) {
1234
1335
  if (start >= end) return [];
1235
- const intervals = [];
1236
- const cursor = new Date(start);
1336
+ var intervals = [];
1337
+ var cursor = new Date(start);
1237
1338
  cursor.setHours(0, 0, 0, 0);
1238
1339
 
1239
1340
  while (cursor <= end) {
1240
- const shifts = getShiftsForDay(cursor, cal);
1341
+ var shifts = getShiftsForDay(cursor, cal);
1241
1342
 
1242
- for (const shift of shifts) {
1243
- const shiftStart = new Date(cursor);
1343
+ for (var _iterator = _createForOfIteratorHelperLoose(shifts), _step; !(_step = _iterator()).done;) {
1344
+ var shift = _step.value;
1345
+ var shiftStart = new Date(cursor);
1244
1346
  shiftStart.setHours(Math.floor(shift.start / 60), Math.floor(shift.start % 60), Math.round(shift.start % 1 * 60), 0);
1245
- const shiftEnd = new Date(cursor);
1347
+ var shiftEnd = new Date(cursor);
1246
1348
  shiftEnd.setHours(Math.floor(shift.end / 60), Math.floor(shift.end % 60), Math.round(shift.end % 1 * 60), 0);
1247
- const intervalStart = shiftStart < start ? start : shiftStart;
1248
- const intervalEnd = shiftEnd > end ? end : shiftEnd;
1349
+ var intervalStart = shiftStart < start ? start : shiftStart;
1350
+ var intervalEnd = shiftEnd > end ? end : shiftEnd;
1249
1351
 
1250
1352
  if (intervalStart < intervalEnd) {
1251
1353
  intervals.push({
@@ -1261,19 +1363,21 @@ function getWorkingIntervals(start, end, cal) {
1261
1363
  return intervals;
1262
1364
  }
1263
1365
  function snapToWorkingTime(date, cal, direction) {
1264
- const MAX_DAYS = 60;
1265
- const result = new Date(date);
1366
+ var MAX_DAYS = 60;
1367
+ var result = new Date(date);
1266
1368
 
1267
- for (let attempt = 0; attempt < MAX_DAYS * 24 * 60; attempt++) {
1268
- const dayStart = new Date(result);
1369
+ for (var attempt = 0; attempt < MAX_DAYS * 24 * 60; attempt++) {
1370
+ var dayStart = new Date(result);
1269
1371
  dayStart.setHours(0, 0, 0, 0);
1270
- const shifts = getShiftsForDay(dayStart, cal);
1372
+ var shifts = getShiftsForDay(dayStart, cal);
1271
1373
 
1272
1374
  if (shifts.length > 0) {
1273
1375
  if (direction === "forward") {
1274
- const currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
1376
+ var currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
1377
+
1378
+ for (var _iterator2 = _createForOfIteratorHelperLoose(shifts), _step2; !(_step2 = _iterator2()).done;) {
1379
+ var shift = _step2.value;
1275
1380
 
1276
- for (const shift of shifts) {
1277
1381
  if (currentMins <= shift.end) {
1278
1382
  if (currentMins < shift.start) {
1279
1383
  result.setHours(Math.floor(shift.start / 60), Math.round(shift.start % 60), 0, 0);
@@ -1286,11 +1390,11 @@ function snapToWorkingTime(date, cal, direction) {
1286
1390
  result.setDate(result.getDate() + 1);
1287
1391
  result.setHours(0, 0, 0, 0);
1288
1392
  } else {
1289
- const currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
1393
+ var _currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
1290
1394
 
1291
- for (let i = shifts.length - 1; i >= 0; i--) {
1292
- if (currentMins >= shifts[i].start) {
1293
- if (currentMins > shifts[i].end) {
1395
+ for (var i = shifts.length - 1; i >= 0; i--) {
1396
+ if (_currentMins >= shifts[i].start) {
1397
+ if (_currentMins > shifts[i].end) {
1294
1398
  result.setHours(Math.floor(shifts[i].end / 60), Math.round(shifts[i].end % 60), 0, 0);
1295
1399
  }
1296
1400
 
@@ -1315,69 +1419,72 @@ function snapToWorkingTime(date, cal, direction) {
1315
1419
  return date;
1316
1420
  }
1317
1421
  function getQuarterNumber(date, quarterStart) {
1318
- const month = date.getMonth();
1319
- const offset = (month - quarterStart + 12) % 12;
1422
+ var month = date.getMonth();
1423
+ var offset = (month - quarterStart + 12) % 12;
1320
1424
  return Math.floor(offset / 3) + 1;
1321
1425
  }
1322
1426
 
1323
1427
  var styles$5 = {"gridRow":"_2dZTy","gridRowLookAhead":"_2RRca","gridRowLine":"_3rUKi","gridTick":"_RuwuK","gridTickWeekStart":"_1q0EV","gridTickDashed":"_Zh9jh","darkerGridRow":"_2M-tt"};
1324
1428
 
1325
- const GridBody = _ref => {
1326
- let {
1327
- tasks,
1328
- scheduleType,
1329
- dates,
1330
- rowHeight,
1331
- svgWidth,
1332
- columnWidth,
1333
- todayColor,
1334
- weekendColor,
1335
- rtl,
1336
- virtualItems = [],
1337
- visibleStartY,
1338
- visibleEndY,
1339
- projectCalendar,
1340
- viewMode
1341
- } = _ref;
1342
- const visibleHeight = visibleEndY - visibleStartY;
1343
- const now = new Date();
1344
- const items = virtualItems.length > 0 ? virtualItems : tasks.map((_, i) => ({
1345
- index: i,
1346
- start: i * rowHeight,
1347
- end: (i + 1) * rowHeight,
1348
- size: rowHeight,
1349
- key: i
1350
- }));
1429
+ var GridBody = function GridBody(_ref) {
1430
+ var _projectCalendar$week;
1431
+
1432
+ var tasks = _ref.tasks,
1433
+ scheduleType = _ref.scheduleType,
1434
+ dates = _ref.dates,
1435
+ rowHeight = _ref.rowHeight,
1436
+ svgWidth = _ref.svgWidth,
1437
+ columnWidth = _ref.columnWidth,
1438
+ todayColor = _ref.todayColor,
1439
+ weekendColor = _ref.weekendColor,
1440
+ rtl = _ref.rtl,
1441
+ _ref$virtualItems = _ref.virtualItems,
1442
+ virtualItems = _ref$virtualItems === void 0 ? [] : _ref$virtualItems,
1443
+ visibleStartY = _ref.visibleStartY,
1444
+ visibleEndY = _ref.visibleEndY,
1445
+ projectCalendar = _ref.projectCalendar,
1446
+ viewMode = _ref.viewMode;
1447
+ var visibleHeight = visibleEndY - visibleStartY;
1448
+ var now = new Date();
1449
+ var items = virtualItems != null ? virtualItems : tasks.map(function (_, i) {
1450
+ return {
1451
+ index: i,
1452
+ start: i * rowHeight,
1453
+ end: (i + 1) * rowHeight,
1454
+ size: rowHeight,
1455
+ key: i
1456
+ };
1457
+ });
1351
1458
 
1352
- const isDayOff = date => {
1459
+ var isDayOff = function isDayOff(date) {
1353
1460
  if (projectCalendar) return isOffDay(date, projectCalendar);
1354
- const d = date.getDay();
1461
+ var d = date.getDay();
1355
1462
  return d === 0 || d === 6;
1356
1463
  };
1357
1464
 
1358
- const isTodayColumn = i => {
1359
- const date = dates[i];
1360
- const next = dates[i + 1];
1465
+ var isTodayColumn = function isTodayColumn(i) {
1466
+ var date = dates[i];
1467
+ var next = dates[i + 1];
1361
1468
  if (next && date <= now && next > now) return true;
1362
1469
 
1363
1470
  if (!next && date <= now) {
1364
- const prev = dates[i - 1];
1365
- const step = prev ? date.getTime() - prev.getTime() : 86400000;
1366
- const end = addToDate(date, step, "millisecond");
1471
+ var prev = dates[i - 1];
1472
+ var step = prev ? date.getTime() - prev.getTime() : 86400000;
1473
+ var end = addToDate(date, step, "millisecond");
1367
1474
  return end > now;
1368
1475
  }
1369
1476
 
1370
1477
  return false;
1371
1478
  };
1372
1479
 
1373
- const todayRects = [];
1374
- const offDayRects = [];
1375
- const weekStartDay = (projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) ?? 1;
1480
+ var todayRects = [];
1481
+ var offDayRects = [];
1482
+ var weekStartDay = (_projectCalendar$week = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) != null ? _projectCalendar$week : 1;
1376
1483
 
1377
- for (let i = 0, x = 0; i < dates.length; i++, x += columnWidth) {
1484
+ for (var i = 0, x = 0; i < dates.length; i++, x += columnWidth) {
1378
1485
  if (isTodayColumn(i)) {
1379
1486
  todayRects.push(React__default.createElement("rect", {
1380
- key: `today-${i}`,
1487
+ key: "today-" + i,
1381
1488
  x: rtl ? x + columnWidth : x,
1382
1489
  y: visibleStartY,
1383
1490
  width: columnWidth,
@@ -1387,24 +1494,26 @@ const GridBody = _ref => {
1387
1494
  }
1388
1495
 
1389
1496
  if (viewMode !== exports.ViewMode.Month && viewMode !== exports.ViewMode.Quarter) {
1390
- const pEnd = dates[i + 1] ?? addToDate(dates[i], 1, "day");
1391
- const periodMs = pEnd.getTime() - dates[i].getTime();
1497
+ var _dates;
1498
+
1499
+ var pEnd = (_dates = dates[i + 1]) != null ? _dates : addToDate(dates[i], 1, "day");
1500
+ var periodMs = pEnd.getTime() - dates[i].getTime();
1392
1501
 
1393
1502
  if (periodMs > 0) {
1394
- const cursor = new Date(dates[i]);
1503
+ var cursor = new Date(dates[i]);
1395
1504
  cursor.setHours(0, 0, 0, 0);
1396
1505
 
1397
1506
  while (cursor.getTime() < pEnd.getTime()) {
1398
1507
  if (isDayOff(cursor)) {
1399
- const ds = cursor.getTime() - dates[i].getTime();
1400
- const de = ds + 86400000;
1401
- const startFrac = Math.max(0, ds) / periodMs;
1402
- const endFrac = Math.min(periodMs, de) / periodMs;
1403
- const rw = (endFrac - startFrac) * columnWidth;
1508
+ var ds = cursor.getTime() - dates[i].getTime();
1509
+ var de = ds + 86400000;
1510
+ var startFrac = Math.max(0, ds) / periodMs;
1511
+ var endFrac = Math.min(periodMs, de) / periodMs;
1512
+ var rw = (endFrac - startFrac) * columnWidth;
1404
1513
 
1405
1514
  if (rw > 0.5) {
1406
1515
  offDayRects.push(React__default.createElement("rect", {
1407
- key: `offday-${i}-${cursor.getTime()}`,
1516
+ key: "offday-" + i + "-" + cursor.getTime(),
1408
1517
  x: x + startFrac * columnWidth,
1409
1518
  y: visibleStartY,
1410
1519
  width: rw,
@@ -1420,10 +1529,10 @@ const GridBody = _ref => {
1420
1529
  }
1421
1530
  }
1422
1531
 
1423
- const isDayView = viewMode === exports.ViewMode.Day;
1424
- const isWeekView = viewMode === exports.ViewMode.Week;
1425
- const tickLines = dates.map((date, i) => {
1426
- let tickClass = styles$5.gridTick;
1532
+ var isDayView = viewMode === exports.ViewMode.Day;
1533
+ var isWeekView = viewMode === exports.ViewMode.Week;
1534
+ var tickLines = dates.map(function (date, i) {
1535
+ var tickClass = styles$5.gridTick;
1427
1536
 
1428
1537
  if (isDayView) {
1429
1538
  tickClass = date.getDay() === weekStartDay ? styles$5.gridTickWeekStart : styles$5.gridTickDashed;
@@ -1432,7 +1541,7 @@ const GridBody = _ref => {
1432
1541
  }
1433
1542
 
1434
1543
  return React__default.createElement("line", {
1435
- key: `tick-${i}`,
1544
+ key: "tick-" + i,
1436
1545
  x1: i * columnWidth,
1437
1546
  y1: visibleStartY,
1438
1547
  x2: i * columnWidth,
@@ -1440,9 +1549,9 @@ const GridBody = _ref => {
1440
1549
  className: tickClass
1441
1550
  });
1442
1551
  });
1443
- const rowBackgrounds = [];
1444
- const rowLines = [];
1445
- const rowOverlays = [];
1552
+ var rowBackgrounds = [];
1553
+ var rowLines = [];
1554
+ var rowOverlays = [];
1446
1555
  rowLines.push(React__default.createElement("line", {
1447
1556
  key: "top-line",
1448
1557
  x1: 0,
@@ -1451,16 +1560,17 @@ const GridBody = _ref => {
1451
1560
  y2: visibleStartY,
1452
1561
  className: styles$5.gridRowLine
1453
1562
  }));
1454
- const showPerRowOffDays = viewMode !== exports.ViewMode.Month && viewMode !== exports.ViewMode.Quarter;
1563
+ var showPerRowOffDays = viewMode !== exports.ViewMode.Month && viewMode !== exports.ViewMode.Quarter;
1455
1564
 
1456
- for (const vi of items) {
1457
- const task = tasks[vi.index];
1565
+ for (var _iterator = _createForOfIteratorHelperLoose(items), _step; !(_step = _iterator()).done;) {
1566
+ var vi = _step.value;
1567
+ var task = tasks[vi.index];
1458
1568
  if (!task) break;
1459
- const y = vi.start;
1460
- const isMilestone = task.type === "milestone";
1461
- const rowClass = isMilestone ? styles$5.darkerGridRow : scheduleType === "lookAhead" ? styles$5.gridRowLookAhead : styles$5.gridRow;
1569
+ var y = vi.start;
1570
+ var isMilestone = task.type === "milestone";
1571
+ var rowClass = isMilestone ? styles$5.darkerGridRow : scheduleType === "lookAhead" ? styles$5.gridRowLookAhead : styles$5.gridRow;
1462
1572
  rowBackgrounds.push(React__default.createElement("rect", {
1463
- key: `bg-${vi.key}`,
1573
+ key: "bg-" + vi.key,
1464
1574
  x: 0,
1465
1575
  y: y,
1466
1576
  width: svgWidth,
@@ -1468,7 +1578,7 @@ const GridBody = _ref => {
1468
1578
  className: rowClass
1469
1579
  }));
1470
1580
  rowLines.push(React__default.createElement("line", {
1471
- key: `line-${vi.key}`,
1581
+ key: "line-" + vi.key,
1472
1582
  x1: 0,
1473
1583
  y1: y + rowHeight,
1474
1584
  x2: svgWidth,
@@ -1477,47 +1587,57 @@ const GridBody = _ref => {
1477
1587
  }));
1478
1588
 
1479
1589
  if (showPerRowOffDays) {
1480
- const rowEven = vi.index % 2 === 1;
1481
- const rowFill = isMilestone ? "#e6e4e4" : scheduleType === "lookAhead" ? "#fff" : rowEven ? "#f5f5f5" : "#fff";
1590
+ var rowEven = vi.index % 2 === 1;
1591
+ var rowFill = isMilestone ? "#e6e4e4" : scheduleType === "lookAhead" ? "#fff" : rowEven ? "#f5f5f5" : "#fff";
1482
1592
  rowOverlays.push(React__default.createElement("rect", {
1483
- key: `row-clean-${vi.key}`,
1593
+ key: "row-clean-" + vi.key,
1484
1594
  x: 0,
1485
1595
  y: y,
1486
1596
  width: svgWidth,
1487
1597
  height: rowHeight,
1488
1598
  fill: rowFill
1489
1599
  }));
1490
- const cal = task.calendar;
1600
+ var cal = task.calendar;
1491
1601
 
1492
1602
  if (cal) {
1493
- for (let i = 0, x = 0; i < dates.length; i++, x += columnWidth) {
1494
- const pEnd = dates[i + 1] ?? addToDate(dates[i], 1, "day");
1495
- const periodMs = pEnd.getTime() - dates[i].getTime();
1496
- if (periodMs <= 0) continue;
1497
- const cursor = new Date(dates[i]);
1498
- cursor.setHours(0, 0, 0, 0);
1499
-
1500
- while (cursor.getTime() < pEnd.getTime()) {
1501
- if (isOffDay(cursor, cal)) {
1502
- const ds = cursor.getTime() - dates[i].getTime();
1503
- const de = ds + 86400000;
1504
- const startFrac = Math.max(0, ds) / periodMs;
1505
- const endFrac = Math.min(periodMs, de) / periodMs;
1506
- const rw = (endFrac - startFrac) * columnWidth;
1507
-
1508
- if (rw > 0.5) {
1603
+ for (var _i = 0, _x = 0; _i < dates.length; _i++, _x += columnWidth) {
1604
+ var _dates2;
1605
+
1606
+ var _pEnd = (_dates2 = dates[_i + 1]) != null ? _dates2 : addToDate(dates[_i], 1, "day");
1607
+
1608
+ var _periodMs = _pEnd.getTime() - dates[_i].getTime();
1609
+
1610
+ if (_periodMs <= 0) continue;
1611
+
1612
+ var _cursor = new Date(dates[_i]);
1613
+
1614
+ _cursor.setHours(0, 0, 0, 0);
1615
+
1616
+ while (_cursor.getTime() < _pEnd.getTime()) {
1617
+ if (isOffDay(_cursor, cal)) {
1618
+ var _ds = _cursor.getTime() - dates[_i].getTime();
1619
+
1620
+ var _de = _ds + 86400000;
1621
+
1622
+ var _startFrac = Math.max(0, _ds) / _periodMs;
1623
+
1624
+ var _endFrac = Math.min(_periodMs, _de) / _periodMs;
1625
+
1626
+ var _rw = (_endFrac - _startFrac) * columnWidth;
1627
+
1628
+ if (_rw > 0.5) {
1509
1629
  rowOverlays.push(React__default.createElement("rect", {
1510
- key: `row-offday-${vi.key}-${cursor.getTime()}`,
1511
- x: rtl ? x + columnWidth - (startFrac * columnWidth + rw) : x + startFrac * columnWidth,
1630
+ key: "row-offday-" + vi.key + "-" + _cursor.getTime(),
1631
+ x: rtl ? _x + columnWidth - (_startFrac * columnWidth + _rw) : _x + _startFrac * columnWidth,
1512
1632
  y: y,
1513
- width: rw,
1633
+ width: _rw,
1514
1634
  height: rowHeight,
1515
1635
  fill: weekendColor
1516
1636
  }));
1517
1637
  }
1518
1638
  }
1519
1639
 
1520
- cursor.setDate(cursor.getDate() + 1);
1640
+ _cursor.setDate(_cursor.getDate() + 1);
1521
1641
  }
1522
1642
  }
1523
1643
  }
@@ -1541,7 +1661,7 @@ const GridBody = _ref => {
1541
1661
  }, todayRects));
1542
1662
  };
1543
1663
 
1544
- const Grid = props => {
1664
+ var Grid = function Grid(props) {
1545
1665
  return React__default.createElement("g", {
1546
1666
  className: "grid"
1547
1667
  }, React__default.createElement(GridBody, Object.assign({}, props)));
@@ -1549,17 +1669,16 @@ const Grid = props => {
1549
1669
 
1550
1670
  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"};
1551
1671
 
1552
- const TopPartOfCalendar = _ref => {
1553
- let {
1554
- value,
1555
- x1Line,
1556
- y1Line,
1557
- y2Line,
1558
- xText,
1559
- yText,
1560
- textAnchor = "middle"
1561
- } = _ref;
1562
- const textAnchorClass = textAnchor === "start" ? styles$6.textAnchorStart : textAnchor === "middle" ? styles$6.textAnchorMiddle : styles$6.textAnchorEnd;
1672
+ var TopPartOfCalendar = function TopPartOfCalendar(_ref) {
1673
+ var value = _ref.value,
1674
+ x1Line = _ref.x1Line,
1675
+ y1Line = _ref.y1Line,
1676
+ y2Line = _ref.y2Line,
1677
+ xText = _ref.xText,
1678
+ yText = _ref.yText,
1679
+ _ref$textAnchor = _ref.textAnchor,
1680
+ textAnchor = _ref$textAnchor === void 0 ? "middle" : _ref$textAnchor;
1681
+ var textAnchorClass = textAnchor === "start" ? styles$6.textAnchorStart : textAnchor === "middle" ? styles$6.textAnchorMiddle : styles$6.textAnchorEnd;
1563
1682
  return React__default.createElement("g", {
1564
1683
  className: "calendarTop"
1565
1684
  }, React__default.createElement("line", {
@@ -1573,41 +1692,41 @@ const TopPartOfCalendar = _ref => {
1573
1692
  key: value + "text",
1574
1693
  y: yText,
1575
1694
  x: xText,
1576
- className: `${styles$6.calendarTopText} ${textAnchorClass}`
1695
+ className: styles$6.calendarTopText + " " + textAnchorClass
1577
1696
  }, value));
1578
1697
  };
1579
1698
 
1580
- const Calendar = _ref => {
1581
- let {
1582
- dateSetup,
1583
- locale,
1584
- viewMode,
1585
- rtl,
1586
- headerHeight,
1587
- columnWidth,
1588
- fontFamily,
1589
- fontSize,
1590
- projectCalendar,
1591
- weekendColor
1592
- } = _ref;
1593
-
1594
- const isDayOff = date => {
1699
+ var Calendar = function Calendar(_ref) {
1700
+ var dateSetup = _ref.dateSetup,
1701
+ locale = _ref.locale,
1702
+ viewMode = _ref.viewMode,
1703
+ rtl = _ref.rtl,
1704
+ headerHeight = _ref.headerHeight,
1705
+ columnWidth = _ref.columnWidth,
1706
+ fontFamily = _ref.fontFamily,
1707
+ fontSize = _ref.fontSize,
1708
+ projectCalendar = _ref.projectCalendar,
1709
+ weekendColor = _ref.weekendColor;
1710
+
1711
+ var isDayOff = function isDayOff(date) {
1595
1712
  if (projectCalendar) return isOffDay(date, projectCalendar);
1596
1713
  return false;
1597
1714
  };
1598
1715
 
1599
- const shortMonth = date => date.toLocaleString(locale, {
1600
- month: "short"
1601
- });
1716
+ var shortMonth = function shortMonth(date) {
1717
+ return date.toLocaleString(locale, {
1718
+ month: "short"
1719
+ });
1720
+ };
1602
1721
 
1603
- const getCalendarValuesForYear = () => {
1604
- const topValues = [];
1605
- const bottomValues = [];
1606
- const topDefaultHeight = headerHeight * 0.5;
1722
+ var getCalendarValuesForYear = function getCalendarValuesForYear() {
1723
+ var topValues = [];
1724
+ var bottomValues = [];
1725
+ var topDefaultHeight = headerHeight * 0.5;
1607
1726
 
1608
- for (let i = 0; i < dateSetup.dates.length; i++) {
1609
- const date = dateSetup.dates[i];
1610
- const bottomValue = date.getFullYear();
1727
+ for (var i = 0; i < dateSetup.dates.length; i++) {
1728
+ var date = dateSetup.dates[i];
1729
+ var bottomValue = date.getFullYear();
1611
1730
  bottomValues.push(React__default.createElement("text", {
1612
1731
  key: date.getFullYear(),
1613
1732
  y: headerHeight * 0.8,
@@ -1616,8 +1735,8 @@ const Calendar = _ref => {
1616
1735
  }, bottomValue));
1617
1736
 
1618
1737
  if (i === 0 || date.getFullYear() !== dateSetup.dates[i - 1].getFullYear()) {
1619
- const topValue = date.getFullYear().toString();
1620
- let xText;
1738
+ var topValue = date.getFullYear().toString();
1739
+ var xText = void 0;
1621
1740
 
1622
1741
  if (rtl) {
1623
1742
  xText = (6 + i + date.getFullYear() + 1) * columnWidth;
@@ -1640,35 +1759,37 @@ const Calendar = _ref => {
1640
1759
  return [topValues, bottomValues];
1641
1760
  };
1642
1761
 
1643
- const getCalendarValuesForQuarter = () => {
1644
- const topValues = [];
1645
- const bottomValues = [];
1646
- const offDayRects = [];
1647
- const quarterStart = (projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) ?? 0;
1648
- const rowH = headerHeight / 3;
1762
+ var getCalendarValuesForQuarter = function getCalendarValuesForQuarter() {
1763
+ var _projectCalendar$quar;
1649
1764
 
1650
- for (let i = 0; i < dateSetup.dates.length; i++) {
1651
- const date = dateSetup.dates[i];
1652
- const qNum = getQuarterNumber(date, quarterStart);
1765
+ var topValues = [];
1766
+ var bottomValues = [];
1767
+ var offDayRects = [];
1768
+ var quarterStart = (_projectCalendar$quar = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar : 0;
1769
+ var rowH = headerHeight / 3;
1653
1770
 
1654
- for (let m = 0; m < 3; m++) {
1655
- const monthDate = addToDate(date, m, "month");
1771
+ for (var i = 0; i < dateSetup.dates.length; i++) {
1772
+ var date = dateSetup.dates[i];
1773
+ var qNum = getQuarterNumber(date, quarterStart);
1774
+
1775
+ for (var m = 0; m < 3; m++) {
1776
+ var monthDate = addToDate(date, m, "month");
1656
1777
  bottomValues.push(React__default.createElement("text", {
1657
- key: `qmonth-${i}-${m}`,
1778
+ key: "qmonth-" + i + "-" + m,
1658
1779
  y: headerHeight * 0.9,
1659
1780
  x: columnWidth * i + columnWidth * (m * 2 + 1) / 6,
1660
- className: `${styles$6.calendarTopText} ${styles$6.textAnchorMiddle}`
1781
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
1661
1782
  }, shortMonth(monthDate)));
1662
1783
  }
1663
1784
 
1664
1785
  bottomValues.push(React__default.createElement("text", {
1665
- key: `qlabel-${i}`,
1786
+ key: "qlabel-" + i,
1666
1787
  y: rowH * 1.6,
1667
1788
  x: columnWidth * i + columnWidth * 0.5,
1668
- className: `${styles$6.calendarTopText} ${styles$6.textAnchorMiddle}`
1669
- }, `Qtr ${qNum}`));
1789
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
1790
+ }, "Qtr " + qNum));
1670
1791
  bottomValues.push(React__default.createElement("line", {
1671
- key: `qsep-${i}`,
1792
+ key: "qsep-" + i,
1672
1793
  x1: columnWidth * i,
1673
1794
  y1: rowH,
1674
1795
  x2: columnWidth * i,
@@ -1696,14 +1817,14 @@ const Calendar = _ref => {
1696
1817
  }
1697
1818
 
1698
1819
  if (i === 0 || date.getFullYear() !== dateSetup.dates[i - 1].getFullYear()) {
1699
- const topValue = date.getFullYear().toString();
1700
- let span = 0;
1820
+ var topValue = date.getFullYear().toString();
1821
+ var span = 0;
1701
1822
 
1702
- for (let j = i; j < dateSetup.dates.length && dateSetup.dates[j].getFullYear() === date.getFullYear(); j++) {
1823
+ for (var j = i; j < dateSetup.dates.length && dateSetup.dates[j].getFullYear() === date.getFullYear(); j++) {
1703
1824
  span++;
1704
1825
  }
1705
1826
 
1706
- const xText = columnWidth * i + columnWidth * span / 2;
1827
+ var xText = columnWidth * i + columnWidth * span / 2;
1707
1828
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1708
1829
  key: topValue + i,
1709
1830
  value: topValue,
@@ -1720,36 +1841,38 @@ const Calendar = _ref => {
1720
1841
  return [topValues, bottomValues, offDayRects];
1721
1842
  };
1722
1843
 
1723
- const getCalendarValuesForMonth = () => {
1724
- const topValues = [];
1725
- const bottomValues = [];
1726
- const offDayRects = [];
1727
- const topDefaultHeight = headerHeight * 0.5;
1728
- const quarterStart = (projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) ?? 0;
1844
+ var getCalendarValuesForMonth = function getCalendarValuesForMonth() {
1845
+ var _projectCalendar$quar2;
1846
+
1847
+ var topValues = [];
1848
+ var bottomValues = [];
1849
+ var offDayRects = [];
1850
+ var topDefaultHeight = headerHeight * 0.5;
1851
+ var quarterStart = (_projectCalendar$quar2 = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar2 : 0;
1729
1852
 
1730
- for (let i = 0; i < dateSetup.dates.length; i++) {
1731
- const date = dateSetup.dates[i];
1732
- const bottomValue = shortMonth(date);
1853
+ for (var i = 0; i < dateSetup.dates.length; i++) {
1854
+ var date = dateSetup.dates[i];
1855
+ var bottomValue = shortMonth(date);
1733
1856
  bottomValues.push(React__default.createElement("text", {
1734
1857
  key: bottomValue + date.getFullYear() + i,
1735
1858
  y: headerHeight * 0.8,
1736
1859
  x: columnWidth * i + columnWidth * 0.5,
1737
- className: `${styles$6.calendarTopText} ${styles$6.textAnchorMiddle}`
1860
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
1738
1861
  }, bottomValue));
1739
- const qNum = getQuarterNumber(date, quarterStart);
1740
- const prevDate = i > 0 ? dateSetup.dates[i - 1] : null;
1741
- const prevQNum = prevDate ? getQuarterNumber(prevDate, quarterStart) : -1;
1742
- const isNewQuarter = i === 0 || qNum !== prevQNum || date.getFullYear() !== (prevDate ? prevDate.getFullYear() : -1);
1862
+ var qNum = getQuarterNumber(date, quarterStart);
1863
+ var prevDate = i > 0 ? dateSetup.dates[i - 1] : null;
1864
+ var prevQNum = prevDate ? getQuarterNumber(prevDate, quarterStart) : -1;
1865
+ var isNewQuarter = i === 0 || qNum !== prevQNum || date.getFullYear() !== (prevDate ? prevDate.getFullYear() : -1);
1743
1866
 
1744
1867
  if (isNewQuarter) {
1745
- const topValue = `Qtr ${qNum}, ${date.getFullYear()}`;
1746
- let span = 0;
1868
+ var topValue = "Qtr " + qNum + ", " + date.getFullYear();
1869
+ var span = 0;
1747
1870
 
1748
- for (let j = i; j < dateSetup.dates.length && getQuarterNumber(dateSetup.dates[j], quarterStart) === qNum && dateSetup.dates[j].getFullYear() === date.getFullYear(); j++) {
1871
+ for (var j = i; j < dateSetup.dates.length && getQuarterNumber(dateSetup.dates[j], quarterStart) === qNum && dateSetup.dates[j].getFullYear() === date.getFullYear(); j++) {
1749
1872
  span++;
1750
1873
  }
1751
1874
 
1752
- const xText = rtl ? columnWidth * i + columnWidth * span * 0.5 + columnWidth : columnWidth * i + columnWidth * span / 2;
1875
+ var xText = rtl ? columnWidth * i + columnWidth * span * 0.5 + columnWidth : columnWidth * i + columnWidth * span / 2;
1753
1876
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1754
1877
  key: topValue + i,
1755
1878
  value: topValue,
@@ -1763,7 +1886,7 @@ const Calendar = _ref => {
1763
1886
 
1764
1887
  if (i > 0) {
1765
1888
  bottomValues.push(React__default.createElement("line", {
1766
- key: `qbound-${i}`,
1889
+ key: "qbound-" + i,
1767
1890
  x1: columnWidth * i,
1768
1891
  y1: topDefaultHeight,
1769
1892
  x2: columnWidth * i,
@@ -1777,28 +1900,28 @@ const Calendar = _ref => {
1777
1900
  return [topValues, bottomValues, offDayRects];
1778
1901
  };
1779
1902
 
1780
- const getCalendarValuesForWeek = () => {
1781
- const topValues = [];
1782
- const bottomValues = [];
1783
- const offDayRects = [];
1784
- let weeksCount = 1;
1785
- const topDefaultHeight = headerHeight * 0.5;
1786
- const dates = dateSetup.dates;
1903
+ var getCalendarValuesForWeek = function getCalendarValuesForWeek() {
1904
+ var topValues = [];
1905
+ var bottomValues = [];
1906
+ var offDayRects = [];
1907
+ var weeksCount = 1;
1908
+ var topDefaultHeight = headerHeight * 0.5;
1909
+ var dates = dateSetup.dates;
1787
1910
 
1788
- for (let i = dates.length - 1; i >= 0; i--) {
1789
- const date = dates[i];
1790
- let topValue = "";
1911
+ for (var i = dates.length - 1; i >= 0; i--) {
1912
+ var date = dates[i];
1913
+ var topValue = "";
1791
1914
 
1792
1915
  if (i === 0 || date.getMonth() !== dates[i - 1].getMonth()) {
1793
- topValue = `${shortMonth(date)} ${date.getFullYear()}`;
1916
+ topValue = shortMonth(date) + " " + date.getFullYear();
1794
1917
  }
1795
1918
 
1796
- const bottomValue = date.getDate().toString();
1919
+ var bottomValue = date.getDate().toString();
1797
1920
  bottomValues.push(React__default.createElement("text", {
1798
1921
  key: date.getTime(),
1799
1922
  y: headerHeight * 0.8,
1800
1923
  x: columnWidth * (i + +rtl),
1801
- className: `${styles$6.calendarTopText} ${styles$6.textAnchorStart}`
1924
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorStart
1802
1925
  }, bottomValue));
1803
1926
 
1804
1927
  if (topValue) {
@@ -1824,21 +1947,23 @@ const Calendar = _ref => {
1824
1947
  return [topValues, bottomValues, offDayRects];
1825
1948
  };
1826
1949
 
1827
- const getCalendarValuesForDay = () => {
1828
- const topValues = [];
1829
- const bottomValues = [];
1830
- const offDayRects = [];
1831
- const tickLines = [];
1832
- const topDefaultHeight = headerHeight * 0.5;
1833
- const dates = dateSetup.dates;
1834
- const weekStartDay = (projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) ?? 1;
1950
+ var getCalendarValuesForDay = function getCalendarValuesForDay() {
1951
+ var _projectCalendar$week;
1835
1952
 
1836
- for (let i = 0; i < dates.length; i++) {
1837
- const date = dates[i];
1953
+ var topValues = [];
1954
+ var bottomValues = [];
1955
+ var offDayRects = [];
1956
+ var tickLines = [];
1957
+ var topDefaultHeight = headerHeight * 0.5;
1958
+ var dates = dateSetup.dates;
1959
+ var weekStartDay = (_projectCalendar$week = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) != null ? _projectCalendar$week : 1;
1960
+
1961
+ for (var i = 0; i < dates.length; i++) {
1962
+ var date = dates[i];
1838
1963
 
1839
1964
  if (isDayOff(date)) {
1840
1965
  offDayRects.push(React__default.createElement("rect", {
1841
- key: `offday-header-${i}`,
1966
+ key: "offday-header-" + i,
1842
1967
  x: columnWidth * i,
1843
1968
  y: topDefaultHeight,
1844
1969
  width: columnWidth,
@@ -1847,25 +1972,25 @@ const Calendar = _ref => {
1847
1972
  }));
1848
1973
  }
1849
1974
 
1850
- const isWeekStart = date.getDay() === weekStartDay;
1975
+ var isWeekStart = date.getDay() === weekStartDay;
1851
1976
  tickLines.push(React__default.createElement("line", {
1852
- key: `tick-day-${i}`,
1977
+ key: "tick-day-" + i,
1853
1978
  x1: columnWidth * i,
1854
1979
  y1: topDefaultHeight,
1855
1980
  x2: columnWidth * i,
1856
1981
  y2: headerHeight,
1857
1982
  className: isWeekStart ? styles$6.calendarTickSolid : styles$6.calendarTickDashed
1858
1983
  }));
1859
- const bottomValue = columnWidth > 55 ? `${getLocalDayOfWeek(date, locale, "short")}, ${date.getDate()}` : `${getLocalDayOfWeek(date, locale, "narrow")},${date.getDate()}`;
1984
+ var bottomValue = columnWidth > 55 ? getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate() : getLocalDayOfWeek(date, locale, "narrow") + "," + date.getDate();
1860
1985
  bottomValues.push(React__default.createElement("text", {
1861
1986
  key: date.getTime(),
1862
1987
  y: headerHeight * 0.8,
1863
1988
  x: columnWidth * i + columnWidth * 0.5,
1864
- className: `${styles$6.calendarTopText} ${styles$6.textAnchorMiddle}`
1989
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
1865
1990
  }, bottomValue));
1866
1991
 
1867
1992
  if (i + 1 !== dates.length && date.getMonth() !== dates[i + 1].getMonth()) {
1868
- const topValue = `${shortMonth(date)} ${date.getFullYear()}`;
1993
+ var topValue = shortMonth(date) + " " + date.getFullYear();
1869
1994
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1870
1995
  key: topValue + i,
1871
1996
  value: topValue,
@@ -1878,10 +2003,11 @@ const Calendar = _ref => {
1878
2003
  }
1879
2004
 
1880
2005
  if (i + 1 === dates.length) {
1881
- const topValue = `${shortMonth(date)} ${date.getFullYear()}`;
2006
+ var _topValue = shortMonth(date) + " " + date.getFullYear();
2007
+
1882
2008
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1883
- key: topValue + "last",
1884
- value: topValue,
2009
+ key: _topValue + "last",
2010
+ value: _topValue,
1885
2011
  x1Line: columnWidth * (i + 1),
1886
2012
  y1Line: 0,
1887
2013
  y2Line: topDefaultHeight,
@@ -1894,28 +2020,28 @@ const Calendar = _ref => {
1894
2020
  return [topValues, bottomValues, offDayRects, tickLines];
1895
2021
  };
1896
2022
 
1897
- const getCalendarValuesForPartOfDay = () => {
1898
- const topValues = [];
1899
- const bottomValues = [];
1900
- const ticks = viewMode === exports.ViewMode.HalfDay ? 2 : 4;
1901
- const topDefaultHeight = headerHeight * 0.5;
1902
- const dates = dateSetup.dates;
2023
+ var getCalendarValuesForPartOfDay = function getCalendarValuesForPartOfDay() {
2024
+ var topValues = [];
2025
+ var bottomValues = [];
2026
+ var ticks = viewMode === exports.ViewMode.HalfDay ? 2 : 4;
2027
+ var topDefaultHeight = headerHeight * 0.5;
2028
+ var dates = dateSetup.dates;
1903
2029
 
1904
- for (let i = 0; i < dates.length; i++) {
1905
- const date = dates[i];
1906
- const bottomValue = getCachedDateTimeFormat(locale, {
2030
+ for (var i = 0; i < dates.length; i++) {
2031
+ var date = dates[i];
2032
+ var bottomValue = getCachedDateTimeFormat(locale, {
1907
2033
  hour: "numeric"
1908
2034
  }).format(date);
1909
2035
  bottomValues.push(React__default.createElement("text", {
1910
2036
  key: date.getTime(),
1911
2037
  y: headerHeight * 0.8,
1912
2038
  x: columnWidth * (i + +rtl),
1913
- className: `${styles$6.calendarTopText} ${styles$6.textAnchorMiddle}`,
2039
+ className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle,
1914
2040
  fontFamily: fontFamily
1915
2041
  }, bottomValue));
1916
2042
 
1917
2043
  if (i === 0 || date.getDate() !== dates[i - 1].getDate()) {
1918
- const topValue = `${getLocalDayOfWeek(date, locale, "short")}, ${date.getDate()} ${shortMonth(date)}`;
2044
+ var topValue = getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate() + " " + shortMonth(date);
1919
2045
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1920
2046
  key: topValue + date.getFullYear(),
1921
2047
  value: topValue,
@@ -1931,15 +2057,15 @@ const Calendar = _ref => {
1931
2057
  return [topValues, bottomValues];
1932
2058
  };
1933
2059
 
1934
- const getCalendarValuesForHour = () => {
1935
- const topValues = [];
1936
- const bottomValues = [];
1937
- const topDefaultHeight = headerHeight * 0.5;
1938
- const dates = dateSetup.dates;
2060
+ var getCalendarValuesForHour = function getCalendarValuesForHour() {
2061
+ var topValues = [];
2062
+ var bottomValues = [];
2063
+ var topDefaultHeight = headerHeight * 0.5;
2064
+ var dates = dateSetup.dates;
1939
2065
 
1940
- for (let i = 0; i < dates.length; i++) {
1941
- const date = dates[i];
1942
- const bottomValue = getCachedDateTimeFormat(locale, {
2066
+ for (var i = 0; i < dates.length; i++) {
2067
+ var date = dates[i];
2068
+ var bottomValue = getCachedDateTimeFormat(locale, {
1943
2069
  hour: "numeric"
1944
2070
  }).format(date);
1945
2071
  bottomValues.push(React__default.createElement("text", {
@@ -1951,9 +2077,9 @@ const Calendar = _ref => {
1951
2077
  }, bottomValue));
1952
2078
 
1953
2079
  if (i !== 0 && date.getDate() !== dates[i - 1].getDate()) {
1954
- const displayDate = dates[i - 1];
1955
- const topValue = `${getLocalDayOfWeek(displayDate, locale, "long")}, ${displayDate.getDate()} ${shortMonth(displayDate)}`;
1956
- const topPosition = (date.getHours() - 24) / 2;
2080
+ var displayDate = dates[i - 1];
2081
+ var topValue = getLocalDayOfWeek(displayDate, locale, "long") + ", " + displayDate.getDate() + " " + shortMonth(displayDate);
2082
+ var topPosition = (date.getHours() - 24) / 2;
1957
2083
  topValues.push(React__default.createElement(TopPartOfCalendar, {
1958
2084
  key: topValue + displayDate.getFullYear(),
1959
2085
  value: topValue,
@@ -1969,19 +2095,22 @@ const Calendar = _ref => {
1969
2095
  return [topValues, bottomValues];
1970
2096
  };
1971
2097
 
1972
- let topValues = [];
1973
- let bottomValues = [];
1974
- let extraValues = [];
1975
- let tickLines = [];
2098
+ var topValues = [];
2099
+ var bottomValues = [];
2100
+ var extraValues = [];
2101
+ var tickLines = [];
1976
2102
 
1977
2103
  switch (dateSetup.viewMode) {
1978
2104
  case exports.ViewMode.Year:
1979
- [topValues, bottomValues] = getCalendarValuesForYear();
2105
+ var _getCalendarValuesFor = getCalendarValuesForYear();
2106
+
2107
+ topValues = _getCalendarValuesFor[0];
2108
+ bottomValues = _getCalendarValuesFor[1];
1980
2109
  break;
1981
2110
 
1982
2111
  case exports.ViewMode.Quarter:
1983
2112
  {
1984
- const r = getCalendarValuesForQuarter();
2113
+ var r = getCalendarValuesForQuarter();
1985
2114
  topValues = r[0];
1986
2115
  bottomValues = r[1];
1987
2116
  extraValues = r[2] || [];
@@ -1990,25 +2119,27 @@ const Calendar = _ref => {
1990
2119
 
1991
2120
  case exports.ViewMode.Month:
1992
2121
  {
1993
- const r = getCalendarValuesForMonth();
1994
- topValues = r[0];
1995
- bottomValues = r[1];
1996
- extraValues = r[2] || [];
2122
+ var _r = getCalendarValuesForMonth();
2123
+
2124
+ topValues = _r[0];
2125
+ bottomValues = _r[1];
2126
+ extraValues = _r[2] || [];
1997
2127
  break;
1998
2128
  }
1999
2129
 
2000
2130
  case exports.ViewMode.Week:
2001
2131
  {
2002
- const r = getCalendarValuesForWeek();
2003
- topValues = r[0];
2004
- bottomValues = r[1];
2005
- extraValues = r[2] || [];
2132
+ var _r2 = getCalendarValuesForWeek();
2133
+
2134
+ topValues = _r2[0];
2135
+ bottomValues = _r2[1];
2136
+ extraValues = _r2[2] || [];
2006
2137
  break;
2007
2138
  }
2008
2139
 
2009
2140
  case exports.ViewMode.Day:
2010
2141
  {
2011
- const result = getCalendarValuesForDay();
2142
+ var result = getCalendarValuesForDay();
2012
2143
  topValues = result[0];
2013
2144
  bottomValues = result[1];
2014
2145
  extraValues = result[2];
@@ -2018,11 +2149,17 @@ const Calendar = _ref => {
2018
2149
 
2019
2150
  case exports.ViewMode.QuarterDay:
2020
2151
  case exports.ViewMode.HalfDay:
2021
- [topValues, bottomValues] = getCalendarValuesForPartOfDay();
2152
+ var _getCalendarValuesFor2 = getCalendarValuesForPartOfDay();
2153
+
2154
+ topValues = _getCalendarValuesFor2[0];
2155
+ bottomValues = _getCalendarValuesFor2[1];
2022
2156
  break;
2023
2157
 
2024
2158
  case exports.ViewMode.Hour:
2025
- [topValues, bottomValues] = getCalendarValuesForHour();
2159
+ var _getCalendarValuesFor3 = getCalendarValuesForHour();
2160
+
2161
+ topValues = _getCalendarValuesFor3[0];
2162
+ bottomValues = _getCalendarValuesFor3[1];
2026
2163
  }
2027
2164
 
2028
2165
  return React__default.createElement("g", {
@@ -2058,17 +2195,19 @@ function _catch(body, recover) {
2058
2195
  return result;
2059
2196
  }
2060
2197
 
2061
- const Arrow = _ref => {
2062
- let {
2063
- taskFrom,
2064
- taskTo,
2065
- rowHeight,
2066
- taskHeight,
2067
- arrowIndent,
2068
- arrowColor,
2069
- dependencyType
2070
- } = _ref;
2071
- let [path, trianglePoints] = drawPathAndTriangle(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent, dependencyType);
2198
+ var Arrow = function Arrow(_ref) {
2199
+ var taskFrom = _ref.taskFrom,
2200
+ taskTo = _ref.taskTo,
2201
+ rowHeight = _ref.rowHeight,
2202
+ taskHeight = _ref.taskHeight,
2203
+ arrowIndent = _ref.arrowIndent,
2204
+ arrowColor = _ref.arrowColor,
2205
+ dependencyType = _ref.dependencyType;
2206
+
2207
+ var _drawPathAndTriangle = drawPathAndTriangle(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent, dependencyType),
2208
+ path = _drawPathAndTriangle[0],
2209
+ trianglePoints = _drawPathAndTriangle[1];
2210
+
2072
2211
  return React__default.createElement("g", {
2073
2212
  className: "arrow"
2074
2213
  }, React__default.createElement("path", {
@@ -2082,40 +2221,40 @@ const Arrow = _ref => {
2082
2221
  }));
2083
2222
  };
2084
2223
 
2085
- const drawPathAndTriangle = (taskFrom, taskTo, rowHeight, taskHeight, arrowIndent, dependencyType) => {
2086
- const indexCompare = taskFrom.index > taskTo.index ? -1 : 1;
2087
- const taskToEndY = taskTo.y + taskHeight / 2;
2088
- const verticalOffset = indexCompare * (rowHeight / 2);
2224
+ var drawPathAndTriangle = function drawPathAndTriangle(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent, dependencyType) {
2225
+ var indexCompare = taskFrom.index > taskTo.index ? -1 : 1;
2226
+ var taskToEndY = taskTo.y + taskHeight / 2;
2227
+ var verticalOffset = indexCompare * (rowHeight / 2);
2089
2228
 
2090
- const minX = t => {
2229
+ var minX = function minX(t) {
2091
2230
  if (t.plannedSegments && t.plannedSegments.length > 0) {
2092
- const p = t.plannedSegments[0].x1;
2231
+ var p = t.plannedSegments[0].x1;
2093
2232
  if (t.actualSegments && t.actualSegments.length > 0) return Math.min(p, t.actualSegments[0].x1);
2094
2233
  return p;
2095
2234
  }
2096
2235
 
2097
2236
  if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[0].x1;
2098
- const candidates = [];
2237
+ var candidates = [];
2099
2238
  if (t.x2 > t.x1) candidates.push(t.x1);
2100
2239
  if (t.actualx2 > t.actualx1) candidates.push(t.actualx1);
2101
- return candidates.length > 0 ? Math.min(...candidates) : 0;
2240
+ return candidates.length > 0 ? Math.min.apply(Math, candidates) : 0;
2102
2241
  };
2103
2242
 
2104
- const maxX = t => {
2243
+ var maxX = function maxX(t) {
2105
2244
  if (t.plannedSegments && t.plannedSegments.length > 0) {
2106
- const p = t.plannedSegments[t.plannedSegments.length - 1].x2;
2245
+ var p = t.plannedSegments[t.plannedSegments.length - 1].x2;
2107
2246
  if (t.actualSegments && t.actualSegments.length > 0) return Math.max(p, t.actualSegments[t.actualSegments.length - 1].x2);
2108
2247
  return p;
2109
2248
  }
2110
2249
 
2111
2250
  if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[t.actualSegments.length - 1].x2;
2112
- const candidates = [];
2251
+ var candidates = [];
2113
2252
  if (t.x2 > t.x1) candidates.push(t.x2);
2114
2253
  if (t.actualx2 > t.actualx1) candidates.push(t.actualx2);
2115
- return candidates.length > 0 ? Math.max(...candidates) : 0;
2254
+ return candidates.length > 0 ? Math.max.apply(Math, candidates) : 0;
2116
2255
  };
2117
2256
 
2118
- let fromPoint, toPoint;
2257
+ var fromPoint, toPoint;
2119
2258
 
2120
2259
  switch (dependencyType) {
2121
2260
  case "SS":
@@ -2139,51 +2278,35 @@ const drawPathAndTriangle = (taskFrom, taskTo, rowHeight, taskHeight, arrowInden
2139
2278
  break;
2140
2279
  }
2141
2280
 
2142
- const arrowPoints = function (x, y, right) {
2281
+ var arrowPoints = function arrowPoints(x, y, right) {
2143
2282
  if (right === void 0) {
2144
2283
  right = true;
2145
2284
  }
2146
2285
 
2147
- return right ? `${x},${y} ${x - 5},${y - 5} ${x - 5},${y + 5}` : `${x},${y} ${x + 5},${y - 5} ${x + 5},${y + 5}`;
2286
+ return right ? x + "," + y + " " + (x - 5) + "," + (y - 5) + " " + (x - 5) + "," + (y + 5) : x + "," + y + " " + (x + 5) + "," + (y - 5) + " " + (x + 5) + "," + (y + 5);
2148
2287
  };
2149
2288
 
2150
- let path;
2151
- let trianglePoints;
2289
+ var path;
2290
+ var trianglePoints;
2152
2291
 
2153
2292
  switch (dependencyType) {
2154
2293
  case "SS":
2155
- path = `M ${fromPoint} ${taskFrom.y + taskHeight / 2}
2156
- H ${fromPoint + Math.min(toPoint - fromPoint, 0) - 2 * arrowIndent}
2157
- V ${taskToEndY}
2158
- H ${toPoint - 5}`;
2294
+ path = "M " + fromPoint + " " + (taskFrom.y + taskHeight / 2) + "\n H " + (fromPoint + Math.min(toPoint - fromPoint, 0) - 2 * arrowIndent) + "\n V " + taskToEndY + "\n H " + (toPoint - 5);
2159
2295
  trianglePoints = arrowPoints(toPoint, taskToEndY, true);
2160
2296
  break;
2161
2297
 
2162
2298
  case "SF":
2163
- path = `M ${fromPoint} ${taskFrom.y + taskHeight / 2}
2164
- H ${fromPoint - 2 * arrowIndent}
2165
- V ${taskFrom.y + taskHeight / 2 + verticalOffset}
2166
- ${fromPoint - toPoint > 4 * arrowIndent ? "" : `H ${toPoint + 2 * arrowIndent}`}
2167
- V ${taskToEndY}
2168
- H ${toPoint + 5}`;
2299
+ path = "M " + fromPoint + " " + (taskFrom.y + taskHeight / 2) + "\n H " + (fromPoint - 2 * arrowIndent) + "\n V " + (taskFrom.y + taskHeight / 2 + verticalOffset) + "\n " + (fromPoint - toPoint > 4 * arrowIndent ? "" : "H " + (toPoint + 2 * arrowIndent)) + "\n V " + taskToEndY + "\n H " + (toPoint + 5);
2169
2300
  trianglePoints = arrowPoints(toPoint, taskToEndY, false);
2170
2301
  break;
2171
2302
 
2172
2303
  case "FS":
2173
- path = `M ${fromPoint} ${taskFrom.y + taskHeight / 2}
2174
- H ${fromPoint + 2 * arrowIndent}
2175
- V ${taskFrom.y + taskHeight / 2 + verticalOffset}
2176
- ${toPoint - fromPoint > 4 * arrowIndent ? "" : `H ${toPoint - 2 * arrowIndent}`}
2177
- V ${taskToEndY}
2178
- H ${toPoint - 5}`;
2304
+ path = "M " + fromPoint + " " + (taskFrom.y + taskHeight / 2) + "\n H " + (fromPoint + 2 * arrowIndent) + "\n V " + (taskFrom.y + taskHeight / 2 + verticalOffset) + "\n " + (toPoint - fromPoint > 4 * arrowIndent ? "" : "H " + (toPoint - 2 * arrowIndent)) + "\n V " + taskToEndY + "\n H " + (toPoint - 5);
2179
2305
  trianglePoints = arrowPoints(toPoint, taskToEndY, true);
2180
2306
  break;
2181
2307
 
2182
2308
  case "FF":
2183
- path = `M ${fromPoint} ${taskFrom.y + taskHeight / 2}
2184
- H ${fromPoint + Math.max(toPoint - fromPoint, 0) + 2 * arrowIndent}
2185
- V ${taskToEndY}
2186
- H ${toPoint + 5}`;
2309
+ path = "M " + fromPoint + " " + (taskFrom.y + taskHeight / 2) + "\n H " + (fromPoint + Math.max(toPoint - fromPoint, 0) + 2 * arrowIndent) + "\n V " + taskToEndY + "\n H " + (toPoint + 5);
2187
2310
  trianglePoints = arrowPoints(toPoint, taskToEndY, false);
2188
2311
  break;
2189
2312
  }
@@ -2195,25 +2318,25 @@ var convertToBarTasks = function convertToBarTasks(tasks, dates, columnWidth, ro
2195
2318
  var barTasks = tasks.map(function (t, i) {
2196
2319
  return convertToBarTask(t, i, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor);
2197
2320
  });
2321
+ var indexById = new Map();
2322
+
2323
+ for (var i = 0; i < barTasks.length; i++) {
2324
+ indexById.set(barTasks[i].id, i);
2325
+ }
2326
+
2198
2327
  barTasks = barTasks.map(function (task) {
2199
2328
  var dependencies = task.dependencies || [];
2200
2329
 
2201
- var _loop = function _loop(j) {
2202
- var dependence = barTasks.findIndex(function (value) {
2203
- return value.id === dependencies[j].id;
2204
- });
2330
+ for (var j = 0; j < dependencies.length; j++) {
2331
+ var dependence = indexById.get(dependencies[j].id);
2205
2332
 
2206
- if (dependence !== -1 && task.start.getTime() > 0 && task.end.getTime() > 0) {
2333
+ if (dependence !== undefined && task.start.getTime() > 0 && task.end.getTime() > 0) {
2207
2334
  var barchild = _extends({}, task, {
2208
2335
  dependencyType: dependencies[j].type
2209
2336
  });
2210
2337
 
2211
2338
  barTasks[dependence].barChildren.push(barchild);
2212
2339
  }
2213
- };
2214
-
2215
- for (var j = 0; j < dependencies.length; j++) {
2216
- _loop(j);
2217
2340
  }
2218
2341
 
2219
2342
  return task;
@@ -2371,10 +2494,33 @@ var convertToMilestone = function convertToMilestone(task, index, dates, columnW
2371
2494
  });
2372
2495
  };
2373
2496
 
2497
+ var dateTimesCache = new WeakMap();
2498
+
2499
+ var getDateTimes = function getDateTimes(dates) {
2500
+ var times = dateTimesCache.get(dates);
2501
+
2502
+ if (!times) {
2503
+ times = dates.map(function (d) {
2504
+ return d.getTime();
2505
+ });
2506
+ dateTimesCache.set(dates, times);
2507
+ }
2508
+
2509
+ return times;
2510
+ };
2511
+
2374
2512
  var taskXCoordinate = function taskXCoordinate(xDate, dates, columnWidth) {
2375
- var index = dates.findIndex(function (d) {
2376
- return d.getTime() >= xDate.getTime();
2377
- }) - 1;
2513
+ var times = getDateTimes(dates);
2514
+ var target = xDate.getTime();
2515
+ var lo = 0;
2516
+ var hi = times.length - 1;
2517
+
2518
+ while (lo <= hi) {
2519
+ var mid = lo + hi >> 1;
2520
+ if (times[mid] >= target) hi = mid - 1;else lo = mid + 1;
2521
+ }
2522
+
2523
+ var index = (lo === times.length ? -1 : lo) - 1;
2378
2524
 
2379
2525
  if (index < 0) {
2380
2526
  if (dates[dates.length - 1].getTime() <= xDate.getTime()) {
@@ -2686,59 +2832,60 @@ var sortTasks = function sortTasks(taskA, taskB) {
2686
2832
  }
2687
2833
  };
2688
2834
 
2689
- const BarDisplay = _ref => {
2690
- let {
2691
- x,
2692
- y,
2693
- type,
2694
- width,
2695
- height,
2696
- isSelected,
2697
- progressX,
2698
- progressWidth,
2699
- barCornerRadius,
2700
- styles,
2701
- segments,
2702
- onMouseDown
2703
- } = _ref;
2704
-
2705
- const getProcessColor = () => {
2835
+ var BarDisplay = function BarDisplay(_ref) {
2836
+ var x = _ref.x,
2837
+ y = _ref.y,
2838
+ type = _ref.type,
2839
+ width = _ref.width,
2840
+ height = _ref.height,
2841
+ isSelected = _ref.isSelected,
2842
+ progressX = _ref.progressX,
2843
+ progressWidth = _ref.progressWidth,
2844
+ barCornerRadius = _ref.barCornerRadius,
2845
+ styles = _ref.styles,
2846
+ segments = _ref.segments,
2847
+ onMouseDown = _ref.onMouseDown;
2848
+
2849
+ var getProcessColor = function getProcessColor() {
2706
2850
  return isSelected ? styles.progressSelectedColor : styles.progressColor;
2707
2851
  };
2708
2852
 
2709
- const getBarColor = () => {
2853
+ var getBarColor = function getBarColor() {
2710
2854
  return isSelected ? styles.backgroundSelectedColor : styles.backgroundColor;
2711
2855
  };
2712
2856
 
2713
2857
  if (type === "planned") {
2714
2858
  if (segments && segments.length > 0) {
2715
- const totalWidth = width;
2859
+ var totalWidth = width;
2716
2860
  return React__default.createElement("g", {
2717
2861
  onMouseDown: onMouseDown
2718
- }, segments.map((seg, idx) => React__default.createElement("rect", {
2719
- key: `seg-${idx}`,
2720
- x: seg.x1,
2721
- width: seg.x2 - seg.x1,
2722
- y: y,
2723
- height: height,
2724
- ry: barCornerRadius,
2725
- rx: barCornerRadius,
2726
- fill: getBarColor(),
2727
- strokeWidth: 2,
2728
- stroke: styles.criticalPathColor
2729
- })), progressWidth > 0 && (() => {
2730
- const rects = [];
2731
- let remaining = progressWidth;
2732
-
2733
- for (const seg of segments) {
2862
+ }, segments.map(function (seg, idx) {
2863
+ return React__default.createElement("rect", {
2864
+ key: "seg-" + idx,
2865
+ x: seg.x1,
2866
+ width: seg.x2 - seg.x1,
2867
+ y: y,
2868
+ height: height,
2869
+ ry: barCornerRadius,
2870
+ rx: barCornerRadius,
2871
+ fill: getBarColor(),
2872
+ strokeWidth: 2,
2873
+ stroke: styles.criticalPathColor
2874
+ });
2875
+ }), progressWidth > 0 && function () {
2876
+ var rects = [];
2877
+ var remaining = progressWidth;
2878
+
2879
+ for (var _iterator = _createForOfIteratorHelperLoose(segments), _step; !(_step = _iterator()).done;) {
2880
+ var seg = _step.value;
2734
2881
  if (remaining <= 0) break;
2735
- const segW = seg.x2 - seg.x1;
2736
- const ratio = totalWidth > 0 ? segW / totalWidth : 0;
2737
- const pw = Math.min(remaining, progressWidth * ratio);
2882
+ var segW = seg.x2 - seg.x1;
2883
+ var ratio = totalWidth > 0 ? segW / totalWidth : 0;
2884
+ var pw = Math.min(remaining, progressWidth * ratio);
2738
2885
 
2739
2886
  if (pw > 0) {
2740
2887
  rects.push(React__default.createElement("rect", {
2741
- key: `prog-${seg.x1}`,
2888
+ key: "prog-" + seg.x1,
2742
2889
  x: seg.x1,
2743
2890
  width: pw,
2744
2891
  y: y,
@@ -2752,7 +2899,7 @@ const BarDisplay = _ref => {
2752
2899
  }
2753
2900
 
2754
2901
  return rects;
2755
- })());
2902
+ }());
2756
2903
  }
2757
2904
 
2758
2905
  return React__default.createElement("g", {
@@ -2780,16 +2927,18 @@ const BarDisplay = _ref => {
2780
2927
  if (segments && segments.length > 0) {
2781
2928
  return React__default.createElement("g", {
2782
2929
  onMouseDown: onMouseDown
2783
- }, segments.map((seg, idx) => React__default.createElement("rect", {
2784
- key: `aseg-${idx}`,
2785
- x: seg.x1,
2786
- width: seg.x2 - seg.x1,
2787
- y: y,
2788
- height: height,
2789
- ry: barCornerRadius,
2790
- rx: barCornerRadius,
2791
- fill: styles.taskProgressColor
2792
- })), React__default.createElement("rect", {
2930
+ }, segments.map(function (seg, idx) {
2931
+ return React__default.createElement("rect", {
2932
+ key: "aseg-" + idx,
2933
+ x: seg.x1,
2934
+ width: seg.x2 - seg.x1,
2935
+ y: y,
2936
+ height: height,
2937
+ ry: barCornerRadius,
2938
+ rx: barCornerRadius,
2939
+ fill: styles.taskProgressColor
2940
+ });
2941
+ }), React__default.createElement("rect", {
2793
2942
  x: progressX,
2794
2943
  width: progressWidth,
2795
2944
  y: y,
@@ -2824,15 +2973,13 @@ const BarDisplay = _ref => {
2824
2973
 
2825
2974
  var styles$7 = {"barWrapper":"_KxSXS","barHandle":"_3w_5u","barBackground":"_31ERP"};
2826
2975
 
2827
- const BarDateHandle = _ref => {
2828
- let {
2829
- x,
2830
- y,
2831
- width,
2832
- height,
2833
- barCornerRadius,
2834
- onMouseDown
2835
- } = _ref;
2976
+ var BarDateHandle = function BarDateHandle(_ref) {
2977
+ var x = _ref.x,
2978
+ y = _ref.y,
2979
+ width = _ref.width,
2980
+ height = _ref.height,
2981
+ barCornerRadius = _ref.barCornerRadius,
2982
+ onMouseDown = _ref.onMouseDown;
2836
2983
  return React__default.createElement("rect", {
2837
2984
  x: x,
2838
2985
  y: y,
@@ -2845,28 +2992,28 @@ const BarDateHandle = _ref => {
2845
2992
  });
2846
2993
  };
2847
2994
 
2848
- const BarProgressHandle = _ref => {
2995
+ var BarProgressHandle = function BarProgressHandle(_ref) {
2996
+ _objectDestructuringEmpty(_ref);
2997
+
2849
2998
  return React__default.createElement("div", null);
2850
2999
  };
2851
3000
 
2852
- const Bar = _ref => {
2853
- let {
2854
- task,
2855
- isProgressChangeable,
2856
- isDateChangeable,
2857
- rtl,
2858
- type,
2859
- onEventStart,
2860
- isSelected
2861
- } = _ref;
2862
- const progressPoint = getProgressPoint(+!rtl * task.progressWidth + task.progressX, task.y, task.height);
2863
- const handleHeight = task.height / 2 - 1;
2864
- const plannedSegs = task.plannedSegments;
2865
- const plannedLeftHandleX = plannedSegs !== null && plannedSegs !== void 0 && plannedSegs.length ? plannedSegs[0].x1 : task.x1;
2866
- const plannedRightHandleX = plannedSegs !== null && plannedSegs !== void 0 && plannedSegs.length ? plannedSegs[plannedSegs.length - 1].x2 : task.x2;
2867
- const actualSegs = task.actualSegments;
2868
- const actualLeftHandleX = actualSegs !== null && actualSegs !== void 0 && actualSegs.length ? actualSegs[0].x1 : task.actualx1;
2869
- const actualRightHandleX = actualSegs !== null && actualSegs !== void 0 && actualSegs.length ? actualSegs[actualSegs.length - 1].x2 : task.actualx2;
3001
+ var Bar = function Bar(_ref) {
3002
+ var task = _ref.task,
3003
+ isProgressChangeable = _ref.isProgressChangeable,
3004
+ isDateChangeable = _ref.isDateChangeable,
3005
+ rtl = _ref.rtl,
3006
+ type = _ref.type,
3007
+ onEventStart = _ref.onEventStart,
3008
+ isSelected = _ref.isSelected;
3009
+ var progressPoint = getProgressPoint(+!rtl * task.progressWidth + task.progressX, task.y, task.height);
3010
+ var handleHeight = task.height / 2 - 1;
3011
+ var plannedSegs = task.plannedSegments;
3012
+ var plannedLeftHandleX = plannedSegs !== null && plannedSegs !== void 0 && plannedSegs.length ? plannedSegs[0].x1 : task.x1;
3013
+ var plannedRightHandleX = plannedSegs !== null && plannedSegs !== void 0 && plannedSegs.length ? plannedSegs[plannedSegs.length - 1].x2 : task.x2;
3014
+ var actualSegs = task.actualSegments;
3015
+ var actualLeftHandleX = actualSegs !== null && actualSegs !== void 0 && actualSegs.length ? actualSegs[0].x1 : task.actualx1;
3016
+ var actualRightHandleX = actualSegs !== null && actualSegs !== void 0 && actualSegs.length ? actualSegs[actualSegs.length - 1].x2 : task.actualx2;
2870
3017
 
2871
3018
  if (type == "planned") {
2872
3019
  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", {
@@ -2892,7 +3039,7 @@ const Bar = _ref => {
2892
3039
  styles: task.styles,
2893
3040
  isSelected: isSelected,
2894
3041
  segments: task.plannedSegments,
2895
- onMouseDown: e => {
3042
+ onMouseDown: function onMouseDown(e) {
2896
3043
  isDateChangeable && onEventStart("move", task, e, "planned");
2897
3044
  }
2898
3045
  }), React__default.createElement("g", {
@@ -2903,7 +3050,7 @@ const Bar = _ref => {
2903
3050
  width: task.handleWidth,
2904
3051
  height: handleHeight,
2905
3052
  barCornerRadius: task.barCornerRadius,
2906
- onMouseDown: e => {
3053
+ onMouseDown: function onMouseDown(e) {
2907
3054
  onEventStart("start", task, e, "planned");
2908
3055
  }
2909
3056
  }), React__default.createElement(BarDateHandle, {
@@ -2912,12 +3059,12 @@ const Bar = _ref => {
2912
3059
  width: task.handleWidth,
2913
3060
  height: handleHeight,
2914
3061
  barCornerRadius: task.barCornerRadius,
2915
- onMouseDown: e => {
3062
+ onMouseDown: function onMouseDown(e) {
2916
3063
  onEventStart("end", task, e, "planned");
2917
3064
  }
2918
3065
  })), isProgressChangeable && React__default.createElement(BarProgressHandle, {
2919
3066
  progressPoint: progressPoint,
2920
- onMouseDown: e => {
3067
+ onMouseDown: function onMouseDown(e) {
2921
3068
  onEventStart("progress", task, e, "planned");
2922
3069
  }
2923
3070
  })));else return React__default.createElement("g", {
@@ -2948,7 +3095,7 @@ const Bar = _ref => {
2948
3095
  styles: task.styles,
2949
3096
  isSelected: isSelected,
2950
3097
  segments: task.actualSegments,
2951
- onMouseDown: e => {
3098
+ onMouseDown: function onMouseDown(e) {
2952
3099
  isDateChangeable && onEventStart("move", task, e, "actual");
2953
3100
  }
2954
3101
  }), React__default.createElement("g", {
@@ -2959,7 +3106,7 @@ const Bar = _ref => {
2959
3106
  width: task.handleWidth,
2960
3107
  height: handleHeight,
2961
3108
  barCornerRadius: task.barCornerRadius,
2962
- onMouseDown: e => {
3109
+ onMouseDown: function onMouseDown(e) {
2963
3110
  onEventStart("start", task, e, "actual");
2964
3111
  }
2965
3112
  }), React__default.createElement(BarDateHandle, {
@@ -2968,12 +3115,12 @@ const Bar = _ref => {
2968
3115
  width: task.handleWidth,
2969
3116
  height: handleHeight,
2970
3117
  barCornerRadius: task.barCornerRadius,
2971
- onMouseDown: e => {
3118
+ onMouseDown: function onMouseDown(e) {
2972
3119
  onEventStart("end", task, e, "actual");
2973
3120
  }
2974
3121
  })), isProgressChangeable && React__default.createElement(BarProgressHandle, {
2975
3122
  progressPoint: progressPoint,
2976
- onMouseDown: e => {
3123
+ onMouseDown: function onMouseDown(e) {
2977
3124
  onEventStart("progress", task, e, "actual");
2978
3125
  }
2979
3126
  })));
@@ -2985,16 +3132,14 @@ const Bar = _ref => {
2985
3132
  }
2986
3133
  };
2987
3134
 
2988
- const BarSmall = _ref => {
2989
- let {
2990
- task,
2991
- type,
2992
- isProgressChangeable,
2993
- isDateChangeable,
2994
- onEventStart,
2995
- isSelected
2996
- } = _ref;
2997
- const progressPoint = getProgressPoint(task.progressWidth + task.x1, task.y, task.height);
3135
+ var BarSmall = function BarSmall(_ref) {
3136
+ var task = _ref.task,
3137
+ type = _ref.type,
3138
+ isProgressChangeable = _ref.isProgressChangeable,
3139
+ isDateChangeable = _ref.isDateChangeable,
3140
+ onEventStart = _ref.onEventStart,
3141
+ isSelected = _ref.isSelected;
3142
+ var progressPoint = getProgressPoint(task.progressWidth + task.x1, task.y, task.height);
2998
3143
  return React__default.createElement("g", {
2999
3144
  className: styles$7.barWrapper,
3000
3145
  tabIndex: 0
@@ -3011,14 +3156,14 @@ const BarSmall = _ref => {
3011
3156
  barCornerRadius: task.barCornerRadius,
3012
3157
  styles: task.styles,
3013
3158
  isSelected: isSelected,
3014
- onMouseDown: e => {
3159
+ onMouseDown: function onMouseDown(e) {
3015
3160
  isDateChangeable && onEventStart("move", task, e);
3016
3161
  }
3017
3162
  }), React__default.createElement("g", {
3018
3163
  className: "handleGroup"
3019
3164
  }, isProgressChangeable && React__default.createElement(BarProgressHandle, {
3020
3165
  progressPoint: progressPoint,
3021
- onMouseDown: e => {
3166
+ onMouseDown: function onMouseDown(e) {
3022
3167
  onEventStart("progress", task, e);
3023
3168
  }
3024
3169
  })));
@@ -3026,17 +3171,14 @@ const BarSmall = _ref => {
3026
3171
 
3027
3172
  var styles$8 = {"milestoneWrapper":"_RRr13","milestoneBackground":"_2P2B1"};
3028
3173
 
3029
- const Milestone = _ref => {
3030
- let {
3031
- task,
3032
- isDateChangeable,
3033
- onEventStart,
3034
- isSelected
3035
- } = _ref;
3036
- const transform = `rotate(45 ${task.x1 + task.height * 0.356}
3037
- ${task.y + task.height * 0.85})`;
3038
-
3039
- const getBarColor = () => {
3174
+ var Milestone = function Milestone(_ref) {
3175
+ var task = _ref.task,
3176
+ isDateChangeable = _ref.isDateChangeable,
3177
+ onEventStart = _ref.onEventStart,
3178
+ isSelected = _ref.isSelected;
3179
+ var transform = "rotate(45 " + (task.x1 + task.height * 0.356) + " \n " + (task.y + task.height * 0.85) + ")";
3180
+
3181
+ var getBarColor = function getBarColor() {
3040
3182
  return isSelected ? task.styles.backgroundSelectedColor : task.styles.backgroundColor;
3041
3183
  };
3042
3184
 
@@ -3053,10 +3195,10 @@ const Milestone = _ref => {
3053
3195
  ry: task.barCornerRadius,
3054
3196
  transform: transform,
3055
3197
  className: styles$8.milestoneBackground,
3056
- onMouseDown: e => {
3198
+ onMouseDown: function onMouseDown(e) {
3057
3199
  isDateChangeable && onEventStart("move", task, e, "planned");
3058
3200
  },
3059
- onDoubleClick: e => {
3201
+ onDoubleClick: function onDoubleClick(e) {
3060
3202
  onEventStart("dblclick", task, e);
3061
3203
  }
3062
3204
  }));
@@ -3064,16 +3206,14 @@ const Milestone = _ref => {
3064
3206
 
3065
3207
  var styles$9 = {"projectWrapper":"_1KJ6x","projectBackground":"_2RbVy","projectTop":"_2pZMF"};
3066
3208
 
3067
- const Project = _ref => {
3068
- let {
3069
- task,
3070
- isSelected
3071
- } = _ref;
3072
- const barColor = isSelected ? task.styles.backgroundSelectedColor : task.styles.backgroundColor;
3073
- const processColor = isSelected ? task.styles.progressSelectedColor : task.styles.progressColor;
3074
- const projectWith = task.x2 - task.x1;
3075
- const projectLeftTriangle = [task.x1, task.y + task.height / 2 - 1, task.x1, task.y + task.height, task.x1 + 15, task.y + task.height / 2 - 1].join(",");
3076
- const projectRightTriangle = [task.x2, task.y + task.height / 2 - 1, task.x2, task.y + task.height, task.x2 - 15, task.y + task.height / 2 - 1].join(",");
3209
+ var Project = function Project(_ref) {
3210
+ var task = _ref.task,
3211
+ isSelected = _ref.isSelected;
3212
+ var barColor = isSelected ? task.styles.backgroundSelectedColor : task.styles.backgroundColor;
3213
+ var processColor = isSelected ? task.styles.progressSelectedColor : task.styles.progressColor;
3214
+ var projectWith = task.x2 - task.x1;
3215
+ var projectLeftTriangle = [task.x1, task.y + task.height / 2 - 1, task.x1, task.y + task.height, task.x1 + 15, task.y + task.height / 2 - 1].join(",");
3216
+ var projectRightTriangle = [task.x2, task.y + task.height / 2 - 1, task.x2, task.y + task.height, task.x2 - 15, task.y + task.height / 2 - 1].join(",");
3077
3217
  return React__default.createElement("g", {
3078
3218
  tabIndex: 0,
3079
3219
  className: styles$9.projectWrapper
@@ -3114,16 +3254,18 @@ const Project = _ref => {
3114
3254
  }));
3115
3255
  };
3116
3256
 
3117
- const TaskItem = props => {
3118
- const {
3119
- task,
3120
- isDelete,
3121
- isSelected,
3122
- onEventStart
3123
- } = { ...props
3124
- };
3125
- const [taskItem, setTaskItem] = React.useState([React__default.createElement("div", null)]);
3126
- React.useEffect(() => {
3257
+ var TaskItem = function TaskItem(props) {
3258
+ var _props = _extends({}, props),
3259
+ task = _props.task,
3260
+ isDelete = _props.isDelete,
3261
+ isSelected = _props.isSelected,
3262
+ onEventStart = _props.onEventStart;
3263
+
3264
+ var _useState = React.useState([React__default.createElement("div", null)]),
3265
+ taskItem = _useState[0],
3266
+ setTaskItem = _useState[1];
3267
+
3268
+ React.useEffect(function () {
3127
3269
  switch (task.typeInternal) {
3128
3270
  case "milestone":
3129
3271
  if (task.x1 >= 0 && task.actualx1 >= 0) setTaskItem([React__default.createElement(Milestone, Object.assign({}, props))]);else setTaskItem([]);
@@ -3139,27 +3281,27 @@ const TaskItem = props => {
3139
3281
 
3140
3282
  default:
3141
3283
  {
3142
- let taskItem = [];
3284
+ var _taskItem = [];
3143
3285
 
3144
3286
  if ((task === null || task === void 0 ? void 0 : task.x1) >= 0 && (task === null || task === void 0 ? void 0 : task.x2) >= 0) {
3145
- taskItem.push(React__default.createElement(Bar, Object.assign({}, props, {
3287
+ _taskItem.push(React__default.createElement(Bar, Object.assign({}, props, {
3146
3288
  type: "planned"
3147
3289
  })));
3148
3290
  }
3149
3291
 
3150
3292
  if ((task === null || task === void 0 ? void 0 : task.actualx1) >= 0 && (task === null || task === void 0 ? void 0 : task.actualx2) >= 0) {
3151
- taskItem.push(React__default.createElement(Bar, Object.assign({}, props, {
3293
+ _taskItem.push(React__default.createElement(Bar, Object.assign({}, props, {
3152
3294
  type: "actual"
3153
3295
  })));
3154
3296
  }
3155
3297
 
3156
- setTaskItem(taskItem);
3298
+ setTaskItem(_taskItem);
3157
3299
  }
3158
3300
  break;
3159
3301
  }
3160
3302
  }, [task, isSelected]);
3161
3303
  return React__default.createElement("g", null, React__default.createElement("g", {
3162
- onKeyDown: e => {
3304
+ onKeyDown: function onKeyDown(e) {
3163
3305
  switch (e.key) {
3164
3306
  case "Delete":
3165
3307
  {
@@ -3170,20 +3312,20 @@ const TaskItem = props => {
3170
3312
 
3171
3313
  e.stopPropagation();
3172
3314
  },
3173
- onMouseEnter: e => {
3315
+ onMouseEnter: function onMouseEnter(e) {
3174
3316
  onEventStart("mouseenter", task, e, "planned");
3175
3317
  },
3176
- onMouseLeave: e => {
3318
+ onMouseLeave: function onMouseLeave(e) {
3177
3319
  onEventStart("mouseleave", task, e, "planned");
3178
3320
  },
3179
- onDoubleClick: e => {
3321
+ onDoubleClick: function onDoubleClick(e) {
3180
3322
  onEventStart("dblclick", task, e, "planned");
3181
3323
  },
3182
- onClick: e => {
3324
+ onClick: function onClick(e) {
3183
3325
  onEventStart("click", task, e, "planned");
3184
3326
  }
3185
3327
  }, taskItem[0]), React__default.createElement("g", {
3186
- onKeyDown: e => {
3328
+ onKeyDown: function onKeyDown(e) {
3187
3329
  switch (e.key) {
3188
3330
  case "Delete":
3189
3331
  {
@@ -3194,152 +3336,177 @@ const TaskItem = props => {
3194
3336
 
3195
3337
  e.stopPropagation();
3196
3338
  },
3197
- onMouseEnter: e => {
3339
+ onMouseEnter: function onMouseEnter(e) {
3198
3340
  onEventStart("mouseenter", task, e, "actual");
3199
3341
  },
3200
- onMouseLeave: e => {
3342
+ onMouseLeave: function onMouseLeave(e) {
3201
3343
  onEventStart("mouseleave", task, e, "actual");
3202
3344
  },
3203
- onDoubleClick: e => {
3345
+ onDoubleClick: function onDoubleClick(e) {
3204
3346
  onEventStart("dblclick", task, e, "actual");
3205
3347
  },
3206
- onClick: e => {
3348
+ onClick: function onClick(e) {
3207
3349
  onEventStart("click", task, e, "actual");
3208
3350
  }
3209
3351
  }, taskItem[1]));
3210
3352
  };
3211
3353
 
3212
- const TaskGanttContent = _ref => {
3354
+ var TaskGanttContent = function TaskGanttContent(_ref) {
3213
3355
  var _svg$current;
3214
3356
 
3215
- let {
3216
- tasks,
3217
- dates,
3218
- ganttEvent,
3219
- selectedTask,
3220
- rowHeight,
3221
- columnWidth,
3222
- timeStep,
3223
- svg,
3224
- taskHeight,
3225
- arrowIndent,
3226
- fontFamily,
3227
- fontSize,
3228
- rtl,
3229
- virtualItems = [],
3230
- setGanttEvent,
3231
- setFailedTask,
3232
- setSelectedTask,
3233
- onBarTasksUpdate,
3234
- onDateChange,
3235
- onProgressChange,
3236
- onDoubleClick,
3237
- onClick,
3238
- onDelete,
3239
- onCalendarError,
3240
- projectCalendar,
3241
- visibleStartY,
3242
- visibleEndY,
3243
- sliderTime
3244
- } = _ref;
3245
- const point = svg === null || svg === void 0 ? void 0 : (_svg$current = svg.current) === null || _svg$current === void 0 ? void 0 : _svg$current.createSVGPoint();
3246
- const [xStep, setXStep] = React.useState(0);
3247
- const [initEventX1Delta, setInitEventX1Delta] = React.useState(0);
3248
- const [isMoving, setIsMoving] = React.useState(false);
3249
- React.useEffect(() => {
3357
+ var tasks = _ref.tasks,
3358
+ dates = _ref.dates,
3359
+ ganttEvent = _ref.ganttEvent,
3360
+ selectedTask = _ref.selectedTask,
3361
+ rowHeight = _ref.rowHeight,
3362
+ columnWidth = _ref.columnWidth,
3363
+ timeStep = _ref.timeStep,
3364
+ svg = _ref.svg,
3365
+ taskHeight = _ref.taskHeight,
3366
+ arrowIndent = _ref.arrowIndent,
3367
+ fontFamily = _ref.fontFamily,
3368
+ fontSize = _ref.fontSize,
3369
+ rtl = _ref.rtl,
3370
+ _ref$virtualItems = _ref.virtualItems,
3371
+ virtualItems = _ref$virtualItems === void 0 ? [] : _ref$virtualItems,
3372
+ setGanttEvent = _ref.setGanttEvent,
3373
+ setFailedTask = _ref.setFailedTask,
3374
+ setSelectedTask = _ref.setSelectedTask,
3375
+ onBarTasksUpdate = _ref.onBarTasksUpdate,
3376
+ onDateChange = _ref.onDateChange,
3377
+ onProgressChange = _ref.onProgressChange,
3378
+ onDoubleClick = _ref.onDoubleClick,
3379
+ onClick = _ref.onClick,
3380
+ onDelete = _ref.onDelete,
3381
+ onCalendarError = _ref.onCalendarError,
3382
+ projectCalendar = _ref.projectCalendar,
3383
+ visibleStartY = _ref.visibleStartY,
3384
+ visibleEndY = _ref.visibleEndY,
3385
+ sliderTime = _ref.sliderTime;
3386
+ var point = svg === null || svg === void 0 ? void 0 : (_svg$current = svg.current) === null || _svg$current === void 0 ? void 0 : _svg$current.createSVGPoint();
3387
+
3388
+ var _useState = React.useState(0),
3389
+ xStep = _useState[0],
3390
+ setXStep = _useState[1];
3391
+
3392
+ var _useState2 = React.useState(0),
3393
+ initEventX1Delta = _useState2[0],
3394
+ setInitEventX1Delta = _useState2[1];
3395
+
3396
+ var _useState3 = React.useState(false),
3397
+ isMoving = _useState3[0],
3398
+ setIsMoving = _useState3[1];
3399
+
3400
+ React.useEffect(function () {
3250
3401
  if (dates.length < 2) {
3251
3402
  setXStep(timeStep * columnWidth / 86400000);
3252
3403
  return;
3253
3404
  }
3254
3405
 
3255
- const dateDelta = dates[1].getTime() - dates[0].getTime() - dates[1].getTimezoneOffset() * 60 * 1000 + dates[0].getTimezoneOffset() * 60 * 1000;
3256
- const newXStep = timeStep * columnWidth / dateDelta;
3406
+ var dateDelta = dates[1].getTime() - dates[0].getTime() - dates[1].getTimezoneOffset() * 60 * 1000 + dates[0].getTimezoneOffset() * 60 * 1000;
3407
+ var newXStep = timeStep * columnWidth / dateDelta;
3257
3408
  setXStep(newXStep);
3258
3409
  }, [columnWidth, dates, timeStep]);
3259
- React.useEffect(() => {
3260
- const handleMouseMove = function (event) {
3410
+ React.useEffect(function () {
3411
+ var handleMouseMove = function handleMouseMove(event) {
3261
3412
  try {
3262
3413
  var _svg$current$getScree;
3263
3414
 
3264
3415
  if (!ganttEvent.changedTask || !point || !(svg !== null && svg !== void 0 && svg.current)) return Promise.resolve();
3265
3416
  event.preventDefault();
3266
3417
  point.x = event.clientX;
3267
- const cursor = point.matrixTransform(svg === null || svg === void 0 ? void 0 : (_svg$current$getScree = svg.current.getScreenCTM()) === null || _svg$current$getScree === void 0 ? void 0 : _svg$current$getScree.inverse());
3268
- const {
3269
- isChanged,
3270
- changedTask
3271
- } = handleTaskBySVGMouseEvent(cursor.x, ganttEvent.action, ganttEvent.changedTask, ganttEvent.type, xStep, timeStep, initEventX1Delta, rtl);
3418
+ var cursor = point.matrixTransform(svg === null || svg === void 0 ? void 0 : (_svg$current$getScree = svg.current.getScreenCTM()) === null || _svg$current$getScree === void 0 ? void 0 : _svg$current$getScree.inverse());
3419
+
3420
+ var _handleTaskBySVGMouse = handleTaskBySVGMouseEvent(cursor.x, ganttEvent.action, ganttEvent.changedTask, ganttEvent.type, xStep, timeStep, initEventX1Delta, rtl),
3421
+ isChanged = _handleTaskBySVGMouse.isChanged,
3422
+ changedTask = _handleTaskBySVGMouse.changedTask;
3272
3423
 
3273
3424
  if (isChanged) {
3274
- let finalTask = { ...changedTask
3275
- };
3276
- const dragType = ganttEvent.type;
3425
+ var finalTask = _extends({}, changedTask);
3426
+
3427
+ var dragType = ganttEvent.type;
3277
3428
 
3278
3429
  if (changedTask.calendar && (ganttEvent.action === "end" || ganttEvent.action === "start" || ganttEvent.action === "move")) {
3279
- const cal = finalTask.calendar;
3430
+ var cal = finalTask.calendar;
3280
3431
 
3281
3432
  if (dragType === "actual") {
3282
3433
  if (ganttEvent.action === "end") {
3283
- const snapped = snapToWorkingTime(finalTask.actualEnd, cal, "forward");
3434
+ var snapped = snapToWorkingTime(finalTask.actualEnd, cal, "forward");
3284
3435
  finalTask.actualEnd = snapped;
3285
3436
  finalTask.actualx2 = taskXCoordinate(snapped, dates, columnWidth);
3286
3437
  } else if (ganttEvent.action === "start") {
3287
- const snapped = snapToWorkingTime(finalTask.actualStart, cal, "forward");
3288
- finalTask.actualStart = snapped;
3289
- finalTask.actualx1 = taskXCoordinate(snapped, dates, columnWidth);
3438
+ var _snapped = snapToWorkingTime(finalTask.actualStart, cal, "forward");
3439
+
3440
+ finalTask.actualStart = _snapped;
3441
+ finalTask.actualx1 = taskXCoordinate(_snapped, dates, columnWidth);
3290
3442
  } else {
3291
- const snapped = snapToWorkingTime(finalTask.actualStart, cal, "forward");
3292
- const delta = snapped.getTime() - finalTask.actualStart.getTime();
3293
- finalTask.actualStart = snapped;
3443
+ var _snapped2 = snapToWorkingTime(finalTask.actualStart, cal, "forward");
3444
+
3445
+ var delta = _snapped2.getTime() - finalTask.actualStart.getTime();
3446
+ finalTask.actualStart = _snapped2;
3294
3447
  finalTask.actualEnd = new Date(finalTask.actualEnd.getTime() + delta);
3295
3448
  finalTask.actualx1 = taskXCoordinate(finalTask.actualStart, dates, columnWidth);
3296
3449
  finalTask.actualx2 = taskXCoordinate(finalTask.actualEnd, dates, columnWidth);
3297
3450
  }
3298
3451
 
3299
- const actEnd = addToDate(startOfDate(finalTask.actualEnd, "day"), 1, "day");
3300
- const actIntervals = getWorkingIntervals(finalTask.actualStart, actEnd, cal);
3301
- const actSegs = actIntervals.map(iv => ({
3302
- x1: taskXCoordinate(iv.start, dates, columnWidth),
3303
- x2: taskXCoordinate(iv.end, dates, columnWidth)
3304
- })).filter(s => s.x2 > s.x1);
3452
+ var actEnd = addToDate(startOfDate(finalTask.actualEnd, "day"), 1, "day");
3453
+ var actIntervals = getWorkingIntervals(finalTask.actualStart, actEnd, cal);
3454
+ var actSegs = actIntervals.map(function (iv) {
3455
+ return {
3456
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
3457
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
3458
+ };
3459
+ }).filter(function (s) {
3460
+ return s.x2 > s.x1;
3461
+ });
3305
3462
  finalTask.actualSegments = actSegs.length > 0 ? actSegs : undefined;
3306
- const actDays = Math.max(1, Math.round((finalTask.actualEnd.getTime() - finalTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3463
+ var actDays = Math.max(1, Math.round((finalTask.actualEnd.getTime() - finalTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3307
3464
  finalTask.actualDuration = actDays;
3308
3465
  } else {
3309
3466
  if (ganttEvent.action === "end") {
3310
- const snapped = snapToWorkingTime(finalTask.end, cal, "forward");
3311
- finalTask.end = snapped;
3312
- finalTask.x2 = taskXCoordinate(snapped, dates, columnWidth);
3467
+ var _snapped3 = snapToWorkingTime(finalTask.end, cal, "forward");
3468
+
3469
+ finalTask.end = _snapped3;
3470
+ finalTask.x2 = taskXCoordinate(_snapped3, dates, columnWidth);
3313
3471
  } else if (ganttEvent.action === "start") {
3314
- const snapped = snapToWorkingTime(finalTask.start, cal, "forward");
3315
- finalTask.start = snapped;
3316
- finalTask.x1 = taskXCoordinate(snapped, dates, columnWidth);
3472
+ var _snapped4 = snapToWorkingTime(finalTask.start, cal, "forward");
3473
+
3474
+ finalTask.start = _snapped4;
3475
+ finalTask.x1 = taskXCoordinate(_snapped4, dates, columnWidth);
3317
3476
  } else {
3318
- const snapped = snapToWorkingTime(finalTask.start, cal, "forward");
3319
- const delta = snapped.getTime() - finalTask.start.getTime();
3320
- finalTask.start = snapped;
3321
- finalTask.end = new Date(finalTask.end.getTime() + delta);
3477
+ var _snapped5 = snapToWorkingTime(finalTask.start, cal, "forward");
3478
+
3479
+ var _delta = _snapped5.getTime() - finalTask.start.getTime();
3480
+
3481
+ finalTask.start = _snapped5;
3482
+ finalTask.end = new Date(finalTask.end.getTime() + _delta);
3322
3483
  finalTask.x1 = taskXCoordinate(finalTask.start, dates, columnWidth);
3323
3484
  finalTask.x2 = taskXCoordinate(finalTask.end, dates, columnWidth);
3324
3485
  }
3325
3486
 
3326
- const planEnd = addToDate(startOfDate(finalTask.end, "day"), 1, "day");
3327
- const planIntervals = getWorkingIntervals(finalTask.start, planEnd, cal);
3328
- const planSegs = planIntervals.map(iv => ({
3329
- x1: taskXCoordinate(iv.start, dates, columnWidth),
3330
- x2: taskXCoordinate(iv.end, dates, columnWidth)
3331
- })).filter(s => s.x2 > s.x1);
3487
+ var planEnd = addToDate(startOfDate(finalTask.end, "day"), 1, "day");
3488
+ var planIntervals = getWorkingIntervals(finalTask.start, planEnd, cal);
3489
+ var planSegs = planIntervals.map(function (iv) {
3490
+ return {
3491
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
3492
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
3493
+ };
3494
+ }).filter(function (s) {
3495
+ return s.x2 > s.x1;
3496
+ });
3332
3497
  finalTask.plannedSegments = planSegs.length > 0 ? planSegs : undefined;
3333
- const planDays = Math.max(1, Math.round((finalTask.end.getTime() - finalTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3498
+ var planDays = Math.max(1, Math.round((finalTask.end.getTime() - finalTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3334
3499
  finalTask.plannedDuration = planDays;
3335
3500
  }
3336
3501
  } else {
3337
3502
  if (dragType === "actual") {
3338
- const actDays = Math.max(1, Math.round((finalTask.actualEnd.getTime() - finalTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3339
- finalTask.actualDuration = actDays;
3503
+ var _actDays = Math.max(1, Math.round((finalTask.actualEnd.getTime() - finalTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3504
+
3505
+ finalTask.actualDuration = _actDays;
3340
3506
  } else {
3341
- const planDays = Math.max(1, Math.round((finalTask.end.getTime() - finalTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3342
- finalTask.plannedDuration = planDays;
3507
+ var _planDays = Math.max(1, Math.round((finalTask.end.getTime() - finalTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3508
+
3509
+ finalTask.plannedDuration = _planDays;
3343
3510
  }
3344
3511
  }
3345
3512
 
@@ -3356,42 +3523,41 @@ const TaskGanttContent = _ref => {
3356
3523
  }
3357
3524
  };
3358
3525
 
3359
- const handleMouseUp = function (event) {
3526
+ var handleMouseUp = function handleMouseUp(event) {
3360
3527
  try {
3361
3528
  var _svg$current$getScree2;
3362
3529
 
3363
- function _temp5() {
3530
+ var _temp6 = function _temp6() {
3364
3531
  if (!operationSuccess) {
3365
3532
  setFailedTask(originalSelectedTask);
3366
3533
  }
3367
- }
3534
+ };
3368
3535
 
3369
- const {
3370
- action,
3371
- originalSelectedTask,
3372
- changedTask,
3373
- type
3374
- } = ganttEvent;
3536
+ var action = ganttEvent.action,
3537
+ originalSelectedTask = ganttEvent.originalSelectedTask,
3538
+ changedTask = ganttEvent.changedTask,
3539
+ type = ganttEvent.type;
3375
3540
  if (!changedTask || !point || !(svg !== null && svg !== void 0 && svg.current) || !originalSelectedTask) return Promise.resolve();
3376
3541
  event.preventDefault();
3377
3542
  point.x = event.clientX;
3378
- const cursor = point.matrixTransform(svg === null || svg === void 0 ? void 0 : (_svg$current$getScree2 = svg.current.getScreenCTM()) === null || _svg$current$getScree2 === void 0 ? void 0 : _svg$current$getScree2.inverse());
3379
- const {
3380
- changedTask: newChangedTask
3381
- } = handleTaskBySVGMouseEvent(cursor.x, action, changedTask, type, xStep, timeStep, initEventX1Delta, rtl);
3382
- const isNotLikeOriginal = originalSelectedTask.start !== newChangedTask.start || originalSelectedTask.end !== newChangedTask.end || originalSelectedTask.actualStart !== newChangedTask.actualStart || originalSelectedTask.actualEnd !== newChangedTask.actualEnd || originalSelectedTask.progress !== newChangedTask.progress;
3383
- const dropType = type;
3543
+ var cursor = point.matrixTransform(svg === null || svg === void 0 ? void 0 : (_svg$current$getScree2 = svg.current.getScreenCTM()) === null || _svg$current$getScree2 === void 0 ? void 0 : _svg$current$getScree2.inverse());
3544
+
3545
+ var _handleTaskBySVGMouse2 = handleTaskBySVGMouseEvent(cursor.x, action, changedTask, type, xStep, timeStep, initEventX1Delta, rtl),
3546
+ newChangedTask = _handleTaskBySVGMouse2.changedTask;
3547
+
3548
+ var isNotLikeOriginal = originalSelectedTask.start !== newChangedTask.start || originalSelectedTask.end !== newChangedTask.end || originalSelectedTask.actualStart !== newChangedTask.actualStart || originalSelectedTask.actualEnd !== newChangedTask.actualEnd || originalSelectedTask.progress !== newChangedTask.progress;
3549
+ var dropType = type;
3384
3550
 
3385
3551
  if (newChangedTask.calendar && (action === "move" || action === "end" || action === "start")) {
3386
- const cal = newChangedTask.calendar;
3552
+ var cal = newChangedTask.calendar;
3387
3553
 
3388
3554
  if (dropType === "actual") {
3389
3555
  if (action === "end") {
3390
- const snappedEnd = snapToWorkingTime(newChangedTask.actualEnd, cal, "forward");
3556
+ var snappedEnd = snapToWorkingTime(newChangedTask.actualEnd, cal, "forward");
3391
3557
  newChangedTask.actualEnd = snappedEnd;
3392
3558
  newChangedTask.actualx2 = taskXCoordinate(snappedEnd, dates, columnWidth);
3393
3559
  } else if (action === "start") {
3394
- const snappedStart = snapToWorkingTime(newChangedTask.actualStart, cal, "forward");
3560
+ var snappedStart = snapToWorkingTime(newChangedTask.actualStart, cal, "forward");
3395
3561
 
3396
3562
  if (snappedStart >= newChangedTask.actualEnd) {
3397
3563
  setFailedTask(originalSelectedTask);
@@ -3408,32 +3574,38 @@ const TaskGanttContent = _ref => {
3408
3574
  newChangedTask.actualStart = snappedStart;
3409
3575
  newChangedTask.actualx1 = taskXCoordinate(snappedStart, dates, columnWidth);
3410
3576
  } else {
3411
- const snappedStart = snapToWorkingTime(newChangedTask.actualStart, cal, "forward");
3412
- const delta = snappedStart.getTime() - newChangedTask.actualStart.getTime();
3413
- newChangedTask.actualStart = snappedStart;
3577
+ var _snappedStart = snapToWorkingTime(newChangedTask.actualStart, cal, "forward");
3578
+
3579
+ var delta = _snappedStart.getTime() - newChangedTask.actualStart.getTime();
3580
+ newChangedTask.actualStart = _snappedStart;
3414
3581
  newChangedTask.actualEnd = new Date(newChangedTask.actualEnd.getTime() + delta);
3415
- newChangedTask.actualx1 = taskXCoordinate(snappedStart, dates, columnWidth);
3582
+ newChangedTask.actualx1 = taskXCoordinate(_snappedStart, dates, columnWidth);
3416
3583
  newChangedTask.actualx2 = taskXCoordinate(newChangedTask.actualEnd, dates, columnWidth);
3417
3584
  }
3418
3585
 
3419
- const actEnd = addToDate(startOfDate(newChangedTask.actualEnd, "day"), 1, "day");
3420
- const actIntervals = getWorkingIntervals(newChangedTask.actualStart, actEnd, cal);
3421
- const actSegs = actIntervals.map(iv => ({
3422
- x1: taskXCoordinate(iv.start, dates, columnWidth),
3423
- x2: taskXCoordinate(iv.end, dates, columnWidth)
3424
- })).filter(s => s.x2 > s.x1);
3586
+ var actEnd = addToDate(startOfDate(newChangedTask.actualEnd, "day"), 1, "day");
3587
+ var actIntervals = getWorkingIntervals(newChangedTask.actualStart, actEnd, cal);
3588
+ var actSegs = actIntervals.map(function (iv) {
3589
+ return {
3590
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
3591
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
3592
+ };
3593
+ }).filter(function (s) {
3594
+ return s.x2 > s.x1;
3595
+ });
3425
3596
  newChangedTask.actualSegments = actSegs.length > 0 ? actSegs : undefined;
3426
- const actDays = Math.max(1, Math.round((newChangedTask.actualEnd.getTime() - newChangedTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3597
+ var actDays = Math.max(1, Math.round((newChangedTask.actualEnd.getTime() - newChangedTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3427
3598
  newChangedTask.actualDuration = actDays;
3428
3599
  } else {
3429
3600
  if (action === "end") {
3430
- const snappedEnd = snapToWorkingTime(newChangedTask.end, cal, "forward");
3431
- newChangedTask.end = snappedEnd;
3432
- newChangedTask.x2 = taskXCoordinate(snappedEnd, dates, columnWidth);
3601
+ var _snappedEnd = snapToWorkingTime(newChangedTask.end, cal, "forward");
3602
+
3603
+ newChangedTask.end = _snappedEnd;
3604
+ newChangedTask.x2 = taskXCoordinate(_snappedEnd, dates, columnWidth);
3433
3605
  } else if (action === "start") {
3434
- const snappedStart = snapToWorkingTime(newChangedTask.start, cal, "forward");
3606
+ var _snappedStart2 = snapToWorkingTime(newChangedTask.start, cal, "forward");
3435
3607
 
3436
- if (snappedStart >= newChangedTask.end) {
3608
+ if (_snappedStart2 >= newChangedTask.end) {
3437
3609
  setFailedTask(originalSelectedTask);
3438
3610
  onCalendarError === null || onCalendarError === void 0 ? void 0 : onCalendarError(newChangedTask, "No working time in selected range");
3439
3611
  setGanttEvent({
@@ -3445,34 +3617,42 @@ const TaskGanttContent = _ref => {
3445
3617
  return Promise.resolve();
3446
3618
  }
3447
3619
 
3448
- newChangedTask.start = snappedStart;
3449
- newChangedTask.x1 = taskXCoordinate(snappedStart, dates, columnWidth);
3620
+ newChangedTask.start = _snappedStart2;
3621
+ newChangedTask.x1 = taskXCoordinate(_snappedStart2, dates, columnWidth);
3450
3622
  } else {
3451
- const snappedStart = snapToWorkingTime(newChangedTask.start, cal, "forward");
3452
- const delta = snappedStart.getTime() - newChangedTask.start.getTime();
3453
- newChangedTask.start = snappedStart;
3454
- newChangedTask.end = new Date(newChangedTask.end.getTime() + delta);
3455
- newChangedTask.x1 = taskXCoordinate(snappedStart, dates, columnWidth);
3623
+ var _snappedStart3 = snapToWorkingTime(newChangedTask.start, cal, "forward");
3624
+
3625
+ var _delta2 = _snappedStart3.getTime() - newChangedTask.start.getTime();
3626
+
3627
+ newChangedTask.start = _snappedStart3;
3628
+ newChangedTask.end = new Date(newChangedTask.end.getTime() + _delta2);
3629
+ newChangedTask.x1 = taskXCoordinate(_snappedStart3, dates, columnWidth);
3456
3630
  newChangedTask.x2 = taskXCoordinate(newChangedTask.end, dates, columnWidth);
3457
3631
  }
3458
3632
 
3459
- const planEnd = addToDate(startOfDate(newChangedTask.end, "day"), 1, "day");
3460
- const planIntervals = getWorkingIntervals(newChangedTask.start, planEnd, cal);
3461
- const planSegs = planIntervals.map(iv => ({
3462
- x1: taskXCoordinate(iv.start, dates, columnWidth),
3463
- x2: taskXCoordinate(iv.end, dates, columnWidth)
3464
- })).filter(s => s.x2 > s.x1);
3633
+ var planEnd = addToDate(startOfDate(newChangedTask.end, "day"), 1, "day");
3634
+ var planIntervals = getWorkingIntervals(newChangedTask.start, planEnd, cal);
3635
+ var planSegs = planIntervals.map(function (iv) {
3636
+ return {
3637
+ x1: taskXCoordinate(iv.start, dates, columnWidth),
3638
+ x2: taskXCoordinate(iv.end, dates, columnWidth)
3639
+ };
3640
+ }).filter(function (s) {
3641
+ return s.x2 > s.x1;
3642
+ });
3465
3643
  newChangedTask.plannedSegments = planSegs.length > 0 ? planSegs : undefined;
3466
- const planDays = Math.max(1, Math.round((newChangedTask.end.getTime() - newChangedTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3644
+ var planDays = Math.max(1, Math.round((newChangedTask.end.getTime() - newChangedTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3467
3645
  newChangedTask.plannedDuration = planDays;
3468
3646
  }
3469
3647
  } else if (action === "move" || action === "end" || action === "start") {
3470
3648
  if (dropType === "actual") {
3471
- const actDays = Math.max(1, Math.round((newChangedTask.actualEnd.getTime() - newChangedTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3472
- newChangedTask.actualDuration = actDays;
3649
+ var _actDays2 = Math.max(1, Math.round((newChangedTask.actualEnd.getTime() - newChangedTask.actualStart.getTime()) / (1000 * 60 * 60 * 24)));
3650
+
3651
+ newChangedTask.actualDuration = _actDays2;
3473
3652
  } else {
3474
- const planDays = Math.max(1, Math.round((newChangedTask.end.getTime() - newChangedTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3475
- newChangedTask.plannedDuration = planDays;
3653
+ var _planDays2 = Math.max(1, Math.round((newChangedTask.end.getTime() - newChangedTask.start.getTime()) / (1000 * 60 * 60 * 24)));
3654
+
3655
+ newChangedTask.plannedDuration = _planDays2;
3476
3656
  }
3477
3657
  }
3478
3658
 
@@ -3487,11 +3667,11 @@ const TaskGanttContent = _ref => {
3487
3667
  action: ""
3488
3668
  });
3489
3669
  setIsMoving(false);
3490
- let operationSuccess = true;
3670
+ var operationSuccess = true;
3491
3671
 
3492
- const _temp4 = function () {
3672
+ var _temp7 = function () {
3493
3673
  if ((action === "move" || action === "end" || action === "start") && onDateChange && isNotLikeOriginal) {
3494
- const _temp = _catch(function () {
3674
+ var _temp8 = _catch(function () {
3495
3675
  return Promise.resolve(onDateChange(newChangedTask, newChangedTask.barChildren)).then(function (result) {
3496
3676
  if (result !== undefined) {
3497
3677
  operationSuccess = result;
@@ -3501,11 +3681,11 @@ const TaskGanttContent = _ref => {
3501
3681
  operationSuccess = false;
3502
3682
  });
3503
3683
 
3504
- if (_temp && _temp.then) return _temp.then(function () {});
3684
+ if (_temp8 && _temp8.then) return _temp8.then(function () {});
3505
3685
  } else {
3506
- const _temp3 = function () {
3686
+ var _temp9 = function () {
3507
3687
  if (onProgressChange && isNotLikeOriginal) {
3508
- const _temp2 = _catch(function () {
3688
+ var _temp10 = _catch(function () {
3509
3689
  return Promise.resolve(onProgressChange(newChangedTask, newChangedTask.barChildren)).then(function (result) {
3510
3690
  if (result !== undefined) {
3511
3691
  operationSuccess = result;
@@ -3515,15 +3695,15 @@ const TaskGanttContent = _ref => {
3515
3695
  operationSuccess = false;
3516
3696
  });
3517
3697
 
3518
- if (_temp2 && _temp2.then) return _temp2.then(function () {});
3698
+ if (_temp10 && _temp10.then) return _temp10.then(function () {});
3519
3699
  }
3520
3700
  }();
3521
3701
 
3522
- if (_temp3 && _temp3.then) return _temp3.then(function () {});
3702
+ if (_temp9 && _temp9.then) return _temp9.then(function () {});
3523
3703
  }
3524
3704
  }();
3525
3705
 
3526
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
3706
+ return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(_temp6) : _temp6(_temp7));
3527
3707
  } catch (e) {
3528
3708
  return Promise.reject(e);
3529
3709
  }
@@ -3536,7 +3716,7 @@ const TaskGanttContent = _ref => {
3536
3716
  }
3537
3717
  }, [ganttEvent, xStep, initEventX1Delta, onProgressChange, timeStep, onDateChange, onCalendarError, projectCalendar, svg, isMoving, point, rtl, setFailedTask, setGanttEvent, onBarTasksUpdate, dates, columnWidth]);
3538
3718
 
3539
- const handleBarEventStart = function (action, task, event, type) {
3719
+ var handleBarEventStart = function handleBarEventStart(action, task, event, type) {
3540
3720
  try {
3541
3721
  return Promise.resolve(function () {
3542
3722
  if (!event) {
@@ -3545,15 +3725,15 @@ const TaskGanttContent = _ref => {
3545
3725
  }
3546
3726
  } else return function () {
3547
3727
  if (isKeyboardEvent(event)) {
3548
- const _temp8 = function () {
3728
+ var _temp14 = function () {
3549
3729
  if (action === "delete") {
3550
- const _temp7 = function () {
3730
+ var _temp15 = function () {
3551
3731
  if (onDelete) {
3552
- const _temp6 = _catch(function () {
3732
+ var _temp16 = _catch(function () {
3553
3733
  return Promise.resolve(onDelete(task)).then(function (result) {
3554
3734
  if (result !== undefined && result) {
3555
3735
  setGanttEvent({
3556
- action,
3736
+ action: action,
3557
3737
  changedTask: task
3558
3738
  });
3559
3739
  }
@@ -3562,19 +3742,19 @@ const TaskGanttContent = _ref => {
3562
3742
  console.error("Error on Delete. " + error);
3563
3743
  });
3564
3744
 
3565
- if (_temp6 && _temp6.then) return _temp6.then(function () {});
3745
+ if (_temp16 && _temp16.then) return _temp16.then(function () {});
3566
3746
  }
3567
3747
  }();
3568
3748
 
3569
- if (_temp7 && _temp7.then) return _temp7.then(function () {});
3749
+ if (_temp15 && _temp15.then) return _temp15.then(function () {});
3570
3750
  }
3571
3751
  }();
3572
3752
 
3573
- if (_temp8 && _temp8.then) return _temp8.then(function () {});
3753
+ if (_temp14 && _temp14.then) return _temp14.then(function () {});
3574
3754
  } else if (action === "mouseenter") {
3575
3755
  if (!ganttEvent.action) {
3576
3756
  setGanttEvent({
3577
- action,
3757
+ action: action,
3578
3758
  changedTask: task,
3579
3759
  originalSelectedTask: task,
3580
3760
  type: type
@@ -3595,17 +3775,17 @@ const TaskGanttContent = _ref => {
3595
3775
 
3596
3776
  if (!(svg !== null && svg !== void 0 && svg.current) || !point) return;
3597
3777
  point.x = event.clientX;
3598
- const cursor = point.matrixTransform((_svg$current$getScree3 = svg.current.getScreenCTM()) === null || _svg$current$getScree3 === void 0 ? void 0 : _svg$current$getScree3.inverse());
3778
+ var cursor = point.matrixTransform((_svg$current$getScree3 = svg.current.getScreenCTM()) === null || _svg$current$getScree3 === void 0 ? void 0 : _svg$current$getScree3.inverse());
3599
3779
  if (type == "planned") setInitEventX1Delta(cursor.x - task.x1);else if (type == "actual") setInitEventX1Delta(cursor.x - task.actualx1);
3600
3780
  setGanttEvent({
3601
- action,
3781
+ action: action,
3602
3782
  changedTask: task,
3603
3783
  originalSelectedTask: task,
3604
3784
  type: type
3605
3785
  });
3606
3786
  } else {
3607
3787
  setGanttEvent({
3608
- action,
3788
+ action: action,
3609
3789
  changedTask: task,
3610
3790
  originalSelectedTask: task,
3611
3791
  type: type
@@ -3618,60 +3798,77 @@ const TaskGanttContent = _ref => {
3618
3798
  }
3619
3799
  };
3620
3800
 
3621
- const getArrows = (isCritical, criticalPathType) => {
3622
- return tasks.flatMap(_task => {
3623
- const a = ganttEvent.action;
3624
- const isDraggingThis = (a === "move" || a === "start" || a === "end" || a === "progress") && !!ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id;
3625
-
3626
- const _live = isDraggingThis ? { ...ganttEvent.changedTask,
3627
- y: _task.y
3628
- } : _task;
3629
-
3630
- const task = _live.start.getTime() > 0 && _live.end.getTime() > 0 ? _live : undefined;
3631
-
3632
- if (!task) {
3633
- return [];
3801
+ var arrowIndex = React__default.useMemo(function () {
3802
+ var entries = [];
3803
+
3804
+ for (var i = 0; i < tasks.length; i++) {
3805
+ var task = tasks[i];
3806
+ var yFrom = task.y + taskHeight / 2;
3807
+
3808
+ for (var _iterator = _createForOfIteratorHelperLoose(task.barChildren), _step; !(_step = _iterator()).done;) {
3809
+ var child = _step.value;
3810
+ var taskTo = tasks[child.index];
3811
+ if (!taskTo) continue;
3812
+ var yTo = taskTo.y + taskHeight / 2;
3813
+ entries.push({
3814
+ from: i,
3815
+ to: child.index,
3816
+ minY: Math.min(yFrom, yTo),
3817
+ maxY: Math.max(yFrom, yTo),
3818
+ dependencyType: child.dependencyType
3819
+ });
3634
3820
  }
3821
+ }
3635
3822
 
3636
- return task.barChildren.map(child => {
3637
- const taskTo = tasks[child.index];
3638
- const fromDrawable = task.x2 > task.x1 || task.actualx2 > task.actualx1;
3639
- const toDrawable = !!taskTo && (taskTo.x2 > taskTo.x1 || taskTo.actualx2 > taskTo.actualx1);
3823
+ return entries;
3824
+ }, [tasks, taskHeight]);
3640
3825
 
3641
- if (fromDrawable && toDrawable) {
3642
- var _task$criticalPathArr;
3826
+ var getArrows = function getArrows(isCritical, criticalPathType) {
3827
+ var out = [];
3828
+ var a = ganttEvent.action;
3829
+ var dragging = (a === "move" || a === "start" || a === "end" || a === "progress") && !!ganttEvent.changedTask;
3643
3830
 
3644
- const criticalTask = (_task$criticalPathArr = task.criticalPathArrows) === null || _task$criticalPathArr === void 0 ? void 0 : _task$criticalPathArr.find(arrow => arrow.taskId === taskTo.id && (!!arrow.criticalPathType ? arrow.criticalPathType === criticalPathType : !criticalPathType));
3645
- const yFrom = task.y + taskHeight / 2;
3646
- const yTo = taskTo.y + taskHeight / 2;
3647
- const minY = Math.min(yFrom, yTo);
3648
- const maxY = Math.max(yFrom, yTo);
3831
+ var _loop = function _loop() {
3832
+ var _task$criticalPathArr;
3649
3833
 
3650
- if (maxY < visibleStartY || minY > visibleEndY) {
3651
- return null;
3652
- }
3834
+ var e = _step2.value;
3835
+ if (e.maxY < visibleStartY || e.minY > visibleEndY) return "continue";
3836
+ var _task = tasks[e.from];
3837
+ var task = dragging && ganttEvent.changedTask.id === _task.id ? _extends({}, ganttEvent.changedTask, {
3838
+ y: _task.y
3839
+ }) : _task;
3840
+ if (!(task.start.getTime() > 0 && task.end.getTime() > 0)) return "continue";
3841
+ var taskTo = tasks[e.to];
3842
+ var fromDrawable = task.x2 > task.x1 || task.actualx2 > task.actualx1;
3843
+ var toDrawable = taskTo.x2 > taskTo.x1 || taskTo.actualx2 > taskTo.actualx1;
3844
+ if (!fromDrawable || !toDrawable) return "continue";
3845
+ var criticalTask = (_task$criticalPathArr = task.criticalPathArrows) === null || _task$criticalPathArr === void 0 ? void 0 : _task$criticalPathArr.find(function (arrow) {
3846
+ return arrow.taskId === taskTo.id && (!!arrow.criticalPathType ? arrow.criticalPathType === criticalPathType : !criticalPathType);
3847
+ });
3848
+ if (!!criticalTask !== isCritical) return "continue";
3849
+ out.push(React__default.createElement(Arrow, {
3850
+ key: "Arrow from " + task.id + " to " + taskTo.id + (isCritical ? "-critical" : ""),
3851
+ taskFrom: task,
3852
+ taskTo: taskTo,
3853
+ rowHeight: rowHeight,
3854
+ dependencyType: e.dependencyType,
3855
+ taskHeight: taskHeight,
3856
+ arrowIndent: arrowIndent,
3857
+ arrowColor: (criticalTask === null || criticalTask === void 0 ? void 0 : criticalTask.arrowColor) || "#808080"
3858
+ }));
3859
+ };
3653
3860
 
3654
- if (!!criticalTask === isCritical) {
3655
- return React__default.createElement(Arrow, {
3656
- key: `Arrow from ${task.id} to ${taskTo.id}${isCritical ? "-critical" : ""}`,
3657
- taskFrom: task,
3658
- taskTo: taskTo,
3659
- rowHeight: rowHeight,
3660
- dependencyType: child.dependencyType,
3661
- taskHeight: taskHeight,
3662
- arrowIndent: arrowIndent,
3663
- arrowColor: (criticalTask === null || criticalTask === void 0 ? void 0 : criticalTask.arrowColor) || "#808080"
3664
- });
3665
- }
3666
- }
3861
+ for (var _iterator2 = _createForOfIteratorHelperLoose(arrowIndex), _step2; !(_step2 = _iterator2()).done;) {
3862
+ var _ret = _loop();
3667
3863
 
3668
- return null;
3669
- }).filter(Boolean);
3670
- });
3864
+ if (_ret === "continue") continue;
3865
+ }
3866
+
3867
+ return out;
3671
3868
  };
3672
3869
 
3673
- const lineX = sliderTime !== undefined ? taskXCoordinate(new Date(sliderTime), dates, columnWidth) : null;
3674
- const totalHeight = tasks.length * rowHeight;
3870
+ var lineX = sliderTime !== undefined ? taskXCoordinate(new Date(sliderTime), dates, columnWidth) : null;
3871
+ var totalHeight = tasks.length * rowHeight;
3675
3872
  return React__default.createElement("g", {
3676
3873
  className: "content"
3677
3874
  }, lineX !== null && lineX > 0 && React__default.createElement("line", {
@@ -3689,18 +3886,18 @@ const TaskGanttContent = _ref => {
3689
3886
  className: "bar",
3690
3887
  fontFamily: fontFamily,
3691
3888
  fontSize: fontSize
3692
- }, virtualItems.map(vi => {
3693
- const _task = tasks[vi.index];
3694
- const task = ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id ? { ...ganttEvent.changedTask,
3889
+ }, virtualItems.map(function (vi) {
3890
+ var _task = tasks[vi.index];
3891
+ var task = ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id ? _extends({}, ganttEvent.changedTask, {
3695
3892
  y: 0
3696
- } : { ..._task,
3893
+ }) : _extends({}, _task, {
3697
3894
  y: 0
3698
- };
3895
+ });
3699
3896
 
3700
3897
  if (!task && _task.typeInternal === "milestone") {
3701
3898
  return React__default.createElement("g", {
3702
3899
  key: _task.id,
3703
- transform: `translate(0, ${vi.start})`
3900
+ transform: "translate(0, " + vi.start + ")"
3704
3901
  }, React__default.createElement(Milestone, {
3705
3902
  task: task,
3706
3903
  arrowIndent: arrowIndent,
@@ -3717,7 +3914,7 @@ const TaskGanttContent = _ref => {
3717
3914
  if (!task) {
3718
3915
  return React__default.createElement("g", {
3719
3916
  key: _task.id,
3720
- transform: `translate(0, ${vi.start})`,
3917
+ transform: "translate(0, " + vi.start + ")",
3721
3918
  style: {
3722
3919
  height: taskHeight
3723
3920
  }
@@ -3726,7 +3923,7 @@ const TaskGanttContent = _ref => {
3726
3923
 
3727
3924
  return React__default.createElement("g", {
3728
3925
  key: task.id,
3729
- transform: `translate(0, ${vi.start})`
3926
+ transform: "translate(0, " + vi.start + ")"
3730
3927
  }, React__default.createElement(TaskItem, {
3731
3928
  task: task,
3732
3929
  arrowIndent: arrowIndent,
@@ -3851,7 +4048,7 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
3851
4048
  var GANTT_MIN_WIDTH_RATIO = 0.4;
3852
4049
  var TABLE_GANTT_DIVIDER_WIDTH = 20;
3853
4050
  var Gantt = function Gantt(_ref) {
3854
- var _ref2;
4051
+ var _ref3;
3855
4052
 
3856
4053
  var tasks = _ref.tasks,
3857
4054
  primaryPath = _ref.primaryPath,
@@ -3965,9 +4162,9 @@ var Gantt = function Gantt(_ref) {
3965
4162
  setTableContentWidth = _useState2[1];
3966
4163
 
3967
4164
  var _useState3 = React.useState(function () {
3968
- var _ganttDateRange = ganttDateRange(tasks, viewMode, preStepsCount),
3969
- startDateRange = _ganttDateRange[0],
3970
- endDateRange = _ganttDateRange[1];
4165
+ var _ref2 = tasks ? ganttDateRange(tasks, viewMode, preStepsCount) : [new Date(), new Date()],
4166
+ startDateRange = _ref2[0],
4167
+ endDateRange = _ref2[1];
3971
4168
 
3972
4169
  if (scheduleType === "lookAhead") {
3973
4170
  return {
@@ -4119,7 +4316,7 @@ var Gantt = function Gantt(_ref) {
4119
4316
  setComputedColumnWidth(next);
4120
4317
  }
4121
4318
  }, [viewMode, svgContainerWidth, columnWidthProp, computedColumnWidth]);
4122
- var columnWidth = (_ref2 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref2 : 60;
4319
+ var columnWidth = (_ref3 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref3 : 60;
4123
4320
  var effectiveColumnWidth = React.useMemo(function () {
4124
4321
  if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
4125
4322
 
@@ -4191,9 +4388,9 @@ var Gantt = function Gantt(_ref) {
4191
4388
  filteredTasks = removeHiddenTasks(tasks);
4192
4389
  filteredTasks = filteredTasks.sort(sortTasks);
4193
4390
 
4194
- var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_projectCalendar$quar = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar : 0),
4195
- startDateRange = _ganttDateRange2[0],
4196
- endDateRange = _ganttDateRange2[1];
4391
+ var _ganttDateRange = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_projectCalendar$quar = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar : 0),
4392
+ startDateRange = _ganttDateRange[0],
4393
+ endDateRange = _ganttDateRange[1];
4197
4394
 
4198
4395
  var newDates = seedDates(startDateRange, endDateRange, viewMode);
4199
4396
 
@@ -4223,7 +4420,8 @@ var Gantt = function Gantt(_ref) {
4223
4420
  colorPath(primaryPath, "#ff0000", tasks, "primary");
4224
4421
  }
4225
4422
 
4226
- setBarTasks(convertToBarTasks(filteredTasks, newDates, effectiveColumnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
4423
+ var nextBarTasks = convertToBarTasks(filteredTasks, newDates, effectiveColumnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor);
4424
+ setBarTasks(nextBarTasks);
4227
4425
  setIsProcessing(false);
4228
4426
  }, delayToRender);
4229
4427
  }, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay, effectiveColumnWidth, projectCalendar]);
@@ -4795,6 +4993,7 @@ function getCriticalPaths(leafTasks) {
4795
4993
  taskChainList.sort(function (a, b) {
4796
4994
  return b.duration - a.duration;
4797
4995
  });
4996
+ console.debug(taskChainList);
4798
4997
  var primaryLeaf = taskChainList[0].parent;
4799
4998
  var primaryPath = [];
4800
4999
 
@@ -4862,59 +5061,76 @@ function getCriticalPaths(leafTasks) {
4862
5061
  secondaryLeaf = _nextPath.task;
4863
5062
  }
4864
5063
 
4865
- console.debug("Primary", primaryPath);
4866
- console.debug("Secondary", secondaryPath);
5064
+ console.debug("Primary ", primaryPath);
5065
+ console.debug("Secondary ", secondaryPath);
4867
5066
  return [primaryPath, secondaryPath];
4868
5067
  }
4869
5068
 
4870
5069
  return [[], []];
4871
5070
  }
5071
+
5072
+ function getOffTime$1(tIndex, taskMap, start, end) {
5073
+ var startWeek = Math.floor((start / 86400000 + 4) / 7);
5074
+ var endWeek = Math.floor((end / 86400000 + 4) / 7);
5075
+ var offTime = [];
5076
+
5077
+ if (taskMap[tIndex].task.calendar) {
5078
+ if (taskMap[tIndex].task.calendar.off_days && taskMap[tIndex].task.calendar.off_days.length) {
5079
+ for (var d = 0; d < taskMap[tIndex].task.calendar.off_days.length || 0; d++) {
5080
+ for (var w = startWeek; w <= endWeek; w++) {
5081
+ var dayOfTheWeek = taskMap[tIndex].task.calendar.off_days[d];
5082
+ var offDay = 86400000 * (7 * w - 4 + dayOfTheWeek);
5083
+
5084
+ if (offDay >= start && offDay <= end) {
5085
+ offTime.push(offDay);
5086
+ }
5087
+ }
5088
+ }
5089
+ }
5090
+
5091
+ if (taskMap[tIndex].task.calendar.holidays && taskMap[tIndex].task.calendar.holidays.length) {
5092
+ for (var h = 0; h < taskMap[tIndex].task.calendar.holidays.length || 0; h++) {
5093
+ var holiday = taskMap[tIndex].task.calendar.holidays[h];
5094
+ var holiday_timestamp = new Date(holiday).getTime();
5095
+
5096
+ if (holiday_timestamp >= start && holiday_timestamp <= end) {
5097
+ offTime.push(holiday_timestamp);
5098
+ }
5099
+ }
5100
+ }
5101
+ }
5102
+
5103
+ return offTime;
5104
+ }
5105
+
4872
5106
  function computeCriticalPath(taskID, taskMap) {
4873
5107
  var task = taskMap[taskID].task;
4874
5108
  var dependents = taskMap[taskID].dependents;
4875
5109
  taskMap[taskID].start = task.start.getTime();
4876
5110
  taskMap[taskID].end = task.end.getTime();
4877
5111
  taskMap[taskID].paths = [];
5112
+ var parent_off_time = getOffTime$1(taskID, taskMap, taskMap[taskID].start, taskMap[taskID].end);
4878
5113
 
4879
5114
  for (var j = 0; j < dependents.length; j++) {
4880
5115
  var depStart = taskMap[dependents[j]].task.start.getTime();
4881
5116
  var depEnd = taskMap[dependents[j]].task.end.getTime();
4882
5117
  var depDuration = depEnd - depStart;
4883
- var startWeek = Math.floor((depStart / 86400000 + 4) / 7);
4884
- var endWeek = Math.floor((depEnd / 86400000 + 4) / 7);
4885
- var offTime = 0;
4886
-
4887
- if (taskMap[dependents[j]].task.calendar) {
4888
- if (taskMap[dependents[j]].task.calendar.off_days && taskMap[dependents[j]].task.calendar.off_days.length) {
4889
- for (var d = 0; d < taskMap[dependents[j]].task.calendar.off_days.length || 0; d++) {
4890
- for (var w = startWeek; w <= endWeek; w++) {
4891
- var dayOfTheWeek = taskMap[dependents[j]].task.calendar.off_days[d];
4892
- var offDay = 86400000 * (7 * w - 4 + dayOfTheWeek);
4893
-
4894
- if (offDay >= depStart && offDay <= depEnd && (offDay > taskMap[taskID].end || taskMap[taskID].task.calendar.off_days.includes(dayOfTheWeek))) {
4895
- offTime += 86400000;
4896
- }
4897
- }
4898
- }
4899
- }
4900
-
4901
- if (taskMap[dependents[j]].task.calendar.holidays && taskMap[dependents[j]].task.calendar.holidays.length) {
4902
- for (var h = 0; h < taskMap[dependents[j]].task.calendar.holidays.length || 0; h++) {
4903
- var holiday = taskMap[dependents[j]].task.calendar.holidays[h];
5118
+ var child_off_time = getOffTime$1(dependents[j], taskMap, depStart, depEnd);
5119
+ var overlap = Math.max(taskMap[taskID].end - depStart, 0);
4904
5120
 
4905
- if (holiday >= depStart && holiday <= depEnd) {
4906
- offTime += 86400000;
4907
- }
4908
- }
5121
+ for (var t = 0; t < parent_off_time.length; t++) {
5122
+ if (child_off_time.includes(parent_off_time[t])) {
5123
+ parent_off_time.splice(t, 1);
5124
+ t -= 1;
4909
5125
  }
4910
5126
  }
4911
5127
 
4912
- var overlap = Math.max(taskMap[taskID].end - depStart, 0);
5128
+ var offTime = parent_off_time.length + child_off_time.length;
4913
5129
  var paths = taskMap[dependents[j]].paths;
4914
5130
 
4915
5131
  if (paths && paths.length) {
4916
5132
  for (var k = 0; k < paths.length; k++) {
4917
- var totalDuration = taskMap[taskID].end - taskMap[taskID].start - overlap - offTime + paths[k].duration;
5133
+ var totalDuration = taskMap[taskID].end - taskMap[taskID].start - overlap - parent_off_time.length * 86400000 + paths[k].duration;
4918
5134
 
4919
5135
  if (taskMap[taskID].paths.length < 2) {
4920
5136
  taskMap[taskID].paths.push({
@@ -4936,7 +5152,7 @@ function computeCriticalPath(taskID, taskMap) {
4936
5152
  }
4937
5153
  }
4938
5154
  } else {
4939
- var immediateChildDuration = taskMap[taskID].end - taskMap[taskID].start + depDuration - overlap - offTime;
5155
+ var immediateChildDuration = taskMap[taskID].end - taskMap[taskID].start + depDuration - overlap - offTime * 86400000;
4940
5156
 
4941
5157
  if (taskMap[taskID].paths.length < 2) {
4942
5158
  taskMap[taskID].paths.push({
@@ -4966,22 +5182,28 @@ function uncolorAll(tasks) {
4966
5182
  });
4967
5183
  }
4968
5184
  function colorPath(path, color, tasks, criticalPathType) {
4969
- for (var i = 0; i < path.length; i++) {
4970
- var longestIDLength = 0;
4971
- var longestTask = void 0;
5185
+ var byId = new Map();
4972
5186
 
4973
- for (var j = 0; j < tasks.length; j++) {
4974
- if (path[i].id === tasks[j].id) {
4975
- longestTask = tasks[j];
4976
- break;
4977
- }
5187
+ for (var _iterator = _createForOfIteratorHelperLoose(tasks), _step; !(_step = _iterator()).done;) {
5188
+ var task = _step.value;
5189
+ byId.set(task.id, task);
5190
+ }
4978
5191
 
4979
- if (path[i].id.startsWith(tasks[j].id + ".") && tasks[j].id.length > longestIDLength) {
4980
- longestIDLength = tasks[j].id.length;
4981
- longestTask = tasks[j];
4982
- }
5192
+ var nearest = function nearest(id) {
5193
+ var exact = byId.get(id);
5194
+ if (exact) return exact;
5195
+
5196
+ for (var cut = id.lastIndexOf("."); cut > 0; cut = id.lastIndexOf(".", cut - 1)) {
5197
+ var ancestor = byId.get(id.slice(0, cut));
5198
+ if (ancestor) return ancestor;
4983
5199
  }
4984
5200
 
5201
+ return undefined;
5202
+ };
5203
+
5204
+ for (var i = 0; i < path.length; i++) {
5205
+ var longestTask = nearest(path[i].id);
5206
+
4985
5207
  if (longestTask) {
4986
5208
  var _longestTask$styles;
4987
5209
 
@@ -4993,14 +5215,7 @@ function colorPath(path, color, tasks, criticalPathType) {
4993
5215
  }
4994
5216
 
4995
5217
  var _loop = function _loop(_i9) {
4996
- var taskFromTasks = void 0;
4997
-
4998
- for (var _j2 = 0; _j2 < tasks.length; _j2++) {
4999
- if (path[_i9].id === tasks[_j2].id) {
5000
- taskFromTasks = tasks[_j2];
5001
- break;
5002
- }
5003
- }
5218
+ var taskFromTasks = byId.get(path[_i9].id);
5004
5219
 
5005
5220
  if (taskFromTasks) {
5006
5221
  var arrows = taskFromTasks.criticalPathArrows;