gantt-task-react-v 1.0.5 → 1.0.8

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
  {
@@ -5,6 +5,7 @@ import { CalendarProps } from "../calendar/calendar";
5
5
  import { TaskGanttContentProps } from "./task-gantt-content";
6
6
  import { GanttTaskBarActions } from "../../types";
7
7
  export interface TaskGanttProps extends GanttTaskBarActions {
8
+ ganttHeight?: number;
8
9
  barProps: TaskGanttContentProps;
9
10
  calendarProps: Omit<CalendarProps, "scrollRef">;
10
11
  fullRowHeight: number;
@@ -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;
@@ -10720,7 +10720,8 @@ const TaskListInner = ({
10720
10720
  tasks,
10721
10721
  onResizeColumn,
10722
10722
  canReorderTasks,
10723
- tableBottom
10723
+ tableBottom,
10724
+ ganttHeight
10724
10725
  }) => {
10725
10726
  const [
10726
10727
  columns,
@@ -10829,7 +10830,7 @@ const TaskListInner = ({
10829
10830
  className: styles$d.horizontalContainer,
10830
10831
  style: {
10831
10832
  height: Math.min(
10832
- ganttFullHeight,
10833
+ ganttHeight || ganttFullHeight,
10833
10834
  distances.minimumRowDisplayed * distances.rowHeight
10834
10835
  ),
10835
10836
  width: taskListWidth
@@ -13154,13 +13155,17 @@ const TaskGanttContentInner = (props) => {
13154
13155
  ] });
13155
13156
  };
13156
13157
  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";
13158
+ const ganttVerticalContainer = "_ganttVerticalContainer_1044x_1";
13159
+ const horizontalContainer = "_horizontalContainer_1044x_75";
13160
+ const ganttHeader = "_ganttHeader_1044x_87";
13161
+ const ganttBodyScroll = "_ganttBodyScroll_1044x_97";
13162
+ const wrapper = "_wrapper_1044x_109";
13163
+ const calendarDragging = "_calendarDragging_1044x_131";
13161
13164
  const styles$2 = {
13162
13165
  ganttVerticalContainer,
13163
13166
  horizontalContainer,
13167
+ ganttHeader,
13168
+ ganttBodyScroll,
13164
13169
  wrapper,
13165
13170
  calendarDragging
13166
13171
  };
@@ -13295,7 +13300,7 @@ const TaskGanttInner = (props) => {
13295
13300
  onScroll: onVerticalScrollbarScrollX,
13296
13301
  dir: "ltr",
13297
13302
  children: [
13298
- /* @__PURE__ */ jsx(
13303
+ /* @__PURE__ */ jsx("div", { className: styles$2.ganttHeader, children: /* @__PURE__ */ jsx(
13299
13304
  "svg",
13300
13305
  {
13301
13306
  xmlns: "http://www.w3.org/2000/svg",
@@ -13304,8 +13309,8 @@ const TaskGanttInner = (props) => {
13304
13309
  fontFamily: "var(--gantt-font-family)",
13305
13310
  children: /* @__PURE__ */ jsx(Calendar, { scrollRef: verticalGanttContainerRef, ...calendarProps })
13306
13311
  }
13307
- ),
13308
- /* @__PURE__ */ jsx(
13312
+ ) }),
13313
+ /* @__PURE__ */ jsx("div", { className: styles$2.ganttBodyScroll, children: /* @__PURE__ */ jsx(
13309
13314
  "div",
13310
13315
  {
13311
13316
  ref: horizontalContainerRef,
@@ -13335,7 +13340,7 @@ const TaskGanttInner = (props) => {
13335
13340
  }
13336
13341
  ) })
13337
13342
  }
13338
- )
13343
+ ) })
13339
13344
  ]
13340
13345
  }
13341
13346
  );
@@ -18548,7 +18553,8 @@ const Gantt = (props) => {
18548
18553
  viewDate,
18549
18554
  viewMode = ViewMode.Day,
18550
18555
  locale: clientLocale,
18551
- language
18556
+ language,
18557
+ height: clientHeight
18552
18558
  } = props;
18553
18559
  const ganttSVGRef = useRef(null);
18554
18560
  const wrapperRef = useRef(null);
@@ -18557,6 +18563,7 @@ const Gantt = (props) => {
18557
18563
  const theme = useMemo(() => buildGanttTheme(clientTheme), [clientTheme]);
18558
18564
  const { distances, dateFormats: dateFormats2, rtl } = theme;
18559
18565
  const [waitCommitTasks, setWaitCommitTasks] = useState(false);
18566
+ const [measuredHeight, setMeasuredHeight] = useState();
18560
18567
  const taskBar = useMemo(() => {
18561
18568
  return mergeDeepObj(
18562
18569
  {},
@@ -18696,11 +18703,25 @@ const Gantt = (props) => {
18696
18703
  );
18697
18704
  const ganttHeight = useMemo(() => {
18698
18705
  const minRowsHeight = distances.minimumRowDisplayed * distances.rowHeight;
18699
- if (typeof distances.ganttHeight === "number") {
18700
- return Math.min(distances.ganttHeight, ganttFullHeight, minRowsHeight);
18701
- }
18702
- return Math.min(ganttFullHeight, minRowsHeight);
18703
- }, [distances, ganttFullHeight]);
18706
+ const resolvedHeightFromProp = typeof clientHeight === "number" ? clientHeight : void 0;
18707
+ const resolvedHeightFromMeasured = measuredHeight;
18708
+ const resolvedThemeHeight = typeof distances.ganttHeight === "number" ? distances.ganttHeight : void 0;
18709
+ const candidateHeights = [
18710
+ resolvedHeightFromProp,
18711
+ resolvedHeightFromMeasured,
18712
+ resolvedThemeHeight,
18713
+ ganttFullHeight
18714
+ ].filter((v) => typeof v === "number");
18715
+ if (candidateHeights.length === 0) {
18716
+ return Math.min(ganttFullHeight, minRowsHeight);
18717
+ }
18718
+ const chosen = Math.min(
18719
+ ...candidateHeights,
18720
+ ganttFullHeight,
18721
+ minRowsHeight
18722
+ );
18723
+ return chosen;
18724
+ }, [distances, ganttFullHeight, clientHeight, measuredHeight]);
18704
18725
  const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = useMemo(
18705
18726
  () => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
18706
18727
  [visibleTasks, comparisonLevels]
@@ -18883,6 +18904,37 @@ const Gantt = (props) => {
18883
18904
  setScrollXProgrammatically(datesLength * distances.columnWidth);
18884
18905
  }
18885
18906
  }, [datesLength, distances, rtl, setScrollXProgrammatically, scrollX]);
18907
+ useEffect(() => {
18908
+ if (typeof clientHeight === "number") {
18909
+ setMeasuredHeight(clientHeight);
18910
+ return () => {
18911
+ };
18912
+ }
18913
+ const node = wrapperRef.current;
18914
+ if (!node) {
18915
+ return () => {
18916
+ };
18917
+ }
18918
+ setMeasuredHeight(node.getBoundingClientRect().height);
18919
+ const ResizeObserverCtor = window.ResizeObserver;
18920
+ let ro;
18921
+ if (typeof ResizeObserverCtor === "function") {
18922
+ const ctor = ResizeObserverCtor;
18923
+ ro = new ctor(() => {
18924
+ const rect = node.getBoundingClientRect();
18925
+ setMeasuredHeight(rect.height);
18926
+ });
18927
+ ro.observe(node);
18928
+ }
18929
+ return () => {
18930
+ if (ro) {
18931
+ try {
18932
+ ro.disconnect();
18933
+ } catch (e) {
18934
+ }
18935
+ }
18936
+ };
18937
+ }, [clientHeight, wrapperRef]);
18886
18938
  useEffect(() => {
18887
18939
  if (viewDate && !currentViewDate || viewDate && (currentViewDate == null ? void 0 : currentViewDate.valueOf()) !== viewDate.valueOf()) {
18888
18940
  const index2 = getDatesDiff(viewDate, startDate, viewMode);
@@ -19782,6 +19834,7 @@ const Gantt = (props) => {
19782
19834
  distances,
19783
19835
  fullRowHeight,
19784
19836
  ganttFullHeight,
19837
+ ganttHeight,
19785
19838
  getTaskCurrentState,
19786
19839
  handleAddTask,
19787
19840
  handleDeleteTasks,
@@ -19811,6 +19864,7 @@ const Gantt = (props) => {
19811
19864
  distances,
19812
19865
  fullRowHeight,
19813
19866
  ganttFullHeight,
19867
+ ganttHeight,
19814
19868
  getTaskCurrentState,
19815
19869
  handleAddTask,
19816
19870
  handleDeleteTasks,
@@ -19851,6 +19905,7 @@ const Gantt = (props) => {
19851
19905
  fullRowHeight,
19852
19906
  fullSvgWidth,
19853
19907
  ganttFullHeight,
19908
+ ganttHeight,
19854
19909
  ganttSVGRef,
19855
19910
  ganttTodayProps: gridProps,
19856
19911
  horizontalContainerRef,
@@ -10737,7 +10737,8 @@
10737
10737
  tasks,
10738
10738
  onResizeColumn,
10739
10739
  canReorderTasks,
10740
- tableBottom
10740
+ tableBottom,
10741
+ ganttHeight
10741
10742
  }) => {
10742
10743
  const [
10743
10744
  columns,
@@ -10846,7 +10847,7 @@
10846
10847
  className: styles$d.horizontalContainer,
10847
10848
  style: {
10848
10849
  height: Math.min(
10849
- ganttFullHeight,
10850
+ ganttHeight || ganttFullHeight,
10850
10851
  distances.minimumRowDisplayed * distances.rowHeight
10851
10852
  ),
10852
10853
  width: taskListWidth
@@ -13171,13 +13172,17 @@
13171
13172
  ] });
13172
13173
  };
13173
13174
  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";
13175
+ const ganttVerticalContainer = "_ganttVerticalContainer_1044x_1";
13176
+ const horizontalContainer = "_horizontalContainer_1044x_75";
13177
+ const ganttHeader = "_ganttHeader_1044x_87";
13178
+ const ganttBodyScroll = "_ganttBodyScroll_1044x_97";
13179
+ const wrapper = "_wrapper_1044x_109";
13180
+ const calendarDragging = "_calendarDragging_1044x_131";
13178
13181
  const styles$2 = {
13179
13182
  ganttVerticalContainer,
13180
13183
  horizontalContainer,
13184
+ ganttHeader,
13185
+ ganttBodyScroll,
13181
13186
  wrapper,
13182
13187
  calendarDragging
13183
13188
  };
@@ -13312,7 +13317,7 @@
13312
13317
  onScroll: onVerticalScrollbarScrollX,
13313
13318
  dir: "ltr",
13314
13319
  children: [
13315
- /* @__PURE__ */ jsxRuntime.jsx(
13320
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles$2.ganttHeader, children: /* @__PURE__ */ jsxRuntime.jsx(
13316
13321
  "svg",
13317
13322
  {
13318
13323
  xmlns: "http://www.w3.org/2000/svg",
@@ -13321,8 +13326,8 @@
13321
13326
  fontFamily: "var(--gantt-font-family)",
13322
13327
  children: /* @__PURE__ */ jsxRuntime.jsx(Calendar, { scrollRef: verticalGanttContainerRef, ...calendarProps })
13323
13328
  }
13324
- ),
13325
- /* @__PURE__ */ jsxRuntime.jsx(
13329
+ ) }),
13330
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles$2.ganttBodyScroll, children: /* @__PURE__ */ jsxRuntime.jsx(
13326
13331
  "div",
13327
13332
  {
13328
13333
  ref: horizontalContainerRef,
@@ -13352,7 +13357,7 @@
13352
13357
  }
13353
13358
  ) })
13354
13359
  }
13355
- )
13360
+ ) })
13356
13361
  ]
