gantt-task-react-powern 0.6.31 → 0.6.33

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
@@ -270,7 +270,7 @@ var getMonday = function getMonday(date) {
270
270
  return new Date(date.setDate(diff));
271
271
  };
272
272
 
273
- var styles = {"ganttTable":"_3_ygE","ganttTable_Header":"_1nBOt","ganttTable_HeaderSeparator":"_2eZzQ","ganttTable_HeaderItem":"_WuQ0f"};
273
+ var styles = {"ganttTable":"_3_ygE","ganttTable_Header":"_1nBOt","ganttTable_HeaderSeparator":"_2eZzQ","ganttTable_HeaderResizeHandle":"_ddPJg","ganttTable_HeaderItem":"_WuQ0f"};
274
274
 
275
275
  var TaskListHeaderDefault = function TaskListHeaderDefault(_ref) {
276
276
  var headerHeight = _ref.headerHeight,
@@ -279,7 +279,64 @@ var TaskListHeaderDefault = function TaskListHeaderDefault(_ref) {
279
279
  rowWidth = _ref.rowWidth,
280
280
  scheduleType = _ref.scheduleType,
281
281
  allSelected = _ref.allSelected,
282
- onSelectAll = _ref.onSelectAll;
282
+ onSelectAll = _ref.onSelectAll,
283
+ columnWidths = _ref.columnWidths,
284
+ onColumnResize = _ref.onColumnResize;
285
+
286
+ var widthOf = function widthOf(colId, factor) {
287
+ var _columnWidths$colId;
288
+
289
+ return (_columnWidths$colId = columnWidths === null || columnWidths === void 0 ? void 0 : columnWidths[colId]) != null ? _columnWidths$colId : parseInt(rowWidth) * factor;
290
+ };
291
+
292
+ var startResize = function startResize(colId, startWidth) {
293
+ return function (e) {
294
+ if (!onColumnResize) return;
295
+ e.preventDefault();
296
+ e.stopPropagation();
297
+ var startX = e.clientX;
298
+
299
+ var onMove = function onMove(ev) {
300
+ onColumnResize(colId, startWidth + (ev.clientX - startX));
301
+ };
302
+
303
+ var onUp = function onUp() {
304
+ document.removeEventListener("mousemove", onMove);
305
+ document.removeEventListener("mouseup", onUp);
306
+ };
307
+
308
+ document.addEventListener("mousemove", onMove);
309
+ document.addEventListener("mouseup", onUp);
310
+ };
311
+ };
312
+
313
+ var cell = function cell(colId, factor, content, opts) {
314
+ if (opts === void 0) {
315
+ opts = {};
316
+ }
317
+
318
+ var _opts = opts,
319
+ title = _opts.title,
320
+ _opts$resizable = _opts.resizable,
321
+ resizable = _opts$resizable === void 0 ? true : _opts$resizable;
322
+ var width = widthOf(colId, factor);
323
+ return React__default.createElement("div", {
324
+ className: styles.ganttTable_HeaderItem,
325
+ style: {
326
+ minWidth: width,
327
+ maxWidth: width,
328
+ position: "relative"
329
+ },
330
+ title: title
331
+ }, content, resizable && onColumnResize && React__default.createElement("div", {
332
+ className: styles.ganttTable_HeaderResizeHandle,
333
+ style: {
334
+ height: headerHeight - 2
335
+ },
336
+ onMouseDown: startResize(colId, width)
337
+ }));
338
+ };
339
+
283
340
  return React__default.createElement("div", {
284
341
  className: styles.ganttTable,
285
342
  style: {
@@ -291,156 +348,33 @@ var TaskListHeaderDefault = function TaskListHeaderDefault(_ref) {
291
348
  style: {
292
349
  height: headerHeight - 2
293
350
  }
294
- }, onSelectAll && React__default.createElement("div", null, React__default.createElement("div", {
295
- className: styles.ganttTable_HeaderItem,
296
- style: {
297
- minWidth: parseInt(rowWidth) * 0.3,
298
- maxWidth: parseInt(rowWidth) * 0.3
299
- }
300
- }, React__default.createElement("input", {
351
+ }, onSelectAll && cell("select", 0.3, React__default.createElement("input", {
301
352
  type: "checkbox",
302
353
  checked: allSelected,
303
354
  onChange: function onChange(e) {
304
355
  return onSelectAll(e.target.checked);
305
356
  }
306
- }))), React__default.createElement("div", {
307
- className: styles.ganttTable_HeaderItem,
308
- style: {
309
- minWidth: parseInt(rowWidth) * 0.8,
310
- maxWidth: parseInt(rowWidth) * 0.8
311
- }
312
- }, "ID"), React__default.createElement("div", {
313
- className: styles.ganttTable_HeaderSeparator,
314
- style: {
315
- height: headerHeight * 0.5,
316
- marginTop: headerHeight * 0.2
317
- }
318
- }), React__default.createElement("div", {
319
- className: styles.ganttTable_HeaderItem,
320
- style: {
321
- minWidth: parseInt(rowWidth) * 0.8,
322
- maxWidth: parseInt(rowWidth) * 0.8
323
- }
324
- }, "WBS Code / Activity ID"), React__default.createElement("div", {
325
- className: styles.ganttTable_HeaderSeparator,
326
- style: {
327
- height: headerHeight * 0.5,
328
- marginTop: headerHeight * 0.2
329
- }
330
- }), React__default.createElement("div", {
331
- className: styles.ganttTable_HeaderItem,
332
- style: {
333
- minWidth: parseInt(rowWidth) * 1.8,
334
- maxWidth: parseInt(rowWidth) * 1.8
335
- }
336
- }, "Task"), React__default.createElement("div", {
337
- className: styles.ganttTable_HeaderSeparator,
338
- style: {
339
- height: headerHeight * 0.5,
340
- marginTop: headerHeight * 0.2
341
- }
342
- }), React__default.createElement("div", {
343
- className: styles.ganttTable_HeaderItem,
344
- style: {
345
- minWidth: parseInt(rowWidth) * 0.6
346
- },
357
+ }), {
358
+ resizable: false
359
+ }), cell("id", 0.8, "ID"), cell("wbs", 0.8, "WBS Code / Activity ID"), cell("name", 1.8, "Task"), cell("plannedStart", 0.6, "Planned Start", {
347
360
  title: "Planned Start"
348
- }, "Planned Start"), React__default.createElement("div", {
349
- className: styles.ganttTable_HeaderSeparator,
350
- style: {
351
- height: headerHeight * 0.5,
352
- marginTop: headerHeight * 0.25
353
- }
354
- }), React__default.createElement("div", {
355
- className: styles.ganttTable_HeaderItem,
356
- style: {
357
- minWidth: parseInt(rowWidth) * 0.6
358
- },
361
+ }), cell("plannedEnd", 0.6, "Planned End", {
359
362
  title: "Planned End"
360
- }, "Planned End"), scheduleType === "lookAhead" && React__default.createElement("div", {
361
- className: styles.ganttTable_HeaderItem,
362
- style: {
363
- minWidth: parseInt(rowWidth) * 0.6
364
- },
365
- title: "Planned Start"
366
- }, "Actual Start"), scheduleType === "lookAhead" && React__default.createElement("div", {
367
- className: styles.ganttTable_HeaderSeparator,
368
- style: {
369
- height: headerHeight * 0.5,
370
- marginTop: headerHeight * 0.25
371
- }
372
- }), scheduleType === "lookAhead" && React__default.createElement("div", {
373
- className: styles.ganttTable_HeaderItem,
374
- style: {
375
- minWidth: parseInt(rowWidth) * 0.6
376
- },
377
- title: "Planned End"
378
- }, "Actual End"), scheduleType === "main" && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
379
- className: styles.ganttTable_HeaderSeparator,
380
- style: {
381
- height: headerHeight * 0.5,
382
- marginTop: headerHeight * 0.25
383
- }
384
- }), React__default.createElement("div", {
385
- className: styles.ganttTable_HeaderItem,
386
- style: {
387
- minWidth: parseInt(rowWidth) * 0.6,
388
- maxWidth: parseInt(rowWidth) * 0.6
389
- },
363
+ }), scheduleType === "lookAhead" && React__default.createElement(React__default.Fragment, null, cell("actualStart", 0.6, "Actual Start", {
364
+ title: "Actual Start"
365
+ }), cell("actualEnd", 0.6, "Actual End", {
366
+ title: "Actual End"
367
+ })), scheduleType === "main" && React__default.createElement(React__default.Fragment, null, cell("percentComplete", 0.6, "% Complete", {
390
368
  title: "% Complete"
391
- }, "% Complete"), React__default.createElement("div", {
392
- className: styles.ganttTable_HeaderSeparator,
393
- style: {
394
- height: headerHeight * 0.5,
395
- marginTop: headerHeight * 0.25
396
- }
397
- }), React__default.createElement("div", {
398
- className: styles.ganttTable_HeaderItem,
399
- style: {
400
- minWidth: parseInt(rowWidth) * 0.6,
401
- maxWidth: parseInt(rowWidth) * 0.6
402
- },
369
+ }), cell("plannedDuration", 0.6, "Planned Duration", {
403
370
  title: "Planned Duration"
404
- }, "Planned Duration"), React__default.createElement("div", {
405
- className: styles.ganttTable_HeaderSeparator,
406
- style: {
407
- height: headerHeight * 0.5,
408
- marginTop: headerHeight * 0.25
409
- }
410
- }), React__default.createElement("div", {
411
- className: styles.ganttTable_HeaderItem,
412
- style: {
413
- minWidth: parseInt(rowWidth) * 0.7,
414
- maxWidth: parseInt(rowWidth) * 0.7
415
- },
371
+ }), cell("remainingDuration", 0.7, "Remaining Duration", {
416
372
  title: "Remaining Duration"
417
- }, "Remaining Duration"), React__default.createElement("div", {
418
- className: styles.ganttTable_HeaderSeparator,
419
- style: {
420
- height: headerHeight * 0.5,
421
- marginTop: headerHeight * 0.25
422
- }
423
- }), React__default.createElement("div", {
424
- className: styles.ganttTable_HeaderItem,
425
- style: {
426
- minWidth: parseInt(rowWidth) * 0.6,
427
- maxWidth: parseInt(rowWidth) * 0.6
428
- },
373
+ }), cell("actualDuration", 0.6, "Actual Duration", {
429
374
  title: "Actual Duration"
430
- }, "Actual Duration"), React__default.createElement("div", {
431
- className: styles.ganttTable_HeaderSeparator,
432
- style: {
433
- height: headerHeight * 0.5,
434
- marginTop: headerHeight * 0.25
435
- }
436
- }), React__default.createElement("div", {
437
- className: styles.ganttTable_HeaderItem,
438
- style: {
439
- minWidth: parseInt(rowWidth) * 0.8,
440
- maxWidth: parseInt(rowWidth) * 0.8
441
- },
375
+ }), cell("durationType", 0.8, "Duration Type", {
442
376
  title: "Duration Type"
443
- }, "Duration Type"))));
377
+ }))));
444
378
  };
