gantt-task-react-v 1.0.4 → 1.0.6

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 webagility-gantt-task-react
10
+ npm install gantt-task-react-v
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';
17
- import "gantt-task-react/dist/index.css";
16
+ import { Gantt, Task, EventOption, StylingOption, ViewMode, DisplayOption } from 'gantt-task-react-v';
17
+ import "gantt-task-react-v/dist/index.css";
18
18
 
19
19
  let tasks: Task[] = [
20
20
  {
@@ -13154,13 +13154,17 @@ const TaskGanttContentInner = (props) => {
13154
13154
  ] });
13155
13155
  };
13156
13156
  const TaskGanttContent = memo(TaskGanttContentInner);
13157
- const ganttVerticalContainer = "_ganttVerticalContainer_1unzl_1";
13158
- const horizontalContainer = "_horizontalContainer_1unzl_71";
13159
- const wrapper = "_wrapper_1unzl_83";
13160
- const calendarDragging = "_calendarDragging_1unzl_105";
13157
+ const ganttVerticalContainer = "_ganttVerticalContainer_1044x_1";
13158
+ const horizontalContainer = "_horizontalContainer_1044x_75";
13159
+ const ganttHeader = "_ganttHeader_1044x_87";
13160
+ const ganttBodyScroll = "_ganttBodyScroll_1044x_97";
13161
+ const wrapper = "_wrapper_1044x_109";
13162
+ const calendarDragging = "_calendarDragging_1044x_131";
13161
13163
  const styles$2 = {
13162
13164
  ganttVerticalContainer,
13163
13165
  horizontalContainer,
13166
+ ganttHeader,
13167
+ ganttBodyScroll,
13164
13168
  wrapper,
13165
13169
  calendarDragging
13166
13170
  };
@@ -13295,7 +13299,7 @@ const TaskGanttInner = (props) => {
13295
13299
  onScroll: onVerticalScrollbarScrollX,
13296
13300
  dir: "ltr",
13297
13301
  children: [
13298
- /* @__PURE__ */ jsx(
13302
+ /* @__PURE__ */ jsx("div", { className: styles$2.ganttHeader, children: /* @__PURE__ */ jsx(
13299
13303
  "svg",
13300
13304
  {
13301
13305
  xmlns: "http://www.w3.org/2000/svg",
@@ -13304,8 +13308,8 @@ const TaskGanttInner = (props) => {
13304
13308
  fontFamily: "var(--gantt-font-family)",
13305
13309
  children: /* @__PURE__ */ jsx(Calendar, { scrollRef: verticalGanttContainerRef, ...calendarProps })
13306
13310
  }
13307
- ),
13308
- /* @__PURE__ */ jsx(
13311
+ ) }),
13312
+ /* @__PURE__ */ jsx("div", { className: styles$2.ganttBodyScroll, children: /* @__PURE__ */ jsx(
13309
13313
  "div",
13310
13314
  {
13311
13315
  ref: horizontalContainerRef,
@@ -13335,7 +13339,7 @@ const TaskGanttInner = (props) => {
13335
13339
  }
13336
13340
  ) })
13337
13341
  }
13338
- )
13342
+ ) })
13339
13343
  ]
13340
13344
  }
13341
13345
  );
@@ -18548,7 +18552,8 @@ const Gantt = (props) => {
18548
18552
  viewDate,
18549
18553
  viewMode = ViewMode.Day,
18550
18554
  locale: clientLocale,
18551
- language
18555
+ language,
18556
+ height: clientHeight
18552
18557
  } = props;
18553
18558
  const ganttSVGRef = useRef(null);
18554
18559
  const wrapperRef = useRef(null);
