gantt-task-react-v 1.0.40 → 1.0.42

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/README.md CHANGED
@@ -2,12 +2,17 @@
2
2
 
3
3
  ## Interactive Gantt Chart for React with TypeScript.
4
4
 
5
+ ## Recent Updates
6
+
7
+ - Flexible Gantt height now adapts to its parent container, now we always see the horizontal scrolls for both task list and gantt.
8
+ - Fixed sticky gantt header on drag
9
+
5
10
  ## [Live Demo In Storybook](https://661071b076b50cb537c16c19-yrsukdfefs.chromatic.com/)
6
11
 
7
12
  ## Install
8
13
 
9
14
  ```
10
- npm install webagility-gantt-task-react
15
+ npm install https://github.com/aguilanbon/gantt-task-react-v"
11
16
  ```
12
17
 
13
18
  ## How to use it
@@ -96,7 +101,7 @@ yarn storebook
96
101
  | Parameter Name | Type | Description |
97
102
  | :------------------------- | :----- | :--------------------------------------------------------------------------------------------- |
98
103
  | headerHeight | number | Specifies the header height. |
99
- | ganttHeight | number | Specifies the gantt chart height without header. Default is 0. It`s mean no height limitation. |
104
+ | ganttHeight | number | Specifies the gantt chart height without header. If not set or 0, adapts to its parent container. |
100
105
  | columnWidth | number | Specifies the time period width. |
101
106
  | listCellWidth | string | Specifies the task list cell width. Empty string is mean "no display". |
102
107
  | rowHeight | number | Specifies the task row height. |
@@ -5296,8 +5296,7 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5296
5296
  titleCellWidth,
5297
5297
  dateCellWidth,
5298
5298
  dependenciesCellWidth,
5299
- actionColumnWidth,
5300
- tableWidth: defaultTableWidth = 400
5299
+ actionColumnWidth
5301
5300
  } = theme.distances;
5302
5301
  const defaultColumns = useMemo(() => {
5303
5302
  return [
@@ -5333,10 +5332,6 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5333
5332
  const [columnsState, setColumns] = useState(
5334
5333
  clientColumns || defaultColumns
5335
5334
  );
5336
- const taskListWidth = useMemo(
5337
- () => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth,
5338
- [columnsState, extraWidth]
5339
- );
5340
5335
  useEffect(() => {
5341
5336
  if (clientColumns) {
5342
5337
  setColumns([...clientColumns]);
@@ -5344,23 +5339,19 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5344
5339
  const newColumnIds = clientColumns.map((col) => col.id);
5345
5340
  const widthOfAddedColumns = clientColumns.filter((col) => !currentColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
5346
5341
  const widthOfRemovedColumns = clientColumns.filter((col) => !newColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
5347
- setTableWidth((prev) => {
5348
- const newWidth = prev + widthOfAddedColumns - widthOfRemovedColumns;
5349
- return Math.max(newWidth, 100);
5350
- });
5342
+ setTableWidth(
5343
+ (prev) => Math.min(
5344
+ prev + widthOfAddedColumns - widthOfRemovedColumns,
5345
+ clientColumns.reduce((res, { width }) => res + width, 0) + extraWidth
5346
+ )
5347
+ );
5351
5348
  }
5352
- }, [clientColumns, extraWidth, taskListWidth]);
5349
+ }, [clientColumns, extraWidth]);
5353
5350
  const [tableResizeEvent, setTableResizeEvent] = useState(null);
5354
5351
  const [columnResizeEvent, setColumnResizeEvent] = useState(null);
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
- });
5352
+ const [tableWidthState, setTableWidth] = useState(
5353
+ () => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth
5354
+ );
5364
5355
  const onTableResizeStart = (clientX) => {
5365
5356
  const newTableResizeEvent = {
5366
5357
  initialClientX: clientX,
@@ -5379,6 +5370,7 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5379
5370
  };
5380
5371
  const isResizeTableInProgress = Boolean(tableResizeEvent);
5381
5372
  const isResizeColumnInProgress = Boolean(columnResizeEvent);
5373
+ const taskListWidth = columnsState.reduce((res, { width }) => res + width, 0) + extraWidth;
5382
5374
  useEffect(() => {
5383
5375
  if (!isResizeTableInProgress) {
5384
5376
  return void 0;
@@ -5386,15 +5378,9 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5386
5378
  const handleMove = (clientX) => {
5387
5379
  const moveDelta = clientX - tableResizeEvent.initialClientX;
5388
5380
  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);
5393
5381
  return Math.min(
5394
- Math.max(newWidth, 50),
5395
- // Minimum width of 50px
5396
- maxTableWidth
5397
- // Allow table to expand much more
5382
+ Math.max(tableResizeEvent.initialTableWidth + moveDelta, 50),
5383
+ taskListWidth
5398
5384
  );
5399
5385
  });
5400
5386
  };
@@ -5454,18 +5440,12 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
5454
5440
  return newColumns;
5455
5441
  });
5456
5442
  if (previousColumnWidth !== newColumnWidth) {
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
- });
5443
+ setTableWidth(
5444
+ () => Math.min(
5445
+ Math.max(columnResizeEvent.initialTableWidth + moveDelta, 50),
5446
+ taskListWidth
5447
+ )
5448
+ );
5469
5449
  }
5470
5450
  };
5471
5451
  const handleMouseMove = (event) => {
@@ -10657,14 +10637,14 @@ const TaskListTableDefaultInner = ({
10657
10637
  );
10658
10638
  };
10659
10639
  const TaskListTable = memo(TaskListTableDefaultInner);
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";
10640
+ const taskListRoot = "_taskListRoot_yoz76_1";
10641
+ const taskListHorizontalScroll = "_taskListHorizontalScroll_yoz76_19";
10642
+ const taskListResizer = "_taskListResizer_yoz76_81";
10643
+ const horizontalContainer$1 = "_horizontalContainer_yoz76_145";
10644
+ const tableWrapper = "_tableWrapper_yoz76_159";
10645
+ const scrollToTop = "_scrollToTop_yoz76_173";
10646
+ const scrollToBottom = "_scrollToBottom_yoz76_189";
10647
+ const hidden = "_hidden_yoz76_205";
10668
10648
  const styles$d = {
10669
10649
  taskListRoot,
10670
10650
  taskListHorizontalScroll,
@@ -13155,10 +13135,10 @@ const TaskGanttContentInner = (props) => {
13155
13135
  ] });
13156
13136
  };
13157
13137
  const TaskGanttContent = memo(TaskGanttContentInner);
13158
- const ganttVerticalContainer = "_ganttVerticalContainer_5z1c2_1";
13159
- const horizontalContainer = "_horizontalContainer_5z1c2_75";
13160
- const wrapper = "_wrapper_5z1c2_87";
13161
- const calendarDragging = "_calendarDragging_5z1c2_117";
13138
+ const ganttVerticalContainer = "_ganttVerticalContainer_1wr55_1";
13139
+ const horizontalContainer = "_horizontalContainer_1wr55_73";
13140
+ const wrapper = "_wrapper_1wr55_85";
13141
+ const calendarDragging = "_calendarDragging_1wr55_109";
13162
13142
  const styles$2 = {
13163
13143
  ganttVerticalContainer,
13164
13144
  horizontalContainer,
@@ -13184,7 +13164,8 @@ const TaskGanttInner = (props) => {
13184
13164
  verticalGanttContainerRef,
13185
13165
  verticalScrollbarRef
13186
13166
  } = props;
13187
- const ganttBodyRef = React__default.useRef(null);
13167
+ const contentRef = React__default.useRef(null);
13168
+ const moveStateVertRef = useRef(null);
13188
13169
  const moveStateHorRef = useRef(null);
13189
13170
  const moveStateScrollRef = useRef(null);
13190
13171
  const containerStyle = useMemo(
@@ -13216,49 +13197,50 @@ const TaskGanttInner = (props) => {
13216
13197
  ]
13217
13198
  );
13218
13199
  useEffect(() => {
13219
- if (!ganttBodyRef.current) {
13200
+ if (!contentRef.current) {
13220
13201
  return () => {
13221
13202
  };
13222
13203
  }
13223
- const ganttBodyContainer = ganttBodyRef.current;
13204
+ const contentContainer = contentRef.current;
13224
13205
  const onScrollStart = (event) => {
13225
- var _a, _b, _c, _d;
13226
- const mouseEvent = event;
13227
- mouseEvent.preventDefault();
13206
+ event.preventDefault();
13207
+ moveStateVertRef.current = {
13208
+ clientX: event.clientX,
13209
+ clientY: event.clientY,
13210
+ scrollLeft: verticalGanttContainerRef.current.scrollLeft,
13211
+ scrollTop: verticalGanttContainerRef.current.scrollTop
13212
+ };
13228
13213
  moveStateHorRef.current = {
13229
- clientX: mouseEvent.clientX,
13230
- clientY: mouseEvent.clientY,
13231
- scrollLeft: ((_a = verticalGanttContainerRef.current) == null ? void 0 : _a.scrollLeft) || 0,
13232
- scrollTop: ((_b = horizontalContainerRef.current) == null ? void 0 : _b.scrollTop) || 0
13214
+ clientX: event.clientX,
13215
+ clientY: event.clientY,
13216
+ scrollLeft: horizontalContainerRef.current.scrollLeft,
13217
+ scrollTop: horizontalContainerRef.current.scrollTop
13233
13218
  };
13234
13219
  moveStateScrollRef.current = {
13235
- clientX: mouseEvent.clientX,
13236
- clientY: mouseEvent.clientY,
13237
- scrollLeft: ((_c = verticalScrollbarRef.current) == null ? void 0 : _c.scrollLeft) || 0,
13238
- scrollTop: ((_d = verticalScrollbarRef.current) == null ? void 0 : _d.scrollTop) || 0
13220
+ clientX: event.clientX,
13221
+ clientY: event.clientY,
13222
+ scrollLeft: verticalScrollbarRef.current.scrollLeft,
13223
+ scrollTop: verticalScrollbarRef.current.scrollTop
13239
13224
  };
13240
- ganttBodyContainer.classList.add(styles$2.calendarDragging);
13225
+ contentContainer.classList.add(styles$2.calendarDragging);
13241
13226
  };
13242
13227
  const onScrollMove = (event) => {
13243
- if (!moveStateHorRef.current) {
13228
+ if (!moveStateVertRef.current) {
13244
13229
  return;
13245
13230
  }
13246
- const mouseEvent = event;
13247
- mouseEvent.preventDefault();
13231
+ event.preventDefault();
13232
+ const { clientX, scrollLeft } = moveStateVertRef.current;
13233
+ const scrollVertContainer = verticalGanttContainerRef.current;
13234
+ scrollVertContainer.scrollLeft = scrollLeft + clientX - event.clientX;
13248
13235
  const {
13249
13236
  clientX: clientXH,
13250
13237
  scrollLeft: scrollLeftH,
13251
13238
  scrollTop: scrollTopH,
13252
13239
  clientY: clientYH
13253
13240
  } = moveStateHorRef.current;
13254
- const vertContainer = verticalGanttContainerRef.current;
13255
- if (vertContainer) {
13256
- vertContainer.scrollLeft = scrollLeftH + clientXH - mouseEvent.clientX;
13257
- }
13258
13241
  const horContainer = horizontalContainerRef.current;
13259
- if (horContainer) {
13260
- horContainer.scrollTop = scrollTopH + clientYH - mouseEvent.clientY;
13261
- }
13242
+ horContainer.scrollLeft = scrollLeftH + clientXH - event.clientX;
13243
+ horContainer.scrollTop = scrollTopH + clientYH - event.clientY;
13262
13244
  const {
13263
13245
  clientX: clientXS,
13264
13246
  scrollLeft: scrollLeftS,
@@ -13266,27 +13248,24 @@ const TaskGanttInner = (props) => {
13266
13248
  clientY: clientYS
13267
13249
  } = moveStateScrollRef.current;
13268
13250
  const scrollContainer = verticalScrollbarRef.current;
13269
- if (scrollContainer) {
13270
- scrollContainer.scrollLeft = scrollLeftS + clientXS - mouseEvent.clientX;
13271
- scrollContainer.scrollTop = scrollTopS + clientYS - mouseEvent.clientY;
13272
- }
13251
+ scrollContainer.scrollLeft = scrollLeftS + clientXS - event.clientX;
13252
+ scrollContainer.scrollTop = scrollTopS + clientYS - event.clientY;
13273
13253
  };
13274
13254
  const onScrollEnd = (event) => {
13275
- const mouseEvent = event;
13276
- mouseEvent.preventDefault();
13255
+ event.preventDefault();
13256
+ moveStateVertRef.current = null;
13277
13257
  moveStateHorRef.current = null;
13278
- moveStateScrollRef.current = null;
13279
- ganttBodyContainer.classList.remove(styles$2.calendarDragging);
13258
+ contentContainer.classList.remove(styles$2.calendarDragging);
13280
13259
  };
13281
- ganttBodyContainer.addEventListener("mousemove", onScrollMove);
13282
- ganttBodyContainer.addEventListener("mousedown", onScrollStart);
13283
- ganttBodyContainer.addEventListener("mouseup", onScrollEnd);
13284
- ganttBodyContainer.addEventListener("mouseout", onScrollEnd);
13260
+ contentContainer.addEventListener("mousemove", onScrollMove);
13261
+ contentContainer.addEventListener("mousedown", onScrollStart);
13262
+ contentContainer.addEventListener("mouseup", onScrollEnd);
13263
+ contentContainer.addEventListener("mouseout", onScrollEnd);
13285
13264
  return () => {
13286
- ganttBodyContainer.removeEventListener("mousemove", onScrollMove);
13287
- ganttBodyContainer.removeEventListener("mousedown", onScrollStart);
13288
- ganttBodyContainer.removeEventListener("mouseup", onScrollEnd);
13289
- ganttBodyContainer.removeEventListener("mouseout", onScrollEnd);
13265
+ contentContainer.removeEventListener("mousemove", onScrollMove);
13266
+ contentContainer.removeEventListener("mousedown", onScrollStart);
13267
+ contentContainer.removeEventListener("mouseup", onScrollEnd);
13268
+ contentContainer.removeEventListener("mouseout", onScrollEnd);
13290
13269
  };
13291
13270
  }, [verticalScrollbarRef, horizontalContainerRef, verticalGanttContainerRef]);
13292
13271
  return /* @__PURE__ */ jsxs(
@@ -13313,7 +13292,7 @@ const TaskGanttInner = (props) => {
13313
13292
  ref: horizontalContainerRef,
13314
13293
  className: styles$2.horizontalContainer,
13315
13294
  style: containerStyle,
13316
- children: /* @__PURE__ */ jsx("div", { style: gridStyle, ref: ganttBodyRef, children: /* @__PURE__ */ jsxs(
13295
+ children: /* @__PURE__ */ jsx("div", { style: gridStyle, children: /* @__PURE__ */ jsxs(
13317
13296
  "svg",
13318
13297
  {
13319
13298
  xmlns: "http://www.w3.org/2000/svg",
@@ -13323,6 +13302,15 @@ const TaskGanttInner = (props) => {
13323
13302
  ref: ganttSVGRef,
13324
13303
  children: [
13325
13304
  /* @__PURE__ */ jsx(GanttToday, { ...ganttTodayProps }),
13305
+ /* @__PURE__ */ jsx(
13306
+ "rect",
13307
+ {
13308
+ ref: contentRef,
13309
+ width: "100%",
13310
+ height: "100%",
13311
+ fill: "transparent"
13312
+ }
13313
+ ),
13326
13314
  /* @__PURE__ */ jsx(TaskGanttContent, { ...barProps })
13327
13315
  ]
13328
13316
  }
@@ -5313,8 +5313,7 @@
5313
5313
  titleCellWidth,
5314
5314
  dateCellWidth,
5315
5315
  dependenciesCellWidth,
5316
- actionColumnWidth,
5317
- tableWidth: defaultTableWidth = 400
5316
+ actionColumnWidth
5318
5317
  } = theme.distances;
5319
5318
  const defaultColumns = React.useMemo(() => {
5320
5319
  return [
@@ -5350,10 +5349,6 @@
5350
5349
  const [columnsState, setColumns] = React.useState(
5351
5350
  clientColumns || defaultColumns
5352
5351
  );
5353
- const taskListWidth = React.useMemo(
5354
- () => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth,
5355
- [columnsState, extraWidth]
5356
- );
5357
5352
  React.useEffect(() => {
5358
5353
  if (clientColumns) {
5359
5354
  setColumns([...clientColumns]);
@@ -5361,23 +5356,19 @@
5361
5356
  const newColumnIds = clientColumns.map((col) => col.id);
5362
5357
  const widthOfAddedColumns = clientColumns.filter((col) => !currentColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
5363
5358
  const widthOfRemovedColumns = clientColumns.filter((col) => !newColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
5364
- setTableWidth((prev) => {
5365
- const newWidth = prev + widthOfAddedColumns - widthOfRemovedColumns;
5366
- return Math.max(newWidth, 100);
5367
- });
5359
+ setTableWidth(
5360
+ (prev) => Math.min(
5361
+ prev + widthOfAddedColumns - widthOfRemovedColumns,
5362
+ clientColumns.reduce((res, { width }) => res + width, 0) + extraWidth
5363
+ )
5364
+ );
5368
5365
  }
5369
- }, [clientColumns, extraWidth, taskListWidth]);
5366
+ }, [clientColumns, extraWidth]);
5370
5367
  const [tableResizeEvent, setTableResizeEvent] = React.useState(null);
5371
5368
  const [columnResizeEvent, setColumnResizeEvent] = React.useState(null);
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
- });
5369
+ const [tableWidthState, setTableWidth] = React.useState(
5370
+ () => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth
5371
+ );
5381
5372
  const onTableResizeStart = (clientX) => {
5382
5373
  const newTableResizeEvent = {
5383
5374
  initialClientX: clientX,
@@ -5396,6 +5387,7 @@
5396
5387
  };
5397
5388
  const isResizeTableInProgress = Boolean(tableResizeEvent);
5398
5389
  const isResizeColumnInProgress = Boolean(columnResizeEvent);
5390
+ const taskListWidth = columnsState.reduce((res, { width }) => res + width, 0) + extraWidth;
5399
5391
  React.useEffect(() => {
5400
5392
  if (!isResizeTableInProgress) {
5401
5393
  return void 0;
@@ -5403,15 +5395,9 @@
5403
5395
  const handleMove = (clientX) => {
5404
5396
  const moveDelta = clientX - tableResizeEvent.initialClientX;
5405
5397
  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);
5410
5398
  return Math.min(
5411
- Math.max(newWidth, 50),
5412
- // Minimum width of 50px
5413
- maxTableWidth
5414
- // Allow table to expand much more
5399
+ Math.max(tableResizeEvent.initialTableWidth + moveDelta, 50),
5400
+ taskListWidth
5415
5401
  );
5416
5402
  });
5417
5403
  };
@@ -5471,18 +5457,12 @@
5471
5457
  return newColumns;
5472
5458
  });
5473
5459
  if (previousColumnWidth !== newColumnWidth) {
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
- });
5460
+ setTableWidth(
5461
+ () => Math.min(
5462
+ Math.max(columnResizeEvent.initialTableWidth + moveDelta, 50),
5463
+ taskListWidth
5464
+ )
5465
+ );
5486
5466
  }
5487
5467
  };
5488
5468
  const handleMouseMove = (event) => {
@@ -10674,14 +10654,14 @@
10674
10654
  );
10675
10655
  };
10676
10656
  const TaskListTable = React.memo(TaskListTableDefaultInner);
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";
10657
+ const taskListRoot = "_taskListRoot_yoz76_1";
10658
+ const taskListHorizontalScroll = "_taskListHorizontalScroll_yoz76_19";
10659
+ const taskListResizer = "_taskListResizer_yoz76_81";
10660
+ const horizontalContainer$1 = "_horizontalContainer_yoz76_145";
10661
+ const tableWrapper = "_tableWrapper_yoz76_159";
10662
+ const scrollToTop = "_scrollToTop_yoz76_173";
10663
+ const scrollToBottom = "_scrollToBottom_yoz76_189";
10664
+ const hidden = "_hidden_yoz76_205";
10685
10665
  const styles$d = {
10686
10666
  taskListRoot,
10687
10667
  taskListHorizontalScroll,
@@ -13172,10 +13152,10 @@
13172
13152
  ] });
13173
13153
  };
13174
13154
  const TaskGanttContent = React.memo(TaskGanttContentInner);
13175
- const ganttVerticalContainer = "_ganttVerticalContainer_5z1c2_1";
13176
- const horizontalContainer = "_horizontalContainer_5z1c2_75";
13177
- const wrapper = "_wrapper_5z1c2_87";
13178
- const calendarDragging = "_calendarDragging_5z1c2_117";
13155
+ const ganttVerticalContainer = "_ganttVerticalContainer_1wr55_1";
13156
+ const horizontalContainer = "_horizontalContainer_1wr55_73";
13157
+ const wrapper = "_wrapper_1wr55_85";
13158
+ const calendarDragging = "_calendarDragging_1wr55_109";
13179
13159
  const styles$2 = {
13180
13160
  ganttVerticalContainer,
13181
13161
  horizontalContainer,
@@ -13201,7 +13181,8 @@
13201
13181
  verticalGanttContainerRef,
13202
13182
  verticalScrollbarRef
13203
13183
  } = props;
13204
- const ganttBodyRef = React.useRef(null);
13184
+ const contentRef = React.useRef(null);
13185
+ const moveStateVertRef = React.useRef(null);
13205
13186
  const moveStateHorRef = React.useRef(null);
13206
13187
  const moveStateScrollRef = React.useRef(null);
13207
13188
  const containerStyle = React.useMemo(
@@ -13233,49 +13214,50 @@
13233
13214
  ]
13234
13215
  );
13235
13216
  React.useEffect(() => {
13236
- if (!ganttBodyRef.current) {
13217
+ if (!contentRef.current) {
13237
13218
  return () => {
13238
13219
  };
13239
13220
  }
13240
- const ganttBodyContainer = ganttBodyRef.current;
13221
+ const contentContainer = contentRef.current;
13241
13222
  const onScrollStart = (event) => {
13242
- var _a, _b, _c, _d;
13243
- const mouseEvent = event;
13244
- mouseEvent.preventDefault();
13223
+ event.preventDefault();
13224
+ moveStateVertRef.current = {
13225
+ clientX: event.clientX,
13226
+ clientY: event.clientY,
13227
+ scrollLeft: verticalGanttContainerRef.current.scrollLeft,
13228
+ scrollTop: verticalGanttContainerRef.current.scrollTop
13229
+ };
13245
13230
  moveStateHorRef.current = {
13246
- clientX: mouseEvent.clientX,
13247
- clientY: mouseEvent.clientY,
13248
- scrollLeft: ((_a = verticalGanttContainerRef.current) == null ? void 0 : _a.scrollLeft) || 0,
13249
- scrollTop: ((_b = horizontalContainerRef.current) == null ? void 0 : _b.scrollTop) || 0
13231
+ clientX: event.clientX,
13232
+ clientY: event.clientY,
13233
+ scrollLeft: horizontalContainerRef.current.scrollLeft,
13234
+ scrollTop: horizontalContainerRef.current.scrollTop
13250
13235
  };
13251
13236
  moveStateScrollRef.current = {
13252
- clientX: mouseEvent.clientX,
13253
- clientY: mouseEvent.clientY,
13254
- scrollLeft: ((_c = verticalScrollbarRef.current) == null ? void 0 : _c.scrollLeft) || 0,
13255
- scrollTop: ((_d = verticalScrollbarRef.current) == null ? void 0 : _d.scrollTop) || 0
13237
+ clientX: event.clientX,
13238
+ clientY: event.clientY,
13239
+ scrollLeft: verticalScrollbarRef.current.scrollLeft,
13240
+ scrollTop: verticalScrollbarRef.current.scrollTop
13256
13241
  };
13257
- ganttBodyContainer.classList.add(styles$2.calendarDragging);
13242
+ contentContainer.classList.add(styles$2.calendarDragging);
13258
13243
  };
13259
13244
  const onScrollMove = (event) => {
13260
- if (!moveStateHorRef.current) {
13245
+ if (!moveStateVertRef.current) {
13261
13246
  return;
13262
13247
  }
13263
- const mouseEvent = event;
13264
- mouseEvent.preventDefault();
13248
+ event.preventDefault();
13249
+ const { clientX, scrollLeft } = moveStateVertRef.current;
13250
+ const scrollVertContainer = verticalGanttContainerRef.current;
13251
+ scrollVertContainer.scrollLeft = scrollLeft + clientX - event.clientX;
13265
13252
  const {
13266
13253
  clientX: clientXH,
13267
13254
  scrollLeft: scrollLeftH,
13268
13255
  scrollTop: scrollTopH,
13269
13256
  clientY: clientYH
13270
13257
  } = moveStateHorRef.current;
13271
- const vertContainer = verticalGanttContainerRef.current;
13272
- if (vertContainer) {
13273
- vertContainer.scrollLeft = scrollLeftH + clientXH - mouseEvent.clientX;
13274
- }
13275
13258
  const horContainer = horizontalContainerRef.current;
13276
- if (horContainer) {
13277
- horContainer.scrollTop = scrollTopH + clientYH - mouseEvent.clientY;
13278
- }
13259
+ horContainer.scrollLeft = scrollLeftH + clientXH - event.clientX;
13260
+ horContainer.scrollTop = scrollTopH + clientYH - event.clientY;
13279
13261
  const {
13280
13262
  clientX: clientXS,
13281
13263
  scrollLeft: scrollLeftS,
@@ -13283,27 +13265,24 @@
13283
13265
  clientY: clientYS
13284
13266
  } = moveStateScrollRef.current;
13285
13267
  const scrollContainer = verticalScrollbarRef.current;
13286
- if (scrollContainer) {
13287
- scrollContainer.scrollLeft = scrollLeftS + clientXS - mouseEvent.clientX;
13288
- scrollContainer.scrollTop = scrollTopS + clientYS - mouseEvent.clientY;
13289
- }
13268
+ scrollContainer.scrollLeft = scrollLeftS + clientXS - event.clientX;
13269
+ scrollContainer.scrollTop = scrollTopS + clientYS - event.clientY;
13290
13270
  };
13291
13271
  const onScrollEnd = (event) => {
13292
- const mouseEvent = event;
13293
- mouseEvent.preventDefault();
13272
+ event.preventDefault();
13273
+ moveStateVertRef.current = null;
13294
13274
  moveStateHorRef.current = null;
13295
- moveStateScrollRef.current = null;
13296
- ganttBodyContainer.classList.remove(styles$2.calendarDragging);
13275
+ contentContainer.classList.remove(styles$2.calendarDragging);
13297
13276
  };
13298
- ganttBodyContainer.addEventListener("mousemove", onScrollMove);
13299
- ganttBodyContainer.addEventListener("mousedown", onScrollStart);
13300
- ganttBodyContainer.addEventListener("mouseup", onScrollEnd);
13301
- ganttBodyContainer.addEventListener("mouseout", onScrollEnd);
13277
+ contentContainer.addEventListener("mousemove", onScrollMove);
13278
+ contentContainer.addEventListener("mousedown", onScrollStart);
13279
+ contentContainer.addEventListener("mouseup", onScrollEnd);
13280
+ contentContainer.addEventListener("mouseout", onScrollEnd);
13302
13281
  return () => {
13303
- ganttBodyContainer.removeEventListener("mousemove", onScrollMove);
13304
- ganttBodyContainer.removeEventListener("mousedown", onScrollStart);
13305
- ganttBodyContainer.removeEventListener("mouseup", onScrollEnd);
13306
- ganttBodyContainer.removeEventListener("mouseout", onScrollEnd);
13282
+ contentContainer.removeEventListener("mousemove", onScrollMove);
13283
+ contentContainer.removeEventListener("mousedown", onScrollStart);
13284
+ contentContainer.removeEventListener("mouseup", onScrollEnd);
13285
+ contentContainer.removeEventListener("mouseout", onScrollEnd);
13307
13286
  };
13308
13287
  }, [verticalScrollbarRef, horizontalContainerRef, verticalGanttContainerRef]);
13309
13288
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -13330,7 +13309,7 @@
13330
13309
  ref: horizontalContainerRef,
13331
13310
  className: styles$2.horizontalContainer,
13332
13311
  style: containerStyle,
13333
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: gridStyle, ref: ganttBodyRef, children: /* @__PURE__ */ jsxRuntime.jsxs(
13312
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: gridStyle, children: /* @__PURE__ */ jsxRuntime.jsxs(
13334
13313
  "svg",
13335
13314
  {
13336
13315
  xmlns: "http://www.w3.org/2000/svg",
@@ -13340,6 +13319,15 @@
13340
13319
  ref: ganttSVGRef,
13341
13320
  children: [
13342
13321
  /* @__PURE__ */ jsxRuntime.jsx(GanttToday, { ...ganttTodayProps }),
13322
+ /* @__PURE__ */ jsxRuntime.jsx(
13323
+ "rect",
13324
+ {
13325
+ ref: contentRef,
13326
+ width: "100%",
13327
+ height: "100%",
13328
+ fill: "transparent"
13329
+ }
13330
+ ),
13343
13331
  /* @__PURE__ */ jsxRuntime.jsx(TaskGanttContent, { ...barProps })
13344
13332
  ]
13345
13333
  }
package/dist/style.css CHANGED
@@ -282,35 +282,32 @@
282
282
  border-bottom: 1px solid var(--gantt-divider-color);
283
283
  table-layout: fixed;
284
284
  }
285
- ._taskListRoot_13wkq_1 {
285
+ ._taskListRoot_yoz76_1 {
286
286
  position: relative;
287
287
  height: 100%;
288
288
  display: flex;
289
289
  flex-direction: column;
290
- min-width: 0;
291
- flex-shrink: 0;
292
290
  /*noinspection CssUnresolvedCustomProperty*/
293
291
  border-left: 1px solid var(--gantt-table-divider-color, var(--gantt-divider-color));
294
292
  }
295
293
 
296
- ._taskListHorizontalScroll_13wkq_23 {
294
+ ._taskListHorizontalScroll_yoz76_19 {
297
295
  overflow-x: scroll;
298
296
  height: 100%;
299
297
  display: flex;
300
298
  flex-direction: column;
301
- min-width: 0;
302
299
  }
303
300
 
304
- ._taskListHorizontalScroll_13wkq_23::-webkit-scrollbar {
301
+ ._taskListHorizontalScroll_yoz76_19::-webkit-scrollbar {
305
302
  width: 1rem;
306
303
  height: 1rem;
307
304
  }
308
305
 
309
- ._taskListHorizontalScroll_13wkq_23::-webkit-scrollbar-corner {
306
+ ._taskListHorizontalScroll_yoz76_19::-webkit-scrollbar-corner {
310
307
  background: transparent;
311
308
  }
312
309
 
313
- ._taskListHorizontalScroll_13wkq_23::-webkit-scrollbar-thumb {
310
+ ._taskListHorizontalScroll_yoz76_19::-webkit-scrollbar-thumb {
314
311
  border: 4px solid transparent;
315
312
  /*noinspection CssUnresolvedCustomProperty*/
316
313
  background: var(--gantt-scrollbar-thumb-color);
@@ -318,14 +315,14 @@
318
315
  background-clip: padding-box;
319
316
  }
320
317
 
321
- ._taskListHorizontalScroll_13wkq_23::-webkit-scrollbar-thumb:hover {
318
+ ._taskListHorizontalScroll_yoz76_19::-webkit-scrollbar-thumb:hover {
322
319
  border: 2px solid transparent;
323
320
  /*noinspection CssUnresolvedCustomProperty*/
324
321
  background: var(--gantt-scrollbar-thumb-color);
325
322
  background-clip: padding-box;
326
323
  }
327
324
 
328
- ._taskListResizer_13wkq_87 {
325
+ ._taskListResizer_yoz76_81 {
329
326
  position: absolute;
330
327
  top: 0;
331
328
  right: -3px;
@@ -337,16 +334,16 @@
337
334
  }
338
335
 
339
336
  /*noinspection CssUnresolvedCustomProperty*/
340
- ._taskListResizer_13wkq_87:hover {
337
+ ._taskListResizer_yoz76_81:hover {
341
338
  background-color: var(--gantt-table-hover-action-color);
342
339
  filter: var(--gantt-hover-filter);
343
340
  }
344
341
 
345
- ._taskListResizer_13wkq_87:hover::before {
342
+ ._taskListResizer_yoz76_81:hover::before {
346
343
  display: none;
347
344
  }
348
345
 
349
- ._taskListResizer_13wkq_87::before {
346
+ ._taskListResizer_yoz76_81::before {
350
347
  content: "";
351
348
  position: absolute;
352
349
  top: 0;
@@ -357,21 +354,21 @@
357
354
  background-color: var(--gantt-table-resize-color, var(--gantt-divider-color));
358
355
  }
359
356
 
360
- ._horizontalContainer_13wkq_151 {
357
+ ._horizontalContainer_yoz76_145 {
361
358
  margin: 0;
362
359
  padding: 0;
363
360
  overflow: hidden;
364
361
  flex-grow: 1;
365
362
  }
366
363
 
367
- ._tableWrapper_13wkq_165 {
364
+ ._tableWrapper_yoz76_159 {
368
365
  position: relative;
369
366
  flex-grow: 1;
370
367
  display: flex;
371
368
  flex-direction: column;
372
369
  }
373
370
 
374
- ._scrollToTop_13wkq_179 {
371
+ ._scrollToTop_yoz76_173 {
375
372
  position: absolute;
376
373
  top: 0;
377
374
  left: 0;
@@ -379,7 +376,7 @@
379
376
  height: 20px;
380
377
  }
381
378
 
382
- ._scrollToBottom_13wkq_195 {
379
+ ._scrollToBottom_yoz76_189 {
383
380
  position: absolute;
384
381
  bottom: 0;
385
382
  left: 0;
@@ -387,7 +384,7 @@
387
384
  height: 20px;
388
385
  }
389
386
 
390
- ._hidden_13wkq_211 {
387
+ ._hidden_yoz76_205 {
391
388
  display: none;
392
389
  }
393
390
  ._ganttToday_1oyhk_1 {
@@ -581,7 +578,7 @@
581
578
  user-select: none;
582
579
  stroke-width: 0;
583
580
  }
584
- ._ganttVerticalContainer_5z1c2_1 {
581
+ ._ganttVerticalContainer_1wr55_1 {
585
582
  overflow-x: scroll;
586
583
  overflow-y: hidden;
587
584
  font-size: 0;
@@ -591,19 +588,18 @@
591
588
  border-right: 1px solid var(--gantt-calendar-divider-color, var(--gantt-divider-color));
592
589
  flex-grow: 1;
593
590
  height: 100%;
594
- min-width: 0;
595
591
  }
596
592
 
597
- ._ganttVerticalContainer_5z1c2_1::-webkit-scrollbar {
593
+ ._ganttVerticalContainer_1wr55_1::-webkit-scrollbar {
598
594
  width: 1rem;
599
595
  height: 1rem;
600
596
  }
601
597
 
602
- ._ganttVerticalContainer_5z1c2_1::-webkit-scrollbar-corner {
598
+ ._ganttVerticalContainer_1wr55_1::-webkit-scrollbar-corner {
603
599
  background: transparent;
604
600
  }
605
601
 
606
- ._ganttVerticalContainer_5z1c2_1::-webkit-scrollbar-thumb {
602
+ ._ganttVerticalContainer_1wr55_1::-webkit-scrollbar-thumb {
607
603
  border: 4px solid transparent;
608
604
  /*noinspection CssUnresolvedCustomProperty*/
609
605
  background: var(--gantt-scrollbar-thumb-color);
@@ -611,20 +607,20 @@
611
607
  background-clip: padding-box;
612
608
  }
613
609
 
614
- ._ganttVerticalContainer_5z1c2_1::-webkit-scrollbar-thumb:hover {
610
+ ._ganttVerticalContainer_1wr55_1::-webkit-scrollbar-thumb:hover {
615
611
  border: 2px solid transparent;
616
612
  /*noinspection CssUnresolvedCustomProperty*/
617
613
  background: var(--gantt-scrollbar-thumb-color);
618
614
  background-clip: padding-box;
619
615
  }
620
616
 
621
- ._horizontalContainer_5z1c2_75 {
617
+ ._horizontalContainer_1wr55_73 {
622
618
  margin: 0;
623
619
  padding: 0;
624
620
  overflow: hidden;
625
621
  }
626
622
 
627
- ._wrapper_5z1c2_87 {
623
+ ._wrapper_1wr55_85 {
628
624
  display: flex;
629
625
  padding: 0;
630
626
  margin: 0;
@@ -632,14 +628,11 @@
632
628
  outline: none;
633
629
  position: relative;
634
630
  height: 100%;
635
- width: 100%;
636
- max-width: 100%;
637
- overflow: hidden;
638
631
  /*noinspection CssUnresolvedCustomProperty*/
639
632
  border-bottom: 1px solid var(--gantt-divider-color);
640
633
  }
641
634
 
642
- ._calendarDragging_5z1c2_117 {
635
+ ._calendarDragging_1wr55_109 {
643
636
  cursor: grabbing;
644
637
  }
645
638
  /*noinspection CssUnresolvedCustomProperty*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
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",