13357
13362
  }
13358
13363
  );
@@ -18565,7 +18570,8 @@
18565
18570
  viewDate,
18566
18571
  viewMode = ViewMode.Day,
18567
18572
  locale: clientLocale,
18568
- language
18573
+ language,
18574
+ height: clientHeight
18569
18575
  } = props;
18570
18576
  const ganttSVGRef = React.useRef(null);
18571
18577
  const wrapperRef = React.useRef(null);
@@ -18574,6 +18580,7 @@
18574
18580
  const theme = React.useMemo(() => buildGanttTheme(clientTheme), [clientTheme]);
18575
18581
  const { distances, dateFormats: dateFormats2, rtl } = theme;
18576
18582
  const [waitCommitTasks, setWaitCommitTasks] = React.useState(false);
18583
+ const [measuredHeight, setMeasuredHeight] = React.useState();
18577
18584
  const taskBar = React.useMemo(() => {
18578
18585
  return mergeDeepObj(
18579
18586
  {},
@@ -18713,11 +18720,25 @@
18713
18720
  );
18714
18721
  const ganttHeight = React.useMemo(() => {
18715
18722
  const minRowsHeight = distances.minimumRowDisplayed * distances.rowHeight;
18716
- if (typeof distances.ganttHeight === "number") {
18717
- return Math.min(distances.ganttHeight, ganttFullHeight, minRowsHeight);
18718
- }
18719
- return Math.min(ganttFullHeight, minRowsHeight);
18720
- }, [distances, ganttFullHeight]);
18723
+ const resolvedHeightFromProp = typeof clientHeight === "number" ? clientHeight : void 0;
18724
+ const resolvedHeightFromMeasured = measuredHeight;
18725
+ const resolvedThemeHeight = typeof distances.ganttHeight === "number" ? distances.ganttHeight : void 0;
18726
+ const candidateHeights = [
18727
+ resolvedHeightFromProp,
18728
+ resolvedHeightFromMeasured,
18729
+ resolvedThemeHeight,
18730
+ ganttFullHeight
18731
+ ].filter((v) => typeof v === "number");
18732
+ if (candidateHeights.length === 0) {
18733
+ return Math.min(ganttFullHeight, minRowsHeight);
18734
+ }
18735
+ const chosen = Math.min(
18736
+ ...candidateHeights,
18737
+ ganttFullHeight,
18738
+ minRowsHeight
18739
+ );
18740
+ return chosen;
18741
+ }, [distances, ganttFullHeight, clientHeight, measuredHeight]);
18721
18742
  const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = React.useMemo(
18722
18743
  () => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
18723
18744
  [visibleTasks, comparisonLevels]
@@ -18900,6 +18921,37 @@
18900
18921
  setScrollXProgrammatically(datesLength * distances.columnWidth);
18901
18922
  }
