gantt-task-react-v 1.6.14 → 1.6.16

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/README.md CHANGED
@@ -256,6 +256,33 @@ A slide-in panel for viewing task/arrow details with built-in "Go to" navigation
256
256
 
257
257
  The `goToTask(taskId)` function scrolls both horizontally and vertically to center the target task and selects it. Built-in "Go to" buttons also appear automatically in the drawer header for arrow-type panels and task-type panels.
258
258
 
259
+ ### Opening the drawer programmatically
260
+
261
+ Pass `openDrawerTaskId` inside the `drawer` prop to open the drawer for a specific task without any user interaction. When the value changes the drawer updates to show the new task.
262
+
263
+ ```tsx
264
+ const [inspect, setInspect] = useState<string | undefined>(undefined);
265
+
266
+ <Gantt
267
+ tasks={tasks}
268
+ drawer={{
269
+ enableDrawer: true,
270
+ openDrawerTaskId: inspect,
271
+ renderDrawerContent: data => {
272
+ if (data.type === "task") return <div>{data.task.name}</div>;
273
+ return null;
274
+ },
275
+ }}
276
+ />;
277
+
278
+ {
279
+ /* Open drawer for a specific task from anywhere in your UI */
280
+ }
281
+ <button onClick={() => setInspect("task-1")}>Inspect Task 1</button>;
282
+ ```
283
+
284
+ > **Note:** `openDrawerTaskId` is only honoured when `enableDrawer` is `true`.
285
+
259
286
  ## Scroll To Task
260
287
 
261
288
  Programmatically scroll to and select any task by id.
@@ -643,11 +670,12 @@ const tasks: Task[] = [
643
670
 
644
671
  ### GanttDrawerProps
645
672
 
646
- | Prop | Type | Default | Description |
647
- | --------------------- | --------------------- | ------- | ----------------------- |
648
- | `enableDrawer` | `boolean` | `false` | Enable drawer panel |
649
- | `drawerWidth` | `number` | `360` | Panel width in px |
650
- | `renderDrawerContent` | `RenderDrawerContent` | — | Custom content renderer |
673
+ | Prop | Type | Default | Description |
674
+ | --------------------- | --------------------- | ------- | ---------------------------------------------------------- |
675
+ | `enableDrawer` | `boolean` | `false` | Enable drawer panel |
676
+ | `drawerWidth` | `number` | `360` | Panel width in px |
677
+ | `renderDrawerContent` | `RenderDrawerContent` | — | Custom content renderer |
678
+ | `openDrawerTaskId` | `string` | — | Programmatically open the drawer for the task with this id |
651
679
 
652
680
  `RenderDrawerContent = (data: GanttDrawerData, goToTask: (taskId: string) => void) => ReactNode`
653
681
 
@@ -45,6 +45,7 @@ export interface TaskGanttContentProps extends GanttTaskBarActions {
45
45
  taskBarMovingAction: (task: RenderTask) => TaskBarMoveAction | null;
46
46
  viewMode: ViewMode;
47
47
  showProgress?: boolean;
48
+ hideProjectProgress?: boolean;
48
49
  progressColor?: string;
49
50
  }
50
51
  export declare const TaskGanttContent: React.NamedExoticComponent<TaskGanttContentProps>;
@@ -33,6 +33,7 @@ export interface TaskItemProps extends Omit<GanttTaskBarActions, "taskBarMovingA
33
33
  renderCustomLabel?: RenderCustomLabel;
34
34
  viewMode: ViewMode;
35
35
  showProgress?: boolean;
36
+ hideProjectProgress?: boolean;
36
37
  progressColor?: string;
37
38
  }
38
39
  export declare const TaskItem: React.NamedExoticComponent<TaskItemProps>;
