gantt-task-react-v 1.7.0 → 1.7.2

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.
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { TaskLabelProps } from "./types";
3
3
  interface Props extends TaskLabelProps {
4
4
  alwaysOutline?: boolean;
5
+ forceOutside?: boolean;
5
6
  }
6
7
  export declare const TaskResponsiveLabel: React.NamedExoticComponent<Props>;
7
8
  export {};
@@ -13197,9 +13197,9 @@ const Milestone = ({
13197
13197
  relationHandles
13198
13198
  ] });
13199
13199
  };
13200
- const barLabel = "_barLabel_81831_1";
13201
- const barLabelHidden = "_barLabelHidden_81831_27";
13202
- const barLabelOutside = "_barLabelOutside_81831_37";
13200
+ const barLabel = "_barLabel_5nsbb_1";
13201
+ const barLabelHidden = "_barLabelHidden_5nsbb_27";
13202
+ const barLabelOutside = "_barLabelOutside_5nsbb_37";
13203
13203
  const style = {
13204
13204
  barLabel,
13205
13205
  barLabelHidden,
@@ -13209,6 +13209,7 @@ const TaskResponsiveLabelInner = (props) => {
13209
13209
  const {
13210
13210
  alwaysOutline,
13211
13211
  arrowIndent,
13212
+ forceOutside,
13212
13213
  rtl,
13213
13214
  label: label2,
13214
13215
  taskHeight,
@@ -13224,21 +13225,22 @@ const TaskResponsiveLabelInner = (props) => {
13224
13225
  setIsTextInside(textRef.current.getBBox().width < width);
13225
13226
  }
13226
13227
  }, [textRef, width, viewMode]);
13228
+ const shouldBeOutside = alwaysOutline || forceOutside;
13227
13229
  const calculatedX = useMemo(() => {
13228
- if (isTextInside && !alwaysOutline) {
13230
+ if (isTextInside && !shouldBeOutside) {
13229
13231
  return x1 + width * 0.5;
13230
13232
  }
13231
13233
  if (rtl && textRef.current) {
13232
13234
  return x1 - textRef.current.getBBox().width - arrowIndent * 0.8;
13233
13235
  }
13234
13236
  return x1 + width + arrowIndent * 1.2;
13235
- }, [alwaysOutline, x1, width, isTextInside, rtl, arrowIndent]);
13237
+ }, [shouldBeOutside, x1, width, isTextInside, rtl, arrowIndent]);
13236
13238
  return /* @__PURE__ */ jsx(
13237
13239
  "text",
13238
13240
  {
13239
13241
  x: calculatedX,
13240
13242
  y: taskYOffset + taskHeight * 0.5,
13241
- className: isTextInside && !alwaysOutline ? style.barLabel : style.barLabelOutside,
13243
+ className: isTextInside && !shouldBeOutside ? style.barLabel : style.barLabelOutside,
13242
13244
  ref: textRef,
13243
13245
  children: label2
13244
13246
  }
@@ -13502,7 +13504,8 @@ const TaskItemInner = (props) => {
13502
13504
  label: task.name,
13503
13505
  taskYOffset,
13504
13506
  viewMode,
13505
- alwaysOutline: task.type === "project"
13507
+ alwaysOutline: task.type === "project",
13508
+ forceOutside: props.showProgress && width > 40
13506
13509
  }
13507
13510
  )
13508
13511
  ]