18902
18923
  }, [datesLength, distances, rtl, setScrollXProgrammatically, scrollX]);
18924
+ React.useEffect(() => {
18925
+ if (typeof clientHeight === "number") {
18926
+ setMeasuredHeight(clientHeight);
18927
+ return () => {
18928
+ };
18929
+ }
18930
+ const node = wrapperRef.current;
18931
+ if (!node) {
18932
+ return () => {
18933
+ };
18934
+ }
18935
+ setMeasuredHeight(node.getBoundingClientRect().height);
18936
+ const ResizeObserverCtor = window.ResizeObserver;
18937
+ let ro;
18938
+ if (typeof ResizeObserverCtor === "function") {
18939
+ const ctor = ResizeObserverCtor;
18940
+ ro = new ctor(() => {
18941
+ const rect = node.getBoundingClientRect();
18942
+ setMeasuredHeight(rect.height);
18943
+ });
18944
+ ro.observe(node);
18945
+ }
18946
+ return () => {
18947
+ if (ro) {
18948
+ try {
18949
+ ro.disconnect();
18950
+ } catch (e) {
18951
+ }
18952
+ }
18953
+ };
18954
+ }, [clientHeight, wrapperRef]);
18903
18955
  React.useEffect(() => {
18904
18956
  if (viewDate && !currentViewDate || viewDate && (currentViewDate == null ? void 0 : currentViewDate.valueOf()) !== viewDate.valueOf()) {
18905
18957
  const index2 = getDatesDiff(viewDate, startDate, viewMode);
@@ -19799,6 +19851,7 @@
19799
19851
  distances,
19800
19852
  fullRowHeight,
19801
19853
  ganttFullHeight,
19854
+ ganttHeight,
19802
19855
  getTaskCurrentState,
19803
19856
  handleAddTask,
19804
19857
  handleDeleteTasks,
@@ -19828,6 +19881,7 @@
19828
19881
  distances,
19829
19882
  fullRowHeight,
19830
19883
  ganttFullHeight,
19884
+ ganttHeight,
19831
19885
  getTaskCurrentState,
19832
19886
  handleAddTask,
19833
19887
  handleDeleteTasks,
@@ -19868,6 +19922,7 @@
19868
19922
  fullRowHeight,
19869
19923
  fullSvgWidth,
19870
19924
  ganttFullHeight,
19925
+ ganttHeight,
19871
19926
  ganttSVGRef,
19872
19927
  ganttTodayProps: gridProps,
19873
19928
  horizontalContainerRef,
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.5",
3
+ "version": "1.0.8",
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",