@@ -5175,10 +5175,10 @@ const DEFAULT_THEME = {
5175
5175
  projectProgressSelectedColor: "#0097A7",
5176
5176
  projectProgressCriticalColor: "#00838F",
5177
5177
  projectProgressSelectedCriticalColor: "#006064",
5178
- projectBackgroundColor: "#FFA726",
5179
- projectBackgroundSelectedColor: "#F57C00",
5180
- projectBackgroundCriticalColor: "#EF6C00",
5181
- projectBackgroundSelectedCriticalColor: "#E65100",
5178
+ projectBackgroundColor: "#0A0A0A",
5179
+ projectBackgroundSelectedColor: "#1A1A1A",
5180
+ projectBackgroundCriticalColor: "#2A0000",
5181
+ projectBackgroundSelectedCriticalColor: "#3A0000",
5182
5182
  milestoneBackgroundColor: "#FF7043",
5183
5183
  milestoneBackgroundSelectedColor: "#E64A19",
5184
5184
  milestoneBackgroundCriticalColor: "#D84315",
@@ -12781,6 +12781,7 @@ const Bar = (props) => {
12781
12781
  movingAction,
12782
12782
  ganttRelationEvent,
12783
12783
  showProgress = true,
12784
+ hideProjectProgress = false,
12784
12785
  progressColor
12785
12786
  } = props;
12786
12787
  const isSmallWidth = useMemo(() => width < 30, [width]);
@@ -12848,7 +12849,7 @@ const Bar = (props) => {
12848
12849
  isCritical,
12849
12850
  hasChildren,
12850
12851
  startMoveFullTask,
12851
- showProgress,
12852
+ showProgress: hideProjectProgress ? false : showProgress,
12852
12853
  progressColor
12853
12854
  }
12854
12855
  );
@@ -13446,6 +13447,7 @@ const TaskGanttContentInner = (props) => {
13446
13447
  waitCommitTasks,
13447
13448
  viewMode,
13448
13449
  showProgress = true,
13450
+ hideProjectProgress = false,
13449
13451
  progressColor
13450
13452
  } = props;
13451
13453
  const renderedHolidays = useMemo(() => {
@@ -13616,6 +13618,7 @@ const TaskGanttContentInner = (props) => {
13616
13618
  renderCustomLabel,
13617
13619
  viewMode,
13618
13620
  showProgress,
13621
+ hideProjectProgress,
13619
13622
  progressColor
13620
13623
  }
13621
13624
  )
@@ -13976,6 +13979,7 @@ const TaskGanttContentInner = (props) => {
13976
13979
  activeArrowKey,
13977
13980
  activeTaskId,
13978
13981
  showProgress,
13982
+ hideProjectProgress,
13979
13983
  progressColor
13980
13984
  ]);