@@ -18557,6 +18562,7 @@ const Gantt = (props) => {
18557
18562
  const theme = useMemo(() => buildGanttTheme(clientTheme), [clientTheme]);
18558
18563
  const { distances, dateFormats: dateFormats2, rtl } = theme;
18559
18564
  const [waitCommitTasks, setWaitCommitTasks] = useState(false);
18565
+ const [measuredHeight, setMeasuredHeight] = useState();
18560
18566
  const taskBar = useMemo(() => {
18561
18567
  return mergeDeepObj(
18562
18568
  {},
@@ -18694,10 +18700,27 @@ const Gantt = (props) => {
18694
18700
  },
18695
18701
  [maxLevelLength, fullRowHeight, (_a = taskList == null ? void 0 : taskList.tableBottom) == null ? void 0 : _a.height]
18696
18702
  );
18697
- const ganttHeight = useMemo(
18698
- () => distances.ganttHeight ? Math.min(distances.ganttHeight, ganttFullHeight) : ganttFullHeight,
18699
- [distances, ganttFullHeight]
18700
- );
18703
+ const ganttHeight = useMemo(() => {
18704
+ const minRowsHeight = distances.minimumRowDisplayed * distances.rowHeight;
18705
+ const resolvedHeightFromProp = typeof clientHeight === "number" ? clientHeight : void 0;
18706
+ const resolvedHeightFromMeasured = measuredHeight;
18707
+ const resolvedThemeHeight = typeof distances.ganttHeight === "number" ? distances.ganttHeight : void 0;
18708
+ const candidateHeights = [
18709
+ resolvedHeightFromProp,
18710
+ resolvedHeightFromMeasured,
18711
+ resolvedThemeHeight,
18712
+ ganttFullHeight
18713
+ ].filter((v) => typeof v === "number");
18714
+ if (candidateHeights.length === 0) {
18715
+ return Math.min(ganttFullHeight, minRowsHeight);
18716
+ }
18717
+ const chosen = Math.min(
18718
+ ...candidateHeights,
18719
+ ganttFullHeight,
18720
+ minRowsHeight
18721
+ );
18722
+ return chosen;
18723
+ }, [distances, ganttFullHeight, clientHeight, measuredHeight]);
18701
18724
  const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = useMemo(
18702
18725
  () => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
18703
18726
  [visibleTasks, comparisonLevels]
@@ -18880,6 +18903,37 @@ const Gantt = (props) => {
18880
18903
  setScrollXProgrammatically(datesLength * distances.columnWidth);
18881
18904
  }
18882
18905
  }, [datesLength, distances, rtl, setScrollXProgrammatically, scrollX]);
18906
+ useEffect(() => {
18907
+ if (typeof clientHeight === "number") {
18908
+ setMeasuredHeight(clientHeight);
18909
+ return () => {
18910
+ };
18911
+ }
18912
+ const node = wrapperRef.current;
18913
+ if (!node) {
18914
+ return () => {
18915
+ };
18916
+ }
18917
+ setMeasuredHeight(node.getBoundingClientRect().height);
18918
+ const ResizeObserverCtor = window.ResizeObserver;
18919
+ let ro;
18920
+ if (typeof ResizeObserverCtor === "function") {
18921
+ const ctor = ResizeObserverCtor;
18922
+ ro = new ctor(() => {
18923
+ const rect = node.getBoundingClientRect();
18924
+ setMeasuredHeight(rect.height);
18925
+ });
18926
+ ro.observe(node);
18927
+ }
18928
+ return () => {
18929
+ if (ro) {
18930
+ try {
18931
+ ro.disconnect();
18932
+ } catch (e) {
18933
+ }
18934
+ }
18935
+ };
18936
+ }, [clientHeight, wrapperRef]);
18883
18937
  useEffect(() => {
18884
18938
  if (viewDate && !currentViewDate || viewDate && (currentViewDate == null ? void 0 : currentViewDate.valueOf()) !== viewDate.valueOf()) {
18885
18939
  const index2 = getDatesDiff(viewDate, startDate, viewMode);
@@ -13171,13 +13171,17 @@
13171
13171
  ] });
13172
13172
  };
13173
13173
  const TaskGanttContent = React.memo(TaskGanttContentInner);
13174
- const ganttVerticalContainer = "_ganttVerticalContainer_1unzl_1";
13175
- const horizontalContainer = "_horizontalContainer_1unzl_71";
13176
- const wrapper = "_wrapper_1unzl_83";
13177
- const calendarDragging = "_calendarDragging_1unzl_105";
13174
+ const ganttVerticalContainer = "_ganttVerticalContainer_1044x_1";
13175
+ const horizontalContainer = "_horizontalContainer_1044x_75";
13176
+ const ganttHeader = "_ganttHeader_1044x_87";
13177
+ const ganttBodyScroll = "_ganttBodyScroll_1044x_97";
13178
+ const wrapper = "_wrapper_1044x_109";
13179
+ const calendarDragging = "_calendarDragging_1044x_131";
13178
13180
  const styles$2 = {
13179
13181
  ganttVerticalContainer,
13180
13182
  horizontalContainer,
13183
+ ganttHeader,
13184
+ ganttBodyScroll,
13181
13185
  wrapper,
13182
13186
  calendarDragging
13183
13187
  };
@@ -13312,7 +13316,7 @@
13312
13316
  onScroll: onVerticalScrollbarScrollX,
13313
13317
  dir: "ltr",
13314
13318
  children: [
13315
- /* @__PURE__ */ jsxRuntime.jsx(
13319
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles$2.ganttHeader, children: /* @__PURE__ */ jsxRuntime.jsx(
13316
13320
  "svg",
13317
13321
  {
13318
13322
  xmlns: "http://www.w3.org/2000/svg",
@@ -13321,8 +13325,8 @@
13321
13325
  fontFamily: "var(--gantt-font-family)",
13322
13326
  children: /* @__PURE__ */ jsxRuntime.jsx(Calendar, { scrollRef: verticalGanttContainerRef, ...calendarProps })
13323
13327
  }
13324
- ),
13325
- /* @__PURE__ */ jsxRuntime.jsx(
13328
+ ) }),
13329
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles$2.ganttBodyScroll, children: /* @__PURE__ */ jsxRuntime.jsx(
13326
13330
  "div",
13327
13331
  {
13328
13332
  ref: horizontalContainerRef,
@@ -13352,7 +13356,7 @@
13352
13356
  }
13353
13357
  ) })