@@ -13827,6 +13830,10 @@ const TaskGanttContentInner = (props) => {
13827
13830
  const safeComparisonY = isNaN(comparisonDates.y) || !isFinite(comparisonDates.y) ? safeLevelY : comparisonDates.y;
13828
13831
  const safeComparisonWidth = isNaN(comparisonDates.width) || !isFinite(comparisonDates.width) ? 0 : Math.max(comparisonDates.width, 0);
13829
13832
  const safeComparisonHeight = isNaN(comparisonDates.height) || !isFinite(comparisonDates.height) ? 0 : Math.max(comparisonDates.height, 0);
13833
+ const maxComparisonSvgHeight = Math.max(
13834
+ distances.rowHeight - taskYOffset - taskHeight,
13835
+ safeComparisonHeight
13836
+ );
13830
13837
  tasksRes.push(
13831
13838
  /* @__PURE__ */ jsx(
13832
13839
  "svg",
@@ -13836,7 +13843,7 @@ const TaskGanttContentInner = (props) => {
13836
13843
  x: Math.max(safeComparisonX + (additionalLeftSpace || 0), 0),
13837
13844
  y: safeComparisonY,
13838
13845
  width: safeComparisonWidth,
13839
- height: safeComparisonHeight * 2,
13846
+ height: Math.min(safeComparisonHeight * 2, maxComparisonSvgHeight),
13840
13847
  children: /* @__PURE__ */ jsx(
13841
13848
  BarComparison,
13842
13849
  {
@@ -14642,11 +14649,16 @@ const countTaskCoordinates = (task, taskToRowIndexMap, startDate, viewMode, rtl,
14642
14649
  );
14643
14650
  cx1 = isNaN(cx1) || !isFinite(cx1) ? x1 : cx1;
14644
14651
  cx2 = isNaN(cx2) || !isFinite(cx2) ? x2 : cx2;
14652
+ const remainingRowSpace = distances.rowHeight - taskYOffset - taskHeight;
14653
+ const clampedHeight = Math.min(
14654
+ barComparisonTaskHeight,
14655
+ Math.max(remainingRowSpace - 2, 2)
14656
+ );
14645
14657
  comparisonDates = {
14646
14658
  x: cx1,
14647
14659
  y: y + taskHeight,
14648
14660
  width: Math.max(cx2 - cx1, 0),
14649
- height: barComparisonTaskHeight
14661
+ height: clampedHeight
14650
14662
  };
14651
14663
  }
14652
14664
  return {
@@ -13214,9 +13214,9 @@
13214
13214
  relationHandles
13215
13215
  ] });
13216
13216
  };
13217
- const barLabel = "_barLabel_81831_1";
13218
- const barLabelHidden = "_barLabelHidden_81831_27";
13219
- const barLabelOutside = "_barLabelOutside_81831_37";
13217
+ const barLabel = "_barLabel_5nsbb_1";
13218
+ const barLabelHidden = "_barLabelHidden_5nsbb_27";
13219
+ const barLabelOutside = "_barLabelOutside_5nsbb_37";
13220
13220
  const style = {
13221
13221
  barLabel,
13222
13222
  barLabelHidden,
@@ -13226,6 +13226,7 @@
13226
13226
  const {
13227
13227
  alwaysOutline,
13228
13228
  arrowIndent,
13229
+ forceOutside,
13229
13230
  rtl,
13230
13231
  label: label2,
13231
13232
  taskHeight,
@@ -13241,21 +13242,22 @@
13241
13242
  setIsTextInside(textRef.current.getBBox().width < width);
13242
13243
  }
13243
13244
  }, [textRef, width, viewMode]);
13245
+ const shouldBeOutside = alwaysOutline || forceOutside;
13244
13246
  const calculatedX = React.useMemo(() => {
13245
- if (isTextInside && !alwaysOutline) {
13247
+ if (isTextInside && !shouldBeOutside) {
13246
13248
  return x1 + width * 0.5;
13247
13249
  }
13248
13250
  if (rtl && textRef.current) {
13249
13251
  return x1 - textRef.current.getBBox().width - arrowIndent * 0.8;
13250
13252
  }
13251
13253
  return x1 + width + arrowIndent * 1.2;
13252
- }, [alwaysOutline, x1, width, isTextInside, rtl, arrowIndent]);
13254
+ }, [shouldBeOutside, x1, width, isTextInside, rtl, arrowIndent]);
13253
13255
  return /* @__PURE__ */ jsxRuntime.jsx(
13254
13256
  "text",
13255
13257
  {
13256
13258
  x: calculatedX,
13257
13259
  y: taskYOffset + taskHeight * 0.5,
13258
- className: isTextInside && !alwaysOutline ? style.barLabel : style.barLabelOutside,
13260
+ className: isTextInside && !shouldBeOutside ? style.barLabel : style.barLabelOutside,
13259
13261
  ref: textRef,
13260
13262
  children: label2
13261
13263
  }
@@ -13519,7 +13521,8 @@
13519
13521
  label: task.name,
13520
13522
  taskYOffset,
13521
13523
  viewMode,
13522
- alwaysOutline: task.type === "project"
13524
+ alwaysOutline: task.type === "project",
13525
+ forceOutside: props.showProgress && width > 40
13523
13526
  }