13981
13985
  return /* @__PURE__ */ jsxs("g", { className: "content", children: [
@@ -19784,6 +19788,7 @@ const Gantt = (props) => {
19784
19788
  todayLabel = "Today",
19785
19789
  dataDateLabel = "Data Date",
19786
19790
  showProgress = true,
19791
+ hideProjectProgress = false,
19787
19792
  progressColor,
19788
19793
  scrollToTaskId,
19789
19794
  drawer: drawerProps
@@ -19806,6 +19811,7 @@ const Gantt = (props) => {
19806
19811
  const enableDrawer = (drawerProps == null ? void 0 : drawerProps.enableDrawer) ?? false;
19807
19812
  const drawerWidth = (drawerProps == null ? void 0 : drawerProps.drawerWidth) ?? 360;
19808
19813
  const renderDrawerContent = drawerProps == null ? void 0 : drawerProps.renderDrawerContent;
19814
+ const openDrawerTaskId = drawerProps == null ? void 0 : drawerProps.openDrawerTaskId;
19809
19815
  const [drawerData, setDrawerData] = useState(null);
19810
19816
  const [activeArrowKey, setActiveArrowKey] = useState(null);
19811
19817
  const [activeTaskId, setActiveTaskId] = useState(null);
@@ -20138,6 +20144,24 @@ const Gantt = (props) => {
20138
20144
  setScrollYProgrammatically,
20139
20145
  selectTask
20140
20146
  ]);
20147
+ const prevOpenDrawerTaskIdRef = useRef(void 0);
20148
+ useEffect(() => {
20149
+ if (!enableDrawer || !openDrawerTaskId)
20150
+ return;
20151
+ if (openDrawerTaskId === prevOpenDrawerTaskIdRef.current)
20152
+ return;
20153
+ prevOpenDrawerTaskIdRef.current = openDrawerTaskId;
20154
+ for (const [, levelMap] of tasksMap) {
20155
+ const task = levelMap.get(openDrawerTaskId);
20156
+ if (!task || task.type === "empty")
20157
+ continue;
20158
+ setActiveArrowKey(null);
20159
+ setActiveTaskId(openDrawerTaskId);
20160
+ setDrawerData({ type: "task", task });
20161
+ selectTask(openDrawerTaskId);
20162
+ break;
20163
+ }
20164
+ }, [enableDrawer, openDrawerTaskId, tasksMap, selectTask]);
20141
20165
  const { contextMenu, handleCloseContextMenu, handleOpenContextMenu } = useContextMenu(wrapperRef, scrollToTask);
20142
20166
  const [ganttContextMenu, setGanttContextMenu] = useState({
20143
20167
  task: null,
@@ -21299,6 +21323,7 @@ const Gantt = (props) => {
21299
21323
  visibleTasksMirror,
21300
21324
  viewMode,
21301
21325
  showProgress,
21326
+ hideProjectProgress,
21302
21327
  progressColor
21303
21328
  }),
21304
21329
  [
@@ -21344,6 +21369,7 @@ const Gantt = (props) => {
21344
21369
  changeInProgress == null ? void 0 : changeInProgress.action,
21345
21370
  handleDeleteTasks,
21346
21371
  showProgress,
21372
+ hideProjectProgress,
21347
21373
  progressColor
21348
21374
  ]
21349
21375
  );
@@ -5192,10 +5192,10 @@
5192
5192
  projectProgressSelectedColor: "#0097A7",
5193
5193
  projectProgressCriticalColor: "#00838F",
5194
5194
  projectProgressSelectedCriticalColor: "#006064",
5195
- projectBackgroundColor: "#FFA726",
5196
- projectBackgroundSelectedColor: "#F57C00",
5197
- projectBackgroundCriticalColor: "#EF6C00",
5198
- projectBackgroundSelectedCriticalColor: "#E65100",
5195
+ projectBackgroundColor: "#0A0A0A",
5196
+ projectBackgroundSelectedColor: "#1A1A1A",
5197
+ projectBackgroundCriticalColor: "#2A0000",
5198
+ projectBackgroundSelectedCriticalColor: "#3A0000",
5199
5199
  milestoneBackgroundColor: "#FF7043",
5200
5200
  milestoneBackgroundSelectedColor: "#E64A19",
5201
5201
  milestoneBackgroundCriticalColor: "#D84315",
@@ -12798,6 +12798,7 @@
12798
12798
  movingAction,
12799
12799
  ganttRelationEvent,
12800
12800
  showProgress = true,
12801
+ hideProjectProgress = false,
12801
12802
  progressColor
12802
12803
  } = props;
12803
12804
  const isSmallWidth = React.useMemo(() => width < 30, [width]);
@@ -12865,7 +12866,7 @@
12865
12866
  isCritical,
12866
12867
  hasChildren,
12867
12868
  startMoveFullTask,
12868
- showProgress,
12869
+ showProgress: hideProjectProgress ? false : showProgress,
12869
12870
  progressColor
12870
12871
  }
12871
12872
  );
@@ -13463,6 +13464,7 @@
13463
13464
  waitCommitTasks,
13464
13465
  viewMode,
13465
13466
  showProgress = true,
13467
+ hideProjectProgress = false,
13466
13468
  progressColor
13467
13469
  } = props;
13468
13470
  const renderedHolidays = React.useMemo(() => {
@@ -13633,6 +13635,7 @@
13633
13635
  renderCustomLabel,
13634
13636
  viewMode,
13635
13637
  showProgress,
13638
+ hideProjectProgress,
13636
13639
  progressColor
13637
13640
  }
13638
13641
  )
@@ -13993,6 +13996,7 @@
13993
13996
  activeArrowKey,
13994
13997
  activeTaskId,
13995
13998
  showProgress,
13999
+ hideProjectProgress,
13996
14000
  progressColor
13997
14001
  ]);