13354
13358
  }
13355
- )
13359
+ ) })
13356
13360
  ]
13357
13361
  }
13358
13362
  );
@@ -18565,7 +18569,8 @@
18565
18569
  viewDate,
18566
18570
  viewMode = ViewMode.Day,
18567
18571
  locale: clientLocale,
18568
- language
18572
+ language,
18573
+ height: clientHeight
18569
18574
  } = props;
18570
18575
  const ganttSVGRef = React.useRef(null);
18571
18576
  const wrapperRef = React.useRef(null);
@@ -18574,6 +18579,7 @@
18574
18579
  const theme = React.useMemo(() => buildGanttTheme(clientTheme), [clientTheme]);
18575
18580
  const { distances, dateFormats: dateFormats2, rtl } = theme;
18576
18581
  const [waitCommitTasks, setWaitCommitTasks] = React.useState(false);
18582
+ const [measuredHeight, setMeasuredHeight] = React.useState();
18577
18583
  const taskBar = React.useMemo(() => {
18578
18584
  return mergeDeepObj(
18579
18585
  {},
@@ -18711,10 +18717,27 @@
18711
18717
  },
18712
18718
  [maxLevelLength, fullRowHeight, (_a = taskList == null ? void 0 : taskList.tableBottom) == null ? void 0 : _a.height]
18713
18719
  );
18714
- const ganttHeight = React.useMemo(
18715
- () => distances.ganttHeight ? Math.min(distances.ganttHeight, ganttFullHeight) : ganttFullHeight,
18716
- [distances, ganttFullHeight]
18717
- );
18720
+ const ganttHeight = React.useMemo(() => {
18721
+ const minRowsHeight = distances.minimumRowDisplayed * distances.rowHeight;
18722
+ const resolvedHeightFromProp = typeof clientHeight === "number" ? clientHeight : void 0;
18723
+ const resolvedHeightFromMeasured = measuredHeight;
18724
+ const resolvedThemeHeight = typeof distances.ganttHeight === "number" ? distances.ganttHeight : void 0;
18725
+ const candidateHeights = [
18726
+ resolvedHeightFromProp,
18727
+ resolvedHeightFromMeasured,
18728
+ resolvedThemeHeight,
18729
+ ganttFullHeight
18730
+ ].filter((v) => typeof v === "number");
18731
+ if (candidateHeights.length === 0) {
18732
+ return Math.min(ganttFullHeight, minRowsHeight);
18733
+ }
18734
+ const chosen = Math.min(
18735
+ ...candidateHeights,
18736
+ ganttFullHeight,
18737
+ minRowsHeight
18738
+ );
18739
+ return chosen;
18740
+ }, [distances, ganttFullHeight, clientHeight, measuredHeight]);
18718
18741
  const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = React.useMemo(
18719
18742
  () => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
18720
18743
  [visibleTasks, comparisonLevels]
@@ -18897,6 +18920,37 @@
18897
18920
  setScrollXProgrammatically(datesLength * distances.columnWidth);
18898
18921
  }
18899
18922
  }, [datesLength, distances, rtl, setScrollXProgrammatically, scrollX]);
