gantt-task-react-v 1.0.36 → 1.0.38

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
@@ -7,14 +7,14 @@
7
7
  ## Install
8
8
 
9
9
  ```
10
- npm install gantt-task-react-v
10
+ npm install webagility-gantt-task-react
11
11
  ```
12
12
 
13
13
  ## How to use it
14
14
 
15
15
  ```ts
16
- import { Gantt, Task, EventOption, StylingOption, ViewMode, DisplayOption } from 'gantt-task-react-v';
17
- import "gantt-task-react-v/dist/index.css";
16
+ import { Gantt, Task, EventOption, StylingOption, ViewMode, DisplayOption } from 'gantt-task-react';
17
+ import "gantt-task-react/dist/index.css";
18
18
 
19
19
  let tasks: Task[] = [
20
20
  {
@@ -10,6 +10,7 @@ export interface TaskGanttProps extends GanttTaskBarActions {
10
10
  fullRowHeight: number;
11
11
  fullSvgWidth: number;
12
12
  ganttFullHeight: number;
13
+ ganttHeight: number;
13
14
  ganttSVGRef: RefObject<SVGSVGElement>;
14
15
  ganttTodayProps: GanttTodayProps;
15
16
  horizontalContainerRef: RefObject<HTMLDivElement>;
@@ -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;
@@ -4655,6 +4655,7 @@ const styles$k = {
4655
4655
  scroll
4656
4656
  };
4657
4657
  const VerticalScroll = ({
4658
+ ganttHeight,
4658
4659
  ganttFullHeight,
4659
4660
  headerHeight,
4660
4661
  isChangeInProgress,
@@ -4666,7 +4667,7 @@ const VerticalScroll = ({
4666
4667
  "div",
4667
4668
  {
4668
4669
  style: {
4669
- height: `calc(100% - ${headerHeight}px)`,
4670
+ height: ganttHeight,
4670
4671
  marginTop: headerHeight,
4671
4672
  marginLeft: rtl ? void 0 : "-1rem",
4672
4673
  pointerEvents: isChangeInProgress ? "none" : void 0
@@ -5161,7 +5162,6 @@ const DEFAULT_THEME = {
5161
5162
  expandIconWidth: 20,
5162
5163
  handleWidth: 8,
5163
5164
  headerHeight: 50,
5164
- ganttHeight: 600,
5165
5165
  minimumRowDisplayed: 4,
5166
5166
  nestedTaskNameOffset: 20,
5167
5167
  relationCircleOffset: 10,
@@ -10637,14 +10637,14 @@ const TaskListTableDefaultInner = ({
10637
10637
  );
10638
10638
  };
10639
10639
  const TaskListTable = memo(TaskListTableDefaultInner);
10640
- const taskListRoot = "_taskListRoot_1x5nq_1";
10641
- const taskListHorizontalScroll = "_taskListHorizontalScroll_1x5nq_25";
10642
- const taskListResizer = "_taskListResizer_1x5nq_89";
10643
- const horizontalContainer$1 = "_horizontalContainer_1x5nq_153";
10644
- const tableWrapper = "_tableWrapper_1x5nq_171";
10645
- const scrollToTop = "_scrollToTop_1x5nq_183";
10646
- const scrollToBottom = "_scrollToBottom_1x5nq_199";
10647
- const hidden = "_hidden_1x5nq_215";
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";
10648
10648
  const styles$d = {
10649
10649
  taskListRoot,
10650
10650
  taskListHorizontalScroll,
@@ -10678,6 +10678,7 @@ const TaskListInner = ({
10678
10678
  distances,
10679
10679
  fullRowHeight,
10680
10680
  ganttFullHeight,
10681
+ ganttHeight,
10681
10682
  getTaskCurrentState,
10682
10683
  handleAddTask,
10683
10684
  handleDeleteTasks,
@@ -10808,15 +10809,22 @@ const TaskListInner = ({
10808
10809
  ref: taskListContainerRef,
10809
10810
  className: styles$d.horizontalContainer,
10810
10811
  style: {
10812
+ height: Math.max(
10813
+ ganttHeight - ((tableBottom == null ? void 0 : tableBottom.height) || 0),
10814
+ distances.minimumRowDisplayed * distances.rowHeight
10815
+ ),
10811
10816
  width: taskListWidth
10812
10817
  },
10813
10818
  children: /* @__PURE__ */ jsx(
10814
10819
  "div",
10815
10820
  {
10816
10821
  style: {
10822
+ height: Math.max(
10823
+ ganttFullHeight,
10824
+ distances.minimumRowDisplayed * distances.rowHeight
10825
+ ),
10817
10826
  backgroundSize: `100% ${fullRowHeight * 2}px`,
10818
- backgroundImage: `linear-gradient(to bottom, transparent ${fullRowHeight}px, #f5f5f5 ${fullRowHeight}px)`,
10819
- height: "100%"
10827
+ backgroundImage: `linear-gradient(to bottom, transparent ${fullRowHeight}px, #f5f5f5 ${fullRowHeight}px)`
10820
10828
  },
10821
10829
  children: /* @__PURE__ */ jsx(
10822
10830
  RenderTaskListTable,
@@ -13127,17 +13135,13 @@ const TaskGanttContentInner = (props) => {
13127
13135
  ] });
13128
13136
  };
13129
13137
  const TaskGanttContent = memo(TaskGanttContentInner);
