@nocobase/plugin-gantt 2.1.0-beta.38 → 2.1.0-beta.40
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/client/index.js +1 -1
- package/dist/client-v2/793.629d4cd39664b681.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/locale.d.ts +6 -0
- package/dist/client-v2/models/GanttBlockModel.d.ts +1 -1
- package/dist/client-v2/models/components/GanttBlock.helpers.d.ts +8 -0
- package/dist/client-v2/models/components/GanttBlock.styles.d.ts +2 -1
- package/dist/client-v2/models/components/GanttBlock.tree.d.ts +9 -6
- package/dist/{shared → client-v2/shared}/components/grid/style.d.ts +4 -3
- package/dist/{shared → client-v2/shared}/components/other/horizontal-scroll.d.ts +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/locale/en-US.json +4 -1
- package/dist/locale/zh-CN.json +4 -1
- package/package.json +2 -2
- package/dist/client-v2/143.1a8cf1cd5ce17b64.js +0 -10
- package/dist/node_modules/@ctrl/tinycolor/LICENSE +0 -7
- package/dist/node_modules/@ctrl/tinycolor/dist/bundles/tinycolor.umd.min.js +0 -2
- package/dist/node_modules/@ctrl/tinycolor/dist/conversion.d.ts +0 -61
- package/dist/node_modules/@ctrl/tinycolor/dist/conversion.js +0 -250
- package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.d.ts +0 -4
- package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.js +0 -157
- package/dist/node_modules/@ctrl/tinycolor/dist/format-input.d.ts +0 -37
- package/dist/node_modules/@ctrl/tinycolor/dist/format-input.js +0 -189
- package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.d.ts +0 -14
- package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.js +0 -30
- package/dist/node_modules/@ctrl/tinycolor/dist/index.d.ts +0 -207
- package/dist/node_modules/@ctrl/tinycolor/dist/index.js +0 -512
- package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.d.ts +0 -46
- package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.js +0 -2
- package/dist/node_modules/@ctrl/tinycolor/dist/module/conversion.js +0 -235
- package/dist/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js +0 -154
- package/dist/node_modules/@ctrl/tinycolor/dist/module/format-input.js +0 -183
- package/dist/node_modules/@ctrl/tinycolor/dist/module/from-ratio.js +0 -25
- package/dist/node_modules/@ctrl/tinycolor/dist/module/index.js +0 -508
- package/dist/node_modules/@ctrl/tinycolor/dist/module/interfaces.js +0 -1
- package/dist/node_modules/@ctrl/tinycolor/dist/module/public_api.js +0 -12
- package/dist/node_modules/@ctrl/tinycolor/dist/module/random.js +0 -278
- package/dist/node_modules/@ctrl/tinycolor/dist/module/readability.js +0 -80
- package/dist/node_modules/@ctrl/tinycolor/dist/module/to-ms-filter.js +0 -16
- package/dist/node_modules/@ctrl/tinycolor/dist/module/umd_api.js +0 -20
- package/dist/node_modules/@ctrl/tinycolor/dist/module/util.js +0 -82
- package/dist/node_modules/@ctrl/tinycolor/dist/public_api.d.ts +0 -11
- package/dist/node_modules/@ctrl/tinycolor/dist/public_api.js +0 -1
- package/dist/node_modules/@ctrl/tinycolor/dist/random.d.ts +0 -24
- package/dist/node_modules/@ctrl/tinycolor/dist/random.js +0 -282
- package/dist/node_modules/@ctrl/tinycolor/dist/readability.d.ts +0 -46
- package/dist/node_modules/@ctrl/tinycolor/dist/readability.js +0 -86
- package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.d.ts +0 -5
- package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.js +0 -20
- package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.d.ts +0 -23
- package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.js +0 -22
- package/dist/node_modules/@ctrl/tinycolor/dist/util.d.ts +0 -36
- package/dist/node_modules/@ctrl/tinycolor/dist/util.js +0 -92
- package/dist/node_modules/@ctrl/tinycolor/package.json +0 -1
- package/dist/shared/components/calendar/calendar.js +0 -417
- package/dist/shared/components/calendar/style.js +0 -79
- package/dist/shared/components/calendar/top-part-of-calendar.js +0 -57
- package/dist/shared/components/gantt/style.js +0 -74
- package/dist/shared/components/gantt/task-gantt-content.js +0 -337
- package/dist/shared/components/gantt/task-gantt.js +0 -128
- package/dist/shared/components/grid/grid-body.js +0 -114
- package/dist/shared/components/grid/grid.js +0 -50
- package/dist/shared/components/grid/style.js +0 -54
- package/dist/shared/components/other/arrow.js +0 -90
- package/dist/shared/components/other/horizontal-scroll.js +0 -64
- package/dist/shared/components/other/style.js +0 -125
- package/dist/shared/components/other/tooltip.js +0 -137
- package/dist/shared/components/other/vertical-scroll.js +0 -74
- package/dist/shared/components/task-item/bar/bar-date-handle.js +0 -62
- package/dist/shared/components/task-item/bar/bar-display.js +0 -98
- package/dist/shared/components/task-item/bar/bar-progress-handle.js +0 -49
- package/dist/shared/components/task-item/bar/bar-small.js +0 -85
- package/dist/shared/components/task-item/bar/bar.js +0 -113
- package/dist/shared/components/task-item/bar/style.js +0 -58
- package/dist/shared/components/task-item/milestone/milestone.js +0 -72
- package/dist/shared/components/task-item/milestone/style.js +0 -45
- package/dist/shared/components/task-item/project/project.js +0 -77
- package/dist/shared/components/task-item/project/style.js +0 -51
- package/dist/shared/components/task-item/style.js +0 -74
- package/dist/shared/components/task-item/task-item.js +0 -132
- package/dist/shared/helpers/bar-helper.js +0 -415
- package/dist/shared/helpers/date-helper.js +0 -231
- package/dist/shared/helpers/other-helper.js +0 -97
- package/dist/shared/types/bar-task.js +0 -24
- package/dist/shared/types/date-setup.js +0 -24
- package/dist/shared/types/gantt-task-actions.js +0 -24
- package/dist/shared/types/public-types.js +0 -46
- /package/dist/{shared → client-v2/shared}/components/calendar/calendar.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/calendar/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/calendar/top-part-of-calendar.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/gantt/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/gantt/task-gantt-content.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/gantt/task-gantt.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/grid/grid-body.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/grid/grid.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/other/arrow.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/other/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/other/tooltip.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/other/vertical-scroll.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar-date-handle.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar-display.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar-progress-handle.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar-small.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/milestone/milestone.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/milestone/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/project/project.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/project/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/task-item.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/helpers/bar-helper.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/helpers/date-helper.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/helpers/other-helper.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/types/bar-task.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/types/date-setup.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/types/gantt-task-actions.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/types/public-types.d.ts +0 -0
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var task_item_exports = {};
|
|
38
|
-
__export(task_item_exports, {
|
|
39
|
-
TaskItem: () => TaskItem
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(task_item_exports);
|
|
42
|
-
var import_css = require("@emotion/css");
|
|
43
|
-
var import_react = __toESM(require("react"));
|
|
44
|
-
var import_other_helper = require("../../helpers/other-helper");
|
|
45
|
-
var import_bar = require("./bar/bar");
|
|
46
|
-
var import_bar_small = require("./bar/bar-small");
|
|
47
|
-
var import_milestone = require("./milestone/milestone");
|
|
48
|
-
var import_project = require("./project/project");
|
|
49
|
-
var import_style = __toESM(require("./style"));
|
|
50
|
-
const TaskItem = (props) => {
|
|
51
|
-
const { styles } = (0, import_style.default)();
|
|
52
|
-
const { task, arrowIndent, isDelete, taskHeight, rtl, onEventStart } = {
|
|
53
|
-
...props
|
|
54
|
-
};
|
|
55
|
-
const textRef = (0, import_react.useRef)(null);
|
|
56
|
-
const [isTextInside, setIsTextInside] = (0, import_react.useState)(true);
|
|
57
|
-
const isProjectBar = task.typeInternal === "project";
|
|
58
|
-
const renderTaskItem = () => {
|
|
59
|
-
switch (task.typeInternal) {
|
|
60
|
-
case "milestone":
|
|
61
|
-
return /* @__PURE__ */ import_react.default.createElement(import_milestone.Milestone, { ...props });
|
|
62
|
-
case "project":
|
|
63
|
-
return /* @__PURE__ */ import_react.default.createElement(import_project.Project, { ...props });
|
|
64
|
-
case "smalltask":
|
|
65
|
-
return /* @__PURE__ */ import_react.default.createElement(import_bar_small.BarSmall, { ...props });
|
|
66
|
-
default:
|
|
67
|
-
return /* @__PURE__ */ import_react.default.createElement(import_bar.Bar, { ...props });
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
(0, import_react.useEffect)(() => {
|
|
71
|
-
if (textRef.current) {
|
|
72
|
-
setIsTextInside(textRef.current.getBBox().width < task.x2 - task.x1);
|
|
73
|
-
}
|
|
74
|
-
}, [textRef, task]);
|
|
75
|
-
const getX = () => {
|
|
76
|
-
const width = task.x2 - task.x1;
|
|
77
|
-
const hasChild = task.barChildren.length > 0;
|
|
78
|
-
if (isTextInside) {
|
|
79
|
-
return task.x1 + width * 0.5;
|
|
80
|
-
}
|
|
81
|
-
if (rtl && textRef.current) {
|
|
82
|
-
return task.x1 - textRef.current.getBBox().width - arrowIndent * +hasChild - arrowIndent * 0.2;
|
|
83
|
-
} else {
|
|
84
|
-
return task.x1 + width + arrowIndent * +hasChild + arrowIndent * 0.2;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
88
|
-
"g",
|
|
89
|
-
{
|
|
90
|
-
className: (0, import_css.cx)(styles.nbganttTaskitem),
|
|
91
|
-
onKeyDown: (e) => {
|
|
92
|
-
switch (e.key) {
|
|
93
|
-
case "Delete": {
|
|
94
|
-
if (isDelete) onEventStart("delete", task, e);
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
e.stopPropagation();
|
|
99
|
-
},
|
|
100
|
-
onMouseEnter: (e) => {
|
|
101
|
-
onEventStart("mouseenter", task, e);
|
|
102
|
-
},
|
|
103
|
-
onMouseLeave: (e) => {
|
|
104
|
-
onEventStart("mouseleave", task, e);
|
|
105
|
-
},
|
|
106
|
-
onDoubleClick: (e) => {
|
|
107
|
-
onEventStart("dblclick", task, e);
|
|
108
|
-
},
|
|
109
|
-
onClick: (e) => {
|
|
110
|
-
onEventStart("click", task, e);
|
|
111
|
-
},
|
|
112
|
-
onFocus: () => {
|
|
113
|
-
onEventStart("select", task);
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
renderTaskItem(),
|
|
117
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
118
|
-
"text",
|
|
119
|
-
{
|
|
120
|
-
x: isProjectBar ? task.x1 : getX(),
|
|
121
|
-
y: isProjectBar ? task.y - 8 : isTextInside ? task.y + taskHeight * 0.65 : task.y + taskHeight * 0.65,
|
|
122
|
-
className: isProjectBar ? (0, import_css.cx)("projectLabel") : isTextInside ? (0, import_css.cx)("barLabel") : (0, import_css.cx)("barLabelOutside"),
|
|
123
|
-
ref: textRef
|
|
124
|
-
},
|
|
125
|
-
isProjectBar && (0, import_other_helper.getYmd)(task.start) && (0, import_other_helper.getYmd)(task.end) ? `${task.name}: ${(0, import_other_helper.getYmd)(task.start)} ~ ${(0, import_other_helper.getYmd)(task.end)}` : task.name
|
|
126
|
-
)
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
-
0 && (module.exports = {
|
|
131
|
-
TaskItem
|
|
132
|
-
});
|
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var bar_helper_exports = {};
|
|
28
|
-
__export(bar_helper_exports, {
|
|
29
|
-
convertToBarTasks: () => convertToBarTasks,
|
|
30
|
-
getProgressPoint: () => getProgressPoint,
|
|
31
|
-
handleTaskBySVGMouseEvent: () => handleTaskBySVGMouseEvent,
|
|
32
|
-
progressByProgressWidth: () => progressByProgressWidth,
|
|
33
|
-
progressWithByParams: () => progressWithByParams
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(bar_helper_exports);
|
|
36
|
-
const convertToBarTasks = (tasks, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor) => {
|
|
37
|
-
let barTasks = tasks.map((t, i) => {
|
|
38
|
-
return convertToBarTask(
|
|
39
|
-
t,
|
|
40
|
-
i,
|
|
41
|
-
dates,
|
|
42
|
-
columnWidth,
|
|
43
|
-
rowHeight,
|
|
44
|
-
taskHeight,
|
|
45
|
-
barCornerRadius,
|
|
46
|
-
handleWidth,
|
|
47
|
-
rtl,
|
|
48
|
-
barProgressColor,
|
|
49
|
-
barProgressSelectedColor,
|
|
50
|
-
barBackgroundColor,
|
|
51
|
-
barBackgroundSelectedColor,
|
|
52
|
-
projectProgressColor,
|
|
53
|
-
projectProgressSelectedColor,
|
|
54
|
-
projectBackgroundColor,
|
|
55
|
-
projectBackgroundSelectedColor,
|
|
56
|
-
milestoneBackgroundColor,
|
|
57
|
-
milestoneBackgroundSelectedColor
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
barTasks = barTasks.map((task) => {
|
|
61
|
-
const dependencies = task.dependencies || [];
|
|
62
|
-
for (let j = 0; j < dependencies.length; j++) {
|
|
63
|
-
const dependence = barTasks.findIndex((value) => value.id === dependencies[j]);
|
|
64
|
-
if (dependence !== -1) barTasks[dependence].barChildren.push(task);
|
|
65
|
-
}
|
|
66
|
-
return task;
|
|
67
|
-
});
|
|
68
|
-
return barTasks;
|
|
69
|
-
};
|
|
70
|
-
const convertToBarTask = (task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor) => {
|
|
71
|
-
let barTask;
|
|
72
|
-
switch (task.type) {
|
|
73
|
-
case "milestone":
|
|
74
|
-
barTask = convertToMilestone(
|
|
75
|
-
task,
|
|
76
|
-
index,
|
|
77
|
-
dates,
|
|
78
|
-
columnWidth,
|
|
79
|
-
rowHeight,
|
|
80
|
-
taskHeight,
|
|
81
|
-
barCornerRadius,
|
|
82
|
-
handleWidth,
|
|
83
|
-
milestoneBackgroundColor,
|
|
84
|
-
milestoneBackgroundSelectedColor
|
|
85
|
-
);
|
|
86
|
-
break;
|
|
87
|
-
case "project":
|
|
88
|
-
barTask = convertToBar(
|
|
89
|
-
task,
|
|
90
|
-
index,
|
|
91
|
-
dates,
|
|
92
|
-
columnWidth,
|
|
93
|
-
rowHeight,
|
|
94
|
-
taskHeight * 0.5,
|
|
95
|
-
barCornerRadius,
|
|
96
|
-
handleWidth,
|
|
97
|
-
rtl,
|
|
98
|
-
projectProgressColor,
|
|
99
|
-
projectProgressSelectedColor,
|
|
100
|
-
projectBackgroundColor,
|
|
101
|
-
projectBackgroundSelectedColor
|
|
102
|
-
);
|
|
103
|
-
break;
|
|
104
|
-
default:
|
|
105
|
-
barTask = convertToBar(
|
|
106
|
-
task,
|
|
107
|
-
index,
|
|
108
|
-
dates,
|
|
109
|
-
columnWidth,
|
|
110
|
-
rowHeight,
|
|
111
|
-
taskHeight,
|
|
112
|
-
barCornerRadius,
|
|
113
|
-
handleWidth,
|
|
114
|
-
rtl,
|
|
115
|
-
barProgressColor,
|
|
116
|
-
barProgressSelectedColor,
|
|
117
|
-
barBackgroundColor,
|
|
118
|
-
barBackgroundSelectedColor
|
|
119
|
-
);
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
return barTask;
|
|
123
|
-
};
|
|
124
|
-
const convertToBar = (task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor) => {
|
|
125
|
-
let x1;
|
|
126
|
-
let x2;
|
|
127
|
-
if (rtl) {
|
|
128
|
-
x2 = taskXCoordinateRTL(task.start, dates, columnWidth);
|
|
129
|
-
x1 = taskXCoordinateRTL(task.end, dates, columnWidth);
|
|
130
|
-
} else {
|
|
131
|
-
x1 = taskXCoordinate(task.start, dates, columnWidth);
|
|
132
|
-
x2 = taskXCoordinate(task.end, dates, columnWidth);
|
|
133
|
-
}
|
|
134
|
-
let typeInternal = task.type;
|
|
135
|
-
if (typeInternal === "task" && x2 - x1 < handleWidth * 2) {
|
|
136
|
-
typeInternal = "smalltask";
|
|
137
|
-
x2 = x1 > 0 ? x1 + handleWidth * 2 : x1;
|
|
138
|
-
}
|
|
139
|
-
const [progressWidth, progressX] = progressWithByParams(x1, x2, task.progress, rtl);
|
|
140
|
-
const y = task.type === "project" ? taskYCoordinate(index, rowHeight, taskHeight) + 8 : taskYCoordinate(index, rowHeight, taskHeight);
|
|
141
|
-
const hideChildren = task.type === "project" ? task.hideChildren : void 0;
|
|
142
|
-
const styles = {
|
|
143
|
-
backgroundColor: barBackgroundColor,
|
|
144
|
-
backgroundSelectedColor: barBackgroundSelectedColor,
|
|
145
|
-
progressColor: barProgressColor,
|
|
146
|
-
progressSelectedColor: barProgressSelectedColor,
|
|
147
|
-
...task.styles
|
|
148
|
-
};
|
|
149
|
-
return {
|
|
150
|
-
...task,
|
|
151
|
-
typeInternal,
|
|
152
|
-
x1,
|
|
153
|
-
x2,
|
|
154
|
-
y,
|
|
155
|
-
index,
|
|
156
|
-
progressX,
|
|
157
|
-
progressWidth,
|
|
158
|
-
barCornerRadius,
|
|
159
|
-
handleWidth,
|
|
160
|
-
hideChildren,
|
|
161
|
-
height: taskHeight,
|
|
162
|
-
barChildren: [],
|
|
163
|
-
styles
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
const convertToMilestone = (task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, milestoneBackgroundColor, milestoneBackgroundSelectedColor) => {
|
|
167
|
-
const x = taskXCoordinate(task.start, dates, columnWidth);
|
|
168
|
-
const y = taskYCoordinate(index, rowHeight, taskHeight);
|
|
169
|
-
const x1 = x - taskHeight * 0.5;
|
|
170
|
-
const x2 = x + taskHeight * 0.5;
|
|
171
|
-
const rotatedHeight = taskHeight / 1.414;
|
|
172
|
-
const styles = {
|
|
173
|
-
backgroundColor: milestoneBackgroundColor,
|
|
174
|
-
backgroundSelectedColor: milestoneBackgroundSelectedColor,
|
|
175
|
-
progressColor: "",
|
|
176
|
-
progressSelectedColor: "",
|
|
177
|
-
...task.styles
|
|
178
|
-
};
|
|
179
|
-
return {
|
|
180
|
-
...task,
|
|
181
|
-
end: task.start,
|
|
182
|
-
x1,
|
|
183
|
-
x2,
|
|
184
|
-
y,
|
|
185
|
-
index,
|
|
186
|
-
progressX: 0,
|
|
187
|
-
progressWidth: 0,
|
|
188
|
-
barCornerRadius,
|
|
189
|
-
handleWidth,
|
|
190
|
-
typeInternal: task.type,
|
|
191
|
-
progress: 0,
|
|
192
|
-
height: rotatedHeight,
|
|
193
|
-
hideChildren: void 0,
|
|
194
|
-
barChildren: [],
|
|
195
|
-
styles
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
const taskXCoordinate = (xDate, dates, columnWidth) => {
|
|
199
|
-
var _a, _b, _c;
|
|
200
|
-
const index = dates.findIndex((d) => (d == null ? void 0 : d.getTime()) >= (xDate == null ? void 0 : xDate.getTime())) - 1;
|
|
201
|
-
const remainderMillis = (xDate == null ? void 0 : xDate.getTime()) - ((_a = dates[index]) == null ? void 0 : _a.getTime());
|
|
202
|
-
const percentOfInterval = remainderMillis / (((_b = dates[index + 1]) == null ? void 0 : _b.getTime()) - ((_c = dates[index]) == null ? void 0 : _c.getTime()));
|
|
203
|
-
const x = index * columnWidth + percentOfInterval * columnWidth;
|
|
204
|
-
return isNaN(x) ? 0 : x;
|
|
205
|
-
};
|
|
206
|
-
const taskXCoordinateRTL = (xDate, dates, columnWidth) => {
|
|
207
|
-
let x = taskXCoordinate(xDate, dates, columnWidth);
|
|
208
|
-
x += columnWidth;
|
|
209
|
-
return isNaN(x) ? 0 : x;
|
|
210
|
-
};
|
|
211
|
-
const taskYCoordinate = (index, rowHeight, taskHeight) => {
|
|
212
|
-
const y = index * rowHeight + (rowHeight - taskHeight) / 2;
|
|
213
|
-
return isNaN(y) ? 0 : y;
|
|
214
|
-
};
|
|
215
|
-
const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
|
|
216
|
-
const progressWidth = (taskX2 - taskX1) * progress * 0.01;
|
|
217
|
-
let progressX;
|
|
218
|
-
if (rtl) {
|
|
219
|
-
progressX = taskX2 - progressWidth;
|
|
220
|
-
} else {
|
|
221
|
-
progressX = taskX1;
|
|
222
|
-
}
|
|
223
|
-
return [progressWidth, progressX];
|
|
224
|
-
};
|
|
225
|
-
const progressByProgressWidth = (progressWidth, barTask) => {
|
|
226
|
-
const barWidth = barTask.x2 - barTask.x1;
|
|
227
|
-
const progressPercent = Math.round(progressWidth * 100 / barWidth);
|
|
228
|
-
if (progressPercent >= 100) return 100;
|
|
229
|
-
else if (progressPercent <= 0) return 0;
|
|
230
|
-
else return progressPercent;
|
|
231
|
-
};
|
|
232
|
-
const progressByX = (x, task) => {
|
|
233
|
-
if (x >= task.x2) return 100;
|
|
234
|
-
else if (x <= task.x1) return 0;
|
|
235
|
-
else {
|
|
236
|
-
const barWidth = task.x2 - task.x1;
|
|
237
|
-
const progressPercent = Math.round((x - task.x1) * 100 / barWidth);
|
|
238
|
-
return progressPercent;
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
const progressByXRTL = (x, task) => {
|
|
242
|
-
if (x >= task.x2) return 0;
|
|
243
|
-
else if (x <= task.x1) return 100;
|
|
244
|
-
else {
|
|
245
|
-
const barWidth = task.x2 - task.x1;
|
|
246
|
-
const progressPercent = Math.round((task.x2 - x) * 100 / barWidth);
|
|
247
|
-
return progressPercent;
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
const getProgressPoint = (progressX, taskY, taskHeight) => {
|
|
251
|
-
const point = [
|
|
252
|
-
progressX - 5,
|
|
253
|
-
taskY + taskHeight,
|
|
254
|
-
progressX + 5,
|
|
255
|
-
taskY + taskHeight,
|
|
256
|
-
progressX,
|
|
257
|
-
taskY + taskHeight - 8.66
|
|
258
|
-
];
|
|
259
|
-
return point.join(",");
|
|
260
|
-
};
|
|
261
|
-
const startByX = (x, xStep, task) => {
|
|
262
|
-
if (x >= task.x2 - task.handleWidth * 2) {
|
|
263
|
-
x = task.x2 - task.handleWidth * 2;
|
|
264
|
-
}
|
|
265
|
-
const steps = Math.round((x - task.x1) / xStep);
|
|
266
|
-
const additionalXValue = steps * xStep;
|
|
267
|
-
const newX = task.x1 + additionalXValue;
|
|
268
|
-
return newX;
|
|
269
|
-
};
|
|
270
|
-
const endByX = (x, xStep, task) => {
|
|
271
|
-
if (x <= task.x1 + task.handleWidth * 2) {
|
|
272
|
-
x = task.x1 + task.handleWidth * 2;
|
|
273
|
-
}
|
|
274
|
-
const steps = Math.round((x - task.x2) / xStep);
|
|
275
|
-
const additionalXValue = steps * xStep;
|
|
276
|
-
const newX = task.x2 + additionalXValue;
|
|
277
|
-
return newX;
|
|
278
|
-
};
|
|
279
|
-
const moveByX = (x, xStep, task) => {
|
|
280
|
-
const steps = Math.round((x - task.x1) / xStep);
|
|
281
|
-
const additionalXValue = steps * xStep;
|
|
282
|
-
const newX1 = task.x1 + additionalXValue;
|
|
283
|
-
const newX2 = newX1 + task.x2 - task.x1;
|
|
284
|
-
return [newX1, newX2];
|
|
285
|
-
};
|
|
286
|
-
const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
|
|
287
|
-
var _a, _b;
|
|
288
|
-
let newDate = new Date((x - taskX) / xStep * timeStep + ((_a = taskDate == null ? void 0 : taskDate.getTime) == null ? void 0 : _a.call(taskDate)));
|
|
289
|
-
newDate = new Date(((_b = newDate == null ? void 0 : newDate.getTime) == null ? void 0 : _b.call(newDate)) + ((newDate == null ? void 0 : newDate.getTimezoneOffset()) - (taskDate == null ? void 0 : taskDate.getTimezoneOffset())) * 6e4);
|
|
290
|
-
return newDate;
|
|
291
|
-
};
|
|
292
|
-
const handleTaskBySVGMouseEvent = (svgX, action, selectedTask, xStep, timeStep, initEventX1Delta, rtl) => {
|
|
293
|
-
let result;
|
|
294
|
-
switch (selectedTask.type) {
|
|
295
|
-
case "milestone":
|
|
296
|
-
result = handleTaskBySVGMouseEventForMilestone(svgX, action, selectedTask, xStep, timeStep, initEventX1Delta);
|
|
297
|
-
break;
|
|
298
|
-
default:
|
|
299
|
-
result = handleTaskBySVGMouseEventForBar(svgX, action, selectedTask, xStep, timeStep, initEventX1Delta, rtl);
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
return result;
|
|
303
|
-
};
|
|
304
|
-
const handleTaskBySVGMouseEventForBar = (svgX, action, selectedTask, xStep, timeStep, initEventX1Delta, rtl) => {
|
|
305
|
-
const changedTask = { ...selectedTask };
|
|
306
|
-
let isChanged = false;
|
|
307
|
-
switch (action) {
|
|
308
|
-
case "progress":
|
|
309
|
-
if (rtl) {
|
|
310
|
-
changedTask.progress = progressByXRTL(svgX, selectedTask);
|
|
311
|
-
} else {
|
|
312
|
-
changedTask.progress = progressByX(svgX, selectedTask);
|
|
313
|
-
}
|
|
314
|
-
isChanged = changedTask.progress !== selectedTask.progress;
|
|
315
|
-
if (isChanged) {
|
|
316
|
-
const [progressWidth, progressX] = progressWithByParams(
|
|
317
|
-
changedTask.x1,
|
|
318
|
-
changedTask.x2,
|
|
319
|
-
changedTask.progress,
|
|
320
|
-
rtl
|
|
321
|
-
);
|
|
322
|
-
changedTask.progressWidth = progressWidth;
|
|
323
|
-
changedTask.progressX = progressX;
|
|
324
|
-
}
|
|
325
|
-
break;
|
|
326
|
-
case "start": {
|
|
327
|
-
const newX1 = startByX(svgX, xStep, selectedTask);
|
|
328
|
-
changedTask.x1 = newX1;
|
|
329
|
-
isChanged = changedTask.x1 !== selectedTask.x1;
|
|
330
|
-
if (isChanged) {
|
|
331
|
-
if (rtl) {
|
|
332
|
-
changedTask.end = dateByX(newX1, selectedTask.x1, selectedTask.end, xStep, timeStep);
|
|
333
|
-
} else {
|
|
334
|
-
changedTask.start = dateByX(newX1, selectedTask.x1, selectedTask.start, xStep, timeStep);
|
|
335
|
-
}
|
|
336
|
-
const [progressWidth, progressX] = progressWithByParams(
|
|
337
|
-
changedTask.x1,
|
|
338
|
-
changedTask.x2,
|
|
339
|
-
changedTask.progress,
|
|
340
|
-
rtl
|
|
341
|
-
);
|
|
342
|
-
changedTask.progressWidth = progressWidth;
|
|
343
|
-
changedTask.progressX = progressX;
|
|
344
|
-
}
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
case "end": {
|
|
348
|
-
const newX2 = endByX(svgX, xStep, selectedTask);
|
|
349
|
-
changedTask.x2 = newX2;
|
|
350
|
-
isChanged = changedTask.x2 !== selectedTask.x2;
|
|
351
|
-
if (isChanged) {
|
|
352
|
-
if (rtl) {
|
|
353
|
-
changedTask.start = dateByX(newX2, selectedTask.x2, selectedTask.start, xStep, timeStep);
|
|
354
|
-
} else {
|
|
355
|
-
changedTask.end = dateByX(newX2, selectedTask.x2, selectedTask.end, xStep, timeStep);
|
|
356
|
-
}
|
|
357
|
-
const [progressWidth, progressX] = progressWithByParams(
|
|
358
|
-
changedTask.x1,
|
|
359
|
-
changedTask.x2,
|
|
360
|
-
changedTask.progress,
|
|
361
|
-
rtl
|
|
362
|
-
);
|
|
363
|
-
changedTask.progressWidth = progressWidth;
|
|
364
|
-
changedTask.progressX = progressX;
|
|
365
|
-
}
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
case "move": {
|
|
369
|
-
const [newMoveX1, newMoveX2] = moveByX(svgX - initEventX1Delta, xStep, selectedTask);
|
|
370
|
-
isChanged = newMoveX1 !== selectedTask.x1;
|
|
371
|
-
if (isChanged) {
|
|
372
|
-
changedTask.start = dateByX(newMoveX1, selectedTask.x1, selectedTask.start, xStep, timeStep);
|
|
373
|
-
changedTask.end = dateByX(newMoveX2, selectedTask.x2, selectedTask.end, xStep, timeStep);
|
|
374
|
-
changedTask.x1 = newMoveX1;
|
|
375
|
-
changedTask.x2 = newMoveX2;
|
|
376
|
-
const [progressWidth, progressX] = progressWithByParams(
|
|
377
|
-
changedTask.x1,
|
|
378
|
-
changedTask.x2,
|
|
379
|
-
changedTask.progress,
|
|
380
|
-
rtl
|
|
381
|
-
);
|
|
382
|
-
changedTask.progressWidth = progressWidth;
|
|
383
|
-
changedTask.progressX = progressX;
|
|
384
|
-
}
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return { isChanged, changedTask };
|
|
389
|
-
};
|
|
390
|
-
const handleTaskBySVGMouseEventForMilestone = (svgX, action, selectedTask, xStep, timeStep, initEventX1Delta) => {
|
|
391
|
-
const changedTask = { ...selectedTask };
|
|
392
|
-
let isChanged = false;
|
|
393
|
-
switch (action) {
|
|
394
|
-
case "move": {
|
|
395
|
-
const [newMoveX1, newMoveX2] = moveByX(svgX - initEventX1Delta, xStep, selectedTask);
|
|
396
|
-
isChanged = newMoveX1 !== selectedTask.x1;
|
|
397
|
-
if (isChanged) {
|
|
398
|
-
changedTask.start = dateByX(newMoveX1, selectedTask.x1, selectedTask.start, xStep, timeStep);
|
|
399
|
-
changedTask.end = changedTask.start;
|
|
400
|
-
changedTask.x1 = newMoveX1;
|
|
401
|
-
changedTask.x2 = newMoveX2;
|
|
402
|
-
}
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
return { isChanged, changedTask };
|
|
407
|
-
};
|
|
408
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
409
|
-
0 && (module.exports = {
|
|
410
|
-
convertToBarTasks,
|
|
411
|
-
getProgressPoint,
|
|
412
|
-
handleTaskBySVGMouseEvent,
|
|
413
|
-
progressByProgressWidth,
|
|
414
|
-
progressWithByParams
|
|
415
|
-
});
|