@thepocman/gantt-task-react 1.0.30 → 1.0.34
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/dist/components/task-item/task-item.d.ts +3 -2
- package/dist/gantt-task-react.es.js +83 -28
- package/dist/gantt-task-react.umd.js +83 -28
- package/dist/helpers/truncate-task-label.d.ts +1 -0
- package/dist/style.css +9 -11
- package/package.json +1 -1
- package/dist/helpers/get-initial-closed-tasks.d.ts +0 -2
- package/dist/helpers/get-unique-tasks-from-row-index-to-tasks-map.d.ts +0 -2
- package/dist/helpers/sort-visible-tasks.d.ts +0 -2
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { MouseEvent } from "react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { GanttRelationEvent } from "../../types/gantt-task-actions";
|
|
4
|
-
import { BarMoveAction, ChildOutOfParentWarnings, ColorStyles, DateExtremity, Distances, FixPosition, RelationKind, Task, TaskOrEmpty } from "../../types/public-types";
|
|
4
|
+
import { BarMoveAction, ChildOutOfParentWarnings, ColorStyles, DateExtremity, Distances, FixPosition, RelationKind, RowIndexToTasksMap, Task, TaskOrEmpty, TaskToRowIndexMap } from "../../types/public-types";
|
|
5
5
|
export type TaskItemProps = {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
getTaskGlobalIndexByRef: (task: Task) => number;
|
|
8
8
|
hasChildren: boolean;
|
|
9
|
+
rowIndexToTasksMap: RowIndexToTasksMap;
|
|
10
|
+
taskToRowIndexMap: TaskToRowIndexMap;
|
|
9
11
|
hasDependencyWarning: boolean;
|
|
10
12
|
progressWidth: number;
|
|
11
13
|
progressX: number;
|
|
@@ -38,6 +40,5 @@ export type TaskItemProps = {
|
|
|
38
40
|
handleDeleteTasks: (task: TaskOrEmpty[]) => void;
|
|
39
41
|
colorStyles: ColorStyles;
|
|
40
42
|
enableTaskGrouping?: boolean;
|
|
41
|
-
getTaskInitials?: (task: Task) => string;
|
|
42
43
|
};
|
|
43
44
|
export declare const TaskItem: React.NamedExoticComponent<TaskItemProps>;
|
|
@@ -465,14 +465,13 @@ const collectChildren = (arrayRes, mirrorRes, task, childTasksOnLevel, enableTas
|
|
|
465
465
|
if (comparisonLevel === 1) {
|
|
466
466
|
mirrorRes[task.id] = true;
|
|
467
467
|
}
|
|
468
|
-
|
|
469
|
-
if (task.type === "empty" || isTaskGroupingEnabled) {
|
|
468
|
+
if (task.type === "empty") {
|
|
470
469
|
return;
|
|
471
470
|
}
|
|
472
471
|
const childs = childTasksOnLevel.get(task.id);
|
|
473
472
|
if (childs && childs.length > 0) {
|
|
474
473
|
childs.forEach((childTask) => {
|
|
475
|
-
collectChildren(arrayRes, mirrorRes, childTask, childTasksOnLevel
|
|
474
|
+
collectChildren(arrayRes, mirrorRes, childTask, childTasksOnLevel);
|
|
476
475
|
});
|
|
477
476
|
}
|
|
478
477
|
};
|
|
@@ -482,7 +481,7 @@ const collectVisibleTasks = (childTasksMap, rootTasksMap, enableTaskGrouping) =>
|
|
|
482
481
|
for (const [comparisonLevel, rootTasks] of rootTasksMap.entries()) {
|
|
483
482
|
const childTasksOnLevel = childTasksMap.get(comparisonLevel) || /* @__PURE__ */ new Map();
|
|
484
483
|
rootTasks.forEach((task) => {
|
|
485
|
-
collectChildren(arrayRes, mirrorRes, task, childTasksOnLevel
|
|
484
|
+
collectChildren(arrayRes, mirrorRes, task, childTasksOnLevel);
|
|
486
485
|
});
|
|
487
486
|
}
|
|
488
487
|
return [arrayRes, mirrorRes];
|
|
@@ -4229,6 +4228,7 @@ const TaskListTableDefaultInner = ({
|
|
|
4229
4228
|
if (taskIndex) {
|
|
4230
4229
|
[depth, indexStr] = taskIndex;
|
|
4231
4230
|
}
|
|
4231
|
+
console.log("colors :>> ", colors);
|
|
4232
4232
|
renderList.push(
|
|
4233
4233
|
/* @__PURE__ */ jsx(
|
|
4234
4234
|
TaskListTableRow,
|
|
@@ -4579,21 +4579,24 @@ const Calendar = ({
|
|
|
4579
4579
|
)
|
|
4580
4580
|
);
|
|
4581
4581
|
if (!isUnknownDates && (i2 === startColumnIndex || date.getFullYear() !== getDate(i2 - 1).getFullYear())) {
|
|
4582
|
-
const year = date.getFullYear()
|
|
4583
|
-
|
|
4582
|
+
const year = date.getFullYear();
|
|
4583
|
+
console.log("Fulll year :>> ", year);
|
|
4584
|
+
const topValue = year.toString();
|
|
4585
|
+
const startHalfYearIndex = i2 - date.getMonth();
|
|
4586
|
+
const centerX = additionalLeftSpace + columnWidth * i2 + columnWidth;
|
|
4584
4587
|
topValues2.push(
|
|
4585
4588
|
/* @__PURE__ */ jsx(
|
|
4586
4589
|
TopPartOfCalendar,
|
|
4587
4590
|
{
|
|
4588
|
-
value:
|
|
4589
|
-
x1Line: additionalLeftSpace + columnWidth *
|
|
4591
|
+
value: topValue,
|
|
4592
|
+
x1Line: additionalLeftSpace + columnWidth * startHalfYearIndex,
|
|
4590
4593
|
y1Line: 0,
|
|
4591
4594
|
y2Line: topDefaultHeight,
|
|
4592
|
-
xText:
|
|
4595
|
+
xText: centerX,
|
|
4593
4596
|
yText: topDefaultHeight * 0.9,
|
|
4594
4597
|
colors
|
|
4595
4598
|
},
|
|
4596
|
-
year
|
|
4599
|
+
`year-${year}`
|
|
4597
4600
|
)
|
|
4598
4601
|
);
|
|
4599
4602
|
}
|
|
@@ -4936,7 +4939,9 @@ const shouldDrawVerticalDivider = (currentDate, previousDate, viewMode, isUnknow
|
|
|
4936
4939
|
case ViewMode.Year:
|
|
4937
4940
|
return currentDate.getFullYear() !== previousDate.getFullYear();
|
|
4938
4941
|
case ViewMode.HalfYear:
|
|
4939
|
-
|
|
4942
|
+
const currentHalf = Math.ceil((currentDate.getMonth() + 1) / 6);
|
|
4943
|
+
const previousHalf = Math.ceil((previousDate.getMonth() + 1) / 6);
|
|
4944
|
+
return currentHalf !== previousHalf || currentDate.getFullYear() !== previousDate.getFullYear();
|
|
4940
4945
|
case ViewMode.QuarterYear:
|
|
4941
4946
|
return Math.ceil((currentDate.getMonth() + 1) / 3) !== Math.ceil((previousDate.getMonth() + 1) / 3) || currentDate.getFullYear() !== previousDate.getFullYear();
|
|
4942
4947
|
case ViewMode.Month:
|
|
@@ -5572,10 +5577,35 @@ const RelationLine = ({
|
|
|
5572
5577
|
}
|
|
5573
5578
|
);
|
|
5574
5579
|
};
|
|
5575
|
-
const
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5580
|
+
const truncateText = (text, maxWidth, textElement) => {
|
|
5581
|
+
if (!textElement)
|
|
5582
|
+
return text;
|
|
5583
|
+
textElement.textContent = text;
|
|
5584
|
+
const fullWidth = textElement.getBBox().width;
|
|
5585
|
+
if (fullWidth <= maxWidth) {
|
|
5586
|
+
return text;
|
|
5587
|
+
}
|
|
5588
|
+
let start = 0;
|
|
5589
|
+
let end = text.length;
|
|
5590
|
+
let result = text;
|
|
5591
|
+
while (start <= end) {
|
|
5592
|
+
const mid = Math.floor((start + end) / 2);
|
|
5593
|
+
const truncated = text.substring(0, mid);
|
|
5594
|
+
textElement.textContent = truncated;
|
|
5595
|
+
const truncatedWidth = textElement.getBBox().width;
|
|
5596
|
+
if (truncatedWidth <= maxWidth) {
|
|
5597
|
+
result = truncated;
|
|
5598
|
+
start = mid + 1;
|
|
5599
|
+
} else {
|
|
5600
|
+
end = mid - 1;
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
return result;
|
|
5604
|
+
};
|
|
5605
|
+
const hoverVisibleWrapper = "_hoverVisibleWrapper_8hbnp_1";
|
|
5606
|
+
const wrapper = "_wrapper_8hbnp_1";
|
|
5607
|
+
const mainPath = "_mainPath_8hbnp_17";
|
|
5608
|
+
const clickZone = "_clickZone_8hbnp_35";
|
|
5579
5609
|
const styles$4 = {
|
|
5580
5610
|
hoverVisibleWrapper,
|
|
5581
5611
|
wrapper,
|
|
@@ -6267,8 +6297,8 @@ const Milestone = ({
|
|
|
6267
6297
|
}
|
|
6268
6298
|
);
|
|
6269
6299
|
};
|
|
6270
|
-
const barLabel = "
|
|
6271
|
-
const barLabelOutside = "
|
|
6300
|
+
const barLabel = "_barLabel_7emdt_1";
|
|
6301
|
+
const barLabelOutside = "_barLabelOutside_7emdt_25";
|
|
6272
6302
|
const style = {
|
|
6273
6303
|
barLabel,
|
|
6274
6304
|
barLabelOutside
|
|
@@ -6345,6 +6375,7 @@ const TaskWarningInner = ({
|
|
|
6345
6375
|
};
|
|
6346
6376
|
const TaskWarning = memo(TaskWarningInner);
|
|
6347
6377
|
const TaskItemInner = (props) => {
|
|
6378
|
+
var _a, _b, _c;
|
|
6348
6379
|
const {
|
|
6349
6380
|
childOutOfParentWarnings,
|
|
6350
6381
|
colorStyles: stylesProp,
|
|
@@ -6373,6 +6404,9 @@ const TaskItemInner = (props) => {
|
|
|
6373
6404
|
rtl,
|
|
6374
6405
|
selectTaskOnMouseDown,
|
|
6375
6406
|
setTooltipTask,
|
|
6407
|
+
enableTaskGrouping,
|
|
6408
|
+
taskToRowIndexMap,
|
|
6409
|
+
rowIndexToTasksMap,
|
|
6376
6410
|
task,
|
|
6377
6411
|
task: { styles: taskStyles },
|
|
6378
6412
|
taskHalfHeight,
|
|
@@ -6425,6 +6459,11 @@ const TaskItemInner = (props) => {
|
|
|
6425
6459
|
const globalIndex = getTaskGlobalIndexByRef(task);
|
|
6426
6460
|
fixEndPosition(task, end.date, globalIndex);
|
|
6427
6461
|
}, [task, fixEndPosition, outOfParentWarnings, getTaskGlobalIndexByRef]);
|
|
6462
|
+
const taskRowIndex = (_a = taskToRowIndexMap == null ? void 0 : taskToRowIndexMap.get(task.comparisonLevel ?? 1)) == null ? void 0 : _a.get(task.id);
|
|
6463
|
+
if (taskRowIndex === void 0)
|
|
6464
|
+
return null;
|
|
6465
|
+
const isSharedRow = (((_c = (_b = rowIndexToTasksMap == null ? void 0 : rowIndexToTasksMap.get(task.comparisonLevel ?? 1)) == null ? void 0 : _b.get(taskRowIndex)) == null ? void 0 : _c.length) ?? 0) > 1;
|
|
6466
|
+
const isInCollapsedGroup = !!enableTaskGrouping && isSharedRow;
|
|
6428
6467
|
const handleClick = useCallback(
|
|
6429
6468
|
(event) => {
|
|
6430
6469
|
if (onClick) {
|
|
@@ -6458,6 +6497,8 @@ const TaskItemInner = (props) => {
|
|
|
6458
6497
|
}, [onRelationStart, rtl, task]);
|
|
6459
6498
|
const textRef = useRef(null);
|
|
6460
6499
|
const [isTextInside, setIsTextInside] = useState(true);
|
|
6500
|
+
const [truncatedText, setTruncatedText] = useState(task.name);
|
|
6501
|
+
console.log("truncatedText", truncatedText);
|
|
6461
6502
|
const taskItem = useMemo(() => {
|
|
6462
6503
|
const isFromStartRelationAuthorized = authorizedRelations.includes("startToStart") || authorizedRelations.includes("startToEnd");
|
|
6463
6504
|
const isFromEndRelationAuthorized = authorizedRelations.includes("endToEnd") || authorizedRelations.includes("endToStart");
|
|
@@ -6540,10 +6581,15 @@ const TaskItemInner = (props) => {
|
|
|
6540
6581
|
width
|
|
6541
6582
|
]);
|
|
6542
6583
|
useEffect(() => {
|
|
6543
|
-
if (textRef.current)
|
|
6584
|
+
if (!textRef.current)
|
|
6585
|
+
return;
|
|
6586
|
+
if (isInCollapsedGroup) {
|
|
6587
|
+
const truncated = truncateText(task.name, width - 10, textRef.current);
|
|
6588
|
+
setTruncatedText(truncated);
|
|
6589
|
+
} else {
|
|
6544
6590
|
setIsTextInside(textRef.current.getBBox().width < width);
|
|
6545
6591
|
}
|
|
6546
|
-
}, [
|
|
6592
|
+
}, [isInCollapsedGroup, task.name, width]);
|
|
6547
6593
|
const x3 = useMemo(() => {
|
|
6548
6594
|
if (isTextInside) {
|
|
6549
6595
|
return x1 + width * 0.5;
|
|
@@ -6553,6 +6599,9 @@ const TaskItemInner = (props) => {
|
|
|
6553
6599
|
}
|
|
6554
6600
|
return x1 + width + arrowIndent * 1.2;
|
|
6555
6601
|
}, [x1, width, isTextInside, rtl, arrowIndent]);
|
|
6602
|
+
const textForRender = isInCollapsedGroup ? "" : task.name;
|
|
6603
|
+
console.log("testForRender", textForRender);
|
|
6604
|
+
const xForRender = isInCollapsedGroup ? x1 + width * 0.5 : x3;
|
|
6556
6605
|
const onMouseDown = useCallback(
|
|
6557
6606
|
(event) => {
|
|
6558
6607
|
selectTaskOnMouseDown(task.id, event);
|
|
@@ -6596,11 +6645,11 @@ const TaskItemInner = (props) => {
|
|
|
6596
6645
|
"text",
|
|
6597
6646
|
{
|
|
6598
6647
|
fill: barLabelFill,
|
|
6599
|
-
x:
|
|
6648
|
+
x: xForRender,
|
|
6600
6649
|
y: taskYOffset + taskHeight * 0.5,
|
|
6601
6650
|
className: isTextInside ? style.barLabel : style.barLabel && style.barLabelOutside,
|
|
6602
6651
|
ref: textRef,
|
|
6603
|
-
children:
|
|
6652
|
+
children: textForRender
|
|
6604
6653
|
}
|
|
6605
6654
|
),
|
|
6606
6655
|
(outOfParentWarnings || hasDependencyWarning) && /* @__PURE__ */ jsx(
|
|
@@ -6769,6 +6818,9 @@ const TaskGanttContent = ({
|
|
|
6769
6818
|
children: /* @__PURE__ */ jsx(
|
|
6770
6819
|
TaskItem,
|
|
6771
6820
|
{
|
|
6821
|
+
enableTaskGrouping,
|
|
6822
|
+
taskToRowIndexMap,
|
|
6823
|
+
rowIndexToTasksMap,
|
|
6772
6824
|
getTaskGlobalIndexByRef,
|
|
6773
6825
|
hasChildren: checkHasChildren(task, childTasksMap),
|
|
6774
6826
|
hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
|
|
@@ -6801,12 +6853,7 @@ const TaskGanttContent = ({
|
|
|
6801
6853
|
fixStartPosition,
|
|
6802
6854
|
fixEndPosition,
|
|
6803
6855
|
handleDeleteTasks,
|
|
6804
|
-
colorStyles
|
|
6805
|
-
enableTaskGrouping,
|
|
6806
|
-
getTaskInitials: (task2) => {
|
|
6807
|
-
var _a2;
|
|
6808
|
-
return ((_a2 = task2.name) == null ? void 0 : _a2.split(" ").map((word) => word[0]).join("").toUpperCase()) ?? "";
|
|
6809
|
-
}
|
|
6856
|
+
colorStyles
|
|
6810
6857
|
}
|
|
6811
6858
|
)
|
|
6812
6859
|
},
|
|
@@ -10477,6 +10524,14 @@ const defaultRoundEndDate = (date, viewMode) => {
|
|
|
10477
10524
|
}
|
|
10478
10525
|
return subQuarters(end, 1);
|
|
10479
10526
|
}
|
|
10527
|
+
case ViewMode.HalfYear: {
|
|
10528
|
+
const month = date.getMonth();
|
|
10529
|
+
if (month < 6) {
|
|
10530
|
+
return endOfHour(new Date(date.getFullYear(), 5, 1));
|
|
10531
|
+
} else {
|
|
10532
|
+
return endOfYear(date);
|
|
10533
|
+
}
|
|
10534
|
+
}
|
|
10480
10535
|
case ViewMode.Year: {
|
|
10481
10536
|
const end = endOfYear(date);
|
|
10482
10537
|
const diff = differenceInMonths(end, date);
|
|
@@ -11871,7 +11926,7 @@ const Gantt = ({
|
|
|
11871
11926
|
[sortedTasks]
|
|
11872
11927
|
);
|
|
11873
11928
|
const [visibleTasks, visibleTasksMirror] = useMemo(
|
|
11874
|
-
() => collectVisibleTasks(childTasksMap, rootTasksMap
|
|
11929
|
+
() => collectVisibleTasks(childTasksMap, rootTasksMap),
|
|
11875
11930
|
[childTasksMap, rootTasksMap]
|
|
11876
11931
|
);
|
|
11877
11932
|
const tasksMap = useMemo(() => getTasksMap(tasks), [tasks]);
|
|
@@ -478,14 +478,13 @@
|
|
|
478
478
|
if (comparisonLevel === 1) {
|
|
479
479
|
mirrorRes[task.id] = true;
|
|
480
480
|
}
|
|
481
|
-
|
|
482
|
-
if (task.type === "empty" || isTaskGroupingEnabled) {
|
|
481
|
+
if (task.type === "empty") {
|
|
483
482
|
return;
|
|
484
483
|
}
|
|
485
484
|
const childs = childTasksOnLevel.get(task.id);
|
|
486
485
|
if (childs && childs.length > 0) {
|
|
487
486
|
childs.forEach((childTask) => {
|
|
488
|
-
collectChildren(arrayRes, mirrorRes, childTask, childTasksOnLevel
|
|
487
|
+
collectChildren(arrayRes, mirrorRes, childTask, childTasksOnLevel);
|
|
489
488
|
});
|
|
490
489
|
}
|
|
491
490
|
};
|
|
@@ -495,7 +494,7 @@
|
|
|
495
494
|
for (const [comparisonLevel, rootTasks] of rootTasksMap.entries()) {
|
|
496
495
|
const childTasksOnLevel = childTasksMap.get(comparisonLevel) || /* @__PURE__ */ new Map();
|
|
497
496
|
rootTasks.forEach((task) => {
|
|
498
|
-
collectChildren(arrayRes, mirrorRes, task, childTasksOnLevel
|
|
497
|
+
collectChildren(arrayRes, mirrorRes, task, childTasksOnLevel);
|
|
499
498
|
});
|
|
500
499
|
}
|
|
501
500
|
return [arrayRes, mirrorRes];
|
|
@@ -4242,6 +4241,7 @@
|
|
|
4242
4241
|
if (taskIndex) {
|
|
4243
4242
|
[depth, indexStr] = taskIndex;
|
|
4244
4243
|
}
|
|
4244
|
+
console.log("colors :>> ", colors);
|
|
4245
4245
|
renderList.push(
|
|
4246
4246
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4247
4247
|
TaskListTableRow,
|
|
@@ -4592,21 +4592,24 @@
|
|
|
4592
4592
|
)
|
|
4593
4593
|
);
|
|
4594
4594
|
if (!isUnknownDates && (i === startColumnIndex || date.getFullYear() !== getDate(i - 1).getFullYear())) {
|
|
4595
|
-
const year = date.getFullYear()
|
|
4596
|
-
|
|
4595
|
+
const year = date.getFullYear();
|
|
4596
|
+
console.log("Fulll year :>> ", year);
|
|
4597
|
+
const topValue = year.toString();
|
|
4598
|
+
const startHalfYearIndex = i - date.getMonth();
|
|
4599
|
+
const centerX = additionalLeftSpace + columnWidth * i + columnWidth;
|
|
4597
4600
|
topValues2.push(
|
|
4598
4601
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4599
4602
|
TopPartOfCalendar,
|
|
4600
4603
|
{
|
|
4601
|
-
value:
|
|
4602
|
-
x1Line: additionalLeftSpace + columnWidth *
|
|
4604
|
+
value: topValue,
|
|
4605
|
+
x1Line: additionalLeftSpace + columnWidth * startHalfYearIndex,
|
|
4603
4606
|
y1Line: 0,
|
|
4604
4607
|
y2Line: topDefaultHeight,
|
|
4605
|
-
xText:
|
|
4608
|
+
xText: centerX,
|
|
4606
4609
|
yText: topDefaultHeight * 0.9,
|
|
4607
4610
|
colors
|
|
4608
4611
|
},
|
|
4609
|
-
year
|
|
4612
|
+
`year-${year}`
|
|
4610
4613
|
)
|
|
4611
4614
|
);
|
|
4612
4615
|
}
|
|
@@ -4949,7 +4952,9 @@
|
|
|
4949
4952
|
case ViewMode.Year:
|
|
4950
4953
|
return currentDate.getFullYear() !== previousDate.getFullYear();
|
|
4951
4954
|
case ViewMode.HalfYear:
|
|
4952
|
-
|
|
4955
|
+
const currentHalf = Math.ceil((currentDate.getMonth() + 1) / 6);
|
|
4956
|
+
const previousHalf = Math.ceil((previousDate.getMonth() + 1) / 6);
|
|
4957
|
+
return currentHalf !== previousHalf || currentDate.getFullYear() !== previousDate.getFullYear();
|
|
4953
4958
|
case ViewMode.QuarterYear:
|
|
4954
4959
|
return Math.ceil((currentDate.getMonth() + 1) / 3) !== Math.ceil((previousDate.getMonth() + 1) / 3) || currentDate.getFullYear() !== previousDate.getFullYear();
|
|
4955
4960
|
case ViewMode.Month:
|
|
@@ -5585,10 +5590,35 @@
|
|
|
5585
5590
|
}
|
|
5586
5591
|
);
|
|
5587
5592
|
};
|
|
5588
|
-
const
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5593
|
+
const truncateText = (text, maxWidth, textElement) => {
|
|
5594
|
+
if (!textElement)
|
|
5595
|
+
return text;
|
|
5596
|
+
textElement.textContent = text;
|
|
5597
|
+
const fullWidth = textElement.getBBox().width;
|
|
5598
|
+
if (fullWidth <= maxWidth) {
|
|
5599
|
+
return text;
|
|
5600
|
+
}
|
|
5601
|
+
let start = 0;
|
|
5602
|
+
let end = text.length;
|
|
5603
|
+
let result = text;
|
|
5604
|
+
while (start <= end) {
|
|
5605
|
+
const mid = Math.floor((start + end) / 2);
|
|
5606
|
+
const truncated = text.substring(0, mid);
|
|
5607
|
+
textElement.textContent = truncated;
|
|
5608
|
+
const truncatedWidth = textElement.getBBox().width;
|
|
5609
|
+
if (truncatedWidth <= maxWidth) {
|
|
5610
|
+
result = truncated;
|
|
5611
|
+
start = mid + 1;
|
|
5612
|
+
} else {
|
|
5613
|
+
end = mid - 1;
|
|
5614
|
+
}
|
|
5615
|
+
}
|
|
5616
|
+
return result;
|
|
5617
|
+
};
|
|
5618
|
+
const hoverVisibleWrapper = "_hoverVisibleWrapper_8hbnp_1";
|
|
5619
|
+
const wrapper = "_wrapper_8hbnp_1";
|
|
5620
|
+
const mainPath = "_mainPath_8hbnp_17";
|
|
5621
|
+
const clickZone = "_clickZone_8hbnp_35";
|
|
5592
5622
|
const styles$4 = {
|
|
5593
5623
|
hoverVisibleWrapper,
|
|
5594
5624
|
wrapper,
|
|
@@ -6280,8 +6310,8 @@
|
|
|
6280
6310
|
}
|
|
6281
6311
|
);
|
|
6282
6312
|
};
|
|
6283
|
-
const barLabel = "
|
|
6284
|
-
const barLabelOutside = "
|
|
6313
|
+
const barLabel = "_barLabel_7emdt_1";
|
|
6314
|
+
const barLabelOutside = "_barLabelOutside_7emdt_25";
|
|
6285
6315
|
const style = {
|
|
6286
6316
|
barLabel,
|
|
6287
6317
|
barLabelOutside
|
|
@@ -6358,6 +6388,7 @@
|
|
|
6358
6388
|
};
|
|
6359
6389
|
const TaskWarning = React.memo(TaskWarningInner);
|
|
6360
6390
|
const TaskItemInner = (props) => {
|
|
6391
|
+
var _a, _b, _c;
|
|
6361
6392
|
const {
|
|
6362
6393
|
childOutOfParentWarnings,
|
|
6363
6394
|
colorStyles: stylesProp,
|
|
@@ -6386,6 +6417,9 @@
|
|
|
6386
6417
|
rtl,
|
|
6387
6418
|
selectTaskOnMouseDown,
|
|
6388
6419
|
setTooltipTask,
|
|
6420
|
+
enableTaskGrouping,
|
|
6421
|
+
taskToRowIndexMap,
|
|
6422
|
+
rowIndexToTasksMap,
|
|
6389
6423
|
task,
|
|
6390
6424
|
task: { styles: taskStyles },
|
|
6391
6425
|
taskHalfHeight,
|
|
@@ -6438,6 +6472,11 @@
|
|
|
6438
6472
|
const globalIndex = getTaskGlobalIndexByRef(task);
|
|
6439
6473
|
fixEndPosition(task, end.date, globalIndex);
|
|
6440
6474
|
}, [task, fixEndPosition, outOfParentWarnings, getTaskGlobalIndexByRef]);
|
|
6475
|
+
const taskRowIndex = (_a = taskToRowIndexMap == null ? void 0 : taskToRowIndexMap.get(task.comparisonLevel ?? 1)) == null ? void 0 : _a.get(task.id);
|
|
6476
|
+
if (taskRowIndex === void 0)
|
|
6477
|
+
return null;
|
|
6478
|
+
const isSharedRow = (((_c = (_b = rowIndexToTasksMap == null ? void 0 : rowIndexToTasksMap.get(task.comparisonLevel ?? 1)) == null ? void 0 : _b.get(taskRowIndex)) == null ? void 0 : _c.length) ?? 0) > 1;
|
|
6479
|
+
const isInCollapsedGroup = !!enableTaskGrouping && isSharedRow;
|
|
6441
6480
|
const handleClick = React.useCallback(
|
|
6442
6481
|
(event) => {
|
|
6443
6482
|
if (onClick) {
|
|
@@ -6471,6 +6510,8 @@
|
|
|
6471
6510
|
}, [onRelationStart, rtl, task]);
|
|
6472
6511
|
const textRef = React.useRef(null);
|
|
6473
6512
|
const [isTextInside, setIsTextInside] = React.useState(true);
|
|
6513
|
+
const [truncatedText, setTruncatedText] = React.useState(task.name);
|
|
6514
|
+
console.log("truncatedText", truncatedText);
|
|
6474
6515
|
const taskItem = React.useMemo(() => {
|
|
6475
6516
|
const isFromStartRelationAuthorized = authorizedRelations.includes("startToStart") || authorizedRelations.includes("startToEnd");
|
|
6476
6517
|
const isFromEndRelationAuthorized = authorizedRelations.includes("endToEnd") || authorizedRelations.includes("endToStart");
|
|
@@ -6553,10 +6594,15 @@
|
|
|
6553
6594
|
width
|
|
6554
6595
|
]);
|
|
6555
6596
|
React.useEffect(() => {
|
|
6556
|
-
if (textRef.current)
|
|
6597
|
+
if (!textRef.current)
|
|
6598
|
+
return;
|
|
6599
|
+
if (isInCollapsedGroup) {
|
|
6600
|
+
const truncated = truncateText(task.name, width - 10, textRef.current);
|
|
6601
|
+
setTruncatedText(truncated);
|
|
6602
|
+
} else {
|
|
6557
6603
|
setIsTextInside(textRef.current.getBBox().width < width);
|
|
6558
6604
|
}
|
|
6559
|
-
}, [
|
|
6605
|
+
}, [isInCollapsedGroup, task.name, width]);
|
|
6560
6606
|
const x3 = React.useMemo(() => {
|
|
6561
6607
|
if (isTextInside) {
|
|
6562
6608
|
return x1 + width * 0.5;
|
|
@@ -6566,6 +6612,9 @@
|
|
|
6566
6612
|
}
|
|
6567
6613
|
return x1 + width + arrowIndent * 1.2;
|
|
6568
6614
|
}, [x1, width, isTextInside, rtl, arrowIndent]);
|
|
6615
|
+
const textForRender = isInCollapsedGroup ? "" : task.name;
|
|
6616
|
+
console.log("testForRender", textForRender);
|
|
6617
|
+
const xForRender = isInCollapsedGroup ? x1 + width * 0.5 : x3;
|
|
6569
6618
|
const onMouseDown = React.useCallback(
|
|
6570
6619
|
(event) => {
|
|
6571
6620
|
selectTaskOnMouseDown(task.id, event);
|
|
@@ -6609,11 +6658,11 @@
|
|
|
6609
6658
|
"text",
|
|
6610
6659
|
{
|
|
6611
6660
|
fill: barLabelFill,
|
|
6612
|
-
x:
|
|
6661
|
+
x: xForRender,
|
|
6613
6662
|
y: taskYOffset + taskHeight * 0.5,
|
|
6614
6663
|
className: isTextInside ? style.barLabel : style.barLabel && style.barLabelOutside,
|
|
6615
6664
|
ref: textRef,
|
|
6616
|
-
children:
|
|
6665
|
+
children: textForRender
|
|
6617
6666
|
}
|
|
6618
6667
|
),
|
|
6619
6668
|
(outOfParentWarnings || hasDependencyWarning) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6782,6 +6831,9 @@
|
|
|
6782
6831
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6783
6832
|
TaskItem,
|
|
6784
6833
|
{
|
|
6834
|
+
enableTaskGrouping,
|
|
6835
|
+
taskToRowIndexMap,
|
|
6836
|
+
rowIndexToTasksMap,
|
|
6785
6837
|
getTaskGlobalIndexByRef,
|
|
6786
6838
|
hasChildren: checkHasChildren(task, childTasksMap),
|
|
6787
6839
|
hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
|
|
@@ -6814,12 +6866,7 @@
|
|
|
6814
6866
|
fixStartPosition,
|
|
6815
6867
|
fixEndPosition,
|
|
6816
6868
|
handleDeleteTasks,
|
|
6817
|
-
colorStyles
|
|
6818
|
-
enableTaskGrouping,
|
|
6819
|
-
getTaskInitials: (task2) => {
|
|
6820
|
-
var _a2;
|
|
6821
|
-
return ((_a2 = task2.name) == null ? void 0 : _a2.split(" ").map((word) => word[0]).join("").toUpperCase()) ?? "";
|
|
6822
|
-
}
|
|
6869
|
+
colorStyles
|
|
6823
6870
|
}
|
|
6824
6871
|
)
|
|
6825
6872
|
},
|
|
@@ -10490,6 +10537,14 @@
|
|
|
10490
10537
|
}
|
|
10491
10538
|
return subQuarters(end, 1);
|
|
10492
10539
|
}
|
|
10540
|
+
case ViewMode.HalfYear: {
|
|
10541
|
+
const month = date.getMonth();
|
|
10542
|
+
if (month < 6) {
|
|
10543
|
+
return endOfHour(new Date(date.getFullYear(), 5, 1));
|
|
10544
|
+
} else {
|
|
10545
|
+
return endOfYear(date);
|
|
10546
|
+
}
|
|
10547
|
+
}
|
|
10493
10548
|
case ViewMode.Year: {
|
|
10494
10549
|
const end = endOfYear(date);
|
|
10495
10550
|
const diff = differenceInMonths(end, date);
|
|
@@ -11884,7 +11939,7 @@
|
|
|
11884
11939
|
[sortedTasks]
|
|
11885
11940
|
);
|
|
11886
11941
|
const [visibleTasks, visibleTasksMirror] = React.useMemo(
|
|
11887
|
-
() => collectVisibleTasks(childTasksMap, rootTasksMap
|
|
11942
|
+
() => collectVisibleTasks(childTasksMap, rootTasksMap),
|
|
11888
11943
|
[childTasksMap, rootTasksMap]
|
|
11889
11944
|
);
|
|
11890
11945
|
const tasksMap = React.useMemo(() => getTasksMap(tasks), [tasks]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const truncateText: (text: string, maxWidth: number, textElement: SVGTextElement | null) => string;
|
package/dist/style.css
CHANGED
|
@@ -440,28 +440,27 @@
|
|
|
440
440
|
stroke-width: 2;
|
|
441
441
|
stroke-dasharray: 4;
|
|
442
442
|
}
|
|
443
|
-
.
|
|
443
|
+
._hoverVisibleWrapper_8hbnp_1:hover ._wrapper_8hbnp_1 {
|
|
444
444
|
display: initial;
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
.
|
|
447
|
+
._wrapper_8hbnp_1 {
|
|
448
448
|
cursor: pointer;
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
.
|
|
451
|
+
._wrapper_8hbnp_1:hover ._mainPath_8hbnp_17 {
|
|
452
452
|
filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, .7));
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
-
.
|
|
455
|
+
._mainPath_8hbnp_17 {
|
|
456
456
|
fill: none;
|
|
457
457
|
stroke-width: 1.5px;
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
.
|
|
460
|
+
._clickZone_8hbnp_35 {
|
|
461
461
|
fill: transparent;
|
|
462
462
|
stroke: transparent;
|
|
463
|
-
}
|
|
464
|
-
._barWrapper_1kg71_1 {
|
|
463
|
+
}._barWrapper_1kg71_1 {
|
|
465
464
|
cursor: pointer;
|
|
466
465
|
outline: none;
|
|
467
466
|
}
|
|
@@ -521,7 +520,7 @@
|
|
|
521
520
|
._milestoneBackground_vcirf_11 {
|
|
522
521
|
user-select: none;
|
|
523
522
|
}
|
|
524
|
-
.
|
|
523
|
+
._barLabel_7emdt_1 {
|
|
525
524
|
text-anchor: middle;
|
|
526
525
|
font-weight: lighter;
|
|
527
526
|
dominant-baseline: central;
|
|
@@ -533,7 +532,7 @@
|
|
|
533
532
|
pointer-events: none;
|
|
534
533
|
}
|
|
535
534
|
|
|
536
|
-
.
|
|
535
|
+
._barLabelOutside_7emdt_25 {
|
|
537
536
|
text-anchor: start;
|
|
538
537
|
-webkit-touch-callout: none;
|
|
539
538
|
-webkit-user-select: none;
|
|
@@ -541,8 +540,7 @@
|
|
|
541
540
|
-ms-user-select: none;
|
|
542
541
|
user-select: none;
|
|
543
542
|
pointer-events: none;
|
|
544
|
-
}
|
|
545
|
-
._menuOption_z7pb4_1 {
|
|
543
|
+
}._menuOption_z7pb4_1 {
|
|
546
544
|
display: flex;
|
|
547
545
|
align-items: center;
|
|
548
546
|
gap: 5px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thepocman/gantt-task-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"description": "Fork of gantt-task-react with support for grouped tasks on a single row when collapsed",
|
|
5
5
|
"author": "Adrian Bueno <adrianlbueno@users.noreply.github.com>",
|
|
6
6
|
"homepage": "https://github.com/adrianlbueno/gantt-task-react#readme",
|