13130
- const ganttVerticalContainer = "_ganttVerticalContainer_1xboz_1";
13131
- const horizontalContainer = "_horizontalContainer_1xboz_81";
13132
- const ganttHeader = "_ganttHeader_1xboz_97";
13133
- const ganttBodyScroll = "_ganttBodyScroll_1xboz_107";
13134
- const wrapper = "_wrapper_1xboz_123";
13135
- const calendarDragging = "_calendarDragging_1xboz_153";
13138
+ const ganttVerticalContainer = "_ganttVerticalContainer_1wr55_1";
13139
+ const horizontalContainer = "_horizontalContainer_1wr55_73";
13140
+ const wrapper = "_wrapper_1wr55_85";
13141
+ const calendarDragging = "_calendarDragging_1wr55_109";
13136
13142
  const styles$2 = {
13137
13143
  ganttVerticalContainer,
13138
13144
  horizontalContainer,
13139
- ganttHeader,
13140
- ganttBodyScroll,
13141
13145
  wrapper,
13142
13146
  calendarDragging
13143
13147
  };
@@ -13149,6 +13153,7 @@ const TaskGanttInner = (props) => {
13149
13153
  fullRowHeight,
13150
13154
  fullSvgWidth,
13151
13155
  ganttFullHeight,
13156
+ ganttHeight,
13152
13157
  ganttSVGRef,
13153
13158
  ganttTodayProps,
13154
13159
  ganttTodayProps: {
@@ -13165,10 +13170,10 @@ const TaskGanttInner = (props) => {
13165
13170
  const moveStateScrollRef = useRef(null);
13166
13171
  const containerStyle = useMemo(
13167
13172
  () => ({
13168
- height: "100%",
13169
- width: "100%"
13173
+ height: Math.max(ganttHeight, minimumRowDisplayed * rowHeight),
13174
+ width: fullSvgWidth
13170
13175
  }),
13171
- []
13176
+ [ganttHeight, minimumRowDisplayed, rowHeight, fullSvgWidth]
13172
13177
  );
13173
13178
  const gridStyle = useMemo(
13174
13179
  () => ({
@@ -13272,7 +13277,7 @@ const TaskGanttInner = (props) => {
13272
13277
  onScroll: onVerticalScrollbarScrollX,
13273
13278
  dir: "ltr",
13274
13279
  children: [
13275
- /* @__PURE__ */ jsx("div", { className: styles$2.ganttHeader, children: /* @__PURE__ */ jsx(
13280
+ /* @__PURE__ */ jsx(
13276
13281
  "svg",
13277
13282
  {
13278
13283
  xmlns: "http://www.w3.org/2000/svg",
@@ -13281,8 +13286,8 @@ const TaskGanttInner = (props) => {
13281
13286
  fontFamily: "var(--gantt-font-family)",
13282
13287
  children: /* @__PURE__ */ jsx(Calendar, { scrollRef: verticalGanttContainerRef, ...calendarProps })
13283
13288
  }
13284
- ) }),
13285
- /* @__PURE__ */ jsx("div", { className: styles$2.ganttBodyScroll, children: /* @__PURE__ */ jsx(
13289
+ ),
13290
+ /* @__PURE__ */ jsx(
13286
13291
  "div",
13287
13292
  {
13288
13293
  ref: horizontalContainerRef,
@@ -13298,21 +13303,13 @@ const TaskGanttInner = (props) => {
13298
13303
  ref: ganttSVGRef,
13299
13304
  children: [
13300
13305
  /* @__PURE__ */ jsx(GanttToday, { ...ganttTodayProps }),
13301
- /* @__PURE__ */ jsx(
13302
- "rect",
13303
- {
13304
- ref: contentRef,
13305
- width: "100%",
13306
- height: "100%",
13307
- fill: "transparent"
13308
- }
13309
- ),
13306
+ /* @__PURE__ */ jsx("rect", { ref: contentRef, width: "100%", height: "100%", fill: "transparent" }),
13310
13307
  /* @__PURE__ */ jsx(TaskGanttContent, { ...barProps })
13311
13308
  ]
13312
13309
  }
13313
13310
  ) })
13314
13311
  }
13315
- ) })
13312
+ )
13316
13313
  ]
13317
13314
  }
13318
13315
  );
@@ -18525,8 +18522,7 @@ const Gantt = (props) => {
18525
18522
  viewDate,
18526
18523
  viewMode = ViewMode.Day,
18527
18524
  locale: clientLocale,
18528
- language,
18529
- height: clientHeight
18525
+ language
18530
18526
  } = props;
18531
18527
  const ganttSVGRef = useRef(null);
18532
18528
  const wrapperRef = useRef(null);
@@ -18535,7 +18531,6 @@ const Gantt = (props) => {
18535
18531
  const theme = useMemo(() => buildGanttTheme(clientTheme), [clientTheme]);
18536
18532
  const { distances, dateFormats: dateFormats2, rtl } = theme;
18537
18533
  const [waitCommitTasks, setWaitCommitTasks] = useState(false);
18538
- const [measuredHeight, setMeasuredHeight] = useState();
18539
18534
  const taskBar = useMemo(() => {
18540
18535
  return mergeDeepObj(
18541
18536
  {},
@@ -18593,9 +18588,28 @@ const Gantt = (props) => {
18593
18588
  const [sortedTasks, setSortedTasks] = useState(
18594
18589
  () => [...clientTasks].sort(sortTasks)
18595
18590
  );
18591
+ const [containerHeight, setContainerHeight] = useState(
18592
+ void 0
18593
+ );
18596
18594
  useEffect(() => {
18597
18595
  setSortedTasks([...clientTasks].sort(sortTasks));
18598
18596
  }, [clientTasks]);
18597
+ useEffect(() => {
18598
+ if (!wrapperRef.current) {
18599
+ return () => {
18600
+ };
18601
+ }
18602
+ const resizeObserver = new ResizeObserver((entries) => {
18603
+ for (const entry of entries) {
18604
+ const { height } = entry.contentRect;
18605
+ setContainerHeight(height);
18606
+ }
18607
+ });
18608
+ resizeObserver.observe(wrapperRef.current);
18609
+ return () => {
18610
+ resizeObserver.disconnect();
18611
+ };
18612
+ }, []);
18599
18613
  const [childTasksMap, rootTasksMap] = useMemo(
18600
18614
  () => getChildsAndRoots(sortedTasks, null),
18601
18615
  [sortedTasks]
@@ -18674,26 +18688,20 @@ const Gantt = (props) => {
18674
18688
  [maxLevelLength, fullRowHeight, (_a = taskList == null ? void 0 : taskList.tableBottom) == null ? void 0 : _a.height]
18675
18689
  );
18676
18690
  const ganttHeight = useMemo(() => {
18677
- const minRowsHeight = distances.minimumRowDisplayed * distances.rowHeight;
18678
- const resolvedHeightFromProp = typeof clientHeight === "number" ? clientHeight : void 0;
18679
- const resolvedHeightFromMeasured = measuredHeight;
18680
- const resolvedThemeHeight = typeof distances.ganttHeight === "number" ? distances.ganttHeight : void 0;
18681
- const candidateHeights = [
18682
- resolvedHeightFromProp,
18683
- resolvedHeightFromMeasured,
18684
- resolvedThemeHeight,
18685
- ganttFullHeight
18686
- ].filter((v) => typeof v === "number");
18687
- if (candidateHeights.length === 0) {
18688
- return Math.min(ganttFullHeight, minRowsHeight);
18689
- }
18690
- const chosen = Math.min(
18691
- ...candidateHeights,
18692
- ganttFullHeight,
18693
- minRowsHeight
18694
- );
18695
- return chosen;
18696
- }, [distances, ganttFullHeight, clientHeight, measuredHeight]);
18691
+ if (distances.ganttHeight) {
18692
+ return Math.min(distances.ganttHeight, ganttFullHeight);
18693
+ }
18694
+ if (containerHeight) {
18695
+ const availableHeight = containerHeight - distances.headerHeight;
18696
+ return Math.min(availableHeight, ganttFullHeight);
18697
+ }
18698
+ return ganttFullHeight;
18699
+ }, [
18700
+ distances.ganttHeight,
18701
+ distances.headerHeight,
18702
+ ganttFullHeight,
18703
+ containerHeight
18704
+ ]);
18697
18705
  const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = useMemo(
18698
18706
  () => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
18699
18707
  [visibleTasks, comparisonLevels]
@@ -18750,8 +18758,8 @@ const Gantt = (props) => {
18750
18758
  [renderedColumnIndexes]
18751
18759
  );
18752
18760
  const svgWidth = useMemo(
18753
- () => datesLength * distances.columnWidth,
18754
- [datesLength, distances]
18761
+ () => Math.max(datesLength * distances.columnWidth, svgClientWidth),
18762
+ [datesLength, distances, svgClientWidth]
18755
18763
  );
18756
18764
  const countTaskCoordinates$1 = useCallback(
18757
18765
  (task) => countTaskCoordinates(
@@ -18876,37 +18884,6 @@ const Gantt = (props) => {
18876
18884
  setScrollXProgrammatically(datesLength * distances.columnWidth);
18877
18885
  }
18878
18886
  }, [datesLength, distances, rtl, setScrollXProgrammatically, scrollX]);
18879
- useEffect(() => {
18880
- if (typeof clientHeight === "number") {
18881
- setMeasuredHeight(clientHeight);
18882
- return () => {
18883
- };
18884
- }
18885
- const node = wrapperRef.current;
18886
- if (!node) {
18887
- return () => {
18888
- };
18889
- }
18890
- setMeasuredHeight(node.getBoundingClientRect().height);
18891
- const ResizeObserverCtor = window.ResizeObserver;
18892
- let ro;
18893
- if (typeof ResizeObserverCtor === "function") {
18894
- const ctor = ResizeObserverCtor;
18895
- ro = new ctor(() => {
18896
- const rect = node.getBoundingClientRect();
18897
- setMeasuredHeight(rect.height);
18898
- });
18899
- ro.observe(node);
18900
- }
18901
- return () => {
18902
- if (ro) {
18903
- try {
18904
- ro.disconnect();
18905
- } catch (e) {
18906
- }
18907
- }
18908
- };
18909
- }, [clientHeight, wrapperRef]);
18910
18887
  useEffect(() => {
18911
18888
  if (viewDate && !currentViewDate || viewDate && (currentViewDate == null ? void 0 : currentViewDate.valueOf()) !== viewDate.valueOf()) {
18912
18889
  const index2 = getDatesDiff(viewDate, startDate, viewMode);
@@ -19806,6 +19783,7 @@ const Gantt = (props) => {
19806
19783
  distances,
19807
19784
  fullRowHeight,
19808
19785
  ganttFullHeight,
19786
+ ganttHeight,
19809
19787
  getTaskCurrentState,
19810
19788
  handleAddTask,
19811
19789
  handleDeleteTasks,
@@ -19835,6 +19813,7 @@ const Gantt = (props) => {
19835
19813
  distances,
19836
19814
  fullRowHeight,
19837
19815
  ganttFullHeight,
19816
+ ganttHeight,
19838
19817
  getTaskCurrentState,
19839
19818
  handleAddTask,
19840
19819
  handleDeleteTasks,
@@ -19875,6 +19854,7 @@ const Gantt = (props) => {
19875
19854
  fullRowHeight,
19876
19855
  fullSvgWidth,
19877
19856
  ganttFullHeight,
19857
+ ganttHeight,
19878
19858
  ganttSVGRef,
19879
19859
  ganttTodayProps: gridProps,
19880
19860
  horizontalContainerRef,
@@ -4672,6 +4672,7 @@
4672
4672
  scroll
4673
4673
  };
4674
4674
  const VerticalScroll = ({
4675
+ ganttHeight,
4675
4676
  ganttFullHeight,
4676
4677
  headerHeight,
4677
4678
  isChangeInProgress,
@@ -4683,7 +4684,7 @@
4683
4684
  "div",
4684
4685
  {
4685
4686
  style: {
4686
- height: `calc(100% - ${headerHeight}px)`,
4687
+ height: ganttHeight,
4687
4688
  marginTop: headerHeight,
4688
4689
  marginLeft: rtl ? void 0 : "-1rem",
4689
4690
  pointerEvents: isChangeInProgress ? "none" : void 0
@@ -5178,7 +5179,6 @@
5178
5179
  expandIconWidth: 20,
5179
5180
  handleWidth: 8,
5180
5181
  headerHeight: 50,
5181
- ganttHeight: 600,
5182
5182
  minimumRowDisplayed: 4,
5183
5183
  nestedTaskNameOffset: 20,
5184
5184
  relationCircleOffset: 10,
@@ -10654,14 +10654,14 @@
10654
10654
  );
10655
10655
  };
10656
10656
  const TaskListTable = React.memo(TaskListTableDefaultInner);
10657
- const taskListRoot = "_taskListRoot_1x5nq_1";
10658
- const taskListHorizontalScroll = "_taskListHorizontalScroll_1x5nq_25";
10659
- const taskListResizer = "_taskListResizer_1x5nq_89";
10660
- const horizontalContainer$1 = "_horizontalContainer_1x5nq_153";
10661
- const tableWrapper = "_tableWrapper_1x5nq_171";
10662
- const scrollToTop = "_scrollToTop_1x5nq_183";
10663
- const scrollToBottom = "_scrollToBottom_1x5nq_199";
10664
- const hidden = "_hidden_1x5nq_215";
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";
10665
10665
  const styles$d = {
10666
10666
  taskListRoot,
10667
10667
  taskListHorizontalScroll,
@@ -10695,6 +10695,7 @@
10695
10695
  distances,
10696
10696
  fullRowHeight,
10697
10697
  ganttFullHeight,
10698
+ ganttHeight,
10698
10699
  getTaskCurrentState,
10699
10700
  handleAddTask,
10700
10701
  handleDeleteTasks,
@@ -10825,15 +10826,22 @@
10825
10826
  ref: taskListContainerRef,
10826
10827
  className: styles$d.horizontalContainer,
10827
10828
  style: {
10829
+ height: Math.max(
10830
+ ganttHeight - ((tableBottom == null ? void 0 : tableBottom.height) || 0),
10831
+ distances.minimumRowDisplayed * distances.rowHeight
10832
+ ),
10828
10833
  width: taskListWidth
10829
10834
  },
10830
10835
  children: /* @__PURE__ */ jsxRuntime.jsx(
10831
10836
  "div",
10832
10837
  {
10833
10838
  style: {
10839
+ height: Math.max(
10840
+ ganttFullHeight,
10841
+ distances.minimumRowDisplayed * distances.rowHeight
10842
+ ),
10834
10843
  backgroundSize: `100% ${fullRowHeight * 2}px`,
10835
- backgroundImage: `linear-gradient(to bottom, transparent ${fullRowHeight}px, #f5f5f5 ${fullRowHeight}px)`,
10836
- height: "100%"
10844
+ backgroundImage: `linear-gradient(to bottom, transparent ${fullRowHeight}px, #f5f5f5 ${fullRowHeight}px)`
10837
10845
  },
10838
10846
  children: /* @__PURE__ */ jsxRuntime.jsx(
10839
10847
  RenderTaskListTable,
@@ -13144,17 +13152,13 @@
13144
13152
  ] });
13145
13153
  };
13146
13154
  const TaskGanttContent = React.memo(TaskGanttContentInner);
13147
- const ganttVerticalContainer = "_ganttVerticalContainer_1xboz_1";
13148
- const horizontalContainer = "_horizontalContainer_1xboz_81";
13149
- const ganttHeader = "_ganttHeader_1xboz_97";
13150
- const ganttBodyScroll = "_ganttBodyScroll_1xboz_107";
13151
- const wrapper = "_wrapper_1xboz_123";
13152
- const calendarDragging = "_calendarDragging_1xboz_153";
13155
+ const ganttVerticalContainer = "_ganttVerticalContainer_1wr55_1";
13156
+ const horizontalContainer = "_horizontalContainer_1wr55_73";
13157
+ const wrapper = "_wrapper_1wr55_85";
13158
+ const calendarDragging = "_calendarDragging_1wr55_109";
13153
13159
  const styles$2 = {
13154
13160
  ganttVerticalContainer,
13155
13161
  horizontalContainer,
13156
- ganttHeader,
13157
- ganttBodyScroll,
13158
13162
  wrapper,
13159
13163
  calendarDragging
13160
13164
  };
@@ -13166,6 +13170,7 @@
13166
13170
  fullRowHeight,
13167
13171
  fullSvgWidth,
13168
13172
  ganttFullHeight,
13173
+ ganttHeight,
13169
13174
  ganttSVGRef,
13170
13175
  ganttTodayProps,
13171
13176
  ganttTodayProps: {
@@ -13182,10 +13187,10 @@
13182
13187
  const moveStateScrollRef = React.useRef(null);
13183
13188
  const containerStyle = React.useMemo(
13184
13189
  () => ({
13185
- height: "100%",
13186
- width: "100%"
13190
+ height: Math.max(ganttHeight, minimumRowDisplayed * rowHeight),
13191
+ width: fullSvgWidth
13187
13192
  }),
13188
- []
13193
+ [ganttHeight, minimumRowDisplayed, rowHeight, fullSvgWidth]
13189
13194
  );
13190
13195
  const gridStyle = React.useMemo(
13191
13196
  () => ({
@@ -13289,7 +13294,7 @@
13289
13294
  onScroll: onVerticalScrollbarScrollX,
13290
13295
  dir: "ltr",
13291
13296
  children: [
13292
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles$2.ganttHeader, children: /* @__PURE__ */ jsxRuntime.jsx(
13297
+ /* @__PURE__ */ jsxRuntime.jsx(
13293
13298
  "svg",
13294
13299
  {
13295
13300
  xmlns: "http://www.w3.org/2000/svg",
@@ -13298,8 +13303,8 @@
13298
13303
  fontFamily: "var(--gantt-font-family)",
13299
13304
  children: /* @__PURE__ */ jsxRuntime.jsx(Calendar, { scrollRef: verticalGanttContainerRef, ...calendarProps })
13300
13305
  }
13301
- ) }),
13302
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles$2.ganttBodyScroll, children: /* @__PURE__ */ jsxRuntime.jsx(
13306
+ ),
13307
+ /* @__PURE__ */ jsxRuntime.jsx(
13303
13308
  "div",
13304
13309
  {
13305
13310
  ref: horizontalContainerRef,
@@ -13315,21 +13320,13 @@
13315
13320
  ref: ganttSVGRef,
13316
13321
  children: [
13317
13322
  /* @__PURE__ */ jsxRuntime.jsx(GanttToday, { ...ganttTodayProps }),
13318
- /* @__PURE__ */ jsxRuntime.jsx(
13319
- "rect",
13320
- {
13321
- ref: contentRef,
13322
- width: "100%",
13323
- height: "100%",
13324
- fill: "transparent"
13325
- }
13326
- ),
13323
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { ref: contentRef, width: "100%", height: "100%", fill: "transparent" }),
13327
13324
  /* @__PURE__ */ jsxRuntime.jsx(TaskGanttContent, { ...barProps })
13328
13325
  ]
13329
13326
  }
13330
13327
  ) })
13331
13328
  }
13332
- ) })
13329
+ )
13333
13330
  ]
13334
13331
  }
13335
13332
  );
@@ -18542,8 +18539,7 @@
18542
18539
  viewDate,
18543
18540
  viewMode = ViewMode.Day,
18544
18541
  locale: clientLocale,
18545
- language,
18546
- height: clientHeight
18542
+ language
18547
18543
  } = props;
18548
18544
  const ganttSVGRef = React.useRef(null);
18549
18545
  const wrapperRef = React.useRef(null);
@@ -18552,7 +18548,6 @@
18552
18548
  const theme = React.useMemo(() => buildGanttTheme(clientTheme), [clientTheme]);
18553
18549
  const { distances, dateFormats: dateFormats2, rtl } = theme;
18554
18550
  const [waitCommitTasks, setWaitCommitTasks] = React.useState(false);
18555
- const [measuredHeight, setMeasuredHeight] = React.useState();
18556
18551
  const taskBar = React.useMemo(() => {
18557
18552
  return mergeDeepObj(
18558
18553
  {},
@@ -18610,9 +18605,28 @@
18610
18605
  const [sortedTasks, setSortedTasks] = React.useState(
18611
18606
  () => [...clientTasks].sort(sortTasks)
18612
18607
  );
18608
+ const [containerHeight, setContainerHeight] = React.useState(
18609
+ void 0
18610
+ );
18613
18611
  React.useEffect(() => {
18614
18612
  setSortedTasks([...clientTasks].sort(sortTasks));
18615
18613
  }, [clientTasks]);
18614
+ React.useEffect(() => {
18615
+ if (!wrapperRef.current) {
18616
+ return () => {
18617
+ };
18618
+ }
18619
+ const resizeObserver = new ResizeObserver((entries) => {
18620
+ for (const entry of entries) {
18621
+ const { height } = entry.contentRect;
18622
+ setContainerHeight(height);
18623
+ }
18624
+ });
18625
+ resizeObserver.observe(wrapperRef.current);
18626
+ return () => {
18627
+ resizeObserver.disconnect();
18628
+ };
18629
+ }, []);
18616
18630
  const [childTasksMap, rootTasksMap] = React.useMemo(
18617
18631
  () => getChildsAndRoots(sortedTasks, null),
18618
18632
  [sortedTasks]
@@ -18691,26 +18705,20 @@
18691
18705
  [maxLevelLength, fullRowHeight, (_a = taskList == null ? void 0 : taskList.tableBottom) == null ? void 0 : _a.height]
18692
18706
  );
18693
18707
  const ganttHeight = React.useMemo(() => {
18694
- const minRowsHeight = distances.minimumRowDisplayed * distances.rowHeight;
18695
- const resolvedHeightFromProp = typeof clientHeight === "number" ? clientHeight : void 0;
18696
- const resolvedHeightFromMeasured = measuredHeight;
18697
- const resolvedThemeHeight = typeof distances.ganttHeight === "number" ? distances.ganttHeight : void 0;
18698
- const candidateHeights = [
18699
- resolvedHeightFromProp,
18700
- resolvedHeightFromMeasured,
18701
- resolvedThemeHeight,
18702
- ganttFullHeight
18703
- ].filter((v) => typeof v === "number");
18704
- if (candidateHeights.length === 0) {
18705
- return Math.min(ganttFullHeight, minRowsHeight);
18706
- }
18707
- const chosen = Math.min(
18708
- ...candidateHeights,
18709
- ganttFullHeight,
18710
- minRowsHeight
18711
- );
18712
- return chosen;
18713
- }, [distances, ganttFullHeight, clientHeight, measuredHeight]);
18708
+ if (distances.ganttHeight) {
18709
+ return Math.min(distances.ganttHeight, ganttFullHeight);
18710
+ }
18711
+ if (containerHeight) {
18712
+ const availableHeight = containerHeight - distances.headerHeight;
18713
+ return Math.min(availableHeight, ganttFullHeight);
18714
+ }
18715
+ return ganttFullHeight;
18716
+ }, [
18717
+ distances.ganttHeight,
18718
+ distances.headerHeight,
18719
+ ganttFullHeight,
18720
+ containerHeight
18721
+ ]);
18714
18722
  const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = React.useMemo(
18715
18723
  () => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
18716
18724
  [visibleTasks, comparisonLevels]
@@ -18767,8 +18775,8 @@
18767
18775
  [renderedColumnIndexes]
18768
18776
  );
18769
18777
  const svgWidth = React.useMemo(
18770
- () => datesLength * distances.columnWidth,
18771
- [datesLength, distances]
18778
+ () => Math.max(datesLength * distances.columnWidth, svgClientWidth),
18779
+ [datesLength, distances, svgClientWidth]
18772
18780
  );
18773
18781
  const countTaskCoordinates$1 = React.useCallback(
18774
18782
  (task) => countTaskCoordinates(
@@ -18893,37 +18901,6 @@
18893
18901
  setScrollXProgrammatically(datesLength * distances.columnWidth);
18894
18902
  }
18895
18903
  }, [datesLength, distances, rtl, setScrollXProgrammatically, scrollX]);
18896
- React.useEffect(() => {
18897
- if (typeof clientHeight === "number") {
18898
- setMeasuredHeight(clientHeight);
18899
- return () => {
18900
- };
18901
- }
18902
- const node = wrapperRef.current;
18903
- if (!node) {
18904
- return () => {
18905
- };
18906
- }
18907
- setMeasuredHeight(node.getBoundingClientRect().height);
18908
- const ResizeObserverCtor = window.ResizeObserver;
18909
- let ro;
18910
- if (typeof ResizeObserverCtor === "function") {
18911
- const ctor = ResizeObserverCtor;
18912
- ro = new ctor(() => {
18913
- const rect = node.getBoundingClientRect();
18914
- setMeasuredHeight(rect.height);
18915
- });
18916
- ro.observe(node);
18917
- }
18918
- return () => {
18919
- if (ro) {
18920
- try {
18921
- ro.disconnect();
18922
- } catch (e) {
18923
- }
18924
- }
18925
- };
18926
- }, [clientHeight, wrapperRef]);
18927
18904
  React.useEffect(() => {
18928
18905
  if (viewDate && !currentViewDate || viewDate && (currentViewDate == null ? void 0 : currentViewDate.valueOf()) !== viewDate.valueOf()) {
18929
18906
  const index2 = getDatesDiff(viewDate, startDate, viewMode);
@@ -19823,6 +19800,7 @@
19823
19800
  distances,
19824
19801
  fullRowHeight,
19825
19802
  ganttFullHeight,
19803
+ ganttHeight,
19826
19804
  getTaskCurrentState,
19827
19805
  handleAddTask,
19828
19806
  handleDeleteTasks,
@@ -19852,6 +19830,7 @@
19852
19830
  distances,
19853
19831
  fullRowHeight,
19854
19832
  ganttFullHeight,
19833
+ ganttHeight,
19855
19834
  getTaskCurrentState,
19856
19835
  handleAddTask,
19857
19836
  handleDeleteTasks,
@@ -19892,6 +19871,7 @@
19892
19871
  fullRowHeight,
19893
19872
  fullSvgWidth,
19894
19873
  ganttFullHeight,
19874
+ ganttHeight,
19895
19875
  ganttSVGRef,
19896
19876
  ganttTodayProps: gridProps,
19897
19877
  horizontalContainerRef,
package/dist/style.css CHANGED
@@ -282,36 +282,32 @@
282
282
  border-bottom: 1px solid var(--gantt-divider-color);
283
283
  table-layout: fixed;
284
284
  }
285
- ._taskListRoot_1x5nq_1 {
285
+ ._taskListRoot_yoz76_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;
292
- overflow: hidden;
293
- max-width: 100%;
294
- flex-shrink: 0;
290
+ /*noinspection CssUnresolvedCustomProperty*/
291
+ border-left: 1px solid var(--gantt-table-divider-color, var(--gantt-divider-color));
295
292
  }
296
293
 
297
- ._taskListHorizontalScroll_1x5nq_25 {
298
- overflow-x: auto;
299
- overflow-y: hidden;
300
- flex: 1;
294
+ ._taskListHorizontalScroll_yoz76_19 {
295
+ overflow-x: scroll;
296
+ height: 100%;
301
297
  display: flex;
302
298
  flex-direction: column;
303
299
  }
304
300
 
305
- ._taskListHorizontalScroll_1x5nq_25::-webkit-scrollbar {
301
+ ._taskListHorizontalScroll_yoz76_19::-webkit-scrollbar {
306
302
  width: 1rem;
307
303
  height: 1rem;
308
304
  }
309
305
 
310
- ._taskListHorizontalScroll_1x5nq_25::-webkit-scrollbar-corner {
306
+ ._taskListHorizontalScroll_yoz76_19::-webkit-scrollbar-corner {
311
307
  background: transparent;
312
308
  }
313
309
 
314
- ._taskListHorizontalScroll_1x5nq_25::-webkit-scrollbar-thumb {
310
+ ._taskListHorizontalScroll_yoz76_19::-webkit-scrollbar-thumb {
315
311
  border: 4px solid transparent;
316
312
  /*noinspection CssUnresolvedCustomProperty*/
317
313
  background: var(--gantt-scrollbar-thumb-color);
@@ -319,14 +315,14 @@
319
315
  background-clip: padding-box;
320
316
  }
321
317
 
322
- ._taskListHorizontalScroll_1x5nq_25::-webkit-scrollbar-thumb:hover {
318
+ ._taskListHorizontalScroll_yoz76_19::-webkit-scrollbar-thumb:hover {
323
319
  border: 2px solid transparent;
324
320
  /*noinspection CssUnresolvedCustomProperty*/
325
321
  background: var(--gantt-scrollbar-thumb-color);
326
322
  background-clip: padding-box;
327
323
  }
328
324
 
329
- ._taskListResizer_1x5nq_89 {
325
+ ._taskListResizer_yoz76_81 {
330
326
  position: absolute;
331
327
  top: 0;
332
328
  right: -3px;
@@ -338,16 +334,16 @@
338
334
  }
339
335
 
340
336
  /*noinspection CssUnresolvedCustomProperty*/
341
- ._taskListResizer_1x5nq_89:hover {
337
+ ._taskListResizer_yoz76_81:hover {
342
338
  background-color: var(--gantt-table-hover-action-color);
343
339
  filter: var(--gantt-hover-filter);
344
340
  }
345
341
 
346
- ._taskListResizer_1x5nq_89:hover::before {
342
+ ._taskListResizer_yoz76_81:hover::before {
347
343
  display: none;
348
344
  }
349
345
 
350
- ._taskListResizer_1x5nq_89::before {
346
+ ._taskListResizer_yoz76_81::before {
351
347
  content: "";
352
348
  position: absolute;
353
349
  top: 0;
@@ -358,22 +354,21 @@
358
354
  background-color: var(--gantt-table-resize-color, var(--gantt-divider-color));
359
355
  }
360
356
 
361
- ._horizontalContainer_1x5nq_153 {
357
+ ._horizontalContainer_yoz76_145 {
362
358
  margin: 0;
363
359
  padding: 0;
364
- overflow-y: auto;
365
- overflow-x: hidden;
366
- height: 100%;
367
- min-height: 0;
360
+ overflow: hidden;
361
+ flex-grow: 1;
368
362
  }
369
363
 
370
- ._tableWrapper_1x5nq_171 {
364
+ ._tableWrapper_yoz76_159 {
371
365
  position: relative;
372
- flex: 1;
373
- min-height: 0;
366
+ flex-grow: 1;
367
+ display: flex;
368
+ flex-direction: column;
374
369
  }
375
370
 
376
- ._scrollToTop_1x5nq_183 {
371
+ ._scrollToTop_yoz76_173 {
377
372
  position: absolute;
378
373
  top: 0;
379
374
  left: 0;
@@ -381,7 +376,7 @@
381
376
  height: 20px;
382
377
  }
383
378
 
384
- ._scrollToBottom_1x5nq_199 {
379
+ ._scrollToBottom_yoz76_189 {
385
380
  position: absolute;
386
381
  bottom: 0;
387
382
  left: 0;
@@ -389,7 +384,7 @@
389
384
  height: 20px;
390
385
  }
391
386
 
392
- ._hidden_1x5nq_215 {
387
+ ._hidden_yoz76_205 {
393
388
  display: none;
394
389
  }
395
390
  ._ganttToday_1oyhk_1 {
@@ -583,10 +578,8 @@
583
578
  user-select: none;
584
579
  stroke-width: 0;
585
580
  }
586
- ._ganttVerticalContainer_1xboz_1 {
587
- display: flex;
588
- flex-direction: column;
589
- overflow-x: auto;
581
+ ._ganttVerticalContainer_1wr55_1 {
582
+ overflow-x: scroll;
590
583
  overflow-y: hidden;
591
584
  font-size: 0;
592
585
  margin: 0;
@@ -595,20 +588,18 @@
595
588
  border-right: 1px solid var(--gantt-calendar-divider-color, var(--gantt-divider-color));
596
589
  flex-grow: 1;
597
590
  height: 100%;
598
- min-height: 0;
599
- max-width: 100%;
600
591
  }
601
592
 
602
- ._ganttVerticalContainer_1xboz_1::-webkit-scrollbar {
593
+ ._ganttVerticalContainer_1wr55_1::-webkit-scrollbar {
603
594
  width: 1rem;
604
595
  height: 1rem;
605
596
  }
606
597
 
607
- ._ganttVerticalContainer_1xboz_1::-webkit-scrollbar-corner {
598
+ ._ganttVerticalContainer_1wr55_1::-webkit-scrollbar-corner {
608
599
  background: transparent;
609
600
  }
610
601
 
611
- ._ganttVerticalContainer_1xboz_1::-webkit-scrollbar-thumb {
602
+ ._ganttVerticalContainer_1wr55_1::-webkit-scrollbar-thumb {
612
603
  border: 4px solid transparent;
613
604
  /*noinspection CssUnresolvedCustomProperty*/
614
605
  background: var(--gantt-scrollbar-thumb-color);
@@ -616,50 +607,32 @@
616
607
  background-clip: padding-box;
617
608
  }
618
609
 
619
- ._ganttVerticalContainer_1xboz_1::-webkit-scrollbar-thumb:hover {
610
+ ._ganttVerticalContainer_1wr55_1::-webkit-scrollbar-thumb:hover {
620
611
  border: 2px solid transparent;
621
612
  /*noinspection CssUnresolvedCustomProperty*/
622
613
  background: var(--gantt-scrollbar-thumb-color);
623
614
  background-clip: padding-box;
624
615
  }
625
616
 
626
- ._horizontalContainer_1xboz_81 {
617
+ ._horizontalContainer_1wr55_73 {
627
618
  margin: 0;
628
619
  padding: 0;
629
620
  overflow: hidden;
630
- height: 100%;
631
- min-height: 0;
632
- }
633
-
634
- ._ganttHeader_1xboz_97 {
635
- flex: 0 0 auto;
636
- z-index: 3;
637
- }
638
-
639
- ._ganttBodyScroll_1xboz_107 {
640
- flex: 1 1 auto;
641
- overflow-y: auto;
642
- overflow-x: hidden;
643
- min-height: 0;
644
- height: 100%;
645
621
  }
646
622
 
647
- ._wrapper_1xboz_123 {
623
+ ._wrapper_1wr55_85 {
648
624
  display: flex;
649
625
  padding: 0;
650
626
  margin: 0;
651
627
  list-style: none;
652
628
  outline: none;
653
629
  position: relative;
630
+ height: 100%;
654
631
  /*noinspection CssUnresolvedCustomProperty*/
655
632
  border-bottom: 1px solid var(--gantt-divider-color);
656
- height: 100%;
657
- min-height: 0;
658
- max-width: 100%;
659
- overflow: hidden;
660
633
  }
661
634
 
662
- ._calendarDragging_1xboz_153 {
635
+ ._calendarDragging_1wr55_109 {
663
636
  cursor: grabbing;
664
637
  }
665
638
  /*noinspection CssUnresolvedCustomProperty*/
@@ -320,13 +320,6 @@ export interface GanttProps {
320
320
  * Move dates of tasks to working days during change
321
321
  */
322
322
  isAdjustToWorkingDates?: boolean;
323
- /**
324
- * Height of the Gantt component. Can be a number (pixels) or a CSS height string
325
- * (for example "100%" to fill a parent container). When a CSS string is
326
- * provided the component will measure its rendered height and use it for
327
- * internal scroll calculations.
328
- */
329
- height?: number | string;
330
323
  }
331
324
  export interface GanttTaskBarActions {
332
325
  allowMoveTaskBar?: (action: TaskBarMoveAction, task: RenderTask) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
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",
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "storybook": "start-storybook -p 6006",
26
- "build": "vite build && node -e \"require('child_process').execSync('tsc', {stdio:'inherit'})\"",
26
+ "build": "vite build && tsc",
27
27
  "start": "vite --host",
28
28
  "prepare": "npm run build",
29
29
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
@@ -42,10 +42,9 @@
42
42
  "@dnd-kit/sortable": "^8.0.0",
43
43
  "@floating-ui/dom": "1.6.3",
44
44
  "@floating-ui/react": "0.26.11",
45
- "@rollup/rollup-win32-x64-msvc": "^4.48.1",
46
45
  "date-fns": "3.6.0",
47
- "i18next": "^25.4.1",
48
- "react-i18next": "^15.7.2"
46
+ "i18next": "^24.0.5",
47
+ "react-i18next": "^15.1.3"
49
48
  },
50
49
  "peerDependencies": {
51
50
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
@@ -57,14 +56,14 @@
57
56
  "@chromatic-com/storybook": "^1.3.1",
58
57
  "@rollup/plugin-image": "3.0.3",
59
58
  "@storybook/addon-essentials": "^8.0.6",
60
- "@storybook/addon-interactions": "^8.6.14",
59
+ "@storybook/addon-interactions": "^8.0.6",
61
60
  "@storybook/addon-links": "^8.0.6",
62
61
  "@storybook/addon-onboarding": "^8.0.6",
63
62
  "@storybook/blocks": "^8.0.6",
64
63
  "@storybook/cli": "^8.4.4",
65
- "@storybook/react": "^8.6.14",
64
+ "@storybook/react": "^8.4.4",
66
65
  "@storybook/react-vite": "^8.0.6",
67
- "@storybook/test": "^8.6.14",
66
+ "@storybook/test": "^8.0.6",
68
67
  "@testing-library/jest-dom": "^6.4.2",
69
68
  "@testing-library/react": "^14.2.2",
70
69
  "@testing-library/user-event": "^14.2.1",
@@ -1 +0,0 @@
1
- export {};