gantt-lib 0.145.2 → 0.146.1
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/index.css.map +1 -1
- package/dist/index.js +139 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -25
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +32 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6445,6 +6445,7 @@ var DependencyLines = import_react7.default.memo(({
|
|
|
6445
6445
|
const positionedTaskIds = Array.from(taskPositions.keys());
|
|
6446
6446
|
const renderedTaskIdSet = new Set(geometryTasks.map((t) => t.id));
|
|
6447
6447
|
const lines2 = [];
|
|
6448
|
+
const renderedEdgeKeys = /* @__PURE__ */ new Set();
|
|
6448
6449
|
for (const successorId of positionedTaskIds) {
|
|
6449
6450
|
const successorTaskForEdges = taskMap.get(successorId);
|
|
6450
6451
|
if (!successorTaskForEdges?.dependencies?.length) {
|
|
@@ -6461,6 +6462,9 @@ var DependencyLines = import_react7.default.memo(({
|
|
|
6461
6462
|
type: dependency.type,
|
|
6462
6463
|
lag: dependency.lag ?? 0
|
|
6463
6464
|
};
|
|
6465
|
+
const renderKey = JSON.stringify([edge.predecessorId, edge.successorId, edge.type, edge.lag]);
|
|
6466
|
+
if (renderedEdgeKeys.has(renderKey)) continue;
|
|
6467
|
+
renderedEdgeKeys.add(renderKey);
|
|
6464
6468
|
const predecessor = taskPositions.get(edge.predecessorId);
|
|
6465
6469
|
const successor = taskPositions.get(edge.successorId);
|
|
6466
6470
|
const predecessorIndex = taskIndices.get(edge.predecessorId);
|
|
@@ -6521,6 +6525,7 @@ var DependencyLines = import_react7.default.memo(({
|
|
|
6521
6525
|
);
|
|
6522
6526
|
lines2.push({
|
|
6523
6527
|
id: `${edge.predecessorId}-${edge.successorId}-${edge.type}`,
|
|
6528
|
+
renderKey,
|
|
6524
6529
|
predecessorId: edge.predecessorId,
|
|
6525
6530
|
successorId: edge.successorId,
|
|
6526
6531
|
linkType: edge.type,
|
|
@@ -6669,7 +6674,7 @@ var DependencyLines = import_react7.default.memo(({
|
|
|
6669
6674
|
onLineLeave: handleLineLeave,
|
|
6670
6675
|
onDependencyClick
|
|
6671
6676
|
},
|
|
6672
|
-
line.
|
|
6677
|
+
line.renderKey
|
|
6673
6678
|
);
|
|
6674
6679
|
})
|
|
6675
6680
|
]
|
|
@@ -7716,6 +7721,7 @@ var DepChip = ({
|
|
|
7716
7721
|
weekendPredicate
|
|
7717
7722
|
}) => {
|
|
7718
7723
|
const [popoverOpen, setPopoverOpen] = (0, import_react12.useState)(false);
|
|
7724
|
+
const [typeMenuOpen, setTypeMenuOpen] = (0, import_react12.useState)(false);
|
|
7719
7725
|
const lagAbs = Math.abs(lag ?? 0);
|
|
7720
7726
|
const [inputAbs, setInputAbs] = (0, import_react12.useState)(lagAbs === 0 ? "" : String(lagAbs));
|
|
7721
7727
|
(0, import_react12.useEffect)(() => {
|
|
@@ -7837,6 +7843,69 @@ var DepChip = ({
|
|
|
7837
7843
|
const Icon = LINK_TYPE_ICONS[dep.type];
|
|
7838
7844
|
const depName = predecessorName ?? dep.taskId;
|
|
7839
7845
|
const effectiveLag = lag ?? 0;
|
|
7846
|
+
const handleTypeChange = (0, import_react12.useCallback)(
|
|
7847
|
+
(newType) => {
|
|
7848
|
+
if (newType === dep.type) return;
|
|
7849
|
+
if (!onTasksChange || !allTasks) return;
|
|
7850
|
+
if ((task.dependencies ?? []).some((d) => d.taskId === dep.taskId && d.type === newType)) return;
|
|
7851
|
+
const taskById = new Map(allTasks.map((t) => [t.id, t]));
|
|
7852
|
+
const predecessor = taskById.get(dep.taskId);
|
|
7853
|
+
if (!predecessor) return;
|
|
7854
|
+
const predStart = parseUTCDate(predecessor.startDate);
|
|
7855
|
+
const predEnd = predecessor.type === "milestone" ? predStart : parseUTCDate(predecessor.endDate);
|
|
7856
|
+
const origStart = parseUTCDate(task.startDate);
|
|
7857
|
+
const origEnd = parseUTCDate(task.endDate);
|
|
7858
|
+
const durationMs = origEnd.getTime() - origStart.getTime();
|
|
7859
|
+
const normalizedLag = normalizeDependencyLag(
|
|
7860
|
+
newType,
|
|
7861
|
+
effectiveLag,
|
|
7862
|
+
predStart,
|
|
7863
|
+
predEnd,
|
|
7864
|
+
businessDays,
|
|
7865
|
+
weekendPredicate,
|
|
7866
|
+
task.type
|
|
7867
|
+
);
|
|
7868
|
+
const constraintDate = calculateSuccessorDate(
|
|
7869
|
+
predStart,
|
|
7870
|
+
predEnd,
|
|
7871
|
+
newType,
|
|
7872
|
+
normalizedLag,
|
|
7873
|
+
businessDays,
|
|
7874
|
+
weekendPredicate,
|
|
7875
|
+
task.type
|
|
7876
|
+
);
|
|
7877
|
+
let newStart, newEnd;
|
|
7878
|
+
if (newType === "FS" || newType === "SS") {
|
|
7879
|
+
newStart = constraintDate;
|
|
7880
|
+
if (businessDays) {
|
|
7881
|
+
const businessDuration = getBusinessDaysCount(origStart, origEnd, weekendPredicate);
|
|
7882
|
+
newEnd = addBusinessDays(constraintDate, businessDuration, weekendPredicate);
|
|
7883
|
+
} else {
|
|
7884
|
+
newEnd = new Date(constraintDate.getTime() + durationMs);
|
|
7885
|
+
}
|
|
7886
|
+
} else {
|
|
7887
|
+
newEnd = constraintDate;
|
|
7888
|
+
if (businessDays) {
|
|
7889
|
+
const businessDuration = getBusinessDaysCount(origStart, origEnd, weekendPredicate);
|
|
7890
|
+
newStart = subtractBusinessDays(constraintDate, businessDuration, weekendPredicate);
|
|
7891
|
+
} else {
|
|
7892
|
+
newStart = new Date(constraintDate.getTime() - durationMs);
|
|
7893
|
+
}
|
|
7894
|
+
}
|
|
7895
|
+
onTasksChange([
|
|
7896
|
+
{
|
|
7897
|
+
...task,
|
|
7898
|
+
startDate: newStart.toISOString().split("T")[0],
|
|
7899
|
+
endDate: newEnd.toISOString().split("T")[0],
|
|
7900
|
+
dependencies: (task.dependencies ?? []).map(
|
|
7901
|
+
(existingDep) => existingDep.taskId === dep.taskId && existingDep.type === dep.type ? { ...existingDep, type: newType, lag: normalizedLag } : existingDep
|
|
7902
|
+
)
|
|
7903
|
+
}
|
|
7904
|
+
]);
|
|
7905
|
+
onChipSelect?.({ successorId: taskId, predecessorId: dep.taskId, linkType: newType });
|
|
7906
|
+
},
|
|
7907
|
+
[dep.type, dep.taskId, task, allTasks, onTasksChange, businessDays, weekendPredicate, effectiveLag, onChipSelect, taskId]
|
|
7908
|
+
);
|
|
7840
7909
|
const actionVerb = dep.type === "FS" || dep.type === "SS" ? "\u043D\u0430\u0447\u0430\u0442\u044C" : "\u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044C";
|
|
7841
7910
|
const zeroPlaceholder = dep.type === "SF" ? "\u0447\u0451\u0442\u043A\u043E" : dep.type === "FF" ? "\u0432\u043C\u0435\u0441\u0442\u0435" : dep.type === "SS" ? "\u0432\u043C\u0435\u0441\u0442\u0435" : "\u0441\u0440\u0430\u0437\u0443";
|
|
7842
7911
|
let afterWhat;
|
|
@@ -7968,27 +8037,71 @@ var DepChip = ({
|
|
|
7968
8037
|
!disableDependencyEditing && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
7969
8038
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("hr", { className: "gantt-tl-dep-edit-divider" }),
|
|
7970
8039
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "gantt-tl-dep-edit-actions", children: [
|
|
7971
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
8040
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Popover, { open: typeMenuOpen, onOpenChange: setTypeMenuOpen, children: [
|
|
8041
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
8042
|
+
"button",
|
|
8043
|
+
{
|
|
8044
|
+
type: "button",
|
|
8045
|
+
className: "gantt-tl-dep-edit-type-trigger",
|
|
8046
|
+
onClick: (e) => e.stopPropagation(),
|
|
8047
|
+
"aria-label": "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0442\u0438\u043F \u0441\u0432\u044F\u0437\u0438",
|
|
8048
|
+
title: "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0442\u0438\u043F \u0441\u0432\u044F\u0437\u0438",
|
|
8049
|
+
children: [
|
|
8050
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon, {}),
|
|
8051
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: LINK_TYPE_LABELS_RU2[dep.type] }),
|
|
8052
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "gantt-tl-dep-edit-type-caret", "aria-hidden": "true", children: "\u25BE" })
|
|
8053
|
+
]
|
|
8054
|
+
}
|
|
8055
|
+
) }),
|
|
8056
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PopoverContent, { portal: true, align: "start", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "gantt-tl-dep-type-menu", children: LINK_TYPE_ORDER.map((linkType) => {
|
|
8057
|
+
const TypeIcon = LINK_TYPE_ICONS[linkType];
|
|
8058
|
+
const isCurrent = linkType === dep.type;
|
|
8059
|
+
const isDuplicate = !isCurrent && (task.dependencies ?? []).some(
|
|
8060
|
+
(d) => d.taskId === dep.taskId && d.type === linkType
|
|
8061
|
+
);
|
|
8062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
8063
|
+
"button",
|
|
8064
|
+
{
|
|
8065
|
+
type: "button",
|
|
8066
|
+
className: `gantt-tl-dep-type-option${isCurrent ? " active" : ""}${isDuplicate ? " gantt-tl-dep-type-option-duplicate" : ""}`,
|
|
8067
|
+
disabled: isDuplicate,
|
|
8068
|
+
onClick: () => {
|
|
8069
|
+
handleTypeChange(linkType);
|
|
8070
|
+
setTypeMenuOpen(false);
|
|
8071
|
+
},
|
|
8072
|
+
title: isDuplicate ? "\u0421\u0432\u044F\u0437\u044C \u0442\u0430\u043A\u043E\u0433\u043E \u0442\u0438\u043F\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044C" : `\u0422\u0438\u043F \u0441\u0432\u044F\u0437\u0438 ${LINK_TYPE_LABELS_RU2[linkType]}`,
|
|
8073
|
+
children: [
|
|
8074
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TypeIcon, {}),
|
|
8075
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: LINK_TYPE_LABELS_RU2[linkType] })
|
|
8076
|
+
]
|
|
8077
|
+
},
|
|
8078
|
+
linkType
|
|
8079
|
+
);
|
|
8080
|
+
}) }) })
|
|
8081
|
+
] }),
|
|
8082
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "gantt-tl-dep-edit-actions-right", children: [
|
|
8083
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
8084
|
+
"button",
|
|
8085
|
+
{
|
|
8086
|
+
type: "button",
|
|
8087
|
+
className: "gantt-tl-dep-edit-close",
|
|
8088
|
+
onClick: () => {
|
|
8089
|
+
setPopoverOpen(false);
|
|
8090
|
+
onChipSelectClear();
|
|
8091
|
+
},
|
|
8092
|
+
children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C"
|
|
8093
|
+
}
|
|
8094
|
+
),
|
|
8095
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
8096
|
+
"button",
|
|
8097
|
+
{
|
|
8098
|
+
type: "button",
|
|
8099
|
+
className: "gantt-tl-dep-edit-delete",
|
|
8100
|
+
onClick: handleTrashClick,
|
|
8101
|
+
children: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0432\u044F\u0437\u044C"
|
|
8102
|
+
}
|
|
8103
|
+
)
|
|
8104
|
+
] })
|
|
7992
8105
|
] })
|
|
7993
8106
|
] })
|
|
7994
8107
|
] })
|
|
@@ -9494,7 +9607,7 @@ var TaskListRow = import_react12.default.memo(
|
|
|
9494
9607
|
{
|
|
9495
9608
|
className: "gantt-tl-dep-overflow-list",
|
|
9496
9609
|
onClick: (e) => e.stopPropagation(),
|
|
9497
|
-
children: chips.map(({ dep, lag, predecessorName }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
9610
|
+
children: chips.map(({ dep, lag, predecessorName }, chipIndex) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
9498
9611
|
DepChip,
|
|
9499
9612
|
{
|
|
9500
9613
|
lag,
|
|
@@ -9516,7 +9629,7 @@ var TaskListRow = import_react12.default.memo(
|
|
|
9516
9629
|
businessDays,
|
|
9517
9630
|
weekendPredicate
|
|
9518
9631
|
},
|
|
9519
|
-
`${dep.taskId}-${
|
|
9632
|
+
`${dep.taskId}-${chipIndex}`
|
|
9520
9633
|
))
|
|
9521
9634
|
}
|
|
9522
9635
|
) })
|
|
@@ -9544,7 +9657,8 @@ var TaskListRow = import_react12.default.memo(
|
|
|
9544
9657
|
onTasksChange,
|
|
9545
9658
|
businessDays,
|
|
9546
9659
|
weekendPredicate
|
|
9547
|
-
}
|
|
9660
|
+
},
|
|
9661
|
+
chips[0].dep.taskId
|
|
9548
9662
|
)
|
|
9549
9663
|
) : null,
|
|
9550
9664
|
!printDependencyLabels && !disableDependencyEditing && !isPicking && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|