@thepocman/gantt-task-react 1.0.20 → 1.0.22

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.
@@ -49,5 +49,4 @@ export type TaskGanttContentProps = {
49
49
  ContextualPalette?: React.FC<TaskContextualPaletteProps>;
50
50
  TaskDependencyContextualPalette?: React.FC<TaskDependencyContextualPaletteProps>;
51
51
  };
52
- export declare const generateRenderId: (task: TaskOrEmpty, index: number) => string;
53
52
  export declare const TaskGanttContent: React.FC<TaskGanttContentProps>;
@@ -676,6 +676,7 @@ var ViewMode = /* @__PURE__ */ ((ViewMode2) => {
676
676
  ViewMode2["Week"] = "Week";
677
677
  ViewMode2["Month"] = "Month";
678
678
  ViewMode2["QuarterYear"] = "QuarterYear";
679
+ ViewMode2["HalfYear"] = "HalfYear";
679
680
  ViewMode2["Year"] = "Year";
680
681
  return ViewMode2;
681
682
  })(ViewMode || {});
@@ -858,6 +859,11 @@ const getDatesDiff = (dateFrom, dateTo, viewMode) => {
858
859
  throw new Error("Unknown view mode");
859
860
  }
860
861
  };
862
+ const startOfHalfYear = (date) => {
863
+ const d4 = new Date(date);
864
+ const startMonth = d4.getMonth() < 6 ? 0 : 6;
865
+ return new Date(d4.getFullYear(), startMonth, 1);
866
+ };
861
867
  const ganttDateRange = (tasks, viewMode, preStepsCount) => {
862
868
  let minTaskDate = null;
863
869
  let maxTaskDate = null;
@@ -883,6 +889,12 @@ const ganttDateRange = (tasks, viewMode, preStepsCount) => {
883
889
  newEndDate = addYears(maxTaskDate, 1);
884
890
  newEndDate = startOfYear(newEndDate);
885
891
  break;
892
+ case ViewMode.HalfYear:
893
+ newStartDate = subMonths(minTaskDate, preStepsCount * 6);
894
+ newStartDate = startOfHalfYear(newStartDate);
895
+ newEndDate = addMonths(maxTaskDate, 6);
896
+ newEndDate = startOfHalfYear(addMonths(newEndDate, 6));
897
+ break;
886
898
  case ViewMode.QuarterYear:
887
899
  newStartDate = subMonths(minTaskDate, preStepsCount * 3);
888
900
  newStartDate = startOfQuarter(newStartDate);
@@ -1945,20 +1957,14 @@ const useOptimizedList = (containerRef, property, cellSize) => {
1945
1957
  return indexes;
1946
1958
  };
1947
1959
  const TASK_SPACING = 2;
1948
- const useGroupedVirtualization = (_containerRef, rowIndexToTasksMap, taskHeight, taskToRowIndexMap) => {
1960
+ const useGroupedVirtualization = (_containerRef, rowIndexToTasksMap, taskHeight) => {
1949
1961
  const rowEntries = useMemo(() => {
1950
1962
  if (!rowIndexToTasksMap || rowIndexToTasksMap.size === 0)
1951
1963
  return [];
1952
- if (!taskToRowIndexMap || taskToRowIndexMap.size === 0)
1953
- return [];
1954
1964
  const rowToHeight = /* @__PURE__ */ new Map();
1955
1965
  for (const levelMap of rowIndexToTasksMap.values()) {
1956
1966
  for (const [rowIndex, tasks] of levelMap.entries()) {
1957
- const visibleGroupedTasks = tasks.filter((task) => {
1958
- var _a;
1959
- return !((_a = taskToRowIndexMap.get(task.comparisonLevel ?? 1)) == null ? void 0 : _a.has(task.id));
1960
- });
1961
- const height = visibleGroupedTasks.length * (taskHeight + TASK_SPACING);
1967
+ const height = tasks.length * (taskHeight + TASK_SPACING);
1962
1968
  rowToHeight.set(rowIndex, (rowToHeight.get(rowIndex) ?? 0) + height);
1963
1969
  }
1964
1970
  }
@@ -3415,7 +3421,6 @@ const TaskListInner = ({
3415
3421
  dependencyMap,
3416
3422
  distances,
3417
3423
  rowIndexToTasksMap,
3418
- taskToRowIndexMap,
3419
3424
  fontFamily,
3420
3425
  fontSize,
3421
3426
  fullRowHeight,
@@ -3457,8 +3462,7 @@ const TaskListInner = ({
3457
3462
  const groupedIndexes = useGroupedVirtualization(
3458
3463
  taskListContentRef,
3459
3464
  rowIndexToTasksMap,
3460
- distances.taskHeight,
3461
- taskToRowIndexMap
3465
+ distances.taskHeight
3462
3466
  );
3463
3467
  const optimizedIndexes = useOptimizedList(
3464
3468
  taskListContentRef,
@@ -4309,6 +4313,9 @@ const defaultRenderBottomHeader = (date, viewMode, dateSetup, index2, isUnknownD
4309
4313
  case ViewMode.Year:
4310
4314
  value = formatDistance3("xYears", offsetFromStart);
4311
4315
  break;
4316
+ case ViewMode.HalfYear:
4317
+ value = formatDistance3("xMonths", offsetFromStart * 6);
4318
+ break;
4312
4319
  case ViewMode.Month:
4313
4320
  value = formatDistance3("xMonths", offsetFromStart);
4314
4321
  break;
@@ -4342,6 +4349,10 @@ const defaultRenderBottomHeader = (date, viewMode, dateSetup, index2, isUnknownD
4342
4349
  switch (viewMode) {
4343
4350
  case ViewMode.Year:
4344
4351
  return date.getFullYear();
4352
+ case ViewMode.HalfYear: {
4353
+ const half = Math.ceil((date.getMonth() + 1) / 6);
4354
+ return `H${half}`;
4355
+ }
4345
4356
  case ViewMode.Month:
4346
4357
  try {
4347
4358
  return format(date, dateSetup.dateFormats.monthBottomHeaderFormat, {
@@ -4397,10 +4408,16 @@ const getQuarterText = (date) => {
4397
4408
  const quarter = Math.ceil((date.getMonth() + 1) / 3);
4398
4409
  return `Q${quarter}`;
4399
4410
  };
4411
+ const getHalfYearText = (date) => {
4412
+ const halfYear = Math.ceil((date.getMonth() + 1) / 6);
4413
+ return `H${halfYear}`;
4414
+ };
4400
4415
  const defaultRenderTopHeader = (date, viewMode, dateSetup) => {
4401
4416
  switch (viewMode) {
4402
4417
  case ViewMode.Year:
4403
4418
  return date.getFullYear().toString();
4419
+ case ViewMode.HalfYear:
4420
+ return `${getHalfYearText(date)} ${date.getFullYear()}`;
4404
4421
  case ViewMode.QuarterYear:
4405
4422
  return `${getQuarterText(date)} ${date.getFullYear()}`;
4406
4423
  case ViewMode.Month:
@@ -4534,6 +4551,48 @@ const Calendar = ({
4534
4551
  }
4535
4552
  return [topValues2, bottomValues2];
4536
4553
  };
4554
+ const getCalenderValuesForHalfYear = () => {
4555
+ const topValues2 = [];
4556
+ const bottomValues2 = [];
4557
+ const topDefaultHeight = headerHeight * 0.5;
4558
+ for (let i2 = startColumnIndex; i2 <= endColumnIndex; i2++) {
4559
+ const date = getDate(i2);
4560
+ const halfYear = "H" + Math.ceil((date.getMonth() + 1) / 6);
4561
+ bottomValues2.push(
4562
+ /* @__PURE__ */ jsx(
4563
+ "text",
4564
+ {
4565
+ y: headerHeight * 0.8,
4566
+ x: additionalLeftSpace + columnWidth * i2 + columnWidth * 0.5,
4567
+ className: styles$a.calendarBottomText,
4568
+ style: { fill: colors.barLabelColor },
4569
+ children: halfYear
4570
+ },
4571
+ `${halfYear}-${date.getFullYear()}-${i2}`
4572
+ )
4573
+ );
4574
+ if (!isUnknownDates && (i2 === startColumnIndex || date.getFullYear() !== getDate(i2 - 1).getFullYear())) {
4575
+ const year = date.getFullYear().toString();
4576
+ const startHalf = Math.floor(i2 / 6) * 6;
4577
+ topValues2.push(
4578
+ /* @__PURE__ */ jsx(
4579
+ TopPartOfCalendar,
4580
+ {
4581
+ value: year,
4582
+ x1Line: additionalLeftSpace + columnWidth * startHalf,
4583
+ y1Line: 0,
4584
+ y2Line: topDefaultHeight,
4585
+ xText: additionalLeftSpace + columnWidth * (startHalf + 3),
4586
+ yText: topDefaultHeight * 0.9,
4587
+ colors
4588
+ },
4589
+ year
4590
+ )
4591
+ );
4592
+ }
4593
+ }
4594
+ return [topValues2, bottomValues2];
4595
+ };
4537
4596
  const getCalendarValuesForQuarterYear = () => {
4538
4597
  const topValues2 = [];
4539
4598
  const bottomValues2 = [];
@@ -4541,6 +4600,7 @@ const Calendar = ({
4541
4600
  for (let i2 = startColumnIndex; i2 <= endColumnIndex; i2++) {
4542
4601
  const date = getDate(i2);
4543
4602
  const quarter = "Q" + Math.ceil((date.getMonth() + 1) / 3);
4603
+ console.log("quarter :>> ", quarter);
4544
4604
  bottomValues2.push(
4545
4605
  /* @__PURE__ */ jsx(
4546
4606
  "text",
@@ -4820,6 +4880,9 @@ const Calendar = ({
4820
4880
  case ViewMode.Year:
4821
4881
  [topValues, bottomValues] = getCalendarValuesForYear();
4822
4882
  break;
4883
+ case ViewMode.HalfYear:
4884
+ [topValues, bottomValues] = getCalenderValuesForHalfYear();
4885
+ break;
4823
4886
  case ViewMode.QuarterYear:
4824
4887
  [topValues, bottomValues] = getCalendarValuesForQuarterYear();
4825
4888
  break;
@@ -5094,9 +5157,9 @@ const Grid = (props) => {
5094
5157
  /* @__PURE__ */ jsx(GridBody, { ...props })
5095
5158
  ] });
5096
5159
  };
5097
- const ganttTaskRoot = "_ganttTaskRoot_1lwsd_1";
5098
- const ganttTaskContent = "_ganttTaskContent_1lwsd_83";
5099
- const wrapper$2 = "_wrapper_1lwsd_111";
5160
+ const ganttTaskRoot = "_ganttTaskRoot_1mu5y_1";
5161
+ const ganttTaskContent = "_ganttTaskContent_1mu5y_83";
5162
+ const wrapper$2 = "_wrapper_1mu5y_111";
5100
5163
  const styles$9 = {
5101
5164
  ganttTaskRoot,
5102
5165
  ganttTaskContent,
@@ -6500,13 +6563,6 @@ const TaskItemInner = (props) => {
6500
6563
  );
6501
6564
  };
6502
6565
  const TaskItem = memo(TaskItemInner);
6503
- const generateRenderId = (task, index2) => {
6504
- if ("renderId" in task && typeof task.renderId === "string")
6505
- return task.renderId;
6506
- if ("type" in task && task.type === "user")
6507
- return `${task.id}-user`;
6508
- return `${task.id}-row-${index2}`;
6509
- };
6510
6566
  const TaskGanttContent = ({
6511
6567
  authorizedRelations,
6512
6568
  additionalLeftSpace,
@@ -6552,7 +6608,7 @@ const TaskGanttContent = ({
6552
6608
  taskToRowIndexMap
6553
6609
  }) => {
6554
6610
  const [renderedTasks, renderedArrows, renderedSelectedTasks] = useMemo(() => {
6555
- var _a, _b;
6611
+ var _a;
6556
6612
  if (!renderedRowIndexes)
6557
6613
  return [null, null, null];
6558
6614
  const [start, end] = renderedRowIndexes;
@@ -6567,7 +6623,7 @@ const TaskGanttContent = ({
6567
6623
  for (let level = 1; level <= comparisonLevels; level++) {
6568
6624
  const levelMap = rowIndexToTasksMap.get(level);
6569
6625
  const rowTasks = levelMap == null ? void 0 : levelMap.get(index2);
6570
- if (rowTasks) {
6626
+ if (Array.isArray(rowTasks)) {
6571
6627
  tasksAtRow.push(...rowTasks);
6572
6628
  }
6573
6629
  }
@@ -6578,32 +6634,31 @@ const TaskGanttContent = ({
6578
6634
  }
6579
6635
  for (const task of tasksAtRow) {
6580
6636
  const comparisonLevel = task.comparisonLevel ?? 1;
6581
- const renderId = generateRenderId(task, index2);
6582
- const taskId = task.id;
6583
- const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6584
- if (typeof rowIndex !== "number")
6585
- continue;
6586
- const key = `${taskId}-${rowIndex}`;
6587
- if (selectedIdsMirror[taskId] && !addedSelectedTasks[`${taskId}-${rowIndex}`]) {
6588
- addedSelectedTasks[key] = true;
6589
- selectedTasksRes.push(
6590
- /* @__PURE__ */ jsx(
6591
- "rect",
6592
- {
6593
- x: 0,
6594
- y: rowIndex * fullRowHeight,
6595
- width: "100%",
6596
- height: fullRowHeight,
6597
- fill: colorStyles.selectedTaskBackgroundColor
6598
- },
6599
- `selected-${key}`
6600
- )
6601
- );
6637
+ const { id: taskId } = task;
6638
+ if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6639
+ addedSelectedTasks[taskId] = true;
6640
+ const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6641
+ if (typeof rowIndex === "number") {
6642
+ selectedTasksRes.push(
6643
+ /* @__PURE__ */ jsx(
6644
+ "rect",
6645
+ {
6646
+ x: 0,
6647
+ y: rowIndex * fullRowHeight,
6648
+ width: "100%",
6649
+ height: fullRowHeight,
6650
+ fill: colorStyles.selectedTaskBackgroundColor
6651
+ },
6652
+ `selected-${taskId}`
6653
+ )
6654
+ );
6655
+ }
6602
6656
  }
6603
6657
  if (comparisonLevel > comparisonLevels)
6604
6658
  continue;
6605
6659
  if (task.type === "empty" || task.type === "user")
6606
6660
  continue;
6661
+ const key = `${comparisonLevel}_${task.id}`;
6607
6662
  const criticalPathOnLevel = criticalPaths == null ? void 0 : criticalPaths.get(comparisonLevel);
6608
6663
  const isCritical = !!(criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.tasks.has(task.id));
6609
6664
  const {
@@ -6617,78 +6672,64 @@ const TaskGanttContent = ({
6617
6672
  x1: taskX1,
6618
6673
  x2: taskX2
6619
6674
  } = getTaskCoordinates2(task);
6620
- const renderContexts = [];
6621
- const oneRowDefaultRender = { y: levelY, keySuffix: "default" };
6622
- renderContexts.push(oneRowDefaultRender);
6623
- if (enableTaskGrouping && task.parent) {
6624
- const parentRowIndex = (_b = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _b.get(task.parent);
6625
- if (typeof parentRowIndex === "number") {
6626
- const yInUserRow = parentRowIndex * fullRowHeight;
6627
- renderContexts.push({ y: yInUserRow, keySuffix: "grouped" });
6628
- }
6629
- }
6630
- for (const context of renderContexts) {
6631
- tasksRes.push(
6632
- /* @__PURE__ */ jsx(
6633
- "svg",
6634
- {
6635
- id: `${renderId}-${context.keySuffix}`,
6636
- className: "TaskItemClassName",
6637
- x: containerX + additionalLeftSpace,
6638
- y: context.y,
6639
- width: containerWidth,
6640
- height: fullRowHeight,
6641
- children: /* @__PURE__ */ jsx(
6642
- TaskItem,
6643
- {
6644
- getTaskGlobalIndexByRef,
6645
- hasChildren: checkHasChildren(task, childTasksMap),
6646
- hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
6647
- progressWidth,
6648
- progressX: rtl ? innerX2 : innerX1,
6649
- selectTaskOnMouseDown,
6650
- task,
6651
- taskYOffset,
6652
- width,
6653
- x1: innerX1,
6654
- x2: innerX2,
6655
- childOutOfParentWarnings,
6656
- distances,
6657
- taskHeight,
6658
- taskHalfHeight,
6659
- isProgressChangeable: !task.isDisabled,
6660
- isDateChangeable: !task.isDisabled,
6661
- isRelationChangeable: !task.isRelationDisabled,
6662
- authorizedRelations,
6663
- ganttRelationEvent,
6664
- isDelete: !task.isDisabled,
6665
- onDoubleClick,
6666
- onClick,
6667
- onEventStart: handleTaskDragStart,
6668
- setTooltipTask,
6669
- onRelationStart: handleBarRelationStart,
6670
- isSelected: Boolean(selectedIdsMirror[taskId]),
6671
- isCritical,
6672
- rtl,
6673
- fixStartPosition,
6674
- fixEndPosition,
6675
- handleDeleteTasks,
6676
- colorStyles
6677
- }
6678
- )
6679
- },
6680
- `${comparisonLevel}_${task.id}_${index2}_${context.keySuffix}`
6681
- )
6682
- );
6683
- }
6675
+ tasksRes.push(
6676
+ /* @__PURE__ */ jsx(
6677
+ "svg",
6678
+ {
6679
+ id: task.id,
6680
+ className: "TaskItemClassName",
6681
+ x: containerX + additionalLeftSpace,
6682
+ y: levelY,
6683
+ width: containerWidth,
6684
+ height: fullRowHeight,
6685
+ children: /* @__PURE__ */ jsx(
6686
+ TaskItem,
6687
+ {
6688
+ getTaskGlobalIndexByRef,
6689
+ hasChildren: checkHasChildren(task, childTasksMap),
6690
+ hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
6691
+ progressWidth,
6692
+ progressX: rtl ? innerX2 : innerX1,
6693
+ selectTaskOnMouseDown,
6694
+ task,
6695
+ taskYOffset,
6696
+ width,
6697
+ x1: innerX1,
6698
+ x2: innerX2,
6699
+ childOutOfParentWarnings,
6700
+ distances,
6701
+ taskHeight,
6702
+ taskHalfHeight,
6703
+ isProgressChangeable: !task.isDisabled,
6704
+ isDateChangeable: !task.isDisabled,
6705
+ isRelationChangeable: !task.isRelationDisabled,
6706
+ authorizedRelations,
6707
+ ganttRelationEvent,
6708
+ isDelete: !task.isDisabled,
6709
+ onDoubleClick,
6710
+ onClick,
6711
+ onEventStart: handleTaskDragStart,
6712
+ setTooltipTask,
6713
+ onRelationStart: handleBarRelationStart,
6714
+ isSelected: Boolean(selectedIdsMirror[taskId]),
6715
+ isCritical,
6716
+ rtl,
6717
+ fixStartPosition,
6718
+ fixEndPosition,
6719
+ handleDeleteTasks,
6720
+ colorStyles
6721
+ }
6722
+ )
6723
+ },
6724
+ key
6725
+ )
6726
+ );
6684
6727
  const addedDependenciesAtLevel = addedDependencies[comparisonLevel] ?? (addedDependencies[comparisonLevel] = {});
6685
6728
  const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] ?? (addedDependenciesAtLevel[taskId] = {});
6686
6729
  const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6687
6730
  const dependenciesByTask = dependenciesAtLevel == null ? void 0 : dependenciesAtLevel.get(taskId);
6688
- dependenciesByTask == null ? void 0 : dependenciesByTask.forEach((dep) => {
6731
+ dependenciesByTask == null ? void 0 : dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach((dep) => {
6689
6732
  var _a2;
6690
- if (!visibleTasksMirror[dep.source.id])
6691
- return;
6692
6733
  if (addedDependenciesAtTask[dep.source.id])
6693
6734
  return;
6694
6735
  addedDependenciesAtTask[dep.source.id] = true;
@@ -6732,21 +6773,20 @@ const TaskGanttContent = ({
6732
6773
  }
6733
6774
  )
6734
6775
  },
6735
- `Arrow from ${dep.source.id} to ${taskId} on ${comparisonLevel} at ${index2}`
6776
+ `Arrow from ${dep.source.id} to ${taskId} on ${comparisonLevel}`
6736
6777
  )
6737
6778
  );
6738
6779
  });
6739
6780
  const dependentsAtLevel = dependentMap.get(comparisonLevel);
6740
6781
  const dependentsByTask = dependentsAtLevel == null ? void 0 : dependentsAtLevel.get(taskId);
6741
- dependentsByTask == null ? void 0 : dependentsByTask.forEach((dep) => {
6742
- var _a2, _b2;
6743
- if (!visibleTasksMirror[dep.dependent.id])
6744
- return;
6782
+ dependentsByTask == null ? void 0 : dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach((dep) => {
6783
+ var _a2, _b;
6784
+ console.log("dependent", dep);
6745
6785
  const addedDepsForDep = addedDependenciesAtLevel[_a2 = dep.dependent.id] ?? (addedDependenciesAtLevel[_a2] = {});
6746
6786
  if (addedDepsForDep[taskId])
6747
6787
  return;
6748
6788
  addedDepsForDep[taskId] = true;
6749
- const isDepCritical = !!((_b2 = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(dep.dependent.id)) == null ? void 0 : _b2.has(task.id));
6789
+ const isDepCritical = !!((_b = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(dep.dependent.id)) == null ? void 0 : _b.has(task.id));
6750
6790
  const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dep.dependent);
6751
6791
  const containerX2 = Math.min(toX1, taskX1) - 300;
6752
6792
  const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
@@ -6786,7 +6826,7 @@ const TaskGanttContent = ({
6786
6826
  }
6787
6827
  )
6788
6828
  },
6789
- `Arrow from ${taskId} to ${dep.dependent.id} on ${comparisonLevel} at ${index2}`
6829
+ `Arrow from ${taskId} to ${dep.dependent.id} on ${comparisonLevel}`
6790
6830
  )
6791
6831
  );
6792
6832
  });
@@ -6856,6 +6896,7 @@ const TaskGanttInner = (props) => {
6856
6896
  height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
6857
6897
  width: (ganttTaskRootRef == null ? void 0 : ganttTaskRootRef.current) ? ganttTaskRootRef.current.clientWidth + ganttTaskRootRef.current.scrollLeft : fullSvgWidth
6858
6898
  };
6899
+ console.log("containerStyle:>> ", containerStyle);
6859
6900
  const gridStyle = useMemo(
6860
6901
  () => ({
6861
6902
  height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
@@ -11483,36 +11524,49 @@ const getMapTaskToRowIndexWithGrouping = (tasks, comparisonLevels, isGrouped = f
11483
11524
  const rowIndexToTasksMap = /* @__PURE__ */ new Map();
11484
11525
  const mapGlobalRowIndexToTask = /* @__PURE__ */ new Map();
11485
11526
  const parentMap = new Map(tasks.map((t2) => [t2.id, t2]));
11486
- const rowCounterPerLevel = {};
11487
- for (let level = 1; level <= comparisonLevels; level++) {
11488
- taskToRowIndexMap.set(level, /* @__PURE__ */ new Map());
11489
- rowIndexToTaskMap.set(level, /* @__PURE__ */ new Map());
11490
- rowIndexToTasksMap.set(level, /* @__PURE__ */ new Map());
11491
- rowCounterPerLevel[level] = 0;
11492
- }
11493
- for (const task of tasks) {
11494
- const comparisonLevel = task.comparisonLevel ?? 1;
11495
- const rowIndex = rowCounterPerLevel[comparisonLevel];
11496
- const taskToRow = taskToRowIndexMap.get(comparisonLevel);
11497
- const rowToTask = rowIndexToTaskMap.get(comparisonLevel);
11498
- const rowToTasks = rowIndexToTasksMap.get(comparisonLevel);
11499
- const { id, parent } = task;
11500
- const parentTask = parent ? parentMap.get(parent) : null;
11501
- if (isGrouped && comparisonLevel === 1 && parent && parentTask && parentTask.hideChildren) {
11502
- const parentRow = taskToRow.get(parent);
11503
- if (parentRow !== void 0) {
11504
- const existing = rowToTasks.get(parentRow) ?? [];
11505
- rowToTasks.set(parentRow, [...existing, task]);
11506
- taskToRow.set(id, parentRow);
11527
+ let globalRowIndex = 0;
11528
+ for (let comparisonLevel = 1; comparisonLevel <= comparisonLevels; comparisonLevel++) {
11529
+ const taskToRow = /* @__PURE__ */ new Map();
11530
+ const rowToTask = /* @__PURE__ */ new Map();
11531
+ const rowToTasks = /* @__PURE__ */ new Map();
11532
+ taskToRowIndexMap.set(comparisonLevel, taskToRow);
11533
+ rowIndexToTaskMap.set(comparisonLevel, rowToTask);
11534
+ rowIndexToTasksMap.set(comparisonLevel, rowToTasks);
11535
+ let rowIndex = 0;
11536
+ for (const task of tasks) {
11537
+ if ((task.comparisonLevel ?? 1) !== comparisonLevel)
11538
+ continue;
11539
+ const { id, parent, type } = task;
11540
+ let assignedRowIndex = rowIndex;
11541
+ if (type === "user" || type === "project") {
11542
+ taskToRow.set(id, rowIndex);
11543
+ rowToTask.set(rowIndex, task);
11544
+ rowToTasks.set(rowIndex, [task]);
11545
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11546
+ rowIndex++;
11547
+ globalRowIndex++;
11507
11548
  continue;
11508
11549
  }
11550
+ if (isGrouped && parent) {
11551
+ const parentTask = parentMap.get(parent);
11552
+ const parentRowIndex = taskToRow.get(parent);
11553
+ if ((parentTask == null ? void 0 : parentTask.hideChildren) && parentRowIndex !== void 0) {
11554
+ assignedRowIndex = parentRowIndex;
11555
+ } else {
11556
+ assignedRowIndex = rowIndex;
11557
+ rowIndex++;
11558
+ }
11559
+ } else {
11560
+ assignedRowIndex = rowIndex;
11561
+ rowIndex++;
11562
+ }
11563
+ taskToRow.set(id, assignedRowIndex);
11564
+ rowToTask.set(assignedRowIndex, task);
11565
+ const existing = rowToTasks.get(assignedRowIndex) ?? [];
11566
+ rowToTasks.set(assignedRowIndex, [...existing, task]);
11567
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11568
+ globalRowIndex++;
11509
11569
  }
11510
- taskToRow.set(id, rowIndex);
11511
- rowToTask.set(rowIndex, task);
11512
- rowToTasks.set(rowIndex, [task]);
11513
- const globalIndex = rowIndex * comparisonLevels + (comparisonLevel - 1);
11514
- mapGlobalRowIndexToTask.set(globalIndex, task);
11515
- rowCounterPerLevel[comparisonLevel]++;
11516
11570
  }
11517
11571
  return [
11518
11572
  taskToRowIndexMap,
@@ -11813,8 +11867,7 @@ const Gantt = ({
11813
11867
  const groupedIndexes = useGroupedVirtualization(
11814
11868
  ganttTaskContentRef,
11815
11869
  rowIndexToTasksMap,
11816
- fullRowHeight,
11817
- taskToRowIndexMap
11870
+ fullRowHeight
11818
11871
  );
11819
11872
  const optimizedIndexes = useOptimizedList(
11820
11873
  ganttTaskContentRef,
@@ -689,6 +689,7 @@
689
689
  ViewMode2["Week"] = "Week";
690
690
  ViewMode2["Month"] = "Month";
691
691
  ViewMode2["QuarterYear"] = "QuarterYear";
692
+ ViewMode2["HalfYear"] = "HalfYear";
692
693
  ViewMode2["Year"] = "Year";
693
694
  return ViewMode2;
694
695
  })(ViewMode || {});
@@ -871,6 +872,11 @@
871
872
  throw new Error("Unknown view mode");
872
873
  }
873
874
  };
875
+ const startOfHalfYear = (date) => {
876
+ const d2 = new Date(date);
877
+ const startMonth = d2.getMonth() < 6 ? 0 : 6;
878
+ return new Date(d2.getFullYear(), startMonth, 1);
879
+ };
874
880
  const ganttDateRange = (tasks, viewMode, preStepsCount) => {
875
881
  let minTaskDate = null;
876
882
  let maxTaskDate = null;
@@ -896,6 +902,12 @@
896
902
  newEndDate = addYears(maxTaskDate, 1);
897
903
  newEndDate = startOfYear(newEndDate);
898
904
  break;
905
+ case ViewMode.HalfYear:
906
+ newStartDate = subMonths(minTaskDate, preStepsCount * 6);
907
+ newStartDate = startOfHalfYear(newStartDate);
908
+ newEndDate = addMonths(maxTaskDate, 6);
909
+ newEndDate = startOfHalfYear(addMonths(newEndDate, 6));
910
+ break;
899
911
  case ViewMode.QuarterYear:
900
912
  newStartDate = subMonths(minTaskDate, preStepsCount * 3);
901
913
  newStartDate = startOfQuarter(newStartDate);
@@ -1958,20 +1970,14 @@
1958
1970
  return indexes;
1959
1971
  };
1960
1972
  const TASK_SPACING = 2;
1961
- const useGroupedVirtualization = (_containerRef, rowIndexToTasksMap, taskHeight, taskToRowIndexMap) => {
1973
+ const useGroupedVirtualization = (_containerRef, rowIndexToTasksMap, taskHeight) => {
1962
1974
  const rowEntries = React.useMemo(() => {
1963
1975
  if (!rowIndexToTasksMap || rowIndexToTasksMap.size === 0)
1964
1976
  return [];
1965
- if (!taskToRowIndexMap || taskToRowIndexMap.size === 0)
1966
- return [];
1967
1977
  const rowToHeight = /* @__PURE__ */ new Map();
1968
1978
  for (const levelMap of rowIndexToTasksMap.values()) {
1969
1979
  for (const [rowIndex, tasks] of levelMap.entries()) {
1970
- const visibleGroupedTasks = tasks.filter((task) => {
1971
- var _a;
1972
- return !((_a = taskToRowIndexMap.get(task.comparisonLevel ?? 1)) == null ? void 0 : _a.has(task.id));
1973
- });
1974
- const height = visibleGroupedTasks.length * (taskHeight + TASK_SPACING);
1980
+ const height = tasks.length * (taskHeight + TASK_SPACING);
1975
1981
  rowToHeight.set(rowIndex, (rowToHeight.get(rowIndex) ?? 0) + height);
1976
1982
  }
1977
1983
  }
@@ -3428,7 +3434,6 @@
3428
3434
  dependencyMap,
3429
3435
  distances,
3430
3436
  rowIndexToTasksMap,
3431
- taskToRowIndexMap,
3432
3437
  fontFamily,
3433
3438
  fontSize,
3434
3439
  fullRowHeight,
@@ -3470,8 +3475,7 @@
3470
3475
  const groupedIndexes = useGroupedVirtualization(
3471
3476
  taskListContentRef,
3472
3477
  rowIndexToTasksMap,
3473
- distances.taskHeight,
3474
- taskToRowIndexMap
3478
+ distances.taskHeight
3475
3479
  );
3476
3480
  const optimizedIndexes = useOptimizedList(
3477
3481
  taskListContentRef,
@@ -4322,6 +4326,9 @@
4322
4326
  case ViewMode.Year:
4323
4327
  value = formatDistance2("xYears", offsetFromStart);
4324
4328
  break;
4329
+ case ViewMode.HalfYear:
4330
+ value = formatDistance2("xMonths", offsetFromStart * 6);
4331
+ break;
4325
4332
  case ViewMode.Month:
4326
4333
  value = formatDistance2("xMonths", offsetFromStart);
4327
4334
  break;
@@ -4355,6 +4362,10 @@
4355
4362
  switch (viewMode) {
4356
4363
  case ViewMode.Year:
4357
4364
  return date.getFullYear();
4365
+ case ViewMode.HalfYear: {
4366
+ const half = Math.ceil((date.getMonth() + 1) / 6);
4367
+ return `H${half}`;
4368
+ }
4358
4369
  case ViewMode.Month:
4359
4370
  try {
4360
4371
  return format(date, dateSetup.dateFormats.monthBottomHeaderFormat, {
@@ -4410,10 +4421,16 @@
4410
4421
  const quarter = Math.ceil((date.getMonth() + 1) / 3);
4411
4422
  return `Q${quarter}`;
4412
4423
  };
4424
+ const getHalfYearText = (date) => {
4425
+ const halfYear = Math.ceil((date.getMonth() + 1) / 6);
4426
+ return `H${halfYear}`;
4427
+ };
4413
4428
  const defaultRenderTopHeader = (date, viewMode, dateSetup) => {
4414
4429
  switch (viewMode) {
4415
4430
  case ViewMode.Year:
4416
4431
  return date.getFullYear().toString();
4432
+ case ViewMode.HalfYear:
4433
+ return `${getHalfYearText(date)} ${date.getFullYear()}`;
4417
4434
  case ViewMode.QuarterYear:
4418
4435
  return `${getQuarterText(date)} ${date.getFullYear()}`;
4419
4436
  case ViewMode.Month:
@@ -4547,6 +4564,48 @@
4547
4564
  }
4548
4565
  return [topValues2, bottomValues2];
4549
4566
  };
4567
+ const getCalenderValuesForHalfYear = () => {
4568
+ const topValues2 = [];
4569
+ const bottomValues2 = [];
4570
+ const topDefaultHeight = headerHeight * 0.5;
4571
+ for (let i = startColumnIndex; i <= endColumnIndex; i++) {
4572
+ const date = getDate(i);
4573
+ const halfYear = "H" + Math.ceil((date.getMonth() + 1) / 6);
4574
+ bottomValues2.push(
4575
+ /* @__PURE__ */ jsxRuntime.jsx(
4576
+ "text",
4577
+ {
4578
+ y: headerHeight * 0.8,
4579
+ x: additionalLeftSpace + columnWidth * i + columnWidth * 0.5,
4580
+ className: styles$a.calendarBottomText,
4581
+ style: { fill: colors.barLabelColor },
4582
+ children: halfYear
4583
+ },
4584
+ `${halfYear}-${date.getFullYear()}-${i}`
4585
+ )
4586
+ );
4587
+ if (!isUnknownDates && (i === startColumnIndex || date.getFullYear() !== getDate(i - 1).getFullYear())) {
4588
+ const year = date.getFullYear().toString();
4589
+ const startHalf = Math.floor(i / 6) * 6;
4590
+ topValues2.push(
4591
+ /* @__PURE__ */ jsxRuntime.jsx(
4592
+ TopPartOfCalendar,
4593
+ {
4594
+ value: year,
4595
+ x1Line: additionalLeftSpace + columnWidth * startHalf,
4596
+ y1Line: 0,
4597
+ y2Line: topDefaultHeight,
4598
+ xText: additionalLeftSpace + columnWidth * (startHalf + 3),
4599
+ yText: topDefaultHeight * 0.9,
4600
+ colors
4601
+ },
4602
+ year
4603
+ )
4604
+ );
4605
+ }
4606
+ }
4607
+ return [topValues2, bottomValues2];
4608
+ };
4550
4609
  const getCalendarValuesForQuarterYear = () => {
4551
4610
  const topValues2 = [];
4552
4611
  const bottomValues2 = [];
@@ -4554,6 +4613,7 @@
4554
4613
  for (let i = startColumnIndex; i <= endColumnIndex; i++) {
4555
4614
  const date = getDate(i);
4556
4615
  const quarter = "Q" + Math.ceil((date.getMonth() + 1) / 3);
4616
+ console.log("quarter :>> ", quarter);
4557
4617
  bottomValues2.push(
4558
4618
  /* @__PURE__ */ jsxRuntime.jsx(
4559
4619
  "text",
@@ -4833,6 +4893,9 @@
4833
4893
  case ViewMode.Year:
4834
4894
  [topValues, bottomValues] = getCalendarValuesForYear();
4835
4895
  break;
4896
+ case ViewMode.HalfYear:
4897
+ [topValues, bottomValues] = getCalenderValuesForHalfYear();
4898
+ break;
4836
4899
  case ViewMode.QuarterYear:
4837
4900
  [topValues, bottomValues] = getCalendarValuesForQuarterYear();
4838
4901
  break;
@@ -5107,9 +5170,9 @@
5107
5170
  /* @__PURE__ */ jsxRuntime.jsx(GridBody, { ...props })
5108
5171
  ] });
5109
5172
  };
5110
- const ganttTaskRoot = "_ganttTaskRoot_1lwsd_1";
5111
- const ganttTaskContent = "_ganttTaskContent_1lwsd_83";
5112
- const wrapper$2 = "_wrapper_1lwsd_111";
5173
+ const ganttTaskRoot = "_ganttTaskRoot_1mu5y_1";
5174
+ const ganttTaskContent = "_ganttTaskContent_1mu5y_83";
5175
+ const wrapper$2 = "_wrapper_1mu5y_111";
5113
5176
  const styles$9 = {
5114
5177
  ganttTaskRoot,
5115
5178
  ganttTaskContent,
@@ -6513,13 +6576,6 @@
6513
6576
  );
6514
6577
  };
6515
6578
  const TaskItem = React.memo(TaskItemInner);
6516
- const generateRenderId = (task, index2) => {
6517
- if ("renderId" in task && typeof task.renderId === "string")
6518
- return task.renderId;
6519
- if ("type" in task && task.type === "user")
6520
- return `${task.id}-user`;
6521
- return `${task.id}-row-${index2}`;
6522
- };
6523
6579
  const TaskGanttContent = ({
6524
6580
  authorizedRelations,
6525
6581
  additionalLeftSpace,
@@ -6565,7 +6621,7 @@
6565
6621
  taskToRowIndexMap
6566
6622
  }) => {
6567
6623
  const [renderedTasks, renderedArrows, renderedSelectedTasks] = React.useMemo(() => {
6568
- var _a, _b;
6624
+ var _a;
6569
6625
  if (!renderedRowIndexes)
6570
6626
  return [null, null, null];
6571
6627
  const [start, end] = renderedRowIndexes;
@@ -6580,7 +6636,7 @@
6580
6636
  for (let level = 1; level <= comparisonLevels; level++) {
6581
6637
  const levelMap = rowIndexToTasksMap.get(level);
6582
6638
  const rowTasks = levelMap == null ? void 0 : levelMap.get(index2);
6583
- if (rowTasks) {
6639
+ if (Array.isArray(rowTasks)) {
6584
6640
  tasksAtRow.push(...rowTasks);
6585
6641
  }
6586
6642
  }
@@ -6591,32 +6647,31 @@
6591
6647
  }
6592
6648
  for (const task of tasksAtRow) {
6593
6649
  const comparisonLevel = task.comparisonLevel ?? 1;
6594
- const renderId = generateRenderId(task, index2);
6595
- const taskId = task.id;
6596
- const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6597
- if (typeof rowIndex !== "number")
6598
- continue;
6599
- const key = `${taskId}-${rowIndex}`;
6600
- if (selectedIdsMirror[taskId] && !addedSelectedTasks[`${taskId}-${rowIndex}`]) {
6601
- addedSelectedTasks[key] = true;
6602
- selectedTasksRes.push(
6603
- /* @__PURE__ */ jsxRuntime.jsx(
6604
- "rect",
6605
- {
6606
- x: 0,
6607
- y: rowIndex * fullRowHeight,
6608
- width: "100%",
6609
- height: fullRowHeight,
6610
- fill: colorStyles.selectedTaskBackgroundColor
6611
- },
6612
- `selected-${key}`
6613
- )
6614
- );
6650
+ const { id: taskId } = task;
6651
+ if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6652
+ addedSelectedTasks[taskId] = true;
6653
+ const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6654
+ if (typeof rowIndex === "number") {
6655
+ selectedTasksRes.push(
6656
+ /* @__PURE__ */ jsxRuntime.jsx(
6657
+ "rect",
6658
+ {
6659
+ x: 0,
6660
+ y: rowIndex * fullRowHeight,
6661
+ width: "100%",
6662
+ height: fullRowHeight,
6663
+ fill: colorStyles.selectedTaskBackgroundColor
6664
+ },
6665
+ `selected-${taskId}`
6666
+ )
6667
+ );
6668
+ }
6615
6669
  }
6616
6670
  if (comparisonLevel > comparisonLevels)
6617
6671
  continue;
6618
6672
  if (task.type === "empty" || task.type === "user")
6619
6673
  continue;
6674
+ const key = `${comparisonLevel}_${task.id}`;
6620
6675
  const criticalPathOnLevel = criticalPaths == null ? void 0 : criticalPaths.get(comparisonLevel);
6621
6676
  const isCritical = !!(criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.tasks.has(task.id));
6622
6677
  const {
@@ -6630,78 +6685,64 @@
6630
6685
  x1: taskX1,
6631
6686
  x2: taskX2
6632
6687
  } = getTaskCoordinates2(task);
6633
- const renderContexts = [];
6634
- const oneRowDefaultRender = { y: levelY, keySuffix: "default" };
6635
- renderContexts.push(oneRowDefaultRender);
6636
- if (enableTaskGrouping && task.parent) {
6637
- const parentRowIndex = (_b = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _b.get(task.parent);
6638
- if (typeof parentRowIndex === "number") {
6639
- const yInUserRow = parentRowIndex * fullRowHeight;
6640
- renderContexts.push({ y: yInUserRow, keySuffix: "grouped" });
6641
- }
6642
- }
6643
- for (const context of renderContexts) {
6644
- tasksRes.push(
6645
- /* @__PURE__ */ jsxRuntime.jsx(
6646
- "svg",
6647
- {
6648
- id: `${renderId}-${context.keySuffix}`,
6649
- className: "TaskItemClassName",
6650
- x: containerX + additionalLeftSpace,
6651
- y: context.y,
6652
- width: containerWidth,
6653
- height: fullRowHeight,
6654
- children: /* @__PURE__ */ jsxRuntime.jsx(
6655
- TaskItem,
6656
- {
6657
- getTaskGlobalIndexByRef,
6658
- hasChildren: checkHasChildren(task, childTasksMap),
6659
- hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
6660
- progressWidth,
6661
- progressX: rtl ? innerX2 : innerX1,
6662
- selectTaskOnMouseDown,
6663
- task,
6664
- taskYOffset,
6665
- width,
6666
- x1: innerX1,
6667
- x2: innerX2,
6668
- childOutOfParentWarnings,
6669
- distances,
6670
- taskHeight,
6671
- taskHalfHeight,
6672
- isProgressChangeable: !task.isDisabled,
6673
- isDateChangeable: !task.isDisabled,
6674
- isRelationChangeable: !task.isRelationDisabled,
6675
- authorizedRelations,
6676
- ganttRelationEvent,
6677
- isDelete: !task.isDisabled,
6678
- onDoubleClick,
6679
- onClick,
6680
- onEventStart: handleTaskDragStart,
6681
- setTooltipTask,
6682
- onRelationStart: handleBarRelationStart,
6683
- isSelected: Boolean(selectedIdsMirror[taskId]),
6684
- isCritical,
6685
- rtl,
6686
- fixStartPosition,
6687
- fixEndPosition,
6688
- handleDeleteTasks,
6689
- colorStyles
6690
- }
6691
- )
6692
- },
6693
- `${comparisonLevel}_${task.id}_${index2}_${context.keySuffix}`
6694
- )
6695
- );
6696
- }
6688
+ tasksRes.push(
6689
+ /* @__PURE__ */ jsxRuntime.jsx(
6690
+ "svg",
6691
+ {
6692
+ id: task.id,
6693
+ className: "TaskItemClassName",
6694
+ x: containerX + additionalLeftSpace,
6695
+ y: levelY,
6696
+ width: containerWidth,
6697
+ height: fullRowHeight,
6698
+ children: /* @__PURE__ */ jsxRuntime.jsx(
6699
+ TaskItem,
6700
+ {
6701
+ getTaskGlobalIndexByRef,
6702
+ hasChildren: checkHasChildren(task, childTasksMap),
6703
+ hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
6704
+ progressWidth,
6705
+ progressX: rtl ? innerX2 : innerX1,
6706
+ selectTaskOnMouseDown,
6707
+ task,
6708
+ taskYOffset,
6709
+ width,
6710
+ x1: innerX1,
6711
+ x2: innerX2,
6712
+ childOutOfParentWarnings,
6713
+ distances,
6714
+ taskHeight,
6715
+ taskHalfHeight,
6716
+ isProgressChangeable: !task.isDisabled,
6717
+ isDateChangeable: !task.isDisabled,
6718
+ isRelationChangeable: !task.isRelationDisabled,
6719
+ authorizedRelations,
6720
+ ganttRelationEvent,
6721
+ isDelete: !task.isDisabled,
6722
+ onDoubleClick,
6723
+ onClick,
6724
+ onEventStart: handleTaskDragStart,
6725
+ setTooltipTask,
6726
+ onRelationStart: handleBarRelationStart,
6727
+ isSelected: Boolean(selectedIdsMirror[taskId]),
6728
+ isCritical,
6729
+ rtl,
6730
+ fixStartPosition,
6731
+ fixEndPosition,
6732
+ handleDeleteTasks,
6733
+ colorStyles
6734
+ }
6735
+ )
6736
+ },
6737
+ key
6738
+ )
6739
+ );
6697
6740
  const addedDependenciesAtLevel = addedDependencies[comparisonLevel] ?? (addedDependencies[comparisonLevel] = {});
6698
6741
  const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] ?? (addedDependenciesAtLevel[taskId] = {});
6699
6742
  const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6700
6743
  const dependenciesByTask = dependenciesAtLevel == null ? void 0 : dependenciesAtLevel.get(taskId);
6701
- dependenciesByTask == null ? void 0 : dependenciesByTask.forEach((dep) => {
6744
+ dependenciesByTask == null ? void 0 : dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach((dep) => {
6702
6745
  var _a2;
6703
- if (!visibleTasksMirror[dep.source.id])
6704
- return;
6705
6746
  if (addedDependenciesAtTask[dep.source.id])
6706
6747
  return;
6707
6748
  addedDependenciesAtTask[dep.source.id] = true;
@@ -6745,21 +6786,20 @@
6745
6786
  }
6746
6787
  )
6747
6788
  },
6748
- `Arrow from ${dep.source.id} to ${taskId} on ${comparisonLevel} at ${index2}`
6789
+ `Arrow from ${dep.source.id} to ${taskId} on ${comparisonLevel}`
6749
6790
  )
6750
6791
  );
6751
6792
  });
6752
6793
  const dependentsAtLevel = dependentMap.get(comparisonLevel);
6753
6794
  const dependentsByTask = dependentsAtLevel == null ? void 0 : dependentsAtLevel.get(taskId);
6754
- dependentsByTask == null ? void 0 : dependentsByTask.forEach((dep) => {
6755
- var _a2, _b2;
6756
- if (!visibleTasksMirror[dep.dependent.id])
6757
- return;
6795
+ dependentsByTask == null ? void 0 : dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach((dep) => {
6796
+ var _a2, _b;
6797
+ console.log("dependent", dep);
6758
6798
  const addedDepsForDep = addedDependenciesAtLevel[_a2 = dep.dependent.id] ?? (addedDependenciesAtLevel[_a2] = {});
6759
6799
  if (addedDepsForDep[taskId])
6760
6800
  return;
6761
6801
  addedDepsForDep[taskId] = true;
6762
- const isDepCritical = !!((_b2 = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(dep.dependent.id)) == null ? void 0 : _b2.has(task.id));
6802
+ const isDepCritical = !!((_b = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(dep.dependent.id)) == null ? void 0 : _b.has(task.id));
6763
6803
  const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dep.dependent);
6764
6804
  const containerX2 = Math.min(toX1, taskX1) - 300;
6765
6805
  const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
@@ -6799,7 +6839,7 @@
6799
6839
  }
6800
6840
  )
6801
6841
  },
6802
- `Arrow from ${taskId} to ${dep.dependent.id} on ${comparisonLevel} at ${index2}`
6842
+ `Arrow from ${taskId} to ${dep.dependent.id} on ${comparisonLevel}`
6803
6843
  )
6804
6844
  );
6805
6845
  });
@@ -6869,6 +6909,7 @@
6869
6909
  height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
6870
6910
  width: (ganttTaskRootRef == null ? void 0 : ganttTaskRootRef.current) ? ganttTaskRootRef.current.clientWidth + ganttTaskRootRef.current.scrollLeft : fullSvgWidth
6871
6911
  };
6912
+ console.log("containerStyle:>> ", containerStyle);
6872
6913
  const gridStyle = React.useMemo(
6873
6914
  () => ({
6874
6915
  height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
@@ -11496,36 +11537,49 @@
11496
11537
  const rowIndexToTasksMap = /* @__PURE__ */ new Map();
11497
11538
  const mapGlobalRowIndexToTask = /* @__PURE__ */ new Map();
11498
11539
  const parentMap = new Map(tasks.map((t) => [t.id, t]));
11499
- const rowCounterPerLevel = {};
11500
- for (let level = 1; level <= comparisonLevels; level++) {
11501
- taskToRowIndexMap.set(level, /* @__PURE__ */ new Map());
11502
- rowIndexToTaskMap.set(level, /* @__PURE__ */ new Map());
11503
- rowIndexToTasksMap.set(level, /* @__PURE__ */ new Map());
11504
- rowCounterPerLevel[level] = 0;
11505
- }
11506
- for (const task of tasks) {
11507
- const comparisonLevel = task.comparisonLevel ?? 1;
11508
- const rowIndex = rowCounterPerLevel[comparisonLevel];
11509
- const taskToRow = taskToRowIndexMap.get(comparisonLevel);
11510
- const rowToTask = rowIndexToTaskMap.get(comparisonLevel);
11511
- const rowToTasks = rowIndexToTasksMap.get(comparisonLevel);
11512
- const { id, parent } = task;
11513
- const parentTask = parent ? parentMap.get(parent) : null;
11514
- if (isGrouped && comparisonLevel === 1 && parent && parentTask && parentTask.hideChildren) {
11515
- const parentRow = taskToRow.get(parent);
11516
- if (parentRow !== void 0) {
11517
- const existing = rowToTasks.get(parentRow) ?? [];
11518
- rowToTasks.set(parentRow, [...existing, task]);
11519
- taskToRow.set(id, parentRow);
11540
+ let globalRowIndex = 0;
11541
+ for (let comparisonLevel = 1; comparisonLevel <= comparisonLevels; comparisonLevel++) {
11542
+ const taskToRow = /* @__PURE__ */ new Map();
11543
+ const rowToTask = /* @__PURE__ */ new Map();
11544
+ const rowToTasks = /* @__PURE__ */ new Map();
11545
+ taskToRowIndexMap.set(comparisonLevel, taskToRow);
11546
+ rowIndexToTaskMap.set(comparisonLevel, rowToTask);
11547
+ rowIndexToTasksMap.set(comparisonLevel, rowToTasks);
11548
+ let rowIndex = 0;
11549
+ for (const task of tasks) {
11550
+ if ((task.comparisonLevel ?? 1) !== comparisonLevel)
11551
+ continue;
11552
+ const { id, parent, type } = task;
11553
+ let assignedRowIndex = rowIndex;
11554
+ if (type === "user" || type === "project") {
11555
+ taskToRow.set(id, rowIndex);
11556
+ rowToTask.set(rowIndex, task);
11557
+ rowToTasks.set(rowIndex, [task]);
11558
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11559
+ rowIndex++;
11560
+ globalRowIndex++;
11520
11561
  continue;
11521
11562
  }
11563
+ if (isGrouped && parent) {
11564
+ const parentTask = parentMap.get(parent);
11565
+ const parentRowIndex = taskToRow.get(parent);
11566
+ if ((parentTask == null ? void 0 : parentTask.hideChildren) && parentRowIndex !== void 0) {
11567
+ assignedRowIndex = parentRowIndex;
11568
+ } else {
11569
+ assignedRowIndex = rowIndex;
11570
+ rowIndex++;
11571
+ }
11572
+ } else {
11573
+ assignedRowIndex = rowIndex;
11574
+ rowIndex++;
11575
+ }
11576
+ taskToRow.set(id, assignedRowIndex);
11577
+ rowToTask.set(assignedRowIndex, task);
11578
+ const existing = rowToTasks.get(assignedRowIndex) ?? [];
11579
+ rowToTasks.set(assignedRowIndex, [...existing, task]);
11580
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11581
+ globalRowIndex++;
11522
11582
  }
11523
- taskToRow.set(id, rowIndex);
11524
- rowToTask.set(rowIndex, task);
11525
- rowToTasks.set(rowIndex, [task]);
11526
- const globalIndex = rowIndex * comparisonLevels + (comparisonLevel - 1);
11527
- mapGlobalRowIndexToTask.set(globalIndex, task);
11528
- rowCounterPerLevel[comparisonLevel]++;
11529
11583
  }
11530
11584
  return [
11531
11585
  taskToRowIndexMap,
@@ -11826,8 +11880,7 @@
11826
11880
  const groupedIndexes = useGroupedVirtualization(
11827
11881
  ganttTaskContentRef,
11828
11882
  rowIndexToTasksMap,
11829
- fullRowHeight,
11830
- taskToRowIndexMap
11883
+ fullRowHeight
11831
11884
  );
11832
11885
  const optimizedIndexes = useOptimizedList(
11833
11886
  ganttTaskContentRef,
@@ -1,3 +1,3 @@
1
- import type { RowIndexToTasksMap, TaskToRowIndexMap } from "../types/public-types";
1
+ import type { RowIndexToTasksMap } from "../types/public-types";
2
2
  import type { OptimizedListParams } from "./use-optimized-list";
3
- export declare const useGroupedVirtualization: (_containerRef: React.RefObject<HTMLElement>, rowIndexToTasksMap: RowIndexToTasksMap, taskHeight: number, taskToRowIndexMap: TaskToRowIndexMap) => OptimizedListParams;
3
+ export declare const useGroupedVirtualization: (_containerRef: React.RefObject<HTMLElement>, rowIndexToTasksMap: RowIndexToTasksMap, taskHeight: number) => OptimizedListParams;
package/dist/style.css CHANGED
@@ -332,7 +332,7 @@
332
332
  stroke: #e0e0e0;
333
333
  stroke-width: 1.4;
334
334
  }
335
- ._ganttTaskRoot_1lwsd_1 {
335
+ ._ganttTaskRoot_1mu5y_1 {
336
336
  display: flex;
337
337
  flex-direction: column;
338
338
  overflow-x: scroll;
@@ -344,7 +344,7 @@
344
344
 
345
345
  /* Only chrome otherwise the firefox scrollbar has no edge*/
346
346
  @media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {
347
- ._ganttTaskRoot_1lwsd_1 {
347
+ ._ganttTaskRoot_1mu5y_1 {
348
348
  scrollbar-width: thin;
349
349
  }
350
350
  }
@@ -373,7 +373,7 @@
373
373
  background-clip: padding-box;
374
374
  } */
375
375
 
376
- ._ganttTaskContent_1lwsd_83 {
376
+ ._ganttTaskContent_1mu5y_83 {
377
377
  margin: 0;
378
378
  padding: 0;
379
379
  overflow-x: hidden;
@@ -382,12 +382,12 @@
382
382
 
383
383
  /* Only chrome otherwise the firefox scrollbar has no edges*/
384
384
  @media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {
385
- ._ganttTaskContent_1lwsd_83 {
385
+ ._ganttTaskContent_1mu5y_83 {
386
386
  scrollbar-width: thin;
387
387
  }
388
388
  }
389
389
 
390
- ._wrapper_1lwsd_111 {
390
+ ._wrapper_1mu5y_111 {
391
391
  display: grid;
392
392
  overflow-x: hidden;
393
393
  overflow-y: auto;
@@ -396,6 +396,7 @@
396
396
  list-style: none;
397
397
  outline: none;
398
398
  position: relative;
399
+ height: 600px;
399
400
  }._hoverVisibleWrapper_11ld1_1:hover ._wrapper_11ld1_1 {
400
401
  display: initial;
401
402
  }
@@ -12,6 +12,7 @@ export declare enum ViewMode {
12
12
  Week = "Week",
13
13
  Month = "Month",
14
14
  QuarterYear = "QuarterYear",
15
+ HalfYear = "HalfYear",
15
16
  Year = "Year"
16
17
  }
17
18
  export interface DateSetup {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thepocman/gantt-task-react",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
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",