gantt-task-react-powern 0.6.30 → 0.6.31

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.
@@ -74,6 +74,7 @@ var ViewMode;
74
74
  ViewMode["Year"] = "Year";
75
75
  })(ViewMode || (ViewMode = {}));
76
76
 
77
+ var _VIEW_MODE_DEFAULT_VI, _VIEW_MODE_MAX_VISIBL;
77
78
  var intlDTCache = {};
78
79
  var getCachedDateTimeFormat = function getCachedDateTimeFormat(locString, opts) {
79
80
  if (opts === void 0) {
@@ -115,6 +116,8 @@ var getFiscalQuarterStartDate = function getFiscalQuarterStartDate(date, quarter
115
116
  return new Date(year, qStartMonth, 1);
116
117
  };
117
118
 
119
+ var VIEW_MODE_DEFAULT_VISIBLE_COUNT = (_VIEW_MODE_DEFAULT_VI = {}, _VIEW_MODE_DEFAULT_VI[ViewMode.Day] = 14, _VIEW_MODE_DEFAULT_VI[ViewMode.Week] = 6, _VIEW_MODE_DEFAULT_VI[ViewMode.Month] = 6, _VIEW_MODE_DEFAULT_VI[ViewMode.Quarter] = 4, _VIEW_MODE_DEFAULT_VI);
120
+ var VIEW_MODE_MAX_VISIBLE_COUNT = (_VIEW_MODE_MAX_VISIBL = {}, _VIEW_MODE_MAX_VISIBL[ViewMode.Day] = 30, _VIEW_MODE_MAX_VISIBL[ViewMode.Week] = 13, _VIEW_MODE_MAX_VISIBL[ViewMode.Month] = 12, _VIEW_MODE_MAX_VISIBL[ViewMode.Quarter] = 8, _VIEW_MODE_MAX_VISIBL);
118
121
  var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount, quarterStart) {
119
122
  var _tasks$, _tasks$2, _tasks$3, _tasks$4;
120
123
 
@@ -3804,6 +3807,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
3804
3807
  };
3805
3808
 
3806
3809
  var Gantt = function Gantt(_ref) {
3810
+ var _ref3;
3811
+
3807
3812
  var tasks = _ref.tasks,
3808
3813
  _ref$leafTasks = _ref.leafTasks,
3809
3814
  leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
@@ -3815,8 +3820,7 @@ var Gantt = function Gantt(_ref) {
3815
3820
  endDate = _ref$endDate === void 0 ? new Date() : _ref$endDate,
3816
3821
  _ref$headerHeight = _ref.headerHeight,
3817
3822
  headerHeight = _ref$headerHeight === void 0 ? 50 : _ref$headerHeight,
3818
- _ref$columnWidth = _ref.columnWidth,
3819
- columnWidth = _ref$columnWidth === void 0 ? 60 : _ref$columnWidth,
3823
+ columnWidthProp = _ref.columnWidth,
3820
3824
  _ref$listCellWidth = _ref.listCellWidth,
3821
3825
  listCellWidth = _ref$listCellWidth === void 0 ? "155px" : _ref$listCellWidth,
3822
3826
  _ref$rowHeight = _ref.rowHeight,
@@ -3897,6 +3901,7 @@ var Gantt = function Gantt(_ref) {
3897
3901
  var wrapperRef = useRef(null);
3898
3902
  var taskListRef = useRef(null);
3899
3903
  var isDraggingTable = useRef(false);
3904
+ var userResizedRef = useRef(false);
3900
3905
  var dragStartX = useRef(0);
3901
3906
  var dragStartWidth = useRef(0);
3902
3907
  var dragMaxWidth = useRef(Infinity);
@@ -3953,6 +3958,7 @@ var Gantt = function Gantt(_ref) {
3953
3958
  var _taskListRef$current$, _taskListRef$current, _ref2, _tableHorizontalConta, _tableHorizontalConta2, _tableInnerScrollRef$, _wrapperRef$current$o, _wrapperRef$current;
3954
3959
 
3955
3960
  isDraggingTable.current = true;
3961
+ userResizedRef.current = true;
3956
3962
  dragStartX.current = e.clientX;
3957
3963
  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;
3958
3964
  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);
@@ -4019,38 +4025,70 @@ var Gantt = function Gantt(_ref) {
4019
4025
  failedTask = _useState11[0],
4020
4026
  setFailedTask = _useState11[1];
4021
4027
 
4028
+ var _useState12 = useState(null),
4029
+ computedColumnWidth = _useState12[0],
4030
+ setComputedColumnWidth = _useState12[1];
4031
+
4032
+ var computedForViewModeRef = useRef(null);
4033
+ useEffect(function () {
4034
+ if (columnWidthProp != null) return;
4035
+ if (svgContainerWidth <= 0) return;
4036
+ var alreadySnappedForView = computedForViewModeRef.current === viewMode && computedColumnWidth != null;
4037
+ if (userResizedRef.current && alreadySnappedForView) return;
4038
+ var target = VIEW_MODE_DEFAULT_VISIBLE_COUNT[viewMode];
4039
+ if (!target) return;
4040
+ var next = Math.max(20, Math.floor(svgContainerWidth / target));
4041
+
4042
+ if (next !== computedColumnWidth) {
4043
+ setComputedColumnWidth(next);
4044
+ }
4045
+
4046
+ computedForViewModeRef.current = viewMode;
4047
+ }, [viewMode, svgContainerWidth, columnWidthProp, computedColumnWidth]);
4048
+ var columnWidth = (_ref3 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref3 : 60;
4022
4049
  var effectiveColumnWidth = useMemo(function () {
4023
4050
  if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
4051
+
4052
+ if (columnWidthProp == null) {
4053
+ var maxVisible = VIEW_MODE_MAX_VISIBLE_COUNT[viewMode];
4054
+
4055
+ if (maxVisible) {
4056
+ return Math.max(columnWidth, Math.ceil(svgContainerWidth / maxVisible));
4057
+ }
4058
+
4059
+ return columnWidth;
4060
+ }
4061
+
4024
4062
  return Math.max(columnWidth, Math.ceil(svgContainerWidth / dateSetup.dates.length));
4025
- }, [columnWidth, svgContainerWidth, dateSetup.dates.length]);
4063
+ }, [columnWidth, columnWidthProp, viewMode, svgContainerWidth, dateSetup.dates.length]);
4026
4064
  var svgWidth = effectiveColumnWidth < 55 ? (dateSetup.dates.length + 0.5) * effectiveColumnWidth : dateSetup.dates.length * effectiveColumnWidth;
4027
4065
  var ganttFullHeight = useMemo(function () {
4028
4066
  return barTasks.length * rowHeight;
4029
4067
  }, [barTasks.length, rowHeight]);
4030
4068
 
4031
- var _useState12 = useState(0),
4032
- scrollY = _useState12[0],
4033
- setScrollY = _useState12[1];
4034
-
4035
- var _useState13 = useState(-1),
4036
- scrollX = _useState13[0],
4037
- setScrollX = _useState13[1];
4069
+ var _useState13 = useState(0),
4070
+ scrollY = _useState13[0],
4071
+ setScrollY = _useState13[1];
4038
4072
 
4039
- var _useState14 = useState(false),
4040
- ignoreScrollEvent = _useState14[0],
4041
- setIgnoreScrollEvent = _useState14[1];
4073
+ var _useState14 = useState(-1),
4074
+ scrollX = _useState14[0],
4075
+ setScrollX = _useState14[1];
4042
4076
 
4043
- var _useState15 = useState(0),
4044
- lastTouchX = _useState15[0],
4045
- setLastTouchX = _useState15[1];
4077
+ var _useState15 = useState(false),
4078
+ ignoreScrollEvent = _useState15[0],
4079
+ setIgnoreScrollEvent = _useState15[1];
4046
4080
 
4047
4081
  var _useState16 = useState(0),
4048
- lastTouchY = _useState16[0],
4049
- setLastTouchY = _useState16[1];
4082
+ lastTouchX = _useState16[0],
4083
+ setLastTouchX = _useState16[1];
4084
+
4085
+ var _useState17 = useState(0),
4086
+ lastTouchY = _useState17[0],
4087
+ setLastTouchY = _useState17[1];
4050
4088
 
4051
- var _useState17 = useState(false),
4052
- isProcessing = _useState17[0],
4053
- setIsProcessing = _useState17[1];
4089
+ var _useState18 = useState(false),
4090
+ isProcessing = _useState18[0],
4091
+ setIsProcessing = _useState18[1];
4054
4092
 
4055
4093
  var buffer = rowHeight * 10;
4056
4094
  var visibleStartY = scrollY - buffer;