18923
+ React.useEffect(() => {
18924
+ if (typeof clientHeight === "number") {
18925
+ setMeasuredHeight(clientHeight);
18926
+ return () => {
18927
+ };
18928
+ }
18929
+ const node = wrapperRef.current;
18930
+ if (!node) {
18931
+ return () => {
18932
+ };
18933
+ }
18934
+ setMeasuredHeight(node.getBoundingClientRect().height);
18935
+ const ResizeObserverCtor = window.ResizeObserver;
18936
+ let ro;
18937
+ if (typeof ResizeObserverCtor === "function") {
18938
+ const ctor = ResizeObserverCtor;
18939
+ ro = new ctor(() => {
18940
+ const rect = node.getBoundingClientRect();
18941
+ setMeasuredHeight(rect.height);
18942
+ });
18943
+ ro.observe(node);
18944
+ }
18945
+ return () => {
18946
+ if (ro) {
18947
+ try {
18948
+ ro.disconnect();
18949
+ } catch (e) {
18950
+ }
18951
+ }
18952
+ };
18953
+ }, [clientHeight, wrapperRef]);
18900
18954
  React.useEffect(() => {
18901
18955
  if (viewDate && !currentViewDate || viewDate && (currentViewDate == null ? void 0 : currentViewDate.valueOf()) !== viewDate.valueOf()) {
18902
18956
  const index2 = getDatesDiff(viewDate, startDate, viewMode);
package/dist/style.css CHANGED
@@ -568,8 +568,10 @@
568
568
  user-select: none;
569
569
  stroke-width: 0;
570
570
  }
571
- ._ganttVerticalContainer_1unzl_1 {
572
- overflow-x: scroll;
571
+ ._ganttVerticalContainer_1044x_1 {
572
+ display: flex;
573
+ flex-direction: column;
574
+ overflow-x: hidden;
573
575
  overflow-y: hidden;
574
576
  font-size: 0;
575
577
  margin: 0;
@@ -579,16 +581,16 @@
579
581
  flex-grow: 1;
580
582
  }
581
583
 
582
- ._ganttVerticalContainer_1unzl_1::-webkit-scrollbar {
584
+ ._ganttVerticalContainer_1044x_1::-webkit-scrollbar {
583
585
  width: 1rem;
584
586
  height: 1rem;
585
587
  }
586
588
 
587
- ._ganttVerticalContainer_1unzl_1::-webkit-scrollbar-corner {
589
+ ._ganttVerticalContainer_1044x_1::-webkit-scrollbar-corner {
588
590
  background: transparent;
589
591
  }
590
592
 
591
- ._ganttVerticalContainer_1unzl_1::-webkit-scrollbar-thumb {
593
+ ._ganttVerticalContainer_1044x_1::-webkit-scrollbar-thumb {
592
594
  border: 4px solid transparent;
593
595
  /*noinspection CssUnresolvedCustomProperty*/
594
596
  background: var(--gantt-scrollbar-thumb-color);
@@ -596,20 +598,31 @@
596
598
  background-clip: padding-box;
597
599
  }
598
600
 
599
- ._ganttVerticalContainer_1unzl_1::-webkit-scrollbar-thumb:hover {
601
+ ._ganttVerticalContainer_1044x_1::-webkit-scrollbar-thumb:hover {
600
602
  border: 2px solid transparent;
601
603
  /*noinspection CssUnresolvedCustomProperty*/
602
604
  background: var(--gantt-scrollbar-thumb-color);
603
605
  background-clip: padding-box;
604
606
  }
605
607
 
606
- ._horizontalContainer_1unzl_71 {
608
+ ._horizontalContainer_1044x_75 {
607
609
  margin: 0;
608
610
  padding: 0;
609
611
  overflow: hidden;
610
612
  }
611
613
 
612
- ._wrapper_1unzl_83 {
614
+ ._ganttHeader_1044x_87 {
615
+ flex: 0 0 auto;
616
+ z-index: 3;
617
+ }
618
+
619
+ ._ganttBodyScroll_1044x_97 {
620
+ flex: 1 1 auto;
621
+ overflow-y: auto;
622
+ overflow-x: hidden;
623
+ }
624
+
625
+ ._wrapper_1044x_109 {
613
626
  display: flex;
614
627
  padding: 0;
615
628
  margin: 0;
@@ -620,7 +633,7 @@
620
633
  border-bottom: 1px solid var(--gantt-divider-color);
621
634
  }
622
635
 
623
- ._calendarDragging_1unzl_105 {
636
+ ._calendarDragging_1044x_131 {
624
637
  cursor: grabbing;
625
638
  }
626
639
  /*noinspection CssUnresolvedCustomProperty*/
@@ -320,6 +320,13 @@ 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;
323
330
  }
324
331
  export interface GanttTaskBarActions {
325
332
  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.4",
3
+ "version": "1.0.6",
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",