13998
14002
  return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "content", children: [
@@ -19801,6 +19805,7 @@
19801
19805
  todayLabel = "Today",
19802
19806
  dataDateLabel = "Data Date",
19803
19807
  showProgress = true,
19808
+ hideProjectProgress = false,
19804
19809
  progressColor,
19805
19810
  scrollToTaskId,
19806
19811
  drawer: drawerProps
@@ -19823,6 +19828,7 @@
19823
19828
  const enableDrawer = (drawerProps == null ? void 0 : drawerProps.enableDrawer) ?? false;
19824
19829
  const drawerWidth = (drawerProps == null ? void 0 : drawerProps.drawerWidth) ?? 360;
19825
19830
  const renderDrawerContent = drawerProps == null ? void 0 : drawerProps.renderDrawerContent;
19831
+ const openDrawerTaskId = drawerProps == null ? void 0 : drawerProps.openDrawerTaskId;
19826
19832
  const [drawerData, setDrawerData] = React.useState(null);
19827
19833
  const [activeArrowKey, setActiveArrowKey] = React.useState(null);
19828
19834
  const [activeTaskId, setActiveTaskId] = React.useState(null);
@@ -20155,6 +20161,24 @@
20155
20161
  setScrollYProgrammatically,
20156
20162
  selectTask
20157
20163
  ]);
20164
+ const prevOpenDrawerTaskIdRef = React.useRef(void 0);
20165
+ React.useEffect(() => {
20166
+ if (!enableDrawer || !openDrawerTaskId)
20167
+ return;
20168
+ if (openDrawerTaskId === prevOpenDrawerTaskIdRef.current)
20169
+ return;
20170
+ prevOpenDrawerTaskIdRef.current = openDrawerTaskId;
20171
+ for (const [, levelMap] of tasksMap) {
20172
+ const task = levelMap.get(openDrawerTaskId);
20173
+ if (!task || task.type === "empty")
20174
+ continue;
20175
+ setActiveArrowKey(null);
20176
+ setActiveTaskId(openDrawerTaskId);
20177
+ setDrawerData({ type: "task", task });
20178
+ selectTask(openDrawerTaskId);
20179
+ break;
20180
+ }
20181
+ }, [enableDrawer, openDrawerTaskId, tasksMap, selectTask]);
20158
20182
  const { contextMenu, handleCloseContextMenu, handleOpenContextMenu } = useContextMenu(wrapperRef, scrollToTask);
20159
20183
  const [ganttContextMenu, setGanttContextMenu] = React.useState({
20160
20184
  task: null,
@@ -21316,6 +21340,7 @@
21316
21340
  visibleTasksMirror,
21317
21341
  viewMode,
21318
21342
  showProgress,
21343
+ hideProjectProgress,
21319
21344
  progressColor
21320
21345
  }),
21321
21346
  [
@@ -21361,6 +21386,7 @@
21361
21386
  changeInProgress == null ? void 0 : changeInProgress.action,
21362
21387
  handleDeleteTasks,
21363
21388
  showProgress,
21389
+ hideProjectProgress,
21364
21390
  progressColor
21365
21391
  ]
21366
21392
  );
@@ -24,6 +24,12 @@ export interface GanttDrawerProps {
24
24
  * Render function for custom drawer content
25
25
  */
26
26
  renderDrawerContent?: RenderDrawerContent;
27
+ /**
28
+ * When set (or changed), the drawer will open and display the details of the
29
+ * task with this id. Requires `enableDrawer: true`.
30
+ * Set to `undefined` or change to a new id to control the drawer imperatively.
31
+ */
32
+ openDrawerTaskId?: string;
27
33
  }
28
34
  export type RenderTopHeader = (date: Date, viewMode: ViewMode, dateSetup: DateSetup) => ReactNode;
29
35
  export type RenderCustomLabel = (task: RenderTask, x1: number, width: number, taskHeight: number, arrowIndent: number, taskYOffset: number, movingAction: TaskBarMoveAction | null, viewMode: ViewMode, rtl?: boolean) => ReactNode;
@@ -407,6 +413,10 @@ export interface GanttProps {
407
413
  * Show/hide progress bar on task bars. Defaults to true.
408
414
  */
409
415
  showProgress?: boolean;
416
+ /**
417
+ * Hide the progress bar specifically on project type task bars. Defaults to false.
418
+ */
419
+ hideProjectProgress?: boolean;
410
420
  /**
411
421
  * Custom color for progress bars. If not provided, theme progress colors are used.
412
422
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.6.14",
3
+ "version": "1.6.16",
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",