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.mjs CHANGED
@@ -6282,6 +6282,7 @@ var DependencyLines = React6.memo(({
6282
6282
  const positionedTaskIds = Array.from(taskPositions.keys());
6283
6283
  const renderedTaskIdSet = new Set(geometryTasks.map((t) => t.id));
6284
6284
  const lines2 = [];
6285
+ const renderedEdgeKeys = /* @__PURE__ */ new Set();
6285
6286
  for (const successorId of positionedTaskIds) {
6286
6287
  const successorTaskForEdges = taskMap.get(successorId);
6287
6288
  if (!successorTaskForEdges?.dependencies?.length) {
@@ -6298,6 +6299,9 @@ var DependencyLines = React6.memo(({
6298
6299
  type: dependency.type,
6299
6300
  lag: dependency.lag ?? 0
6300
6301
  };
6302
+ const renderKey = JSON.stringify([edge.predecessorId, edge.successorId, edge.type, edge.lag]);
6303
+ if (renderedEdgeKeys.has(renderKey)) continue;
6304
+ renderedEdgeKeys.add(renderKey);
6301
6305
  const predecessor = taskPositions.get(edge.predecessorId);
6302
6306
  const successor = taskPositions.get(edge.successorId);
6303
6307
  const predecessorIndex = taskIndices.get(edge.predecessorId);
@@ -6358,6 +6362,7 @@ var DependencyLines = React6.memo(({
6358
6362
  );
6359
6363
  lines2.push({
6360
6364
  id: `${edge.predecessorId}-${edge.successorId}-${edge.type}`,
6365
+ renderKey,
6361
6366
  predecessorId: edge.predecessorId,
6362
6367
  successorId: edge.successorId,
6363
6368
  linkType: edge.type,
@@ -6506,7 +6511,7 @@ var DependencyLines = React6.memo(({
6506
6511
  onLineLeave: handleLineLeave,
6507
6512
  onDependencyClick
6508
6513
  },
6509
- line.id
6514
+ line.renderKey
6510
6515
  );
6511
6516
  })
6512
6517
  ]
@@ -7577,6 +7582,7 @@ var DepChip = ({
7577
7582
  weekendPredicate
7578
7583
  }) => {
7579
7584
  const [popoverOpen, setPopoverOpen] = useState6(false);
7585
+ const [typeMenuOpen, setTypeMenuOpen] = useState6(false);
7580
7586
  const lagAbs = Math.abs(lag ?? 0);
7581
7587
  const [inputAbs, setInputAbs] = useState6(lagAbs === 0 ? "" : String(lagAbs));
7582
7588
  useEffect6(() => {
@@ -7698,6 +7704,69 @@ var DepChip = ({
7698
7704
  const Icon = LINK_TYPE_ICONS[dep.type];
7699
7705
  const depName = predecessorName ?? dep.taskId;
7700
7706
  const effectiveLag = lag ?? 0;
7707
+ const handleTypeChange = useCallback6(
7708
+ (newType) => {
7709
+ if (newType === dep.type) return;
7710
+ if (!onTasksChange || !allTasks) return;
7711
+ if ((task.dependencies ?? []).some((d) => d.taskId === dep.taskId && d.type === newType)) return;
7712
+ const taskById = new Map(allTasks.map((t) => [t.id, t]));
7713
+ const predecessor = taskById.get(dep.taskId);
7714
+ if (!predecessor) return;
7715
+ const predStart = parseUTCDate(predecessor.startDate);
7716
+ const predEnd = predecessor.type === "milestone" ? predStart : parseUTCDate(predecessor.endDate);
7717
+ const origStart = parseUTCDate(task.startDate);
7718
+ const origEnd = parseUTCDate(task.endDate);
7719
+ const durationMs = origEnd.getTime() - origStart.getTime();
7720
+ const normalizedLag = normalizeDependencyLag(
7721
+ newType,
7722
+ effectiveLag,
7723
+ predStart,
7724
+ predEnd,
7725
+ businessDays,
7726
+ weekendPredicate,
7727
+ task.type
7728
+ );
7729
+ const constraintDate = calculateSuccessorDate(
7730
+ predStart,
7731
+ predEnd,
7732
+ newType,
7733
+ normalizedLag,
7734
+ businessDays,
7735
+ weekendPredicate,
7736
+ task.type
7737
+ );
7738
+ let newStart, newEnd;
7739
+ if (newType === "FS" || newType === "SS") {
7740
+ newStart = constraintDate;
7741
+ if (businessDays) {
7742
+ const businessDuration = getBusinessDaysCount(origStart, origEnd, weekendPredicate);
7743
+ newEnd = addBusinessDays(constraintDate, businessDuration, weekendPredicate);
7744
+ } else {
7745
+ newEnd = new Date(constraintDate.getTime() + durationMs);
7746
+ }
7747
+ } else {
7748
+ newEnd = constraintDate;
7749
+ if (businessDays) {
7750
+ const businessDuration = getBusinessDaysCount(origStart, origEnd, weekendPredicate);
7751
+ newStart = subtractBusinessDays(constraintDate, businessDuration, weekendPredicate);
7752
+ } else {
7753
+ newStart = new Date(constraintDate.getTime() - durationMs);
7754
+ }
7755
+ }
7756
+ onTasksChange([
7757
+ {
7758
+ ...task,
7759
+ startDate: newStart.toISOString().split("T")[0],
7760
+ endDate: newEnd.toISOString().split("T")[0],
7761
+ dependencies: (task.dependencies ?? []).map(
7762
+ (existingDep) => existingDep.taskId === dep.taskId && existingDep.type === dep.type ? { ...existingDep, type: newType, lag: normalizedLag } : existingDep
7763
+ )
7764
+ }
7765
+ ]);
7766
+ onChipSelect?.({ successorId: taskId, predecessorId: dep.taskId, linkType: newType });
7767
+ },
7768
+ [dep.type, dep.taskId, task, allTasks, onTasksChange, businessDays, weekendPredicate, effectiveLag, onChipSelect, taskId]
7769
+ );
7701
7770
  const actionVerb = dep.type === "FS" || dep.type === "SS" ? "\u043D\u0430\u0447\u0430\u0442\u044C" : "\u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044C";
7702
7771
  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";
7703
7772
  let afterWhat;
@@ -7829,27 +7898,71 @@ var DepChip = ({
7829
7898
  !disableDependencyEditing && /* @__PURE__ */ jsxs10(Fragment4, { children: [
7830
7899
  /* @__PURE__ */ jsx15("hr", { className: "gantt-tl-dep-edit-divider" }),
7831
7900
  /* @__PURE__ */ jsxs10("div", { className: "gantt-tl-dep-edit-actions", children: [
7832
- /* @__PURE__ */ jsx15(
7833
- "button",
7834
- {
7835
- type: "button",
7836
- className: "gantt-tl-dep-edit-close",
7837
- onClick: () => {
7838
- setPopoverOpen(false);
7839
- onChipSelectClear();
7840
- },
7841
- children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C"
7842
- }
7843
- ),
7844
- /* @__PURE__ */ jsx15(
7845
- "button",
7846
- {
7847
- type: "button",
7848
- className: "gantt-tl-dep-edit-delete",
7849
- onClick: handleTrashClick,
7850
- children: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0432\u044F\u0437\u044C"
7851
- }
7852
- )
7901
+ /* @__PURE__ */ jsxs10(Popover, { open: typeMenuOpen, onOpenChange: setTypeMenuOpen, children: [
7902
+ /* @__PURE__ */ jsx15(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs10(
7903
+ "button",
7904
+ {
7905
+ type: "button",
7906
+ className: "gantt-tl-dep-edit-type-trigger",
7907
+ onClick: (e) => e.stopPropagation(),
7908
+ "aria-label": "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0442\u0438\u043F \u0441\u0432\u044F\u0437\u0438",
7909
+ title: "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0442\u0438\u043F \u0441\u0432\u044F\u0437\u0438",
7910
+ children: [
7911
+ /* @__PURE__ */ jsx15(Icon, {}),
7912
+ /* @__PURE__ */ jsx15("span", { children: LINK_TYPE_LABELS_RU2[dep.type] }),
7913
+ /* @__PURE__ */ jsx15("span", { className: "gantt-tl-dep-edit-type-caret", "aria-hidden": "true", children: "\u25BE" })
7914
+ ]
7915
+ }
7916
+ ) }),
7917
+ /* @__PURE__ */ jsx15(PopoverContent, { portal: true, align: "start", children: /* @__PURE__ */ jsx15("div", { className: "gantt-tl-dep-type-menu", children: LINK_TYPE_ORDER.map((linkType) => {
7918
+ const TypeIcon = LINK_TYPE_ICONS[linkType];
7919
+ const isCurrent = linkType === dep.type;
7920
+ const isDuplicate = !isCurrent && (task.dependencies ?? []).some(
7921
+ (d) => d.taskId === dep.taskId && d.type === linkType
7922
+ );
7923
+ return /* @__PURE__ */ jsxs10(
7924
+ "button",
7925
+ {
7926
+ type: "button",
7927
+ className: `gantt-tl-dep-type-option${isCurrent ? " active" : ""}${isDuplicate ? " gantt-tl-dep-type-option-duplicate" : ""}`,
7928
+ disabled: isDuplicate,
7929
+ onClick: () => {
7930
+ handleTypeChange(linkType);
7931
+ setTypeMenuOpen(false);
7932
+ },
7933
+ 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]}`,
7934
+ children: [
7935
+ /* @__PURE__ */ jsx15(TypeIcon, {}),
7936
+ /* @__PURE__ */ jsx15("span", { children: LINK_TYPE_LABELS_RU2[linkType] })
7937
+ ]
7938
+ },
7939
+ linkType
7940
+ );
7941
+ }) }) })
7942
+ ] }),
7943
+ /* @__PURE__ */ jsxs10("div", { className: "gantt-tl-dep-edit-actions-right", children: [
7944
+ /* @__PURE__ */ jsx15(
7945
+ "button",
7946
+ {
7947
+ type: "button",
7948
+ className: "gantt-tl-dep-edit-close",
7949
+ onClick: () => {
7950
+ setPopoverOpen(false);
7951
+ onChipSelectClear();
7952
+ },
7953
+ children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C"
7954
+ }
7955
+ ),
7956
+ /* @__PURE__ */ jsx15(
7957
+ "button",
7958
+ {
7959
+ type: "button",
7960
+ className: "gantt-tl-dep-edit-delete",
7961
+ onClick: handleTrashClick,
7962
+ children: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0432\u044F\u0437\u044C"
7963
+ }
7964
+ )
7965
+ ] })
7853
7966
  ] })
7854
7967
  ] })
7855
7968
  ] })
@@ -9355,7 +9468,7 @@ var TaskListRow = React11.memo(
9355
9468
  {
9356
9469
  className: "gantt-tl-dep-overflow-list",
9357
9470
  onClick: (e) => e.stopPropagation(),
9358
- children: chips.map(({ dep, lag, predecessorName }) => /* @__PURE__ */ jsx15(
9471
+ children: chips.map(({ dep, lag, predecessorName }, chipIndex) => /* @__PURE__ */ jsx15(
9359
9472
  DepChip,
9360
9473
  {
9361
9474
  lag,
@@ -9377,7 +9490,7 @@ var TaskListRow = React11.memo(
9377
9490
  businessDays,
9378
9491
  weekendPredicate
9379
9492
  },
9380
- `${dep.taskId}-${dep.type}`
9493
+ `${dep.taskId}-${chipIndex}`
9381
9494
  ))
9382
9495
  }
9383
9496
  ) })
@@ -9405,7 +9518,8 @@ var TaskListRow = React11.memo(
9405
9518
  onTasksChange,
9406
9519
  businessDays,
9407
9520
  weekendPredicate
9408
- }
9521
+ },
9522
+ chips[0].dep.taskId
9409
9523
  )
9410
9524
  ) : null,
9411
9525
  !printDependencyLabels && !disableDependencyEditing && !isPicking && /* @__PURE__ */ jsx15(