13524
13527
  )
13525
13528
  ]
@@ -13844,6 +13847,10 @@
13844
13847
  const safeComparisonY = isNaN(comparisonDates.y) || !isFinite(comparisonDates.y) ? safeLevelY : comparisonDates.y;
13845
13848
  const safeComparisonWidth = isNaN(comparisonDates.width) || !isFinite(comparisonDates.width) ? 0 : Math.max(comparisonDates.width, 0);
13846
13849
  const safeComparisonHeight = isNaN(comparisonDates.height) || !isFinite(comparisonDates.height) ? 0 : Math.max(comparisonDates.height, 0);
13850
+ const maxComparisonSvgHeight = Math.max(
13851
+ distances.rowHeight - taskYOffset - taskHeight,
13852
+ safeComparisonHeight
13853
+ );
13847
13854
  tasksRes.push(
13848
13855
  /* @__PURE__ */ jsxRuntime.jsx(
13849
13856
  "svg",
@@ -13853,7 +13860,7 @@
13853
13860
  x: Math.max(safeComparisonX + (additionalLeftSpace || 0), 0),
13854
13861
  y: safeComparisonY,
13855
13862
  width: safeComparisonWidth,
13856
- height: safeComparisonHeight * 2,
13863
+ height: Math.min(safeComparisonHeight * 2, maxComparisonSvgHeight),
13857
13864
  children: /* @__PURE__ */ jsxRuntime.jsx(
13858
13865
  BarComparison,
13859
13866
  {
@@ -14659,11 +14666,16 @@
14659
14666
  );
14660
14667
  cx1 = isNaN(cx1) || !isFinite(cx1) ? x1 : cx1;
14661
14668
  cx2 = isNaN(cx2) || !isFinite(cx2) ? x2 : cx2;
14669
+ const remainingRowSpace = distances.rowHeight - taskYOffset - taskHeight;
14670
+ const clampedHeight = Math.min(
14671
+ barComparisonTaskHeight,
14672
+ Math.max(remainingRowSpace - 2, 2)
14673
+ );
14662
14674
  comparisonDates = {
14663
14675
  x: cx1,
14664
14676
  y: y + taskHeight,
14665
14677
  width: Math.max(cx2 - cx1, 0),
14666
- height: barComparisonTaskHeight
14678
+ height: clampedHeight
14667
14679
  };
14668
14680
  }
14669
14681
  return {
package/dist/style.css CHANGED
@@ -700,7 +700,7 @@
700
700
  ._milestoneBackground_vcirf_11 {
701
701
  user-select: none;
702
702
  }
703
- ._barLabel_81831_1 {
703
+ ._barLabel_5nsbb_1 {
704
704
  fill: #fff;
705
705
  text-anchor: middle;
706
706
  font-weight: lighter;
@@ -713,14 +713,15 @@
713
713
  pointer-events: none;
714
714
  }
715
715
 
716
- ._barLabelHidden_81831_27 {
716
+ ._barLabelHidden_5nsbb_27 {
717
717
  display: none;
718
718
  }
719
719
 
720
720
  /*noinspection CssUnresolvedCustomProperty*/
721
- ._barLabelOutside_81831_37 {
721
+ ._barLabelOutside_5nsbb_37 {
722
722
  fill: var(--gantt-secondary-text-color);
723
723
  text-anchor: start;
724
+ dominant-baseline: central;
724
725
  stroke: white;
725
726
  stroke-width: 4px;
726
727
  stroke-linejoin: round;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "Interactive Gantt Chart for React with TypeScript.",
5
5
  "author": "aguilanbon",
6
6
  "homepage": "https://github.com/aguilanbon/gantt-task-react-v",