445
379
 
446
380
  var styles$1 = {"taskListWrapper":"_3ZbQT","taskListTableRow":"_34SS0","taskListLookAheadRow":"_GzvG4","taskListMilestoneRow":"_3Ykml","taskListCell":"_3lLk3","taskListNameWrapper":"_nI1Xw","taskListExpander":"_2QjE6","taskListExpanderPlaceholder":"_1fnLB","taskListEmptyExpander":"_2TfEi","taskListText":"_2ZvXU"};
@@ -484,7 +418,15 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
484
418
  taskLabelRenderer = _ref$taskLabelRendere === void 0 ? function (t) {
485
419
  return " " + t.name;
486
420
  } : _ref$taskLabelRendere,
487
- virtualItems = _ref.virtualItems;
421
+ virtualItems = _ref.virtualItems,
422
+ columnWidths = _ref.columnWidths;
423
+
424
+ var widthOf = function widthOf(colId, factor) {
425
+ var _columnWidths$colId;
426
+
427
+ return (_columnWidths$colId = columnWidths === null || columnWidths === void 0 ? void 0 : columnWidths[colId]) != null ? _columnWidths$colId : parseInt(rowWidth) * factor;
428
+ };
429
+
488
430
  var toLocaleDateString = React.useMemo(function () {
489
431
  return toLocaleDateStringFactory(locale);
490
432
  }, [locale]);
