gantt-task-react-v 1.0.11 → 1.0.13
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.
|
@@ -6,6 +6,7 @@ import { TaskGanttContentProps } from "./task-gantt-content";
|
|
|
6
6
|
import { GanttTaskBarActions } from "../../types";
|
|
7
7
|
export interface TaskGanttProps extends GanttTaskBarActions {
|
|
8
8
|
ganttHeight?: number;
|
|
9
|
+
useCssHeight?: boolean;
|
|
9
10
|
barProps: TaskGanttContentProps;
|
|
10
11
|
calendarProps: Omit<CalendarProps, "scrollRef">;
|
|
11
12
|
fullRowHeight: number;
|
|
@@ -15,6 +15,7 @@ export type TaskListProps = {
|
|
|
15
15
|
fullRowHeight: number;
|
|
16
16
|
ganttFullHeight: number;
|
|
17
17
|
ganttHeight?: number;
|
|
18
|
+
useCssHeight?: boolean;
|
|
18
19
|
getTaskCurrentState: (task: Task) => Task;
|
|
19
20
|
handleAddTask: (task: Task | null) => void;
|
|
20
21
|
handleDeleteTasks: (task: RenderTask[]) => void;
|
|
@@ -10721,7 +10721,8 @@ const TaskListInner = ({
|
|
|
10721
10721
|
onResizeColumn,
|
|
10722
10722
|
canReorderTasks,
|
|
10723
10723
|
tableBottom,
|
|
10724
|
-
ganttHeight
|
|
10724
|
+
ganttHeight,
|
|
10725
|
+
useCssHeight
|
|
10725
10726
|
}) => {
|
|
10726
10727
|
const [
|
|
10727
10728
|
columns,
|
|
@@ -10829,9 +10830,9 @@ const TaskListInner = ({
|
|
|
10829
10830
|
ref: taskListContainerRef,
|
|
10830
10831
|
className: styles$d.horizontalContainer,
|
|
10831
10832
|
style: {
|
|
10832
|
-
//
|
|
10833
|
-
//
|
|
10834
|
-
height: (() => {
|
|
10833
|
+
// If consumer asked for CSS height (e.g. "100%"), let the
|
|
10834
|
+
// container fill its parent. Otherwise compute pixel height.
|
|
10835
|
+
height: ganttHeight == null && ganttHeight !== 0 && (typeof ganttHeight === "undefined" || useCssHeight) ? "100%" : (() => {
|
|
10835
10836
|
const minRowsHeight = distances.minimumRowDisplayed * distances.rowHeight;
|
|
10836
10837
|
const resolved = typeof ganttHeight === "number" ? ganttHeight : void 0;
|
|
10837
10838
|
const visible = Math.max(
|
|
@@ -13207,7 +13208,7 @@ const TaskGanttInner = (props) => {
|
|
|
13207
13208
|
Math.min(ganttFullHeight, resolved ?? ganttFullHeight)
|
|
13208
13209
|
);
|
|
13209
13210
|
return {
|
|
13210
|
-
height: visible,
|
|
13211
|
+
height: props.useCssHeight ? "100%" : visible,
|
|
13211
13212
|
width: fullSvgWidth
|
|
13212
13213
|
};
|
|
13213
13214
|
}, [
|
|
@@ -13215,7 +13216,8 @@ const TaskGanttInner = (props) => {
|
|
|
13215
13216
|
minimumRowDisplayed,
|
|
13216
13217
|
rowHeight,
|
|
13217
13218
|
fullSvgWidth,
|
|
13218
|
-
ganttHeight
|
|
13219
|
+
ganttHeight,
|
|
13220
|
+
props.useCssHeight
|
|
13219
13221
|
]);
|
|
13220
13222
|
const gridStyle = useMemo(
|
|
13221
13223
|
() => ({
|
|
@@ -18744,6 +18746,7 @@ const Gantt = (props) => {
|
|
|
18744
18746
|
);
|
|
18745
18747
|
return chosen;
|
|
18746
18748
|
}, [distances, ganttFullHeight, clientHeight, measuredHeight]);
|
|
18749
|
+
const isCssHeight = typeof clientHeight === "string";
|
|
18747
18750
|
const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = useMemo(
|
|
18748
18751
|
() => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
|
|
18749
18752
|
[visibleTasks, comparisonLevels]
|
|
@@ -18937,14 +18940,30 @@ const Gantt = (props) => {
|
|
|
18937
18940
|
return () => {
|
|
18938
18941
|
};
|
|
18939
18942
|
}
|
|
18940
|
-
|
|
18943
|
+
const measureWithAncestorFallback = (el) => {
|
|
18944
|
+
const rect = el.getBoundingClientRect();
|
|
18945
|
+
let height = rect.height;
|
|
18946
|
+
try {
|
|
18947
|
+
let p = el.parentElement;
|
|
18948
|
+
while (p) {
|
|
18949
|
+
const pRect = p.getBoundingClientRect();
|
|
18950
|
+
if (pRect.height > height + 1) {
|
|
18951
|
+
height = pRect.height;
|
|
18952
|
+
break;
|
|
18953
|
+
}
|
|
18954
|
+
p = p.parentElement;
|
|
18955
|
+
}
|
|
18956
|
+
} catch (e) {
|
|
18957
|
+
}
|
|
18958
|
+
return height;
|
|
18959
|
+
};
|
|
18960
|
+
setMeasuredHeight(measureWithAncestorFallback(node));
|
|
18941
18961
|
const ResizeObserverCtor = window.ResizeObserver;
|
|
18942
18962
|
let ro;
|
|
18943
18963
|
if (typeof ResizeObserverCtor === "function") {
|
|
18944
18964
|
const ctor = ResizeObserverCtor;
|
|
18945
18965
|
ro = new ctor(() => {
|
|
18946
|
-
|
|
18947
|
-
setMeasuredHeight(rect.height);
|
|
18966
|
+
setMeasuredHeight(measureWithAncestorFallback(node));
|
|
18948
18967
|
});
|
|
18949
18968
|
ro.observe(node);
|
|
18950
18969
|
}
|
|
@@ -19857,6 +19876,7 @@ const Gantt = (props) => {
|
|
|
19857
19876
|
fullRowHeight,
|
|
19858
19877
|
ganttFullHeight,
|
|
19859
19878
|
ganttHeight,
|
|
19879
|
+
useCssHeight: isCssHeight,
|
|
19860
19880
|
getTaskCurrentState,
|
|
19861
19881
|
handleAddTask,
|
|
19862
19882
|
handleDeleteTasks,
|
|
@@ -19887,6 +19907,7 @@ const Gantt = (props) => {
|
|
|
19887
19907
|
fullRowHeight,
|
|
19888
19908
|
ganttFullHeight,
|
|
19889
19909
|
ganttHeight,
|
|
19910
|
+
isCssHeight,
|
|
19890
19911
|
getTaskCurrentState,
|
|
19891
19912
|
handleAddTask,
|
|
19892
19913
|
handleDeleteTasks,
|
|
@@ -19928,6 +19949,7 @@ const Gantt = (props) => {
|
|
|
19928
19949
|
fullSvgWidth,
|
|
19929
19950
|
ganttFullHeight,
|
|
19930
19951
|
ganttHeight,
|
|
19952
|
+
useCssHeight: typeof clientHeight === "string",
|
|
19931
19953
|
ganttSVGRef,
|
|
19932
19954
|
ganttTodayProps: gridProps,
|
|
19933
19955
|
horizontalContainerRef,
|
|
@@ -10738,7 +10738,8 @@
|
|
|
10738
10738
|
onResizeColumn,
|
|
10739
10739
|
canReorderTasks,
|
|
10740
10740
|
tableBottom,
|
|
10741
|
-
ganttHeight
|
|
10741
|
+
ganttHeight,
|
|
10742
|
+
useCssHeight
|
|
10742
10743
|
}) => {
|
|
10743
10744
|
const [
|
|
10744
10745
|
columns,
|
|
@@ -10846,9 +10847,9 @@
|
|
|
10846
10847
|
ref: taskListContainerRef,
|
|
10847
10848
|
className: styles$d.horizontalContainer,
|
|
10848
10849
|
style: {
|
|
10849
|
-
//
|
|
10850
|
-
//
|
|
10851
|
-
height: (() => {
|
|
10850
|
+
// If consumer asked for CSS height (e.g. "100%"), let the
|
|
10851
|
+
// container fill its parent. Otherwise compute pixel height.
|
|
10852
|
+
height: ganttHeight == null && ganttHeight !== 0 && (typeof ganttHeight === "undefined" || useCssHeight) ? "100%" : (() => {
|
|
10852
10853
|
const minRowsHeight = distances.minimumRowDisplayed * distances.rowHeight;
|
|
10853
10854
|
const resolved = typeof ganttHeight === "number" ? ganttHeight : void 0;
|
|
10854
10855
|
const visible = Math.max(
|
|
@@ -13224,7 +13225,7 @@
|
|
|
13224
13225
|
Math.min(ganttFullHeight, resolved ?? ganttFullHeight)
|
|
13225
13226
|
);
|
|
13226
13227
|
return {
|
|
13227
|
-
height: visible,
|
|
13228
|
+
height: props.useCssHeight ? "100%" : visible,
|
|
13228
13229
|
width: fullSvgWidth
|
|
13229
13230
|
};
|
|
13230
13231
|
}, [
|
|
@@ -13232,7 +13233,8 @@
|
|
|
13232
13233
|
minimumRowDisplayed,
|
|
13233
13234
|
rowHeight,
|
|
13234
13235
|
fullSvgWidth,
|
|
13235
|
-
ganttHeight
|
|
13236
|
+
ganttHeight,
|
|
13237
|
+
props.useCssHeight
|
|
13236
13238
|
]);
|
|
13237
13239
|
const gridStyle = React.useMemo(
|
|
13238
13240
|
() => ({
|
|
@@ -18761,6 +18763,7 @@
|
|
|
18761
18763
|
);
|
|
18762
18764
|
return chosen;
|
|
18763
18765
|
}, [distances, ganttFullHeight, clientHeight, measuredHeight]);
|
|
18766
|
+
const isCssHeight = typeof clientHeight === "string";
|
|
18764
18767
|
const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask] = React.useMemo(
|
|
18765
18768
|
() => getMapTaskToRowIndex(visibleTasks, comparisonLevels),
|
|
18766
18769
|
[visibleTasks, comparisonLevels]
|
|
@@ -18954,14 +18957,30 @@
|
|
|
18954
18957
|
return () => {
|
|
18955
18958
|
};
|
|
18956
18959
|
}
|
|
18957
|
-
|
|
18960
|
+
const measureWithAncestorFallback = (el) => {
|
|
18961
|
+
const rect = el.getBoundingClientRect();
|
|
18962
|
+
let height = rect.height;
|
|
18963
|
+
try {
|
|
18964
|
+
let p = el.parentElement;
|
|
18965
|
+
while (p) {
|
|
18966
|
+
const pRect = p.getBoundingClientRect();
|
|
18967
|
+
if (pRect.height > height + 1) {
|
|
18968
|
+
height = pRect.height;
|
|
18969
|
+
break;
|
|
18970
|
+
}
|
|
18971
|
+
p = p.parentElement;
|
|
18972
|
+
}
|
|
18973
|
+
} catch (e) {
|
|
18974
|
+
}
|
|
18975
|
+
return height;
|
|
18976
|
+
};
|
|
18977
|
+
setMeasuredHeight(measureWithAncestorFallback(node));
|
|
18958
18978
|
const ResizeObserverCtor = window.ResizeObserver;
|
|
18959
18979
|
let ro;
|
|
18960
18980
|
if (typeof ResizeObserverCtor === "function") {
|
|
18961
18981
|
const ctor = ResizeObserverCtor;
|
|
18962
18982
|
ro = new ctor(() => {
|
|
18963
|
-
|
|
18964
|
-
setMeasuredHeight(rect.height);
|
|
18983
|
+
setMeasuredHeight(measureWithAncestorFallback(node));
|
|
18965
18984
|
});
|
|
18966
18985
|
ro.observe(node);
|
|
18967
18986
|
}
|
|
@@ -19874,6 +19893,7 @@
|
|
|
19874
19893
|
fullRowHeight,
|
|
19875
19894
|
ganttFullHeight,
|
|
19876
19895
|
ganttHeight,
|
|
19896
|
+
useCssHeight: isCssHeight,
|
|
19877
19897
|
getTaskCurrentState,
|
|
19878
19898
|
handleAddTask,
|
|
19879
19899
|
handleDeleteTasks,
|
|
@@ -19904,6 +19924,7 @@
|
|
|
19904
19924
|
fullRowHeight,
|
|
19905
19925
|
ganttFullHeight,
|
|
19906
19926
|
ganttHeight,
|
|
19927
|
+
isCssHeight,
|
|
19907
19928
|
getTaskCurrentState,
|
|
19908
19929
|
handleAddTask,
|
|
19909
19930
|
handleDeleteTasks,
|
|
@@ -19945,6 +19966,7 @@
|
|
|
19945
19966
|
fullSvgWidth,
|
|
19946
19967
|
ganttFullHeight,
|
|
19947
19968
|
ganttHeight,
|
|
19969
|
+
useCssHeight: typeof clientHeight === "string",
|
|
19948
19970
|
ganttSVGRef,
|
|
19949
19971
|
ganttTodayProps: gridProps,
|
|
19950
19972
|
horizontalContainerRef,
|
package/package.json
CHANGED