gantt-task-react-v 1.1.11 → 1.1.13
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.
|
@@ -8,8 +8,6 @@ type ContextMenuProps = {
|
|
|
8
8
|
handleAction: (task: RenderTask, action: (meta: ActionMetaType) => void) => void;
|
|
9
9
|
handleCloseContextMenu: () => void;
|
|
10
10
|
options: ContextMenuOptionType[];
|
|
11
|
-
/** Optional callback invoked to select the task that opened the context menu (useful for task list) */
|
|
12
|
-
onSelectTask?: (taskId: string) => void;
|
|
13
11
|
/** Optional boundary element to contain the context menu (like tooltips) */
|
|
14
12
|
boundaryElement?: RefObject<HTMLElement>;
|
|
15
13
|
};
|
|
@@ -3,5 +3,5 @@ import { ContextMenuType, Task, RenderTask } from "../../types";
|
|
|
3
3
|
export declare const useContextMenu: (wrapperRef: RefObject<HTMLDivElement>, scrollToTask: (task: Task) => void) => {
|
|
4
4
|
contextMenu: ContextMenuType;
|
|
5
5
|
handleCloseContextMenu: () => void;
|
|
6
|
-
handleOpenContextMenu: (task: RenderTask, clientX: number, clientY: number) => void;
|
|
6
|
+
handleOpenContextMenu: (task: RenderTask, clientX: number, clientY: number, options?: readonly unknown[]) => void;
|
|
7
7
|
};
|
|
@@ -17968,11 +17968,14 @@ const useContextMenu = (wrapperRef, scrollToTask) => {
|
|
|
17968
17968
|
y: 0
|
|
17969
17969
|
});
|
|
17970
17970
|
const handleOpenContextMenu = useCallback(
|
|
17971
|
-
(task, clientX, clientY) => {
|
|
17971
|
+
(task, clientX, clientY, options) => {
|
|
17972
17972
|
const wrapperNode = wrapperRef.current;
|
|
17973
17973
|
if (!wrapperNode) {
|
|
17974
17974
|
return;
|
|
17975
17975
|
}
|
|
17976
|
+
if (options && options.length === 0) {
|
|
17977
|
+
return;
|
|
17978
|
+
}
|
|
17976
17979
|
const { top, left } = wrapperNode.getBoundingClientRect();
|
|
17977
17980
|
setContextMenu({
|
|
17978
17981
|
task,
|
|
@@ -18089,12 +18092,10 @@ function ContextMenu(props) {
|
|
|
18089
18092
|
}, [task, checkHasCopyTasks, checkHasCutTasks, options]);
|
|
18090
18093
|
const handleOptionAction = useCallback(
|
|
18091
18094
|
(option) => {
|
|
18092
|
-
var _a2;
|
|
18093
18095
|
handleCloseContextMenu();
|
|
18094
18096
|
if (!task) {
|
|
18095
18097
|
return;
|
|
18096
18098
|
}
|
|
18097
|
-
(_a2 = props.onSelectTask) == null ? void 0 : _a2.call(props, task.id);
|
|
18098
18099
|
handleAction(task, option.action);
|
|
18099
18100
|
},
|
|
18100
18101
|
[handleAction, handleCloseContextMenu, task]
|
|
@@ -19116,19 +19117,6 @@ const Gantt = (props) => {
|
|
|
19116
19117
|
[mapTaskToCoordinates, setScrollXProgrammatically]
|
|
19117
19118
|
);
|
|
19118
19119
|
const { contextMenu, handleCloseContextMenu, handleOpenContextMenu } = useContextMenu(wrapperRef, scrollToTask);
|
|
19119
|
-
const handleOpenContextMenuForRow = useCallback(
|
|
19120
|
-
(task, clientX, clientY) => {
|
|
19121
|
-
try {
|
|
19122
|
-
if (onRowContextMenu && task) {
|
|
19123
|
-
onRowContextMenu(task);
|
|
19124
|
-
}
|
|
19125
|
-
} catch (err) {
|
|
19126
|
-
console.error(err);
|
|
19127
|
-
}
|
|
19128
|
-
handleOpenContextMenu(task, clientX, clientY);
|
|
19129
|
-
},
|
|
19130
|
-
[onRowContextMenu, handleOpenContextMenu]
|
|
19131
|
-
);
|
|
19132
19120
|
const [ganttContextMenu, setGanttContextMenu] = useState({
|
|
19133
19121
|
task: null,
|
|
19134
19122
|
x: 0,
|
|
@@ -19945,6 +19933,22 @@ const Gantt = (props) => {
|
|
|
19945
19933
|
createDeleteOption(locale)
|
|
19946
19934
|
];
|
|
19947
19935
|
}, [taskList.contextMenuOptions, locale]);
|
|
19936
|
+
const handleOpenContextMenuForRow = useCallback(
|
|
19937
|
+
(task, clientX, clientY) => {
|
|
19938
|
+
try {
|
|
19939
|
+
if (onRowContextMenu && task) {
|
|
19940
|
+
onRowContextMenu(task);
|
|
19941
|
+
}
|
|
19942
|
+
} catch (err) {
|
|
19943
|
+
console.error(err);
|
|
19944
|
+
}
|
|
19945
|
+
if (task && task.type !== "empty") {
|
|
19946
|
+
selectTask(task.id);
|
|
19947
|
+
}
|
|
19948
|
+
handleOpenContextMenu(task, clientX, clientY, contextMenuOptions);
|
|
19949
|
+
},
|
|
19950
|
+
[onRowContextMenu, handleOpenContextMenu, selectTask, contextMenuOptions]
|
|
19951
|
+
);
|
|
19948
19952
|
const ganttContextMenuOptions = useMemo(() => {
|
|
19949
19953
|
if (taskBar.taskGanttContextMenuOption) {
|
|
19950
19954
|
return taskBar.taskGanttContextMenuOption;
|
|
@@ -20255,7 +20259,7 @@ const Gantt = (props) => {
|
|
|
20255
20259
|
verticalScrollbarRef
|
|
20256
20260
|
}
|
|
20257
20261
|
),
|
|
20258
|
-
taskList.enableTableListContextMenu && !waitCommitTasks && /* @__PURE__ */ jsx(
|
|
20262
|
+
taskList.enableTableListContextMenu && !waitCommitTasks && contextMenuOptions.length > 0 && /* @__PURE__ */ jsx(
|
|
20259
20263
|
ContextMenu,
|
|
20260
20264
|
{
|
|
20261
20265
|
checkHasCopyTasks,
|
|
@@ -20264,7 +20268,6 @@ const Gantt = (props) => {
|
|
|
20264
20268
|
distances,
|
|
20265
20269
|
handleAction,
|
|
20266
20270
|
handleCloseContextMenu,
|
|
20267
|
-
onSelectTask: selectTask,
|
|
20268
20271
|
options: contextMenuOptions,
|
|
20269
20272
|
boundaryElement: taskListHorizontalScrollRef
|
|
20270
20273
|
}
|
|
@@ -17985,11 +17985,14 @@
|
|
|
17985
17985
|
y: 0
|
|
17986
17986
|
});
|
|
17987
17987
|
const handleOpenContextMenu = React.useCallback(
|
|
17988
|
-
(task, clientX, clientY) => {
|
|
17988
|
+
(task, clientX, clientY, options) => {
|
|
17989
17989
|
const wrapperNode = wrapperRef.current;
|
|
17990
17990
|
if (!wrapperNode) {
|
|
17991
17991
|
return;
|
|
17992
17992
|
}
|
|
17993
|
+
if (options && options.length === 0) {
|
|
17994
|
+
return;
|
|
17995
|
+
}
|
|
17993
17996
|
const { top, left } = wrapperNode.getBoundingClientRect();
|
|
17994
17997
|
setContextMenu({
|
|
17995
17998
|
task,
|
|
@@ -18106,12 +18109,10 @@
|
|
|
18106
18109
|
}, [task, checkHasCopyTasks, checkHasCutTasks, options]);
|
|
18107
18110
|
const handleOptionAction = React.useCallback(
|
|
18108
18111
|
(option) => {
|
|
18109
|
-
var _a2;
|
|
18110
18112
|
handleCloseContextMenu();
|
|
18111
18113
|
if (!task) {
|
|
18112
18114
|
return;
|
|
18113
18115
|
}
|
|
18114
|
-
(_a2 = props.onSelectTask) == null ? void 0 : _a2.call(props, task.id);
|
|
18115
18116
|
handleAction(task, option.action);
|
|
18116
18117
|
},
|
|
18117
18118
|
[handleAction, handleCloseContextMenu, task]
|
|
@@ -19133,19 +19134,6 @@
|
|
|
19133
19134
|
[mapTaskToCoordinates, setScrollXProgrammatically]
|
|
19134
19135
|
);
|
|
19135
19136
|
const { contextMenu, handleCloseContextMenu, handleOpenContextMenu } = useContextMenu(wrapperRef, scrollToTask);
|
|
19136
|
-
const handleOpenContextMenuForRow = React.useCallback(
|
|
19137
|
-
(task, clientX, clientY) => {
|
|
19138
|
-
try {
|
|
19139
|
-
if (onRowContextMenu && task) {
|
|
19140
|
-
onRowContextMenu(task);
|
|
19141
|
-
}
|
|
19142
|
-
} catch (err) {
|
|
19143
|
-
console.error(err);
|
|
19144
|
-
}
|
|
19145
|
-
handleOpenContextMenu(task, clientX, clientY);
|
|
19146
|
-
},
|
|
19147
|
-
[onRowContextMenu, handleOpenContextMenu]
|
|
19148
|
-
);
|
|
19149
19137
|
const [ganttContextMenu, setGanttContextMenu] = React.useState({
|
|
19150
19138
|
task: null,
|
|
19151
19139
|
x: 0,
|
|
@@ -19962,6 +19950,22 @@
|
|
|
19962
19950
|
createDeleteOption(locale)
|
|
19963
19951
|
];
|
|
19964
19952
|
}, [taskList.contextMenuOptions, locale]);
|
|
19953
|
+
const handleOpenContextMenuForRow = React.useCallback(
|
|
19954
|
+
(task, clientX, clientY) => {
|
|
19955
|
+
try {
|
|
19956
|
+
if (onRowContextMenu && task) {
|
|
19957
|
+
onRowContextMenu(task);
|
|
19958
|
+
}
|
|
19959
|
+
} catch (err) {
|
|
19960
|
+
console.error(err);
|
|
19961
|
+
}
|
|
19962
|
+
if (task && task.type !== "empty") {
|
|
19963
|
+
selectTask(task.id);
|
|
19964
|
+
}
|
|
19965
|
+
handleOpenContextMenu(task, clientX, clientY, contextMenuOptions);
|
|
19966
|
+
},
|
|
19967
|
+
[onRowContextMenu, handleOpenContextMenu, selectTask, contextMenuOptions]
|
|
19968
|
+
);
|
|
19965
19969
|
const ganttContextMenuOptions = React.useMemo(() => {
|
|
19966
19970
|
if (taskBar.taskGanttContextMenuOption) {
|
|
19967
19971
|
return taskBar.taskGanttContextMenuOption;
|
|
@@ -20272,7 +20276,7 @@
|
|
|
20272
20276
|
verticalScrollbarRef
|
|
20273
20277
|
}
|
|
20274
20278
|
),
|
|
20275
|
-
taskList.enableTableListContextMenu && !waitCommitTasks && /* @__PURE__ */ jsxRuntime.jsx(
|
|
20279
|
+
taskList.enableTableListContextMenu && !waitCommitTasks && contextMenuOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
20276
20280
|
ContextMenu,
|
|
20277
20281
|
{
|
|
20278
20282
|
checkHasCopyTasks,
|
|
@@ -20281,7 +20285,6 @@
|
|
|
20281
20285
|
distances,
|
|
20282
20286
|
handleAction,
|
|
20283
20287
|
handleCloseContextMenu,
|
|
20284
|
-
onSelectTask: selectTask,
|
|
20285
20288
|
options: contextMenuOptions,
|
|
20286
20289
|
boundaryElement: taskListHorizontalScrollRef
|
|
20287
20290
|
}
|
package/package.json
CHANGED