gantt-task-react-v 1.0.37 → 1.0.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.
@@ -8,5 +8,4 @@ export declare const VerticalScroll: React.FC<{
8
8
  onScroll: (event: SyntheticEvent<HTMLDivElement>) => void;
9
9
  rtl: boolean;
10
10
  verticalScrollbarRef: RefObject<HTMLDivElement>;
11
- containerHeight?: number | null;
12
11
  }>;
@@ -14,6 +14,7 @@ export type TaskListProps = {
14
14
  distances: Distances;
15
15
  fullRowHeight: number;
16
16
  ganttFullHeight: number;
17
+ ganttHeight: number;
17
18
  getTaskCurrentState: (task: Task) => Task;
18
19
  handleAddTask: (task: Task | null) => void;
19
20
  handleDeleteTasks: (task: RenderTask[]) => void;
@@ -4661,15 +4661,13 @@ const VerticalScroll = ({
4661
4661
  isChangeInProgress,
4662
4662
  onScroll,
4663
4663
  rtl,
4664
- verticalScrollbarRef,
4665
- containerHeight
4664
+ verticalScrollbarRef
4666
4665
  }) => {
4667
- const scrollHeight = containerHeight !== null && containerHeight !== void 0 ? Math.max(containerHeight - headerHeight, 100) : ganttHeight;
4668
4666
  return /* @__PURE__ */ jsx(
4669
4667
  "div",
4670
4668
  {
4671
4669
  style: {
4672
- height: scrollHeight,
4670
+ height: ganttHeight,
4673
4671
  marginTop: headerHeight,
4674
4672
  marginLeft: rtl ? void 0 : "-1rem",
4675
4673
  pointerEvents: isChangeInProgress ? "none" : void 0
@@ -5164,7 +5162,6 @@ const DEFAULT_THEME = {
5164
5162
  expandIconWidth: 20,
5165
5163
  handleWidth: 8,
5166
5164
  headerHeight: 50,
5167
- ganttHeight: 600,
5168
5165
  minimumRowDisplayed: 4,
5169
5166
  nestedTaskNameOffset: 20,
5170
5167
  relationCircleOffset: 10,
@@ -5299,7 +5296,8 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5299
5296
  titleCellWidth,
5300
5297
  dateCellWidth,
5301
5298
  dependenciesCellWidth,
5302
- actionColumnWidth
5299
+ actionColumnWidth,
5300
+ tableWidth: defaultTableWidth = 400
5303
5301
  } = theme.distances;
5304
5302
  const defaultColumns = useMemo(() => {
5305
5303
  return [
@@ -5335,6 +5333,10 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5335
5333
  const [columnsState, setColumns] = useState(
5336
5334
  clientColumns || defaultColumns
5337
5335
  );
5336
+ const taskListWidth = useMemo(
5337
+ () => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth,
5338
+ [columnsState, extraWidth]
5339
+ );
5338
5340
  useEffect(() => {
5339
5341
  if (clientColumns) {
5340
5342
  setColumns([...clientColumns]);
@@ -5342,19 +5344,23 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5342
5344
  const newColumnIds = clientColumns.map((col) => col.id);
5343
5345
  const widthOfAddedColumns = clientColumns.filter((col) => !currentColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
5344
5346
  const widthOfRemovedColumns = clientColumns.filter((col) => !newColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
5345
- setTableWidth(
5346
- (prev) => Math.min(
5347
- prev + widthOfAddedColumns - widthOfRemovedColumns,
5348
- clientColumns.reduce((res, { width }) => res + width, 0) + extraWidth
5349
- )
5350
- );
5347
+ setTableWidth((prev) => {
5348
+ const newWidth = prev + widthOfAddedColumns - widthOfRemovedColumns;
5349
+ return Math.max(newWidth, 100);
5350
+ });
5351
5351
  }
5352
- }, [clientColumns, extraWidth]);
5352
+ }, [clientColumns, extraWidth, taskListWidth]);
5353
5353
  const [tableResizeEvent, setTableResizeEvent] = useState(null);
5354
5354
  const [columnResizeEvent, setColumnResizeEvent] = useState(null);
5355
- const [tableWidthState, setTableWidth] = useState(
5356
- () => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth
5357
- );
5355
+ const [tableWidthState, setTableWidth] = useState(() => {
5356
+ const calculatedWidth = columnsState.reduce((res, { width }) => res + width, 0) + extraWidth;
5357
+ const MAX_INITIAL_WIDTH = 600;
5358
+ if (calculatedWidth <= MAX_INITIAL_WIDTH) {
5359
+ return calculatedWidth;
5360
+ } else {
5361
+ return defaultTableWidth;
5362
+ }
5363
+ });
5358
5364
  const onTableResizeStart = (clientX) => {
5359
5365
  const newTableResizeEvent = {
5360
5366
  initialClientX: clientX,
@@ -5373,7 +5379,6 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5373
5379
  };
5374
5380
  const isResizeTableInProgress = Boolean(tableResizeEvent);
5375
5381
  const isResizeColumnInProgress = Boolean(columnResizeEvent);
5376
- const taskListWidth = columnsState.reduce((res, { width }) => res + width, 0) + extraWidth;
5377
5382
  useEffect(() => {
5378
5383
  if (!isResizeTableInProgress) {
5379
5384
  return void 0;
@@ -5381,9 +5386,15 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5381
5386
  const handleMove = (clientX) => {
5382
5387
  const moveDelta = clientX - tableResizeEvent.initialClientX;
5383
5388
  setTableWidth(() => {
5389
+ const newWidth = tableResizeEvent.initialTableWidth + moveDelta;
5390
+ const ganttContainer = ganttRef.current;
5391
+ const containerWidth = ganttContainer ? ganttContainer.offsetWidth : 1e3;
5392
+ const maxTableWidth = Math.max(containerWidth - 100, taskListWidth);
5384
5393
  return Math.min(
5385
- Math.max(tableResizeEvent.initialTableWidth + moveDelta, 50),
5386
- taskListWidth
5394
+ Math.max(newWidth, 50),
5395
+ // Minimum width of 50px
5396
+ maxTableWidth
5397
+ // Allow table to expand much more
5387
5398
  );
5388
5399
  });
5389
5400
  };
@@ -5443,12 +5454,18 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5443
5454
  return newColumns;
5444
5455
  });
5445
5456
  if (previousColumnWidth !== newColumnWidth) {
5446
- setTableWidth(
5447
- () => Math.min(
5448
- Math.max(columnResizeEvent.initialTableWidth + moveDelta, 50),
5449
- taskListWidth
5450
- )
5451
- );
5457
+ setTableWidth(() => {
5458
+ const newTableWidth = columnResizeEvent.initialTableWidth + moveDelta;
5459
+ const ganttContainer = ganttRef.current;
5460
+ const containerWidth = ganttContainer ? ganttContainer.offsetWidth : 1e3;
5461
+ const maxTableWidth = Math.max(containerWidth - 100, taskListWidth);
5462
+ return Math.min(
5463
+ Math.max(newTableWidth, 50),
5464
+ // Minimum width
5465
+ maxTableWidth
5466
+ // Allow expansion beyond column width
5467
+ );
5468
+ });
5452
5469
  }
5453
5470
  };
5454
5471
  const handleMouseMove = (event) => {
@@ -10640,14 +10657,14 @@ const TaskListTableDefaultInner = ({
10640
10657
  );
10641
10658
  };
10642
10659
  const TaskListTable = memo(TaskListTableDefaultInner);
10643
- const taskListRoot = "_taskListRoot_apbmu_1";
10644
- const taskListHorizontalScroll = "_taskListHorizontalScroll_apbmu_19";
10645
- const taskListResizer = "_taskListResizer_apbmu_83";
10646
- const horizontalContainer$1 = "_horizontalContainer_apbmu_147";
10647
- const tableWrapper = "_tableWrapper_apbmu_163";
10648
- const scrollToTop = "_scrollToTop_apbmu_177";
10649
- const scrollToBottom = "_scrollToBottom_apbmu_193";
10650
- const hidden = "_hidden_apbmu_209";
10660
+ const taskListRoot = "_taskListRoot_13wkq_1";
10661
+ const taskListHorizontalScroll = "_taskListHorizontalScroll_13wkq_23";
10662
+ const taskListResizer = "_taskListResizer_13wkq_87";
10663
+ const horizontalContainer$1 = "_horizontalContainer_13wkq_151";
10664
+ const tableWrapper = "_tableWrapper_13wkq_165";
10665
+ const scrollToTop = "_scrollToTop_13wkq_179";
10666
+ const scrollToBottom = "_scrollToBottom_13wkq_195";
10667
+ const hidden = "_hidden_13wkq_211";
10651
10668
  const styles$d = {
10652
10669
  taskListRoot,
10653
10670
  taskListHorizontalScroll,
@@ -10681,6 +10698,7 @@ const TaskListInner = ({
10681
10698
  distances,
10682
10699
  fullRowHeight,
10683
10700
  ganttFullHeight,
10701
+ ganttHeight,
10684
10702
  getTaskCurrentState,
10685
10703
  handleAddTask,
10686
10704
  handleDeleteTasks,
@@ -10811,16 +10829,17 @@ const TaskListInner = ({
10811
10829
  ref: taskListContainerRef,
10812
10830
  className: styles$d.horizontalContainer,
10813
10831
  style: {
10814
- height: "100%",
10815
- minHeight: distances.minimumRowDisplayed * distances.rowHeight,
10832
+ height: Math.max(
10833
+ ganttHeight - ((tableBottom == null ? void 0 : tableBottom.height) || 0),
10834
+ distances.minimumRowDisplayed * distances.rowHeight
10835
+ ),
10816
10836
  width: taskListWidth
10817
10837
  },
10818
10838
  children: /* @__PURE__ */ jsx(
10819
10839
  "div",
10820
10840
  {
10821
10841
  style: {
10822
- height: "100%",
10823
- minHeight: Math.max(
10842
+ height: Math.max(
10824
10843
  ganttFullHeight,
10825
10844
  distances.minimumRowDisplayed * distances.rowHeight
10826
10845
  ),
@@ -13136,10 +13155,10 @@ const TaskGanttContentInner = (props) => {
13136
13155
  ] });
13137
13156
  };
13138
13157
  const TaskGanttContent = memo(TaskGanttContentInner);
13139
- const ganttVerticalContainer = "_ganttVerticalContainer_i4cef_1";
13140
- const horizontalContainer = "_horizontalContainer_i4cef_79";
13141
- const wrapper = "_wrapper_i4cef_95";
13142
- const calendarDragging = "_calendarDragging_i4cef_125";
13158
+ const ganttVerticalContainer = "_ganttVerticalContainer_5z1c2_1";
13159
+ const horizontalContainer = "_horizontalContainer_5z1c2_75";
13160
+ const wrapper = "_wrapper_5z1c2_87";
13161
+ const calendarDragging = "_calendarDragging_5z1c2_117";
13143
13162
  const styles$2 = {
13144
13163
  ganttVerticalContainer,
13145
13164
  horizontalContainer,
@@ -13154,6 +13173,7 @@ const TaskGanttInner = (props) => {
13154
13173
  fullRowHeight,
13155
13174
  fullSvgWidth,
13156
13175
  ganttFullHeight,
13176
+ ganttHeight,
13157
13177
  ganttSVGRef,
13158
13178
  ganttTodayProps,
13159
13179
  ganttTodayProps: {
@@ -13170,16 +13190,14 @@ const TaskGanttInner = (props) => {
13170
13190
  const moveStateScrollRef = useRef(null);
13171
13191
  const containerStyle = useMemo(
13172
13192
  () => ({
13173
- height: "100%",
13174
- width: fullSvgWidth,
13175
- minHeight: minimumRowDisplayed * rowHeight
13193
+ height: Math.max(ganttHeight, minimumRowDisplayed * rowHeight),
13194
+ width: fullSvgWidth
13176
13195
  }),
13177
- [minimumRowDisplayed, rowHeight, fullSvgWidth]
13196
+ [ganttHeight, minimumRowDisplayed, rowHeight, fullSvgWidth]
13178
13197
  );
13179
13198
  const gridStyle = useMemo(
13180
13199
  () => ({
13181
- height: "100%",
13182
- minHeight: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
13200
+ height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
13183
13201
  width: fullSvgWidth,
13184
13202
  backgroundSize: `${columnWidth}px ${fullRowHeight * 2}px`,
13185
13203
  backgroundPositionX: additionalLeftSpace || void 0,
@@ -13210,7 +13228,7 @@ const TaskGanttInner = (props) => {
13210
13228
  clientX: event.clientX,
13211
13229
  clientY: event.clientY,
13212
13230
  scrollLeft: verticalGanttContainerRef.current.scrollLeft,
13213
- scrollTop: verticalGanttContainerRef.current.scrollTop
13231
+ scrollTop: horizontalContainerRef.current.scrollTop
13214
13232
  };
13215
13233
  moveStateHorRef.current = {
13216
13234
  clientX: event.clientX,
@@ -13231,10 +13249,9 @@ const TaskGanttInner = (props) => {
13231
13249
  return;
13232
13250
  }
13233
13251
  event.preventDefault();
13234
- const { clientX, scrollLeft, scrollTop, clientY } = moveStateVertRef.current;
13252
+ const { clientX, scrollLeft } = moveStateVertRef.current;
13235
13253
  const scrollVertContainer = verticalGanttContainerRef.current;
13236
13254
  scrollVertContainer.scrollLeft = scrollLeft + clientX - event.clientX;
13237
- scrollVertContainer.scrollTop = scrollTop + clientY - event.clientY;
13238
13255
  const {
13239
13256
  clientX: clientXH,
13240
13257
  scrollLeft: scrollLeftH,
@@ -13258,6 +13275,7 @@ const TaskGanttInner = (props) => {
13258
13275
  event.preventDefault();
13259
13276
  moveStateVertRef.current = null;
13260
13277
  moveStateHorRef.current = null;
13278
+ moveStateScrollRef.current = null;
13261
13279
  contentContainer.classList.remove(styles$2.calendarDragging);
13262
13280
  };
13263
13281
  contentContainer.addEventListener("mousemove", onScrollMove);
@@ -18598,9 +18616,28 @@ const Gantt = (props) => {
18598
18616
  const [sortedTasks, setSortedTasks] = useState(
18599
18617
  () => [...clientTasks].sort(sortTasks)
18600
18618
  );
18619
+ const [containerHeight, setContainerHeight] = useState(
18620
+ void 0
18621
+ );
18601
18622
  useEffect(() => {
18602
18623
  setSortedTasks([...clientTasks].sort(sortTasks));
18603
18624
  }, [clientTasks]);
18625
+ useEffect(() => {
18626
+ if (!wrapperRef.current) {
18627
+ return () => {
18628
+ };
18629
+ }
18630
+ const resizeObserver = new ResizeObserver((entries) => {
18631
+ for (const entry of entries) {
18632
+ const { height } = entry.contentRect;
18633
+ setContainerHeight(height);
18634
+ }
18635
+ });
18636
+ resizeObserver.observe(wrapperRef.current);
18637
+ return () => {
18638
+ resizeObserver.disconnect();
18639
+ };
18640
+ }, []);
18604
18641
  const [childTasksMap, rootTasksMap] = useMemo(
18605
18642
  () => getChildsAndRoots(sortedTasks, null),
18606
18643
  [sortedTasks]
@@ -18678,34 +18715,21 @@ const Gantt = (props) => {
18678
18715
  },
18679
18716
  [maxLevelLength, fullRowHeight, (_a = taskList == null ? void 0 : taskList.tableBottom) == null ? void 0 : _a.height]
18680
18717
  );
18681
- const [containerHeight, setContainerHeight] = useState(null);
18682
- useEffect(() => {
18683
- const wrapperElement = wrapperRef.current;
18684
- if (!wrapperElement) {
18685
- return void 0;
18686
- }
18687
- const resizeObserver = new ResizeObserver((entries) => {
18688
- for (const entry of entries) {
18689
- const { height } = entry.contentRect;
18690
- if (height > 0) {
18691
- setContainerHeight(height);
18692
- }
18693
- }
18694
- });
18695
- resizeObserver.observe(wrapperElement);
18696
- return () => {
18697
- resizeObserver.disconnect();
18698
- };
18699
- }, []);
18700
18718
  const ganttHeight = useMemo(() => {
18701
- if (containerHeight !== null) {
18702
- return Math.min(
18703
- containerHeight - distances.headerHeight,
18704
- ganttFullHeight
18705
- );
18719
+ if (distances.ganttHeight) {
18720
+ return Math.min(distances.ganttHeight, ganttFullHeight);
18721
+ }
18722
+ if (containerHeight) {
18723
+ const availableHeight = containerHeight - distances.headerHeight;
18724
+ return Math.min(availableHeight, ganttFullHeight);
18706
18725
  }
18707
- return distances.ganttHeight ? Math.min(distances.ganttHeight, ganttFullHeight) : ganttFullHeight;
18708
- }, [distances, ganttFullHeight, containerHeight]);
18726
+ return ganttFullHeight;
18727
+ }, [
18728
+ distances.ganttHeight,
18729
+ distances.headerHeight,
18730
+ ganttFullHeight,
18731
+ containerHeight
18732
+ ]);
18709
18733
  const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = useMemo(
18710
18734
  () => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
18711
18735
  [visibleTasks, comparisonLevels]
@@ -19787,6 +19811,7 @@ const Gantt = (props) => {
19787
19811
  distances,
19788
19812
  fullRowHeight,
19789
19813
  ganttFullHeight,
19814
+ ganttHeight,
19790
19815
  getTaskCurrentState,
19791
19816
  handleAddTask,
19792
19817
  handleDeleteTasks,
@@ -19816,6 +19841,7 @@ const Gantt = (props) => {
19816
19841
  distances,
19817
19842
  fullRowHeight,
19818
19843
  ganttFullHeight,
19844
+ ganttHeight,
19819
19845
  getTaskCurrentState,
19820
19846
  handleAddTask,
19821
19847
  handleDeleteTasks,
@@ -19886,8 +19912,7 @@ const Gantt = (props) => {
19886
19912
  isChangeInProgress: Boolean(changeInProgress),
19887
19913
  onScroll: onVerticalScrollbarScrollY,
19888
19914
  rtl,
19889
- verticalScrollbarRef,
19890
- containerHeight
19915
+ verticalScrollbarRef
19891
19916
  }
19892
19917
  ),
19893
19918
  taskList.enableTableListContextMenu && !waitCommitTasks && /* @__PURE__ */ jsx(
@@ -4678,15 +4678,13 @@
4678
4678
  isChangeInProgress,
4679
4679
  onScroll,
4680
4680
  rtl,
4681
- verticalScrollbarRef,
4682
- containerHeight
4681
+ verticalScrollbarRef
4683
4682
  }) => {
4684
- const scrollHeight = containerHeight !== null && containerHeight !== void 0 ? Math.max(containerHeight - headerHeight, 100) : ganttHeight;
4685
4683
  return /* @__PURE__ */ jsxRuntime.jsx(
4686
4684
  "div",
4687
4685
  {
4688
4686
  style: {
4689
- height: scrollHeight,
4687
+ height: ganttHeight,
4690
4688
  marginTop: headerHeight,
4691
4689
  marginLeft: rtl ? void 0 : "-1rem",
4692
4690
  pointerEvents: isChangeInProgress ? "none" : void 0
@@ -5181,7 +5179,6 @@
5181
5179
  expandIconWidth: 20,
5182
5180
  handleWidth: 8,
5183
5181
  headerHeight: 50,
5184
- ganttHeight: 600,
5185
5182
  minimumRowDisplayed: 4,
5186
5183
  nestedTaskNameOffset: 20,
5187
5184
  relationCircleOffset: 10,
@@ -5316,7 +5313,8 @@
5316
5313
  titleCellWidth,
5317
5314
  dateCellWidth,
5318
5315
  dependenciesCellWidth,
5319
- actionColumnWidth
5316
+ actionColumnWidth,
5317
+ tableWidth: defaultTableWidth = 400
5320
5318
  } = theme.distances;
5321
5319
  const defaultColumns = React.useMemo(() => {
5322
5320
  return [
@@ -5352,6 +5350,10 @@
5352
5350
  const [columnsState, setColumns] = React.useState(
5353
5351
  clientColumns || defaultColumns
5354
5352
  );
5353
+ const taskListWidth = React.useMemo(
5354
+ () => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth,
5355
+ [columnsState, extraWidth]
5356
+ );
5355
5357
  React.useEffect(() => {
5356
5358
  if (clientColumns) {
5357
5359
  setColumns([...clientColumns]);
@@ -5359,19 +5361,23 @@
5359
5361
  const newColumnIds = clientColumns.map((col) => col.id);
5360
5362
  const widthOfAddedColumns = clientColumns.filter((col) => !currentColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
5361
5363
  const widthOfRemovedColumns = clientColumns.filter((col) => !newColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
5362
- setTableWidth(
5363
- (prev) => Math.min(
5364
- prev + widthOfAddedColumns - widthOfRemovedColumns,
5365
- clientColumns.reduce((res, { width }) => res + width, 0) + extraWidth
5366
- )
5367
- );
5364
+ setTableWidth((prev) => {
5365
+ const newWidth = prev + widthOfAddedColumns - widthOfRemovedColumns;
5366
+ return Math.max(newWidth, 100);
5367
+ });
5368
5368
  }
5369
- }, [clientColumns, extraWidth]);
5369
+ }, [clientColumns, extraWidth, taskListWidth]);
5370
5370
  const [tableResizeEvent, setTableResizeEvent] = React.useState(null);
5371
5371
  const [columnResizeEvent, setColumnResizeEvent] = React.useState(null);
5372
- const [tableWidthState, setTableWidth] = React.useState(
5373
- () => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth
5374
- );
5372
+ const [tableWidthState, setTableWidth] = React.useState(() => {
5373
+ const calculatedWidth = columnsState.reduce((res, { width }) => res + width, 0) + extraWidth;
5374
+ const MAX_INITIAL_WIDTH = 600;
5375
+ if (calculatedWidth <= MAX_INITIAL_WIDTH) {
5376
+ return calculatedWidth;
5377
+ } else {
5378
+ return defaultTableWidth;
5379
+ }
5380
+ });
5375
5381
  const onTableResizeStart = (clientX) => {
5376
5382
  const newTableResizeEvent = {
5377
5383
  initialClientX: clientX,
@@ -5390,7 +5396,6 @@
5390
5396
  };
5391
5397
  const isResizeTableInProgress = Boolean(tableResizeEvent);
5392
5398
  const isResizeColumnInProgress = Boolean(columnResizeEvent);
5393
- const taskListWidth = columnsState.reduce((res, { width }) => res + width, 0) + extraWidth;
5394
5399
  React.useEffect(() => {
5395
5400
  if (!isResizeTableInProgress) {
5396
5401
  return void 0;
@@ -5398,9 +5403,15 @@
5398
5403
  const handleMove = (clientX) => {
5399
5404
  const moveDelta = clientX - tableResizeEvent.initialClientX;
5400
5405
  setTableWidth(() => {
5406
+ const newWidth = tableResizeEvent.initialTableWidth + moveDelta;
5407
+ const ganttContainer = ganttRef.current;
5408
+ const containerWidth = ganttContainer ? ganttContainer.offsetWidth : 1e3;
5409
+ const maxTableWidth = Math.max(containerWidth - 100, taskListWidth);
5401
5410
  return Math.min(
5402
- Math.max(tableResizeEvent.initialTableWidth + moveDelta, 50),
5403
- taskListWidth
5411
+ Math.max(newWidth, 50),
5412
+ // Minimum width of 50px
5413
+ maxTableWidth
5414
+ // Allow table to expand much more
5404
5415
  );
5405
5416
  });
5406
5417
  };
@@ -5460,12 +5471,18 @@
5460
5471
  return newColumns;
5461
5472
  });
5462
5473
  if (previousColumnWidth !== newColumnWidth) {
5463
- setTableWidth(
5464
- () => Math.min(
5465
- Math.max(columnResizeEvent.initialTableWidth + moveDelta, 50),
5466
- taskListWidth
5467
- )
5468
- );
5474
+ setTableWidth(() => {
5475
+ const newTableWidth = columnResizeEvent.initialTableWidth + moveDelta;
5476
+ const ganttContainer = ganttRef.current;
5477
+ const containerWidth = ganttContainer ? ganttContainer.offsetWidth : 1e3;
5478
+ const maxTableWidth = Math.max(containerWidth - 100, taskListWidth);
5479
+ return Math.min(
5480
+ Math.max(newTableWidth, 50),
5481
+ // Minimum width
5482
+ maxTableWidth
5483
+ // Allow expansion beyond column width
5484
+ );
5485
+ });
5469
5486
  }
5470
5487
  };
5471
5488
  const handleMouseMove = (event) => {
@@ -10657,14 +10674,14 @@
10657
10674
  );
10658
10675
  };
10659
10676
  const TaskListTable = React.memo(TaskListTableDefaultInner);
10660
- const taskListRoot = "_taskListRoot_apbmu_1";
10661
- const taskListHorizontalScroll = "_taskListHorizontalScroll_apbmu_19";
10662
- const taskListResizer = "_taskListResizer_apbmu_83";
10663
- const horizontalContainer$1 = "_horizontalContainer_apbmu_147";
10664
- const tableWrapper = "_tableWrapper_apbmu_163";
10665
- const scrollToTop = "_scrollToTop_apbmu_177";
10666
- const scrollToBottom = "_scrollToBottom_apbmu_193";
10667
- const hidden = "_hidden_apbmu_209";
10677
+ const taskListRoot = "_taskListRoot_13wkq_1";
10678
+ const taskListHorizontalScroll = "_taskListHorizontalScroll_13wkq_23";
10679
+ const taskListResizer = "_taskListResizer_13wkq_87";
10680
+ const horizontalContainer$1 = "_horizontalContainer_13wkq_151";
10681
+ const tableWrapper = "_tableWrapper_13wkq_165";
10682
+ const scrollToTop = "_scrollToTop_13wkq_179";
10683
+ const scrollToBottom = "_scrollToBottom_13wkq_195";
10684
+ const hidden = "_hidden_13wkq_211";
10668
10685
  const styles$d = {
10669
10686
  taskListRoot,
10670
10687
  taskListHorizontalScroll,
@@ -10698,6 +10715,7 @@
10698
10715
  distances,
10699
10716
  fullRowHeight,
10700
10717
  ganttFullHeight,
10718
+ ganttHeight,
10701
10719
  getTaskCurrentState,
10702
10720
  handleAddTask,
10703
10721
  handleDeleteTasks,
@@ -10828,16 +10846,17 @@
10828
10846
  ref: taskListContainerRef,
10829
10847
  className: styles$d.horizontalContainer,
10830
10848
  style: {
10831
- height: "100%",
10832
- minHeight: distances.minimumRowDisplayed * distances.rowHeight,
10849
+ height: Math.max(
10850
+ ganttHeight - ((tableBottom == null ? void 0 : tableBottom.height) || 0),
10851
+ distances.minimumRowDisplayed * distances.rowHeight
10852
+ ),
10833
10853
  width: taskListWidth
10834
10854
  },
10835
10855
  children: /* @__PURE__ */ jsxRuntime.jsx(
10836
10856
  "div",
10837
10857
  {
10838
10858
  style: {
10839
- height: "100%",
10840
- minHeight: Math.max(
10859
+ height: Math.max(
10841
10860
  ganttFullHeight,
10842
10861
  distances.minimumRowDisplayed * distances.rowHeight
10843
10862
  ),
@@ -13153,10 +13172,10 @@
13153
13172
  ] });
13154
13173
  };
13155
13174
  const TaskGanttContent = React.memo(TaskGanttContentInner);
13156
- const ganttVerticalContainer = "_ganttVerticalContainer_i4cef_1";
13157
- const horizontalContainer = "_horizontalContainer_i4cef_79";
13158
- const wrapper = "_wrapper_i4cef_95";
13159
- const calendarDragging = "_calendarDragging_i4cef_125";
13175
+ const ganttVerticalContainer = "_ganttVerticalContainer_5z1c2_1";
13176
+ const horizontalContainer = "_horizontalContainer_5z1c2_75";
13177
+ const wrapper = "_wrapper_5z1c2_87";
13178
+ const calendarDragging = "_calendarDragging_5z1c2_117";
13160
13179
  const styles$2 = {
13161
13180
  ganttVerticalContainer,
13162
13181
  horizontalContainer,
@@ -13171,6 +13190,7 @@
13171
13190
  fullRowHeight,
13172
13191
  fullSvgWidth,
13173
13192
  ganttFullHeight,
13193
+ ganttHeight,
13174
13194
  ganttSVGRef,
13175
13195
  ganttTodayProps,
13176
13196
  ganttTodayProps: {
@@ -13187,16 +13207,14 @@
13187
13207
  const moveStateScrollRef = React.useRef(null);
13188
13208
  const containerStyle = React.useMemo(
13189
13209
  () => ({
13190
- height: "100%",
13191
- width: fullSvgWidth,
13192
- minHeight: minimumRowDisplayed * rowHeight
13210
+ height: Math.max(ganttHeight, minimumRowDisplayed * rowHeight),
13211
+ width: fullSvgWidth
13193
13212
  }),
13194
- [minimumRowDisplayed, rowHeight, fullSvgWidth]
13213
+ [ganttHeight, minimumRowDisplayed, rowHeight, fullSvgWidth]
13195
13214
  );
13196
13215
  const gridStyle = React.useMemo(
13197
13216
  () => ({
13198
- height: "100%",
13199
- minHeight: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
13217
+ height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
13200
13218
  width: fullSvgWidth,
13201
13219
  backgroundSize: `${columnWidth}px ${fullRowHeight * 2}px`,
13202
13220
  backgroundPositionX: additionalLeftSpace || void 0,
@@ -13227,7 +13245,7 @@
13227
13245
  clientX: event.clientX,
13228
13246
  clientY: event.clientY,
13229
13247
  scrollLeft: verticalGanttContainerRef.current.scrollLeft,
13230
- scrollTop: verticalGanttContainerRef.current.scrollTop
13248
+ scrollTop: horizontalContainerRef.current.scrollTop
13231
13249
  };
13232
13250
  moveStateHorRef.current = {
13233
13251
  clientX: event.clientX,
@@ -13248,10 +13266,9 @@
13248
13266
  return;
13249
13267
  }
13250
13268
  event.preventDefault();
13251
- const { clientX, scrollLeft, scrollTop, clientY } = moveStateVertRef.current;
13269
+ const { clientX, scrollLeft } = moveStateVertRef.current;
13252
13270
  const scrollVertContainer = verticalGanttContainerRef.current;
13253
13271
  scrollVertContainer.scrollLeft = scrollLeft + clientX - event.clientX;
13254
- scrollVertContainer.scrollTop = scrollTop + clientY - event.clientY;
13255
13272
  const {
13256
13273
  clientX: clientXH,
13257
13274
  scrollLeft: scrollLeftH,
@@ -13275,6 +13292,7 @@
13275
13292
  event.preventDefault();
13276
13293
  moveStateVertRef.current = null;
13277
13294
  moveStateHorRef.current = null;
13295
+ moveStateScrollRef.current = null;
13278
13296
  contentContainer.classList.remove(styles$2.calendarDragging);
13279
13297
  };
13280
13298
  contentContainer.addEventListener("mousemove", onScrollMove);
@@ -18615,9 +18633,28 @@
18615
18633
  const [sortedTasks, setSortedTasks] = React.useState(
18616
18634
  () => [...clientTasks].sort(sortTasks)
18617
18635
  );
18636
+ const [containerHeight, setContainerHeight] = React.useState(
18637
+ void 0
18638
+ );
18618
18639
  React.useEffect(() => {
18619
18640
  setSortedTasks([...clientTasks].sort(sortTasks));
18620
18641
  }, [clientTasks]);
18642
+ React.useEffect(() => {
18643
+ if (!wrapperRef.current) {
18644
+ return () => {
18645
+ };
18646
+ }
18647
+ const resizeObserver = new ResizeObserver((entries) => {
18648
+ for (const entry of entries) {
18649
+ const { height } = entry.contentRect;
18650
+ setContainerHeight(height);
18651
+ }
18652
+ });
18653
+ resizeObserver.observe(wrapperRef.current);
18654
+ return () => {
18655
+ resizeObserver.disconnect();
18656
+ };
18657
+ }, []);
18621
18658
  const [childTasksMap, rootTasksMap] = React.useMemo(
18622
18659
  () => getChildsAndRoots(sortedTasks, null),
18623
18660
  [sortedTasks]
@@ -18695,34 +18732,21 @@
18695
18732
  },
18696
18733
  [maxLevelLength, fullRowHeight, (_a = taskList == null ? void 0 : taskList.tableBottom) == null ? void 0 : _a.height]
18697
18734
  );
18698
- const [containerHeight, setContainerHeight] = React.useState(null);
18699
- React.useEffect(() => {
18700
- const wrapperElement = wrapperRef.current;
18701
- if (!wrapperElement) {
18702
- return void 0;
18703
- }
18704
- const resizeObserver = new ResizeObserver((entries) => {
18705
- for (const entry of entries) {
18706
- const { height } = entry.contentRect;
18707
- if (height > 0) {
18708
- setContainerHeight(height);
18709
- }
18710
- }
18711
- });
18712
- resizeObserver.observe(wrapperElement);
18713
- return () => {
18714
- resizeObserver.disconnect();
18715
- };
18716
- }, []);
18717
18735
  const ganttHeight = React.useMemo(() => {
18718
- if (containerHeight !== null) {
18719
- return Math.min(
18720
- containerHeight - distances.headerHeight,
18721
- ganttFullHeight
18722
- );
18736
+ if (distances.ganttHeight) {
18737
+ return Math.min(distances.ganttHeight, ganttFullHeight);
18738
+ }
18739
+ if (containerHeight) {
18740
+ const availableHeight = containerHeight - distances.headerHeight;
18741
+ return Math.min(availableHeight, ganttFullHeight);
18723
18742
  }
18724
- return distances.ganttHeight ? Math.min(distances.ganttHeight, ganttFullHeight) : ganttFullHeight;
18725
- }, [distances, ganttFullHeight, containerHeight]);
18743
+ return ganttFullHeight;
18744
+ }, [
18745
+ distances.ganttHeight,
18746
+ distances.headerHeight,
18747
+ ganttFullHeight,
18748
+ containerHeight
18749
+ ]);
18726
18750
  const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = React.useMemo(
18727
18751
  () => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
18728
18752
  [visibleTasks, comparisonLevels]
@@ -19804,6 +19828,7 @@
19804
19828
  distances,
19805
19829
  fullRowHeight,
19806
19830
  ganttFullHeight,
19831
+ ganttHeight,
19807
19832
  getTaskCurrentState,
19808
19833
  handleAddTask,
19809
19834
  handleDeleteTasks,
@@ -19833,6 +19858,7 @@
19833
19858
  distances,
19834
19859
  fullRowHeight,
19835
19860
  ganttFullHeight,
19861
+ ganttHeight,
19836
19862
  getTaskCurrentState,
19837
19863
  handleAddTask,
19838
19864
  handleDeleteTasks,
@@ -19903,8 +19929,7 @@
19903
19929
  isChangeInProgress: Boolean(changeInProgress),
19904
19930
  onScroll: onVerticalScrollbarScrollY,
19905
19931
  rtl,
19906
- verticalScrollbarRef,
19907
- containerHeight
19932
+ verticalScrollbarRef
19908
19933
  }
19909
19934
  ),
19910
19935
  taskList.enableTableListContextMenu && !waitCommitTasks && /* @__PURE__ */ jsxRuntime.jsx(
package/dist/style.css CHANGED
@@ -282,33 +282,35 @@
282
282
  border-bottom: 1px solid var(--gantt-divider-color);
283
283
  table-layout: fixed;
284
284
  }
285
- ._taskListRoot_apbmu_1 {
285
+ ._taskListRoot_13wkq_1 {
286
286
  position: relative;
287
- /*noinspection CssUnresolvedCustomProperty*/
288
- border-left: 1px solid var(--gantt-table-divider-color, var(--gantt-divider-color));
289
287
  height: 100%;
290
288
  display: flex;
291
289
  flex-direction: column;
290
+ min-width: 0;
291
+ flex-shrink: 0;
292
+ /*noinspection CssUnresolvedCustomProperty*/
293
+ border-left: 1px solid var(--gantt-table-divider-color, var(--gantt-divider-color));
292
294
  }
293
295
 
294
- ._taskListHorizontalScroll_apbmu_19 {
296
+ ._taskListHorizontalScroll_13wkq_23 {
295
297
  overflow-x: scroll;
296
- flex: 1;
297
- min-height: 0;
298
+ height: 100%;
298
299
  display: flex;
299
300
  flex-direction: column;
301
+ min-width: 0;
300
302
  }
301
303
 
302
- ._taskListHorizontalScroll_apbmu_19::-webkit-scrollbar {
304
+ ._taskListHorizontalScroll_13wkq_23::-webkit-scrollbar {
303
305
  width: 1rem;
304
306
  height: 1rem;
305
307
  }
306
308
 
307
- ._taskListHorizontalScroll_apbmu_19::-webkit-scrollbar-corner {
309
+ ._taskListHorizontalScroll_13wkq_23::-webkit-scrollbar-corner {
308
310
  background: transparent;
309
311
  }
310
312
 
311
- ._taskListHorizontalScroll_apbmu_19::-webkit-scrollbar-thumb {
313
+ ._taskListHorizontalScroll_13wkq_23::-webkit-scrollbar-thumb {
312
314
  border: 4px solid transparent;
313
315
  /*noinspection CssUnresolvedCustomProperty*/
314
316
  background: var(--gantt-scrollbar-thumb-color);
@@ -316,14 +318,14 @@
316
318
  background-clip: padding-box;
317
319
  }
318
320
 
319
- ._taskListHorizontalScroll_apbmu_19::-webkit-scrollbar-thumb:hover {
321
+ ._taskListHorizontalScroll_13wkq_23::-webkit-scrollbar-thumb:hover {
320
322
  border: 2px solid transparent;
321
323
  /*noinspection CssUnresolvedCustomProperty*/
322
324
  background: var(--gantt-scrollbar-thumb-color);
323
325
  background-clip: padding-box;
324
326
  }
325
327
 
326
- ._taskListResizer_apbmu_83 {
328
+ ._taskListResizer_13wkq_87 {
327
329
  position: absolute;
328
330
  top: 0;
329
331
  right: -3px;
@@ -335,16 +337,16 @@
335
337
  }
336
338
 
337
339
  /*noinspection CssUnresolvedCustomProperty*/
338
- ._taskListResizer_apbmu_83:hover {
340
+ ._taskListResizer_13wkq_87:hover {
339
341
  background-color: var(--gantt-table-hover-action-color);
340
342
  filter: var(--gantt-hover-filter);
341
343
  }
342
344
 
343
- ._taskListResizer_apbmu_83:hover::before {
345
+ ._taskListResizer_13wkq_87:hover::before {
344
346
  display: none;
345
347
  }
346
348
 
347
- ._taskListResizer_apbmu_83::before {
349
+ ._taskListResizer_13wkq_87::before {
348
350
  content: "";
349
351
  position: absolute;
350
352
  top: 0;
@@ -355,22 +357,21 @@
355
357
  background-color: var(--gantt-table-resize-color, var(--gantt-divider-color));
356
358
  }
357
359
 
358
- ._horizontalContainer_apbmu_147 {
360
+ ._horizontalContainer_13wkq_151 {
359
361
  margin: 0;
360
362
  padding: 0;
361
363
  overflow: hidden;
362
- flex: 1;
363
- min-height: 0;
364
+ flex-grow: 1;
364
365
  }
365
366
 
366
- ._tableWrapper_apbmu_163 {
367
+ ._tableWrapper_13wkq_165 {
367
368
  position: relative;
368
- flex: 1;
369
- min-height: 0;
370
- overflow: hidden;
369
+ flex-grow: 1;
370
+ display: flex;
371
+ flex-direction: column;
371
372
  }
372
373
 
373
- ._scrollToTop_apbmu_177 {
374
+ ._scrollToTop_13wkq_179 {
374
375
  position: absolute;
375
376
  top: 0;
376
377
  left: 0;
@@ -378,7 +379,7 @@
378
379
  height: 20px;
379
380
  }
380
381
 
381
- ._scrollToBottom_apbmu_193 {
382
+ ._scrollToBottom_13wkq_195 {
382
383
  position: absolute;
383
384
  bottom: 0;
384
385
  left: 0;
@@ -386,7 +387,7 @@
386
387
  height: 20px;
387
388
  }
388
389
 
389
- ._hidden_apbmu_209 {
390
+ ._hidden_13wkq_211 {
390
391
  display: none;
391
392
  }
392
393
  ._ganttToday_1oyhk_1 {
@@ -580,7 +581,7 @@
580
581
  user-select: none;
581
582
  stroke-width: 0;
582
583
  }
583
- ._ganttVerticalContainer_i4cef_1 {
584
+ ._ganttVerticalContainer_5z1c2_1 {
584
585
  overflow-x: scroll;
585
586
  overflow-y: hidden;
586
587
  font-size: 0;
@@ -589,22 +590,20 @@
589
590
  /*noinspection CssUnresolvedCustomProperty*/
590
591
  border-right: 1px solid var(--gantt-calendar-divider-color, var(--gantt-divider-color));
591
592
  flex-grow: 1;
592
- min-width: 0;
593
593
  height: 100%;
594
- display: flex;
595
- flex-direction: column;
594
+ min-width: 0;
596
595
  }
597
596
 
598
- ._ganttVerticalContainer_i4cef_1::-webkit-scrollbar {
597
+ ._ganttVerticalContainer_5z1c2_1::-webkit-scrollbar {
599
598
  width: 1rem;
600
599
  height: 1rem;
601
600
  }
602
601
 
603
- ._ganttVerticalContainer_i4cef_1::-webkit-scrollbar-corner {
602
+ ._ganttVerticalContainer_5z1c2_1::-webkit-scrollbar-corner {
604
603
  background: transparent;
605
604
  }
606
605
 
607
- ._ganttVerticalContainer_i4cef_1::-webkit-scrollbar-thumb {
606
+ ._ganttVerticalContainer_5z1c2_1::-webkit-scrollbar-thumb {
608
607
  border: 4px solid transparent;
609
608
  /*noinspection CssUnresolvedCustomProperty*/
610
609
  background: var(--gantt-scrollbar-thumb-color);
@@ -612,37 +611,35 @@
612
611
  background-clip: padding-box;
613
612
  }
614
613
 
615
- ._ganttVerticalContainer_i4cef_1::-webkit-scrollbar-thumb:hover {
614
+ ._ganttVerticalContainer_5z1c2_1::-webkit-scrollbar-thumb:hover {
616
615
  border: 2px solid transparent;
617
616
  /*noinspection CssUnresolvedCustomProperty*/
618
617
  background: var(--gantt-scrollbar-thumb-color);
619
618
  background-clip: padding-box;
620
619
  }
621
620
 
622
- ._horizontalContainer_i4cef_79 {
621
+ ._horizontalContainer_5z1c2_75 {
623
622
  margin: 0;
624
623
  padding: 0;
625
624
  overflow: hidden;
626
- flex: 1;
627
- min-height: 0;
628
625
  }
629
626
 
630
- ._wrapper_i4cef_95 {
627
+ ._wrapper_5z1c2_87 {
631
628
  display: flex;
632
629
  padding: 0;
633
630
  margin: 0;
634
631
  list-style: none;
635
632
  outline: none;
636
633
  position: relative;
637
- /*noinspection CssUnresolvedCustomProperty*/
638
- border-bottom: 1px solid var(--gantt-divider-color);
639
634
  height: 100%;
640
- min-height: 0;
641
- flex: 1;
635
+ width: 100%;
636
+ max-width: 100%;
642
637
  overflow: hidden;
638
+ /*noinspection CssUnresolvedCustomProperty*/
639
+ border-bottom: 1px solid var(--gantt-divider-color);
643
640
  }
644
641
 
645
- ._calendarDragging_i4cef_125 {
642
+ ._calendarDragging_5z1c2_117 {
646
643
  cursor: grabbing;
647
644
  }
648
645
  /*noinspection CssUnresolvedCustomProperty*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "Interactive Gantt Chart for React with TypeScript.",
5
5
  "author": "aguilanbon",
6
6
  "homepage": "https://github.com/aguilanbon/gantt-task-react-v",