@@ -556,8 +498,8 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
556
498
  }, onTaskSelect && React__default.createElement("div", {
557
499
  className: styles$1.taskListCell,
558
500
  style: {
559
- minWidth: parseInt(rowWidth) * 0.3,
560
- maxWidth: parseInt(rowWidth) * 0.3
501
+ minWidth: widthOf("select", 0.3),
502
+ maxWidth: widthOf("select", 0.3)
561
503
  }
562
504
  }, React__default.createElement("div", {
563
505
  className: styles$1.taskListText,
@@ -579,8 +521,8 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
579
521
  }))), React__default.createElement("div", {
580
522
  className: styles$1.taskListCell,
581
523
  style: {
582
- minWidth: parseInt(rowWidth) * 0.8,
583
- maxWidth: parseInt(rowWidth) * 0.8
524
+ minWidth: widthOf("id", 0.8),
525
+ maxWidth: widthOf("id", 0.8)
584
526
  },
585
527
  title: t.id
586
528
  }, React__default.createElement("div", {
@@ -606,15 +548,15 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
606
548
  }, "\u2714") : ""))), React__default.createElement("div", {
607
549
  className: styles$1.taskListCell,
608
550
  style: {
609
- minWidth: parseInt(rowWidth) * 0.8,
610
- maxWidth: parseInt(rowWidth) * 0.8
551
+ minWidth: widthOf("wbs", 0.8),
552
+ maxWidth: widthOf("wbs", 0.8)
611
553
  },
612
554
  title: t.optionalId ? t.optionalId : ""
613
555
  }, t.optionalId), React__default.createElement("div", {
614
556
  className: styles$1.taskListCell,
615
557
  style: {
616
- minWidth: parseInt(rowWidth) * 1.8,
617
- maxWidth: parseInt(rowWidth) * 1.8
558
+ minWidth: widthOf("name", 1.8),
559
+ maxWidth: widthOf("name", 1.8)
618
560
  },
619
561
  title: t.name
620
562
  }, React__default.createElement("div", {
@@ -622,32 +564,32 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
622
564
  }, taskLabelRenderer(t))), React__default.createElement("div", {
623
565
  className: styles$1.taskListCell,
624
566
  style: {
625
- minWidth: parseInt(rowWidth) * 0.6,
626
- maxWidth: parseInt(rowWidth) * 0.6
567
+ minWidth: widthOf("plannedStart", 0.6),
568
+ maxWidth: widthOf("plannedStart", 0.6)
627
569
  }
628
570
  }, React__default.createElement("div", {
629
571
  className: styles$1.taskListText
630
572
  }, "\xA0", toLocaleDateString(t.start, dateTimeOptions))), React__default.createElement("div", {
631
573
  className: styles$1.taskListCell,
632
574
  style: {
633
- minWidth: parseInt(rowWidth) * 0.6,
634
- maxWidth: parseInt(rowWidth) * 0.6
575
+ minWidth: widthOf("plannedEnd", 0.6),
576
+ maxWidth: widthOf("plannedEnd", 0.6)
635
577
  }
636
578
  }, React__default.createElement("div", {
637
579
  className: styles$1.taskListText
638
580
  }, "\xA0", toLocaleDateString(t.end, dateTimeOptions))), scheduleType === "lookAhead" && React__default.createElement("div", {
639
581
  className: styles$1.taskListCell,
640
582
  style: {
641
- minWidth: parseInt(rowWidth) * 0.6,
642
- maxWidth: parseInt(rowWidth) * 0.6
583
+ minWidth: widthOf("actualStart", 0.6),
584
+ maxWidth: widthOf("actualStart", 0.6)
643
585
  }
644
586
  }, React__default.createElement("div", {
645
587
  className: styles$1.taskListText
646
588
  }, "\xA0", toLocaleDateString(t.actualStart, dateTimeOptions))), scheduleType === "lookAhead" && React__default.createElement("div", {
647
589
  className: styles$1.taskListCell,
648
590
  style: {
649
- minWidth: parseInt(rowWidth) * 0.6,
650
- maxWidth: parseInt(rowWidth) * 0.6
591
+ minWidth: widthOf("actualEnd", 0.6),
592
+ maxWidth: widthOf("actualEnd", 0.6)
651
593
  }
652
594
  }, React__default.createElement("div", {
653
595
  className: styles$1.taskListText
@@ -667,40 +609,40 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
667
609
  return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
668
610
  className: styles$1.taskListCell,
669
611
  style: {
670
- minWidth: parseInt(rowWidth) * 0.6,
671
- maxWidth: parseInt(rowWidth) * 0.6
612
+ minWidth: widthOf("percentComplete", 0.6),
613
+ maxWidth: widthOf("percentComplete", 0.6)
672
614
  }
673
615
  }, React__default.createElement("div", {
674
616
  className: styles$1.taskListText
675
617
  }, "\xA0", percentComplete != null ? percentComplete + "%" : "")), React__default.createElement("div", {
676
618
  className: styles$1.taskListCell,
677
619
  style: {
678
- minWidth: parseInt(rowWidth) * 0.6,
679
- maxWidth: parseInt(rowWidth) * 0.6
620
+ minWidth: widthOf("plannedDuration", 0.6),
621
+ maxWidth: widthOf("plannedDuration", 0.6)
680
622
  }
681
623
  }, React__default.createElement("div", {
682
624
  className: styles$1.taskListText
683
625
  }, "\xA0", plannedDuration != null ? plannedDuration : "")), React__default.createElement("div", {
684
626
  className: styles$1.taskListCell,
685
627
  style: {
686
- minWidth: parseInt(rowWidth) * 0.7,
687
- maxWidth: parseInt(rowWidth) * 0.7
628
+ minWidth: widthOf("remainingDuration", 0.7),
629
+ maxWidth: widthOf("remainingDuration", 0.7)
688
630
  }
689
631
  }, React__default.createElement("div", {
690
632
  className: styles$1.taskListText
691
633
  }, "\xA0", remainingDuration != null ? remainingDuration : "")), React__default.createElement("div", {
692
634
  className: styles$1.taskListCell,
693
635
  style: {
694
- minWidth: parseInt(rowWidth) * 0.6,
695
- maxWidth: parseInt(rowWidth) * 0.6
636
+ minWidth: widthOf("actualDuration", 0.6),
637
+ maxWidth: widthOf("actualDuration", 0.6)
696
638
  }
697
639
  }, React__default.createElement("div", {
698
640
  className: styles$1.taskListText
699
641
  }, "\xA0", actualDuration != null ? actualDuration : "")), React__default.createElement("div", {
700
642
  className: styles$1.taskListCell,
701
643
  style: {
702
- minWidth: parseInt(rowWidth) * 0.8,
703
- maxWidth: parseInt(rowWidth) * 0.8
644
+ minWidth: widthOf("durationType", 0.8),
645
+ maxWidth: widthOf("durationType", 0.8)
704
646
  }
705
647
  }, React__default.createElement("div", {
706
648
  className: styles$1.taskListText
@@ -877,6 +819,73 @@ var VerticalScroll = function VerticalScroll(_ref) {
877
819
  }));
878
820
  };
879
821
 
822
+ function getTaskListColumns(scheduleType, hasCheckbox) {
823
+ var columns = [];
824
+ if (hasCheckbox) columns.push({
825
+ id: "select",
826
+ factor: 0.3
827
+ });
828
+ columns.push({
829
+ id: "id",
830
+ factor: 0.8
831
+ }, {
832
+ id: "wbs",
833
+ factor: 0.8
834
+ }, {
835
+ id: "name",
836
+ factor: 1.8
837
+ }, {
838
+ id: "plannedStart",
839
+ factor: 0.6
840
+ }, {
841
+ id: "plannedEnd",
842
+ factor: 0.6
843
+ });
844
+
845
+ if (scheduleType === "lookAhead") {
846
+ columns.push({
847
+ id: "actualStart",
848
+ factor: 0.6
849
+ }, {
850
+ id: "actualEnd",
851
+ factor: 0.6
852
+ });
853
+ }
854
+
855
+ if (scheduleType === "main") {
856
+ columns.push({
857
+ id: "percentComplete",
858
+ factor: 0.6
859
+ }, {
860
+ id: "plannedDuration",
861
+ factor: 0.6
862
+ }, {
863
+ id: "remainingDuration",
864
+ factor: 0.7
865
+ }, {
866
+ id: "actualDuration",
867
+ factor: 0.6
868
+ }, {
869
+ id: "durationType",
870
+ factor: 0.8
871
+ });
872
+ }
873
+
874
+ return columns;
875
+ }
876
+ var MIN_COLUMN_WIDTH = 40;
877
+ function buildDefaultColumnWidths(scheduleType, hasCheckbox, rowWidth) {
878
+ var base = parseInt(rowWidth) || 0;
879
+ var widths = {};
880
+
881
+ for (var _iterator = _createForOfIteratorHelperLoose(getTaskListColumns(scheduleType, hasCheckbox)), _step; !(_step = _iterator()).done;) {
882
+ var col = _step.value;
883
+ widths[col.id] = base * col.factor;
884
+ }
885
+
886
+ return widths;
887
+ }
888
+
880
889
  var styles$4 = {"hideScrollbar":"_38emS"};
881
890
 
882
891
  var TaskList = function TaskList(_ref) {
@@ -901,6 +910,8 @@ var TaskList = function TaskList(_ref) {
901
910
  taskLabelRenderer = _ref.taskLabelRenderer,
902
911
  onMultiSelect = _ref.onMultiSelect,
903
912
  containerWidth = _ref.containerWidth,
913
+ containerMaxWidth = _ref.containerMaxWidth,
914
+ onContentWidthChange = _ref.onContentWidthChange,
904
915
  innerScrollRef = _ref.innerScrollRef,
905
916
  externalHorizontalContainerRef = _ref.horizontalContainerRef;
906
917
  var internalHorizontalContainerRef = React.useRef(null);
@@ -926,9 +937,55 @@ var TaskList = function TaskList(_ref) {
926
937
  selectedTasks = _useState[0],
927
938
  setSelectedTasks = _useState[1];
928
939
 
929
- var _useState2 = React.useState([]),
930
- pendingTaskSelect = _useState2[0],
931
- setPendingTaskSelect = _useState2[1];
940
+ var hasCheckbox = !!onMultiSelect;
941
+
942
+ var _useState2 = React.useState(function () {
943
+ return buildDefaultColumnWidths(scheduleType, hasCheckbox, rowWidth);
944
+ }),
945
+ columnWidths = _useState2[0],
946
+ setColumnWidths = _useState2[1];
947
+
948
+ React.useEffect(function () {
949
+ var defaults = buildDefaultColumnWidths(scheduleType, hasCheckbox, rowWidth);
950
+ setColumnWidths(function (prev) {
951
+ var ids = Object.keys(defaults);
952
+ var sameSet = ids.length === Object.keys(prev).length && ids.every(function (id) {
953
+ return id in prev;
954
+ });
955
+ if (sameSet) return prev;
956
+ var next = {};
957
+
958
+ for (var _i = 0, _ids = ids; _i < _ids.length; _i++) {
959
+ var _prev$id;
960
+
961
+ var id = _ids[_i];
962
+ next[id] = (_prev$id = prev[id]) != null ? _prev$id : defaults[id];
963
+ }
964
+
965
+ return next;
966
+ });
967
+ }, [scheduleType, hasCheckbox, rowWidth]);
968
+
969
+ var handleColumnResize = function handleColumnResize(colId, width) {
970
+ setColumnWidths(function (prev) {
971
+ var _extends2;
972
+
973
+ return _extends({}, prev, (_extends2 = {}, _extends2[colId] = Math.max(MIN_COLUMN_WIDTH, width), _extends2));
974
+ });
975
+ };
976
+
977
+ var contentWidth = React.useMemo(function () {
978
+ return Object.values(columnWidths).reduce(function (sum, w) {
979
+ return sum + w;
980
+ }, 0);
981
+ }, [columnWidths]);
982
+ React.useEffect(function () {
983
+ onContentWidthChange === null || onContentWidthChange === void 0 ? void 0 : onContentWidthChange(contentWidth);
984
+ }, [contentWidth, onContentWidthChange]);
985
+
986
+ var _useState3 = React.useState([]),
987
+ pendingTaskSelect = _useState3[0],
988
+ setPendingTaskSelect = _useState3[1];
932
989
 
933
990
  var prevSelectedTasksRef = React.useRef([]);
934
991
  var expandedTasks = React.useRef([]);
@@ -1076,7 +1133,9 @@ var TaskList = function TaskList(_ref) {
1076
1133
  rowWidth: rowWidth,
1077
1134
  scheduleType: scheduleType,
1078
1135
  allSelected: tasks.length > 0 && selectedTasks.length === tasks.length,
1079
- onSelectAll: onMultiSelect ? handleSelectAll : undefined
1136
+ onSelectAll: onMultiSelect ? handleSelectAll : undefined,
1137
+ columnWidths: columnWidths,
1138
+ onColumnResize: handleColumnResize
1080
1139
  };
1081
1140
  var selectedTaskId = selectedTask ? selectedTask.id : "";
1082
1141
  var tableProps = {
@@ -1094,15 +1153,19 @@ var TaskList = function TaskList(_ref) {
1094
1153
  selectedTasks: onMultiSelect ? selectedTasks : undefined,
1095
1154
  onTaskSelect: onMultiSelect ? handleTaskSelect : undefined,
1096
1155
  taskLabelRenderer: taskLabelRenderer,
1097
- virtualItems: virtualizer.getVirtualItems()
1156
+ virtualItems: virtualizer.getVirtualItems(),
1157
+ columnWidths: columnWidths
1098
1158
  };
1099
1159
  return React__default.createElement("div", {
1100
1160
  ref: taskListRef,
1101
- style: containerWidth != null ? {
1102
- width: containerWidth,
1161
+ style: containerWidth != null || containerMaxWidth != null ? _extends({}, containerWidth != null ? {
1162
+ width: containerWidth
1163
+ } : {}, containerMaxWidth != null ? {
1164
+ maxWidth: containerMaxWidth
1165
+ } : {}, {
1103
1166
  overflow: "hidden",
1104
1167
  flexShrink: 0
1105
- } : {}
1168
+ }) : {}
1106
1169
  }, React__default.createElement("div", {
1107
1170
  ref: innerScrollRef,
1108
1171
  className: styles$4.hideScrollbar,
@@ -1259,7 +1322,7 @@ function getQuarterNumber(date, quarterStart) {
1259
1322
  return Math.floor(offset / 3) + 1;
1260
1323
  }
1261
1324
 
1262
- var styles$5 = {"gridRow":"_2dZTy","gridRowLookAhead":"_2RRca","gridRowLine":"_3rUKi","gridTick":"_RuwuK","gridTickDashed":"_Zh9jh","darkerGridRow":"_2M-tt"};
1325
+ var styles$5 = {"gridRow":"_2dZTy","gridRowLookAhead":"_2RRca","gridRowLine":"_3rUKi","gridTick":"_RuwuK","gridTickWeekStart":"_1q0EV","gridTickDashed":"_Zh9jh","darkerGridRow":"_2M-tt"};
1263
1326
 
1264
1327
  var GridBody = function GridBody(_ref) {
1265
1328
  var _projectCalendar$week;
@@ -1303,7 +1366,8 @@ var GridBody = function GridBody(_ref) {
1303
1366
  if (next && date <= now && next > now) return true;
1304
1367
 
1305
1368
  if (!next && date <= now) {
1306
- var step = date.getTime() - dates[i - 1].getTime();
1369
+ var prev = dates[i - 1];
1370
+ var step = prev ? date.getTime() - prev.getTime() : 86400000;
1307
1371
  var end = addToDate(date, step, "millisecond");
1308
1372
  return end > now;
1309
1373
  }
@@ -1364,11 +1428,14 @@ var GridBody = function GridBody(_ref) {
1364
1428
  }
1365
1429
 
1366
1430
  var isDayView = viewMode === exports.ViewMode.Day;
1431
+ var isWeekView = viewMode === exports.ViewMode.Week;
1367
1432
  var tickLines = dates.map(function (date, i) {
1368
1433
  var tickClass = styles$5.gridTick;
1369
1434
 
1370
1435
  if (isDayView) {
1371
- tickClass = date.getDay() === weekStartDay ? styles$5.gridTick : styles$5.gridTickDashed;
1436
+ tickClass = date.getDay() === weekStartDay ? styles$5.gridTickWeekStart : styles$5.gridTickDashed;
1437
+ } else if (isWeekView) {
1438
+ tickClass = styles$5.gridTickWeekStart;
1372
1439
  }
1373
1440
 
1374
1441
  return React__default.createElement("line", {
@@ -1536,7 +1603,13 @@ var Calendar = function Calendar(_ref) {
1536
1603
  columnWidth = _ref.columnWidth,
1537
1604
  fontFamily = _ref.fontFamily,
1538
1605
  fontSize = _ref.fontSize,
1539
- projectCalendar = _ref.projectCalendar;
1606
+ projectCalendar = _ref.projectCalendar,
1607
+ weekendColor = _ref.weekendColor;
1608
+
1609
+ var isDayOff = function isDayOff(date) {
1610
+ if (projectCalendar) return isOffDay(date, projectCalendar);
1611
+ return false;
1612
+ };
1540
1613
 
1541
1614
  var shortMonth = function shortMonth(date) {
1542
1615
  return date.toLocaleString(locale, {
@@ -1785,6 +1858,18 @@ var Calendar = function Calendar(_ref) {
1785
1858
 
1786
1859
  for (var i = 0; i < dates.length; i++) {
1787
1860
  var date = dates[i];
1861
+
1862
+ if (isDayOff(date)) {
1863
+ offDayRects.push(React__default.createElement("rect", {
1864
+ key: "offday-header-" + i,
1865
+ x: columnWidth * i,
1866
+ y: topDefaultHeight,
1867
+ width: columnWidth,
1868
+ height: headerHeight - topDefaultHeight,
1869
+ fill: weekendColor
1870
+ }));
1871
+ }
1872
+
1788
1873
  var isWeekStart = date.getDay() === weekStartDay;
1789
1874
  tickLines.push(React__default.createElement("line", {
1790
1875
  key: "tick-day-" + i,
@@ -2048,8 +2133,8 @@ var drawPathAndTriangle = function drawPathAndTriangle(taskFrom, taskTo, rowHeig
2048
2133
 
2049
2134
  if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[0].x1;
2050
2135
  var candidates = [];
2051
- if (t.x1 !== undefined && t.x1 >= 0) candidates.push(t.x1);
2052
- if (t.actualx1 !== undefined && t.actualx1 >= 0) candidates.push(t.actualx1);
2136
+ if (t.x2 > t.x1) candidates.push(t.x1);
2137
+ if (t.actualx2 > t.actualx1) candidates.push(t.actualx1);
2053
2138
  return candidates.length > 0 ? Math.min.apply(Math, candidates) : 0;
2054
2139
  };
2055
2140
 
@@ -2062,8 +2147,8 @@ var drawPathAndTriangle = function drawPathAndTriangle(taskFrom, taskTo, rowHeig
2062
2147
 
2063
2148
  if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[t.actualSegments.length - 1].x2;
2064
2149
  var candidates = [];
2065
- if (t.x2 !== undefined && t.x2 >= 0) candidates.push(t.x2);
2066
- if (t.actualx2 !== undefined && t.actualx2 >= 0) candidates.push(t.actualx2);
2150
+ if (t.x2 > t.x1) candidates.push(t.x2);
2151
+ if (t.actualx2 > t.actualx1) candidates.push(t.actualx2);
2067
2152
  return candidates.length > 0 ? Math.max.apply(Math, candidates) : 0;
2068
2153
  };
2069
2154
 
@@ -3188,6 +3273,11 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3188
3273
  setIsMoving = _useState3[1];
3189
3274
 
3190
3275
  React.useEffect(function () {
3276
+ if (dates.length < 2) {
3277
+ setXStep(timeStep * columnWidth / 86400000);
3278
+ return;
3279
+ }
3280
+
3191
3281
  var dateDelta = dates[1].getTime() - dates[0].getTime() - dates[1].getTimezoneOffset() * 60 * 1000 + dates[0].getTimezoneOffset() * 60 * 1000;
3192
3282
  var newXStep = timeStep * columnWidth / dateDelta;
3193
3283
  setXStep(newXStep);
@@ -3585,7 +3675,12 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3585
3675
 
3586
3676
  var getArrows = function getArrows(isCritical, criticalPathType) {
3587
3677
  return tasks.flatMap(function (_task) {
3588
- var _live = ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id ? ganttEvent.changedTask : _task;
3678
+ var a = ganttEvent.action;
3679
+ var isDraggingThis = (a === "move" || a === "start" || a === "end" || a === "progress") && !!ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id;
3680
+
3681
+ var _live = isDraggingThis ? _extends({}, ganttEvent.changedTask, {
3682
+ y: _task.y
3683
+ }) : _task;
3589
3684
 
3590
3685
  var task = _live.start.getTime() > 0 && _live.end.getTime() > 0 ? _live : undefined;
3591
3686
 
@@ -3594,13 +3689,16 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3594
3689
  }
3595
3690
 
3596
3691
  return task.barChildren.map(function (child) {
3597
- if (task.x2 > task.x1 || task.actualx2 > task.actualx1) {
3692
+ var taskTo = tasks[child.index];
3693
+ var fromDrawable = task.x2 > task.x1 || task.actualx2 > task.actualx1;
3694
+ var toDrawable = !!taskTo && (taskTo.x2 > taskTo.x1 || taskTo.actualx2 > taskTo.actualx1);
3695
+
3696
+ if (fromDrawable && toDrawable) {
3598
3697
  var _task$criticalPathArr;
3599
3698
 
3600
3699
  var criticalTask = (_task$criticalPathArr = task.criticalPathArrows) === null || _task$criticalPathArr === void 0 ? void 0 : _task$criticalPathArr.find(function (arrow) {
3601
- return arrow.taskId === tasks[child.index].id && (!!arrow.criticalPathType ? arrow.criticalPathType === criticalPathType : !criticalPathType);
3700
+ return arrow.taskId === taskTo.id && (!!arrow.criticalPathType ? arrow.criticalPathType === criticalPathType : !criticalPathType);
3602
3701
  });
3603
- var taskTo = tasks[child.index];
3604
3702
  var yFrom = task.y + taskHeight / 2;
3605
3703
  var yTo = taskTo.y + taskHeight / 2;
3606
3704
  var minY = Math.min(yFrom, yTo);
@@ -3612,9 +3710,9 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3612
3710
 
3613
3711
  if (!!criticalTask === isCritical) {
3614
3712
  return React__default.createElement(Arrow, {
3615
- key: "Arrow from " + task.id + " to " + tasks[child.index].id + (isCritical ? "-critical" : ""),
3713
+ key: "Arrow from " + task.id + " to " + taskTo.id + (isCritical ? "-critical" : ""),
3616
3714
  taskFrom: task,
3617
- taskTo: tasks[child.index],
3715
+ taskTo: taskTo,
3618
3716
  rowHeight: rowHeight,
3619
3717
  dependencyType: child.dependencyType,
3620
3718
  taskHeight: taskHeight,
@@ -3807,8 +3905,10 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
3807
3905
  }));
3808
3906
  };
3809
3907
 
3908
+ var GANTT_MIN_WIDTH_RATIO = 0.4;
3909
+ var TABLE_GANTT_DIVIDER_WIDTH = 20;
3810
3910
  var Gantt = function Gantt(_ref) {
3811
- var _ref3;
3911
+ var _ref2;
3812
3912
 
3813
3913
  var tasks = _ref.tasks,
3814
3914
  _ref$leafTasks = _ref.leafTasks,
@@ -3916,8 +4016,8 @@ var Gantt = function Gantt(_ref) {
3916
4016
  var tableHScrollRef = React.useRef(null);
3917
4017
 
3918
4018
  var _useState2 = React.useState(0),
3919
- tableScrollableWidth = _useState2[0],
3920
- setTableScrollableWidth = _useState2[1];
4019
+ tableContentWidth = _useState2[0],
4020
+ setTableContentWidth = _useState2[1];
3921
4021
 
3922
4022
  var _useState3 = React.useState(function () {
3923
4023
  var _ganttDateRange = ganttDateRange(tasks, viewMode, preStepsCount),
@@ -3947,22 +4047,21 @@ var Gantt = function Gantt(_ref) {
3947
4047
  taskListWidth = _useState5[0],
3948
4048
  setTaskListWidth = _useState5[1];
3949
4049
 
3950
- React.useEffect(function () {
3951
- if (tableHorizontalContainerRef.current) {
3952
- setTableScrollableWidth(tableHorizontalContainerRef.current.scrollWidth);
3953
- } else if (tableInnerScrollRef.current) {
3954
- setTableScrollableWidth(tableInnerScrollRef.current.scrollWidth);
3955
- }
3956
- }, [taskListWidth, listCellWidth]);
4050
+ var _useState6 = React.useState(0),
4051
+ wrapperWidth = _useState6[0],
4052
+ setWrapperWidth = _useState6[1];
4053
+
4054
+ var maxTableWidth = wrapperWidth > 0 ? Math.max(100, wrapperWidth * (1 - GANTT_MIN_WIDTH_RATIO) - TABLE_GANTT_DIVIDER_WIDTH) : Infinity;
4055
+ var tableCap = Math.min(maxTableWidth, tableContentWidth > 0 ? tableContentWidth : Infinity);
3957
4056
 
3958
4057
  var handleTableResizeMouseDown = function handleTableResizeMouseDown(e) {
3959
- var _taskListRef$current$, _taskListRef$current, _ref2, _tableHorizontalConta, _tableHorizontalConta2, _tableInnerScrollRef$, _wrapperRef$current$o, _wrapperRef$current;
4058
+ var _taskListRef$current$, _taskListRef$current;
3960
4059
 
3961
4060
  isDraggingTable.current = true;
3962
4061
  userResizedRef.current = true;
3963
4062
  dragStartX.current = e.clientX;
3964
4063
  dragStartWidth.current = tableContainerWidth != null ? tableContainerWidth : (_taskListRef$current$ = (_taskListRef$current = taskListRef.current) === null || _taskListRef$current === void 0 ? void 0 : _taskListRef$current.offsetWidth) != null ? _taskListRef$current$ : 0;
3965
- dragMaxWidth.current = (_ref2 = (_tableHorizontalConta = (_tableHorizontalConta2 = tableHorizontalContainerRef.current) === null || _tableHorizontalConta2 === void 0 ? void 0 : _tableHorizontalConta2.scrollWidth) != null ? _tableHorizontalConta : (_tableInnerScrollRef$ = tableInnerScrollRef.current) === null || _tableInnerScrollRef$ === void 0 ? void 0 : _tableInnerScrollRef$.scrollWidth) != null ? _ref2 : Math.max(100, ((_wrapperRef$current$o = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.offsetWidth) != null ? _wrapperRef$current$o : Infinity) - 200);
4064
+ dragMaxWidth.current = tableCap;
3966
4065
  e.preventDefault();
3967
4066
  };
3968
4067
 
@@ -3986,25 +4085,25 @@ var Gantt = function Gantt(_ref) {
3986
4085
  };
3987
4086
  }, []);
3988
4087
 
3989
- var _useState6 = React.useState(0),
3990
- svgContainerWidth = _useState6[0],
3991
- setSvgContainerWidth = _useState6[1];
4088
+ var _useState7 = React.useState(0),
4089
+ svgContainerWidth = _useState7[0],
4090
+ setSvgContainerWidth = _useState7[1];
3992
4091
 
3993
- var _useState7 = React.useState(ganttHeight),
3994
- svgContainerHeight = _useState7[0],
3995
- setSvgContainerHeight = _useState7[1];
4092
+ var _useState8 = React.useState(ganttHeight),
4093
+ svgContainerHeight = _useState8[0],
4094
+ setSvgContainerHeight = _useState8[1];
3996
4095
 
3997
- var _useState8 = React.useState([]),
3998
- barTasks = _useState8[0],
3999
- setBarTasks = _useState8[1];
4096
+ var _useState9 = React.useState([]),
4097
+ barTasks = _useState9[0],
4098
+ setBarTasks = _useState9[1];
4000
4099
 
4001
4100
  var debounceRef = React.useRef(null);
4002
4101
 
4003
- var _useState9 = React.useState({
4102
+ var _useState10 = React.useState({
4004
4103
  action: ""
4005
4104
  }),
4006
- ganttEvent = _useState9[0],
4007
- setGanttEvent = _useState9[1];
4105
+ ganttEvent = _useState10[0],
4106
+ setGanttEvent = _useState10[1];
4008
4107
 
4009
4108
  var handleBarTasksUpdate = function handleBarTasksUpdate(task) {
4010
4109
  setBarTasks(function (prev) {
@@ -4018,35 +4117,64 @@ var Gantt = function Gantt(_ref) {
4018
4117
  return rowHeight * barFill / 100;
4019
4118
  }, [rowHeight, barFill]);
4020
4119
 
4021
- var _useState10 = React.useState(),
4022
- selectedTask = _useState10[0],
4023
- setSelectedTask = _useState10[1];
4024
-
4025
- var _useState11 = React.useState(null),
4026
- failedTask = _useState11[0],
4027
- setFailedTask = _useState11[1];
4120
+ var _useState11 = React.useState(),
4121
+ selectedTask = _useState11[0],
4122
+ setSelectedTask = _useState11[1];
4028
4123
 
4029
4124
  var _useState12 = React.useState(null),
4030
- computedColumnWidth = _useState12[0],
4031
- setComputedColumnWidth = _useState12[1];
4125
+ failedTask = _useState12[0],
4126
+ setFailedTask = _useState12[1];
4127
+
4128
+ var _useState13 = React.useState(null),
4129
+ computedColumnWidth = _useState13[0],
4130
+ setComputedColumnWidth = _useState13[1];
4032
4131
 
4033
4132
  var computedForViewModeRef = React.useRef(null);
4034
4133
  React.useEffect(function () {
4035
4134
  if (columnWidthProp != null) return;
4036
4135
  if (svgContainerWidth <= 0) return;
4136
+ var minVisible = VIEW_MODE_DEFAULT_VISIBLE_COUNT[viewMode];
4137
+ if (!minVisible) return;
4138
+ var maxVisible = VIEW_MODE_MAX_VISIBLE_COUNT[viewMode];
4139
+ var prevViewMode = computedForViewModeRef.current;
4140
+
4141
+ if (prevViewMode != null && prevViewMode !== viewMode && computedColumnWidth != null) {
4142
+ var visible = svgContainerWidth / computedColumnWidth;
4143
+ var oldMin = VIEW_MODE_DEFAULT_VISIBLE_COUNT[prevViewMode];
4144
+ var oldMax = VIEW_MODE_MAX_VISIBLE_COUNT[prevViewMode];
4145
+ var _next = computedColumnWidth;
4146
+
4147
+ if (maxVisible && oldMin != null && oldMax != null && oldMax > oldMin) {
4148
+ var t = Math.min(1, Math.max(0, (visible - oldMin) / (oldMax - oldMin)));
4149
+ var targetVisible = minVisible + t * (maxVisible - minVisible);
4150
+ _next = Math.floor(svgContainerWidth / targetVisible);
4151
+ } else if (visible < minVisible) {
4152
+ _next = Math.floor(svgContainerWidth / minVisible);
4153
+ } else if (maxVisible && visible > maxVisible) {
4154
+ _next = Math.ceil(svgContainerWidth / maxVisible);
4155
+ }
4156
+
4157
+ _next = Math.max(20, _next);
4158
+ computedForViewModeRef.current = viewMode;
4159
+ userResizedRef.current = true;
4160
+
4161
+ if (_next !== computedColumnWidth) {
4162
+ setComputedColumnWidth(_next);
4163
+ }
4164
+
4165
+ return;
4166
+ }
4167
+
4037
4168
  var alreadySnappedForView = computedForViewModeRef.current === viewMode && computedColumnWidth != null;
4038
4169
  if (userResizedRef.current && alreadySnappedForView) return;
4039
- var target = VIEW_MODE_DEFAULT_VISIBLE_COUNT[viewMode];
4040
- if (!target) return;
4041
- var next = Math.max(20, Math.floor(svgContainerWidth / target));
4170
+ var next = Math.max(20, Math.floor(svgContainerWidth / minVisible));
4171
+ computedForViewModeRef.current = viewMode;
4042
4172
 
4043
4173
  if (next !== computedColumnWidth) {
4044
4174
  setComputedColumnWidth(next);
4045
4175
  }
4046
-
4047
- computedForViewModeRef.current = viewMode;
4048
4176
  }, [viewMode, svgContainerWidth, columnWidthProp, computedColumnWidth]);
4049
- var columnWidth = (_ref3 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref3 : 60;
4177
+ var columnWidth = (_ref2 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref2 : 60;
4050
4178
  var effectiveColumnWidth = React.useMemo(function () {
4051
4179
  if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
4052
4180
 
@@ -4067,29 +4195,29 @@ var Gantt = function Gantt(_ref) {
4067
4195
  return barTasks.length * rowHeight;
4068
4196
  }, [barTasks.length, rowHeight]);
4069
4197
 
4070
- var _useState13 = React.useState(0),
4071
- scrollY = _useState13[0],
4072
- setScrollY = _useState13[1];
4073
-
4074
- var _useState14 = React.useState(-1),
4075
- scrollX = _useState14[0],
4076
- setScrollX = _useState14[1];
4198
+ var _useState14 = React.useState(0),
4199
+ scrollY = _useState14[0],
4200
+ setScrollY = _useState14[1];
4077
4201
 
4078
- var _useState15 = React.useState(false),
4079
- ignoreScrollEvent = _useState15[0],
4080
- setIgnoreScrollEvent = _useState15[1];
4202
+ var _useState15 = React.useState(-1),
4203
+ scrollX = _useState15[0],
4204
+ setScrollX = _useState15[1];
4081
4205
 
4082
- var _useState16 = React.useState(0),
4083
- lastTouchX = _useState16[0],
4084
- setLastTouchX = _useState16[1];
4206
+ var _useState16 = React.useState(false),
4207
+ ignoreScrollEvent = _useState16[0],
4208
+ setIgnoreScrollEvent = _useState16[1];
4085
4209
 
4086
4210
  var _useState17 = React.useState(0),
4087
- lastTouchY = _useState17[0],
4088
- setLastTouchY = _useState17[1];
4211
+ lastTouchX = _useState17[0],
4212
+ setLastTouchX = _useState17[1];
4213
+
4214
+ var _useState18 = React.useState(0),
4215
+ lastTouchY = _useState18[0],
4216
+ setLastTouchY = _useState18[1];
4089
4217
 
4090
- var _useState18 = React.useState(false),
4091
- isProcessing = _useState18[0],
4092
- setIsProcessing = _useState18[1];
4218
+ var _useState19 = React.useState(false),
4219
+ isProcessing = _useState19[0],
4220
+ setIsProcessing = _useState19[1];
4093
4221
 
4094
4222
  var buffer = rowHeight * 10;
4095
4223
  var visibleStartY = scrollY - buffer;
@@ -4210,11 +4338,48 @@ var Gantt = function Gantt(_ref) {
4210
4338
  setTaskListWidth(taskListRef.current.offsetWidth);
4211
4339
  }
4212
4340
  }, [taskListRef, listCellWidth]);
4341
+ React.useEffect(function () {
4342
+ if (!listCellWidth || !taskListRef.current) return;
4343
+ if (typeof ResizeObserver === "undefined") return;
4344
+
4345
+ var measure = function measure() {
4346
+ if (taskListRef.current) {
4347
+ setTaskListWidth(taskListRef.current.offsetWidth);
4348
+ }
4349
+ };
4350
+
4351
+ var observer = new ResizeObserver(measure);
4352
+ observer.observe(taskListRef.current);
4353
+ measure();
4354
+ return function () {
4355
+ return observer.disconnect();
4356
+ };
4357
+ }, [listCellWidth, scheduleType]);
4213
4358
  React.useEffect(function () {
4214
4359
  if (wrapperRef.current) {
4215
4360
  setSvgContainerWidth(wrapperRef.current.offsetWidth - taskListWidth - 20);
4216
4361
  }
4217
- }, [wrapperRef, taskListWidth]);
4362
+ }, [wrapperRef, taskListWidth, wrapperWidth]);
4363
+ React.useEffect(function () {
4364
+ var node = wrapperRef.current;
4365
+ if (!node) return;
4366
+
4367
+ if (typeof ResizeObserver === "undefined") {
4368
+ setWrapperWidth(node.offsetWidth);
4369
+ return;
4370
+ }
4371
+
4372
+ var measure = function measure() {
4373
+ return setWrapperWidth(node.offsetWidth);
4374
+ };
4375
+
4376
+ var observer = new ResizeObserver(measure);
4377
+ observer.observe(node);
4378
+ measure();
4379
+ return function () {
4380
+ return observer.disconnect();
4381
+ };
4382
+ }, []);
4218
4383
  React.useEffect(function () {
4219
4384
  if (ganttHeight) {
4220
4385
  setSvgContainerHeight(ganttHeight + headerHeight);
@@ -4223,7 +4388,7 @@ var Gantt = function Gantt(_ref) {
4223
4388
  }
4224
4389
  }, [ganttHeight, tasks, headerHeight, rowHeight]);
4225
4390
  React.useEffect(function () {
4226
- var _wrapperRef$current2, _wrapperRef$current3, _wrapperRef$current4, _wrapperRef$current5;
4391
+ var _wrapperRef$current, _wrapperRef$current2, _wrapperRef$current3, _wrapperRef$current4;
4227
4392
 
4228
4393
  var handleWheel = function handleWheel(event) {
4229
4394
  if (event.shiftKey || event.deltaX) {
@@ -4297,25 +4462,25 @@ var Gantt = function Gantt(_ref) {
4297
4462
  setIgnoreScrollEvent(true);
4298
4463
  };
4299
4464
 
4300
- (_wrapperRef$current2 = wrapperRef.current) === null || _wrapperRef$current2 === void 0 ? void 0 : _wrapperRef$current2.addEventListener("wheel", handleWheel, {
4465
+ (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.addEventListener("wheel", handleWheel, {
4301
4466
  passive: false
4302
4467
  });
4303
- (_wrapperRef$current3 = wrapperRef.current) === null || _wrapperRef$current3 === void 0 ? void 0 : _wrapperRef$current3.addEventListener("touchmove", handleTouch, {
4468
+ (_wrapperRef$current2 = wrapperRef.current) === null || _wrapperRef$current2 === void 0 ? void 0 : _wrapperRef$current2.addEventListener("touchmove", handleTouch, {
4304
4469
  passive: false
4305
4470
  });
4306
- (_wrapperRef$current4 = wrapperRef.current) === null || _wrapperRef$current4 === void 0 ? void 0 : _wrapperRef$current4.addEventListener("touchstart", handleLogTouch, {
4471
+ (_wrapperRef$current3 = wrapperRef.current) === null || _wrapperRef$current3 === void 0 ? void 0 : _wrapperRef$current3.addEventListener("touchstart", handleLogTouch, {
4307
4472
  passive: false
4308
4473
  });
4309
- (_wrapperRef$current5 = wrapperRef.current) === null || _wrapperRef$current5 === void 0 ? void 0 : _wrapperRef$current5.addEventListener("touchend", handleLogTouch, {
4474
+ (_wrapperRef$current4 = wrapperRef.current) === null || _wrapperRef$current4 === void 0 ? void 0 : _wrapperRef$current4.addEventListener("touchend", handleLogTouch, {
4310
4475
  passive: false
4311
4476
  });
4312
4477
  return function () {
4313
- var _wrapperRef$current6, _wrapperRef$current7, _wrapperRef$current8, _wrapperRef$current9;
4478
+ var _wrapperRef$current5, _wrapperRef$current6, _wrapperRef$current7, _wrapperRef$current8;
4314
4479
 
4315
- (_wrapperRef$current6 = wrapperRef.current) === null || _wrapperRef$current6 === void 0 ? void 0 : _wrapperRef$current6.removeEventListener("wheel", handleWheel);
4316
- (_wrapperRef$current7 = wrapperRef.current) === null || _wrapperRef$current7 === void 0 ? void 0 : _wrapperRef$current7.removeEventListener("touchmove", handleTouch);
4480
+ (_wrapperRef$current5 = wrapperRef.current) === null || _wrapperRef$current5 === void 0 ? void 0 : _wrapperRef$current5.removeEventListener("wheel", handleWheel);
4481
+ (_wrapperRef$current6 = wrapperRef.current) === null || _wrapperRef$current6 === void 0 ? void 0 : _wrapperRef$current6.removeEventListener("touchmove", handleTouch);
4482
+ (_wrapperRef$current7 = wrapperRef.current) === null || _wrapperRef$current7 === void 0 ? void 0 : _wrapperRef$current7.removeEventListener("touchend", handleLogTouch);
4317
4483
  (_wrapperRef$current8 = wrapperRef.current) === null || _wrapperRef$current8 === void 0 ? void 0 : _wrapperRef$current8.removeEventListener("touchend", handleLogTouch);
4318
- (_wrapperRef$current9 = wrapperRef.current) === null || _wrapperRef$current9 === void 0 ? void 0 : _wrapperRef$current9.removeEventListener("touchend", handleLogTouch);
4319
4484
  };
4320
4485
  }, [wrapperRef, scrollY, scrollX, ganttHeight, svgWidth, rtl, ganttFullHeight]);
4321
4486
 
@@ -4329,7 +4494,7 @@ var Gantt = function Gantt(_ref) {
4329
4494
  };
4330
4495
 
4331
4496
  var handleScrollX = function handleScrollX(event) {
4332
- if (scrollX !== event.currentTarget.scrollLeft) {
4497
+ if (scrollX !== event.currentTarget.scrollLeft && !ignoreScrollEvent) {
4333
4498
  setScrollX(event.currentTarget.scrollLeft);
4334
4499
  setIgnoreScrollEvent(true);
4335
4500
  } else {
@@ -4441,7 +4606,8 @@ var Gantt = function Gantt(_ref) {
4441
4606
  fontFamily: fontFamily,
4442
4607
  fontSize: fontSize,
4443
4608
  rtl: rtl,
4444
- projectCalendar: projectCalendar
4609
+ projectCalendar: projectCalendar,
4610
+ weekendColor: weekendColor
4445
4611
  };
4446
4612
  var barProps = {
4447
4613
  tasks: barTasks,
@@ -4500,7 +4666,9 @@ var Gantt = function Gantt(_ref) {
4500
4666
  TaskListTable: TaskListTable,
4501
4667
  taskLabelRenderer: taskLabelRenderer,
4502
4668
  onMultiSelect: onMultiSelect,
4503
- containerWidth: tableContainerWidth != null ? tableContainerWidth : undefined,
4669
+ containerWidth: userResizedRef.current && tableContainerWidth != null ? Math.min(tableContainerWidth, tableCap) : undefined,
4670
+ containerMaxWidth: tableCap === Infinity ? undefined : tableCap,
4671
+ onContentWidthChange: setTableContentWidth,
4504
4672
  innerScrollRef: tableInnerScrollRef,
4505
4673
  horizontalContainerRef: tableHorizontalContainerRef
4506
4674
  };
@@ -4604,7 +4772,7 @@ var Gantt = function Gantt(_ref) {
4604
4772
  }
4605
4773
  }, React__default.createElement("div", {
4606
4774
  style: {
4607
- width: tableScrollableWidth
4775
+ width: tableContentWidth
4608
4776
  }
4609
4777
  })), React__default.createElement("div", {
4610
4778
  style: {
@@ -4639,6 +4807,9 @@ function topologicalOrderingHelper(taskID, taskMap, sortedTaskList) {
4639
4807
  return true;
4640
4808
  }
4641
4809
  function getCriticalPaths(leafTasks) {
4810
+ leafTasks = leafTasks.filter(function (t) {
4811
+ return t.type !== "milestone" && (t.start.getTime() !== 0 || t.end.getTime() !== 0);
4812
+ });
4642
4813
  var taskMap = {};
4643
4814
 
4644
4815
  for (var i = 0; i < leafTasks.length; i++) {
@@ -4821,28 +4992,26 @@ function computeCriticalPath(taskID, taskMap) {
4821
4992
  taskMap[taskID].paths[1].visited = false;
4822
4993
  }
4823
4994
  }
4824
-
4825
- if (paths.length === 0) {
4826
- var immediateChildDuration = taskMap[taskID].end - taskMap[taskID].start + depDuration - overlap - offTime;
4827
-
4828
- if (taskMap[taskID].paths.length < 2) {
4829
- taskMap[taskID].paths.push({
4830
- duration: immediateChildDuration,
4831
- task: dependents[j],
4832
- parent: taskID,
4833
- visited: false
4834
- });
4835
- } else if (immediateChildDuration > taskMap[taskID].paths[0].duration) {
4836
- taskMap[taskID].paths[0].duration = immediateChildDuration;
4837
- taskMap[taskID].paths[0].task = dependents[j];
4838
- taskMap[taskID].paths[0].parent = taskID;
4839
- taskMap[taskID].paths[0].visited = false;
4840
- } else if (immediateChildDuration > taskMap[taskID].paths[1].duration) {
4841
- taskMap[taskID].paths[1].duration = immediateChildDuration;
4842
- taskMap[taskID].paths[1].task = dependents[j];
4843
- taskMap[taskID].paths[1].parent = taskID;
4844
- taskMap[taskID].paths[1].visited = false;
4845
- }
4995
+ } else {
4996
+ var immediateChildDuration = taskMap[taskID].end - taskMap[taskID].start + depDuration - overlap - offTime;
4997
+
4998
+ if (taskMap[taskID].paths.length < 2) {
4999
+ taskMap[taskID].paths.push({
5000
+ duration: immediateChildDuration,
5001
+ task: dependents[j],
5002
+ parent: taskID,
5003
+ visited: false
5004
+ });
5005
+ } else if (immediateChildDuration > taskMap[taskID].paths[0].duration) {
5006
+ taskMap[taskID].paths[0].duration = immediateChildDuration;
5007
+ taskMap[taskID].paths[0].task = dependents[j];
5008
+ taskMap[taskID].paths[0].parent = taskID;
5009
+ taskMap[taskID].paths[0].visited = false;
5010
+ } else if (immediateChildDuration > taskMap[taskID].paths[1].duration) {
5011
+ taskMap[taskID].paths[1].duration = immediateChildDuration;
5012
+ taskMap[taskID].paths[1].task = dependents[j];
5013
+ taskMap[taskID].paths[1].parent = taskID;
5014
+ taskMap[taskID].paths[1].visited = false;
4846
5015
  }
4847
5016
  }
4848
5017
  }