@visactor/vtable-gantt
Version:
canvas table width high performance
678 lines (645 loc) • 53.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.initProjectTaskTimes = exports.checkHasChildTasks = exports.judgeIfHasMarkLine = exports.getNodeClickPos = exports._getTaskInfoByXYForCreateSchedule = exports.updateOptionsWhenMarkLineChanged = exports.updateOptionsWhenDateRangeChanged = exports.updateOptionsWhenRecordChanged = exports.formatRecordDateConsiderHasHour = exports.getSubTaskRowIndexByRecordDate = exports.computeRowsCountByRecordDate = exports.computeRowsCountByRecordDateForCompact = exports.getTaskIndexsByTaskY = exports.clearRecordShowIndex = exports.clearRecordLinkInfos = exports.findRecordByTaskKey = exports.updateSplitLineAndResizeLine = exports.createSplitLineAndResizeLine = exports.convertProgress = exports.getTextPos = exports.generateTimeLineDate = exports.updateOptionsWhenScaleChanged = exports.initOptions = exports.isNode = exports.getVerticalScrollBarSize = exports.getHorizontalScrollBarSize = exports.generateMarkLine = exports.getDateIndexByX = exports.DayTimes = exports.defaultTaskBarStyle = void 0;
const ts_types_1 = require("./ts-types"), util_1 = require("./tools/util");
function setWidthToDefaultTaskBarStyle(width) {
exports.defaultTaskBarStyle.width = width;
}
exports.defaultTaskBarStyle = {
barColor: "blue",
completedBarColor: "gray",
width: 30,
cornerRadius: 3,
borderWidth: 0,
fontFamily: "Arial",
fontSize: 14
};
const isNode = "undefined" == typeof window || void 0 === window.window;
function getDateIndexByX(x, gantt) {
const totalX = x + gantt.stateManager.scroll.horizontalBarPos, firstDateColWidth = gantt.getDateColWidth(0);
return Math.floor((totalX - firstDateColWidth) / gantt.parsedOptions.timelineColWidth) + 1;
}
function generateMarkLine(markLine) {
var _a, _b, _c, _d, _e;
return markLine ? !0 === markLine ? [ {
date: (0, util_1.createDateAtMidnight)().toLocaleDateString(),
content: "",
scrollToMarkLine: !0,
position: "left",
style: {
lineColor: "red",
lineWidth: 1
}
} ] : Array.isArray(markLine) ? markLine.map(((item, index) => {
var _a, _b, _c, _d;
return Object.assign(Object.assign({}, item), {
date: item.date,
scrollToMarkLine: item.scrollToMarkLine,
position: null !== (_a = item.position) && void 0 !== _a ? _a : "left",
style: {
lineColor: (null === (_b = item.style) || void 0 === _b ? void 0 : _b.lineColor) || "red",
lineWidth: (null === (_c = item.style) || void 0 === _c ? void 0 : _c.lineWidth) || 1,
lineDash: null === (_d = item.style) || void 0 === _d ? void 0 : _d.lineDash
}
});
})) : [ Object.assign(Object.assign({}, markLine), {
date: markLine.date,
scrollToMarkLine: null === (_a = markLine.scrollToMarkLine) || void 0 === _a || _a,
position: null !== (_b = markLine.position) && void 0 !== _b ? _b : "left",
style: {
lineColor: (null === (_c = markLine.style) || void 0 === _c ? void 0 : _c.lineColor) || "red",
lineWidth: (null === (_d = markLine.style) || void 0 === _d ? void 0 : _d.lineWidth) || 1,
lineDash: null === (_e = markLine.style) || void 0 === _e ? void 0 : _e.lineDash
}
}) ] : [];
}
function getHorizontalScrollBarSize(scrollStyle) {
var _a;
return (null == scrollStyle ? void 0 : scrollStyle.hoverOn) || (null == scrollStyle ? void 0 : scrollStyle.horizontalVisible) && "none" === (null == scrollStyle ? void 0 : scrollStyle.horizontalVisible) || !(null == scrollStyle ? void 0 : scrollStyle.horizontalVisible) && "none" === (null == scrollStyle ? void 0 : scrollStyle.visible) ? 0 : null !== (_a = null == scrollStyle ? void 0 : scrollStyle.width) && void 0 !== _a ? _a : 7;
}
function getVerticalScrollBarSize(scrollStyle) {
var _a;
return (null == scrollStyle ? void 0 : scrollStyle.hoverOn) || (null == scrollStyle ? void 0 : scrollStyle.verticalVisible) && "none" === (null == scrollStyle ? void 0 : scrollStyle.verticalVisible) || !(null == scrollStyle ? void 0 : scrollStyle.verticalVisible) && "none" === (null == scrollStyle ? void 0 : scrollStyle.visible) ? 0 : null !== (_a = null == scrollStyle ? void 0 : scrollStyle.width) && void 0 !== _a ? _a : 7;
}
function initOptions(gantt) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85;
const options = gantt.options;
gantt.parsedOptions.tasksShowMode = null !== (_a = null == options ? void 0 : options.tasksShowMode) && void 0 !== _a ? _a : ts_types_1.TasksShowMode.Tasks_Separate,
gantt.parsedOptions.pixelRatio = null !== (_b = null == options ? void 0 : options.pixelRatio) && void 0 !== _b ? _b : 1,
gantt.parsedOptions.rowHeight = null !== (_c = null == options ? void 0 : options.rowHeight) && void 0 !== _c ? _c : 40,
gantt.parsedOptions.timelineColWidth = null !== (_e = null === (_d = null == options ? void 0 : options.timelineHeader) || void 0 === _d ? void 0 : _d.colWidth) && void 0 !== _e ? _e : 60,
gantt.parsedOptions.startDateField = null !== (_g = null === (_f = options.taskBar) || void 0 === _f ? void 0 : _f.startDateField) && void 0 !== _g ? _g : "startDate",
gantt.parsedOptions.endDateField = null !== (_j = null === (_h = options.taskBar) || void 0 === _h ? void 0 : _h.endDateField) && void 0 !== _j ? _j : "endDate",
gantt.parsedOptions.progressField = null !== (_l = null === (_k = options.taskBar) || void 0 === _k ? void 0 : _k.progressField) && void 0 !== _l ? _l : "progress",
gantt.parsedOptions.projectSubTasksExpandable = null === (_m = null == options ? void 0 : options.projectSubTasksExpandable) || void 0 === _m || _m;
const {unit: minTimeUnit, startOfWeek: startOfWeek, step: step} = gantt.parsedOptions.reverseSortedTimelineScales[0];
gantt.parsedOptions.minDate = (null == options ? void 0 : options.minDate) ? (0,
util_1.getStartDateByTimeUnit)(new Date(options.minDate), minTimeUnit, startOfWeek) : void 0,
gantt.parsedOptions.maxDate = (null == options ? void 0 : options.maxDate) && (null === (_o = gantt.parsedOptions) || void 0 === _o ? void 0 : _o.minDate) ? (0,
util_1.getEndDateByTimeUnit)(null === (_p = gantt.parsedOptions) || void 0 === _p ? void 0 : _p.minDate, new Date(options.maxDate), minTimeUnit, step) : void 0,
gantt.parsedOptions._minDateTime = null === (_q = gantt.parsedOptions.minDate) || void 0 === _q ? void 0 : _q.getTime(),
gantt.parsedOptions._maxDateTime = null === (_r = gantt.parsedOptions.maxDate) || void 0 === _r ? void 0 : _r.getTime(),
gantt.parsedOptions.overscrollBehavior = null !== (_s = null == options ? void 0 : options.overscrollBehavior) && void 0 !== _s ? _s : "auto",
gantt.parsedOptions.underlayBackgroundColor = null !== (_t = null == options ? void 0 : options.underlayBackgroundColor) && void 0 !== _t ? _t : "#FFF",
gantt.parsedOptions.scrollStyle = Object.assign({}, {
scrollRailColor: "rgba(100, 100, 100, 0.2)",
scrollSliderColor: "rgba(100, 100, 100, 0.5)",
scrollSliderCornerRadius: 4,
width: 10,
visible: "always",
hoverOn: !0,
barToSide: !1
}, null == options ? void 0 : options.scrollStyle), gantt.parsedOptions.timelineHeaderHorizontalLineStyle = null === (_u = null == options ? void 0 : options.timelineHeader) || void 0 === _u ? void 0 : _u.horizontalLine,
gantt.parsedOptions.timelineHeaderVerticalLineStyle = null === (_v = null == options ? void 0 : options.timelineHeader) || void 0 === _v ? void 0 : _v.verticalLine,
gantt.parsedOptions.timelineHeaderBackgroundColor = null === (_w = null == options ? void 0 : options.timelineHeader) || void 0 === _w ? void 0 : _w.backgroundColor,
gantt.parsedOptions.timeLineHeaderRowHeights = [], gantt.parsedOptions.timelineHeaderStyles = [];
for (let i = 0; i < gantt.parsedOptions.sortedTimelineScales.length; i++) {
const style = gantt.parsedOptions.sortedTimelineScales[i].style;
gantt.parsedOptions.timelineHeaderStyles.push(Object.assign({
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
textBaseline: "middle",
color: "#000",
backgroundColor: "#fff"
}, style)), gantt.parsedOptions.timeLineHeaderRowHeights.push(null !== (_y = null !== (_x = gantt.parsedOptions.sortedTimelineScales[i].rowHeight) && void 0 !== _x ? _x : null == options ? void 0 : options.headerRowHeight) && void 0 !== _y ? _y : 40);
}
gantt.parsedOptions.grid = Object.assign({}, null == options ? void 0 : options.grid),
setWidthToDefaultTaskBarStyle(3 * gantt.parsedOptions.rowHeight / 4), gantt.parsedOptions.taskBarStyle = (null === (_z = null == options ? void 0 : options.taskBar) || void 0 === _z ? void 0 : _z.barStyle) && "function" == typeof (null === (_0 = null == options ? void 0 : options.taskBar) || void 0 === _0 ? void 0 : _0.barStyle) ? options.taskBar.barStyle : Object.assign({}, exports.defaultTaskBarStyle, null === (_1 = null == options ? void 0 : options.taskBar) || void 0 === _1 ? void 0 : _1.barStyle),
gantt.parsedOptions.projectBarStyle = (null === (_2 = null == options ? void 0 : options.taskBar) || void 0 === _2 ? void 0 : _2.projectStyle) && "function" == typeof (null === (_3 = null == options ? void 0 : options.taskBar) || void 0 === _3 ? void 0 : _3.projectStyle) ? options.taskBar.projectStyle : (null === (_4 = null == options ? void 0 : options.taskBar) || void 0 === _4 ? void 0 : _4.projectStyle) ? Object.assign({}, exports.defaultTaskBarStyle, null === (_5 = null == options ? void 0 : options.taskBar) || void 0 === _5 ? void 0 : _5.projectStyle) : gantt.parsedOptions.taskBarStyle;
gantt.parsedOptions.taskBarMilestoneStyle = Object.assign("function" == typeof gantt.parsedOptions.taskBarStyle ? {} : {
width: gantt.parsedOptions.taskBarStyle.width,
borderColor: gantt.parsedOptions.taskBarStyle.borderColor,
borderLineWidth: null !== (_6 = gantt.parsedOptions.taskBarStyle.borderLineWidth) && void 0 !== _6 ? _6 : 1,
fillColor: gantt.parsedOptions.taskBarStyle.barColor,
cornerRadius: 0
}, {
labelTextStyle: {
fontSize: 16,
color: "red",
fontFamily: "Arial",
padding: 4
}
}, null === (_7 = null == options ? void 0 : options.taskBar) || void 0 === _7 ? void 0 : _7.milestoneStyle),
gantt.parsedOptions.taskBarMilestoneHypotenuse = gantt.parsedOptions.taskBarMilestoneStyle.width * Math.sqrt(2),
gantt.parsedOptions.dateFormat = null == options ? void 0 : options.dateFormat,
gantt.parsedOptions.taskBarHoverStyle = Object.assign({
barOverlayColor: "rgba(99, 144, 0, 0.4)"
}, null === (_8 = null == options ? void 0 : options.taskBar) || void 0 === _8 ? void 0 : _8.hoverBarStyle),
gantt.parsedOptions.taskBarSelectable = null === (_10 = null === (_9 = null == options ? void 0 : options.taskBar) || void 0 === _9 ? void 0 : _9.selectable) || void 0 === _10 || _10,
gantt.parsedOptions.taskBarSelectedStyle = Object.assign("function" == typeof gantt.parsedOptions.taskBarStyle ? {
shadowBlur: 6,
shadowOffsetX: 0,
shadowOffsetY: 0,
borderLineWidth: 1
} : {
shadowBlur: 6,
shadowOffsetX: 0,
shadowOffsetY: 0,
shadowColor: gantt.parsedOptions.taskBarStyle.barColor,
borderColor: gantt.parsedOptions.taskBarStyle.barColor,
borderLineWidth: 1
}, null === (_11 = null == options ? void 0 : options.taskBar) || void 0 === _11 ? void 0 : _11.selectedBarStyle),
gantt.parsedOptions.taskBarLabelText = null !== (_13 = null === (_12 = null == options ? void 0 : options.taskBar) || void 0 === _12 ? void 0 : _12.labelText) && void 0 !== _13 ? _13 : "",
gantt.parsedOptions.taskBarMoveable = null === (_15 = null === (_14 = null == options ? void 0 : options.taskBar) || void 0 === _14 ? void 0 : _14.moveable) || void 0 === _15 || _15,
gantt.parsedOptions.moveTaskBarToExtendDateRange = null === (_17 = null === (_16 = null == options ? void 0 : options.taskBar) || void 0 === _16 ? void 0 : _16.moveToExtendDateRange) || void 0 === _17 || _17,
gantt.parsedOptions.taskBarResizable = null === (_19 = null === (_18 = null == options ? void 0 : options.taskBar) || void 0 === _18 ? void 0 : _18.resizable) || void 0 === _19 || _19,
gantt.parsedOptions.taskBarDragOrder = null === (_21 = null === (_20 = null == options ? void 0 : options.taskBar) || void 0 === _20 ? void 0 : _20.dragOrder) || void 0 === _21 || _21,
gantt.parsedOptions.taskBarLabelStyle = {
fontFamily: null !== (_24 = null === (_23 = null === (_22 = null == options ? void 0 : options.taskBar) || void 0 === _22 ? void 0 : _22.labelTextStyle) || void 0 === _23 ? void 0 : _23.fontFamily) && void 0 !== _24 ? _24 : "Arial",
fontSize: null !== (_27 = null === (_26 = null === (_25 = null == options ? void 0 : options.taskBar) || void 0 === _25 ? void 0 : _25.labelTextStyle) || void 0 === _26 ? void 0 : _26.fontSize) && void 0 !== _27 ? _27 : 20,
color: null !== (_30 = null === (_29 = null === (_28 = null == options ? void 0 : options.taskBar) || void 0 === _28 ? void 0 : _28.labelTextStyle) || void 0 === _29 ? void 0 : _29.color) && void 0 !== _30 ? _30 : "#F01",
outsideColor: null !== (_33 = null === (_32 = null === (_31 = null == options ? void 0 : options.taskBar) || void 0 === _31 ? void 0 : _31.labelTextStyle) || void 0 === _32 ? void 0 : _32.outsideColor) && void 0 !== _33 ? _33 : "#333333",
textAlign: null !== (_36 = null === (_35 = null === (_34 = null == options ? void 0 : options.taskBar) || void 0 === _34 ? void 0 : _34.labelTextStyle) || void 0 === _35 ? void 0 : _35.textAlign) && void 0 !== _36 ? _36 : "left",
textBaseline: null !== (_39 = null === (_38 = null === (_37 = null == options ? void 0 : options.taskBar) || void 0 === _37 ? void 0 : _37.labelTextStyle) || void 0 === _38 ? void 0 : _38.textBaseline) && void 0 !== _39 ? _39 : "middle",
padding: null !== (_42 = null === (_41 = null === (_40 = null == options ? void 0 : options.taskBar) || void 0 === _40 ? void 0 : _40.labelTextStyle) || void 0 === _41 ? void 0 : _41.padding) && void 0 !== _42 ? _42 : [ 0, 0, 0, 10 ],
textOverflow: null === (_44 = null === (_43 = null == options ? void 0 : options.taskBar) || void 0 === _43 ? void 0 : _43.labelTextStyle) || void 0 === _44 ? void 0 : _44.textOverflow,
orient: null === (_46 = null === (_45 = null == options ? void 0 : options.taskBar) || void 0 === _45 ? void 0 : _45.labelTextStyle) || void 0 === _46 ? void 0 : _46.orient,
orientHandleWithOverflow: null === (_48 = null === (_47 = null == options ? void 0 : options.taskBar) || void 0 === _47 ? void 0 : _47.labelTextStyle) || void 0 === _48 ? void 0 : _48.orientHandleWithOverflow
}, gantt.parsedOptions.taskBarCustomLayout = null === (_49 = null == options ? void 0 : options.taskBar) || void 0 === _49 ? void 0 : _49.customLayout,
gantt.parsedOptions.taskBarCreatable = null !== (_51 = null === (_50 = null == options ? void 0 : options.taskBar) || void 0 === _50 ? void 0 : _50.scheduleCreatable) && void 0 !== _51 ? _51 : !(gantt.parsedOptions.tasksShowMode !== ts_types_1.TasksShowMode.Sub_Tasks_Separate && gantt.parsedOptions.tasksShowMode !== ts_types_1.TasksShowMode.Tasks_Separate),
gantt.parsedOptions.taskBarCreationButtonStyle = Object.assign({
lineColor: "rgb(99, 144, 0)",
lineWidth: 1,
lineDash: [ 5, 5 ],
cornerRadius: 4,
backgroundColor: "#FFF"
}, null === (_53 = null === (_52 = null == options ? void 0 : options.taskBar) || void 0 === _52 ? void 0 : _52.scheduleCreation) || void 0 === _53 ? void 0 : _53.buttonStyle),
gantt.parsedOptions.taskBarCreationCustomLayout = null === (_55 = null === (_54 = null == options ? void 0 : options.taskBar) || void 0 === _54 ? void 0 : _54.scheduleCreation) || void 0 === _55 ? void 0 : _55.customLayout,
gantt.parsedOptions.taskBarCreationMaxWidth = null === (_57 = null === (_56 = null == options ? void 0 : options.taskBar) || void 0 === _56 ? void 0 : _56.scheduleCreation) || void 0 === _57 ? void 0 : _57.maxWidth,
gantt.parsedOptions.taskBarCreationMinWidth = null === (_59 = null === (_58 = null == options ? void 0 : options.taskBar) || void 0 === _58 ? void 0 : _58.scheduleCreation) || void 0 === _59 ? void 0 : _59.minWidth,
gantt.parsedOptions.outerFrameStyle = Object.assign({
borderColor: "#e1e4e8",
borderLineWidth: 1,
cornerRadius: 4
}, null === (_60 = options.frame) || void 0 === _60 ? void 0 : _60.outerFrameStyle),
gantt.parsedOptions.markLine = generateMarkLine(null == options ? void 0 : options.markLine),
null !== (_62 = null === (_61 = gantt.parsedOptions.markLine) || void 0 === _61 ? void 0 : _61.length) && void 0 !== _62 && _62 && ((null === (_63 = gantt.parsedOptions.markLine) || void 0 === _63 ? void 0 : _63.every((item => void 0 === item.scrollToMarkLine))) && (gantt.parsedOptions.markLine[0].scrollToMarkLine = !0),
(null === (_64 = gantt.parsedOptions.markLine) || void 0 === _64 ? void 0 : _64.find((item => item.scrollToMarkLine))) && (gantt.parsedOptions.scrollToMarkLineDate = (0,
util_1.getStartDateByTimeUnit)(new Date(null === (_65 = gantt.parsedOptions.markLine) || void 0 === _65 ? void 0 : _65.find((item => item.scrollToMarkLine)).date), minTimeUnit, startOfWeek))),
gantt.parsedOptions.verticalSplitLineHighlight = null === (_66 = options.frame) || void 0 === _66 ? void 0 : _66.verticalSplitLineHighlight,
gantt.parsedOptions.verticalSplitLine = Object.assign({
lineColor: null === (_67 = gantt.parsedOptions.outerFrameStyle) || void 0 === _67 ? void 0 : _67.borderColor,
lineWidth: null === (_68 = gantt.parsedOptions.outerFrameStyle) || void 0 === _68 ? void 0 : _68.borderLineWidth
}, null === (_69 = options.frame) || void 0 === _69 ? void 0 : _69.verticalSplitLine),
gantt.parsedOptions.horizontalSplitLine = null === (_70 = options.frame) || void 0 === _70 ? void 0 : _70.horizontalSplitLine,
gantt.parsedOptions.verticalSplitLineMoveable = null === (_71 = options.frame) || void 0 === _71 ? void 0 : _71.verticalSplitLineMoveable,
gantt.parsedOptions.taskKeyField = null !== (_72 = options.taskKeyField) && void 0 !== _72 ? _72 : "id",
gantt.parsedOptions.dependencyLinks = null !== (_74 = null === (_73 = options.dependency) || void 0 === _73 ? void 0 : _73.links) && void 0 !== _74 ? _74 : [],
gantt.parsedOptions.dependencyLinkCreatable = null !== (_76 = null === (_75 = options.dependency) || void 0 === _75 ? void 0 : _75.linkCreatable) && void 0 !== _76 && _76,
gantt.parsedOptions.dependencyLinkSelectable = null === (_78 = null === (_77 = options.dependency) || void 0 === _77 ? void 0 : _77.linkSelectable) || void 0 === _78 || _78,
gantt.parsedOptions.dependencyLinkDeletable = null !== (_80 = null === (_79 = options.dependency) || void 0 === _79 ? void 0 : _79.linkDeletable) && void 0 !== _80 && _80,
gantt.parsedOptions.dependencyLinkLineStyle = Object.assign({
lineColor: "red",
lineWidth: 1
}, null === (_81 = options.dependency) || void 0 === _81 ? void 0 : _81.linkLineStyle),
gantt.parsedOptions.dependencyLinkSelectedLineStyle = Object.assign({
shadowBlur: 4,
shadowOffset: 0,
shadowColor: gantt.parsedOptions.dependencyLinkLineStyle.lineColor,
lineColor: gantt.parsedOptions.dependencyLinkLineStyle.lineColor,
lineWidth: gantt.parsedOptions.dependencyLinkLineStyle.lineWidth
}, null === (_82 = null == options ? void 0 : options.dependency) || void 0 === _82 ? void 0 : _82.linkSelectedLineStyle),
gantt.parsedOptions.dependencyLinkLineCreatePointStyle = Object.assign({
strokeColor: "red",
fillColor: "white",
radius: 5,
strokeWidth: 1
}, null === (_83 = null == options ? void 0 : options.dependency) || void 0 === _83 ? void 0 : _83.linkCreatePointStyle),
gantt.parsedOptions.dependencyLinkLineCreatingPointStyle = Object.assign({
strokeColor: "red",
fillColor: "red",
radius: 5,
strokeWidth: 1
}, null === (_84 = null == options ? void 0 : options.dependency) || void 0 === _84 ? void 0 : _84.linkCreatingPointStyle),
gantt.parsedOptions.dependencyLinkLineCreatingStyle = Object.assign({
lineColor: "red",
lineWidth: 1,
lineDash: [ 5, 5 ]
}, null === (_85 = null == options ? void 0 : options.dependency) || void 0 === _85 ? void 0 : _85.linkCreatingLineStyle),
gantt.parsedOptions.eventOptions = null == options ? void 0 : options.eventOptions,
gantt.parsedOptions.keyboardOptions = null == options ? void 0 : options.keyboardOptions,
gantt.parsedOptions.markLineCreateOptions = null == options ? void 0 : options.markLineCreateOptions;
}
function updateOptionsWhenScaleChanged(gantt) {
var _a, _b, _c, _d;
const options = gantt.options, {unit: minTimeUnit, startOfWeek: startOfWeek, step: step} = gantt.parsedOptions.reverseSortedTimelineScales[0];
gantt.parsedOptions.minDate = (0, util_1.getStartDateByTimeUnit)(new Date(gantt.parsedOptions.minDate), minTimeUnit, startOfWeek),
gantt.parsedOptions.maxDate = (0, util_1.getEndDateByTimeUnit)(gantt.parsedOptions.minDate, new Date(gantt.parsedOptions.maxDate), minTimeUnit, step),
gantt.parsedOptions._minDateTime = null === (_a = gantt.parsedOptions.minDate) || void 0 === _a ? void 0 : _a.getTime(),
gantt.parsedOptions._maxDateTime = null === (_b = gantt.parsedOptions.maxDate) || void 0 === _b ? void 0 : _b.getTime(),
gantt.parsedOptions.timeLineHeaderRowHeights = [], gantt.parsedOptions.timelineHeaderStyles = [];
for (let i = 0; i < gantt.parsedOptions.sortedTimelineScales.length; i++) {
const style = gantt.parsedOptions.sortedTimelineScales[i].style;
gantt.parsedOptions.timelineHeaderStyles.push(Object.assign({
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
textBaseline: "middle",
color: "#000",
backgroundColor: "#fff"
}, style)), gantt.parsedOptions.timeLineHeaderRowHeights.push(null !== (_d = null !== (_c = gantt.parsedOptions.sortedTimelineScales[i].rowHeight) && void 0 !== _c ? _c : null == options ? void 0 : options.headerRowHeight) && void 0 !== _d ? _d : 40);
}
}
function generateTimeLineDate(currentDate, endDate, scale) {
var _a;
const {unit: unit, step: step, format: format} = scale, timelineDates = [];
for (;currentDate < endDate; ) if ("day" === unit) {
const year = currentDate.getFullYear(), month = currentDate.getMonth(), day = currentDate.getDate(), end = (0,
util_1.createDateAtLastHour)(new Date(year, month, day + step - 1), !0);
end.getTime() > endDate.getTime() && end.setTime(endDate.getTime());
const start = currentDate, columnTitle = (null == format ? void 0 : format({
dateIndex: day,
startDate: start,
endDate: end
})) || day.toString(), dayCellConfig = {
days: Math.abs(end.getTime() - currentDate.getTime() + 1) / exports.DayTimes,
startDate: start,
endDate: end,
step: step,
unit: "day",
title: columnTitle,
dateIndex: day
};
timelineDates.push(dayCellConfig), currentDate = new Date(year, month, day + step);
} else if ("month" === unit) {
const year = currentDate.getFullYear(), month = currentDate.getMonth(), end = (0,
util_1.createDateAtLastHour)(new Date(year, month + step, 0), !0);
end.getTime() > endDate.getTime() && end.setTime(endDate.getTime());
const start = currentDate, columnTitle = (null == format ? void 0 : format({
dateIndex: month + 1,
startDate: start,
endDate: end
})) || (month + 1).toString(), dayCellConfig = {
days: Math.abs(end.getTime() - currentDate.getTime() + 1) / exports.DayTimes,
startDate: start,
step: step,
unit: "month",
endDate: end,
title: columnTitle,
dateIndex: month + 1
};
timelineDates.push(dayCellConfig), currentDate = new Date(year, month + step, 1);
} else if ("quarter" === unit) {
const year = currentDate.getFullYear(), quarter = Math.floor(currentDate.getMonth() / 3), end = (0,
util_1.createDateAtLastHour)(new Date(year, 3 * (quarter + step), 0), !0);
end.getTime() > endDate.getTime() && end.setTime(endDate.getTime());
const start = currentDate, columnTitle = (null == format ? void 0 : format({
dateIndex: quarter + 1,
startDate: start,
endDate: end
})) || (quarter + 1).toString(), dayCellConfig = {
days: Math.abs(end.getTime() - currentDate.getTime() + 1) / 864e5,
startDate: start,
step: step,
unit: "quarter",
endDate: end,
title: columnTitle,
dateIndex: quarter + 1
};
timelineDates.push(dayCellConfig), currentDate = new Date(year, 3 * (quarter + step), 1);
} else if ("year" === unit) {
const year = currentDate.getFullYear(), end = (0, util_1.createDateAtLastHour)(new Date(year + step - 1, 11, 31), !0);
end.getTime() > endDate.getTime() && end.setTime(endDate.getTime());
const start = currentDate, columnTitle = (null == format ? void 0 : format({
dateIndex: year,
startDate: start,
endDate: end
})) || year.toString(), dayCellConfig = {
days: Math.abs(end.getTime() - currentDate.getTime() + 1) / exports.DayTimes,
startDate: start,
endDate: end,
step: step,
unit: "year",
title: columnTitle,
dateIndex: year
};
timelineDates.push(dayCellConfig), currentDate = new Date(year + step, 0, 1);
} else if ("week" === unit) {
const startOfWeekSetting = null !== (_a = scale.startOfWeek) && void 0 !== _a ? _a : "monday";
let dayOfWeek = currentDate.getDay();
"monday" === startOfWeekSetting && (dayOfWeek = 0 === dayOfWeek ? 6 : dayOfWeek - 1);
const startOfWeek = (0, util_1.createDateAtMidnight)(currentDate), dateEnd = (0,
util_1.createDateAtLastHour)(currentDate.getTime() + 24 * (7 * step - dayOfWeek) * 60 * 60 * 1e3 - 1, !0);
dateEnd > endDate && dateEnd.setTime(endDate.getTime());
const weekNumber = (0, util_1.getWeekNumber)(startOfWeek), columnTitle = (null == format ? void 0 : format({
dateIndex: weekNumber,
startDate: startOfWeek,
endDate: dateEnd
})) || weekNumber.toString(), dayCellConfig = {
days: (dateEnd.getTime() - startOfWeek.getTime() + 1) / exports.DayTimes,
startDate: startOfWeek,
endDate: dateEnd,
step: step,
unit: "week",
title: columnTitle,
dateIndex: weekNumber
};
timelineDates.push(dayCellConfig), currentDate.setTime((0, util_1.createDateAtMidnight)(currentDate.getTime() + 24 * (7 * step - dayOfWeek) * 60 * 60 * 1e3, !0).getTime());
} else if ("hour" === unit) {
const year = currentDate.getFullYear(), month = currentDate.getMonth(), day = currentDate.getDate(), hour = currentDate.getHours(), end = (0,
util_1.createDateAtLastMinute)(new Date(year, month, day, hour + step - 1), !0);
end.getTime() > endDate.getTime() && end.setTime(endDate.getTime());
const start = currentDate, columnTitle = (null == format ? void 0 : format({
dateIndex: hour,
startDate: start,
endDate: end
})) || hour.toString(), dayCellConfig = {
days: Math.abs(end.getTime() - currentDate.getTime() + 1) / exports.DayTimes,
startDate: start,
endDate: end,
step: step,
unit: "hour",
title: columnTitle,
dateIndex: currentDate.getHours()
};
timelineDates.push(dayCellConfig), currentDate = new Date(year, month, day, hour + step);
} else if ("minute" === unit) {
const year = currentDate.getFullYear(), month = currentDate.getMonth(), day = currentDate.getDate(), hour = currentDate.getHours(), minute = currentDate.getMinutes(), end = (0,
util_1.createDateAtLastSecond)(new Date(year, month, day, hour, minute + step - 1), !0);
end.getTime() > endDate.getTime() && end.setTime(endDate.getTime());
const start = currentDate, columnTitle = (null == format ? void 0 : format({
dateIndex: minute,
startDate: start,
endDate: end
})) || minute.toString(), dayCellConfig = {
days: Math.abs(end.getTime() - currentDate.getTime() + 1) / exports.DayTimes,
startDate: start,
endDate: end,
step: step,
unit: "minute",
title: columnTitle,
dateIndex: currentDate.getMinutes()
};
timelineDates.push(dayCellConfig), currentDate = new Date(year, month, day, hour, minute + step);
} else if ("second" === unit) {
const year = currentDate.getFullYear(), month = currentDate.getMonth(), day = currentDate.getDate(), hour = currentDate.getHours(), minute = currentDate.getMinutes(), second = currentDate.getSeconds(), end = (0,
util_1.createDateAtLastMillisecond)(new Date(year, month, day, hour, minute, second + step - 1), !0);
end.getTime() > endDate.getTime() && end.setTime(endDate.getTime());
const start = currentDate, columnTitle = (null == format ? void 0 : format({
dateIndex: second,
startDate: start,
endDate: end
})) || second.toString(), dayCellConfig = {
days: Math.abs(end.getTime() - currentDate.getTime() + 1) / exports.DayTimes,
startDate: start,
endDate: end,
step: step,
unit: "second",
title: columnTitle,
dateIndex: currentDate.getSeconds()
};
timelineDates.push(dayCellConfig), currentDate = new Date(year, month, day, hour, minute, second + step);
}
return timelineDates;
}
function getTextPos(padding, textAlign, textBaseline, width, height) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
let textX = null !== (_a = padding[3]) && void 0 !== _a ? _a : 10;
"right" === textAlign || "end" === textAlign ? textX = width - 0 - (null !== (_b = padding[1]) && void 0 !== _b ? _b : 10) : "center" === textAlign && (textX = 0 + (width - 0 + (null !== (_c = padding[3]) && void 0 !== _c ? _c : 10) - (null !== (_d = padding[1]) && void 0 !== _d ? _d : 10)) / 2);
let textY = 0 + (null !== (_e = padding[0]) && void 0 !== _e ? _e : 10);
return "bottom" === textBaseline || "alphabetic" === textBaseline || "ideographic" === textBaseline ? textY = height - 0 - (null !== (_f = padding[2]) && void 0 !== _f ? _f : 10) : "middle" === textBaseline && (textY = 0 + (height - 0 - (null !== (_g = padding[0]) && void 0 !== _g ? _g : 10) - (null !== (_h = padding[2]) && void 0 !== _h ? _h : 10)) / 2 + (null !== (_j = padding[0]) && void 0 !== _j ? _j : 10)),
{
x: textX,
y: textY
};
}
function convertProgress(progress) {
return "string" == typeof progress && (progress = progress.replace("%", ""), progress = parseFloat(progress)),
Math.round(progress);
}
function createSplitLineAndResizeLine(gantt) {
if (gantt.taskListTableInstance) {
gantt.verticalSplitResizeLine = document.createElement("div"), gantt.verticalSplitResizeLine.style.position = "absolute",
gantt.verticalSplitResizeLine.style.top = gantt.tableY + "px", gantt.verticalSplitResizeLine.style.left = (gantt.taskTableWidth ? gantt.taskTableWidth - 7 + gantt.parsedOptions.verticalSplitLine.lineWidth / 2 : 0) + "px",
gantt.verticalSplitResizeLine.style.width = "14px", gantt.verticalSplitResizeLine.style.height = gantt.drawHeight + "px",
gantt.verticalSplitResizeLine.style.backgroundColor = "rgba(0,0,0,0)", gantt.verticalSplitResizeLine.style.zIndex = "100",
gantt.parsedOptions.verticalSplitLineMoveable && (gantt.verticalSplitResizeLine.style.cursor = "col-resize"),
gantt.verticalSplitResizeLine.style.userSelect = "none", gantt.verticalSplitResizeLine.style.opacity = "1";
const verticalSplitLine = document.createElement("div");
if (verticalSplitLine.style.position = "absolute", verticalSplitLine.style.top = "0px",
verticalSplitLine.style.left = (14 - gantt.parsedOptions.verticalSplitLine.lineWidth) / 2 + "px",
verticalSplitLine.style.width = gantt.parsedOptions.verticalSplitLine.lineWidth + "px",
verticalSplitLine.style.height = "100%", verticalSplitLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLine.lineColor,
verticalSplitLine.style.zIndex = "100", verticalSplitLine.style.userSelect = "none",
verticalSplitLine.style.pointerEvents = "none", verticalSplitLine.style.transition = "background-color 0.3s",
gantt.verticalSplitResizeLine.appendChild(verticalSplitLine), gantt.parsedOptions.verticalSplitLineHighlight) {
const highlightLine = document.createElement("div");
highlightLine.style.position = "absolute", highlightLine.style.top = "0px", highlightLine.style.left = (14 - gantt.parsedOptions.verticalSplitLineHighlight.lineWidth) / 2 + "px",
highlightLine.style.width = gantt.parsedOptions.verticalSplitLineHighlight.lineWidth + "px",
highlightLine.style.height = "100%", highlightLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLineHighlight.lineColor,
highlightLine.style.zIndex = "100", highlightLine.style.cursor = "col-resize", highlightLine.style.userSelect = "none",
highlightLine.style.pointerEvents = "none", highlightLine.style.opacity = "0", highlightLine.style.transition = "background-color 0.3s",
gantt.verticalSplitResizeLine.appendChild(highlightLine);
}
gantt.container.appendChild(gantt.verticalSplitResizeLine);
}
}
function updateSplitLineAndResizeLine(gantt) {
if (gantt.verticalSplitResizeLine) {
gantt.verticalSplitResizeLine.style.position = "absolute", gantt.verticalSplitResizeLine.style.top = gantt.tableY + "px",
gantt.verticalSplitResizeLine.style.left = gantt.taskTableWidth ? gantt.taskTableWidth - 7 + gantt.parsedOptions.verticalSplitLine.lineWidth / 2 + "px" : "0px",
gantt.verticalSplitResizeLine.style.width = "14px", gantt.verticalSplitResizeLine.style.height = gantt.drawHeight + "px",
gantt.verticalSplitResizeLine.style.backgroundColor = "rgba(0,0,0,0)", gantt.verticalSplitResizeLine.style.zIndex = "100",
gantt.parsedOptions.verticalSplitLineMoveable && (gantt.verticalSplitResizeLine.style.cursor = "col-resize"),
gantt.verticalSplitResizeLine.style.userSelect = "none", gantt.verticalSplitResizeLine.style.opacity = "1";
const verticalSplitLine = gantt.verticalSplitResizeLine.childNodes[0];
if (verticalSplitLine.style.position = "absolute", verticalSplitLine.style.top = "0px",
verticalSplitLine.style.left = (14 - gantt.parsedOptions.verticalSplitLine.lineWidth) / 2 + "px",
verticalSplitLine.style.width = gantt.parsedOptions.verticalSplitLine.lineWidth + "px",
verticalSplitLine.style.height = "100%", verticalSplitLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLine.lineColor,
verticalSplitLine.style.zIndex = "100", verticalSplitLine.style.userSelect = "none",
verticalSplitLine.style.pointerEvents = "none", verticalSplitLine.style.transition = "background-color 0.3s",
gantt.verticalSplitResizeLine.childNodes[1]) {
const highlightLine = gantt.verticalSplitResizeLine.childNodes[1];
highlightLine.style.position = "absolute", highlightLine.style.top = "0px", highlightLine.style.left = (14 - gantt.parsedOptions.verticalSplitLineHighlight.lineWidth) / 2 + "px",
highlightLine.style.width = gantt.parsedOptions.verticalSplitLineHighlight.lineWidth + "px",
highlightLine.style.height = "100%", highlightLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLineHighlight.lineColor,
highlightLine.style.zIndex = "100", highlightLine.style.cursor = "col-resize", highlightLine.style.userSelect = "none",
highlightLine.style.pointerEvents = "none", highlightLine.style.opacity = "0", highlightLine.style.transition = "background-color 0.3s";
}
}
}
function findRecordByTaskKey(records, taskKeyField, taskKey, childrenField = "children") {
var _a;
for (let i = 0; i < records.length; i++) {
if (Array.isArray(taskKey) && 1 === taskKey.length && records[i][taskKeyField] === taskKey[0] || records[i][taskKeyField] === taskKey) return {
record: records[i],
index: [ i ]
};
if (null === (_a = records[i][childrenField]) || void 0 === _a ? void 0 : _a.length) if (Array.isArray(taskKey) && taskKey[0] === records[i][taskKeyField]) {
const result = findRecordByTaskKey(records[i][childrenField], taskKeyField, taskKey.slice(1));
if (result) return result.index.unshift(i), result;
} else if (!Array.isArray(taskKey)) {
const result = findRecordByTaskKey(records[i][childrenField], taskKeyField, taskKey);
if (result) return result.index.unshift(i), result;
}
}
}
function clearRecordLinkInfos(records, childrenField = "children") {
var _a;
for (let i = 0; i < records.length; i++) (null === (_a = records[i][childrenField]) || void 0 === _a ? void 0 : _a.length) ? clearRecordLinkInfos(records[i][childrenField], childrenField) : (delete records[i].vtable_gantt_linkedTo,
delete records[i].vtable_gantt_linkedFrom);
}
function clearRecordShowIndex(records, childrenField = "children") {
var _a;
for (let i = 0; i < records.length; i++) (null === (_a = records[i][childrenField]) || void 0 === _a ? void 0 : _a.length) ? clearRecordShowIndex(records[i][childrenField], childrenField) : delete records[i].vtable_gantt_showIndex;
}
function getTaskIndexsByTaskY(y, gantt) {
var _a;
let task_index, sub_task_index;
if (gantt.taskListTableInstance) {
const rowInfo = gantt.taskListTableInstance.getTargetRowAt(y + gantt.headerHeight);
if (rowInfo) {
const {row: row} = rowInfo;
task_index = row - gantt.taskListTableInstance.columnHeaderLevelCount;
const beforeRowsHeight = gantt.getRowsHeightByIndex(0, task_index - 1);
if (gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Sub_Tasks_Inline || gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Sub_Tasks_Arrange || gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Sub_Tasks_Compact || gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Sub_Tasks_Separate) sub_task_index = Math.floor((y - beforeRowsHeight) / gantt.parsedOptions.rowHeight); else if (gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Project_Sub_Tasks_Inline) {
const record = gantt.getRecordByIndex(task_index);
if (record && record.type === ts_types_1.TaskType.PROJECT && (null === (_a = record.children) || void 0 === _a ? void 0 : _a.length) > 0) {
"expand" === record.hierarchyState || !1 === gantt.parsedOptions.projectSubTasksExpandable || (sub_task_index = Math.floor((y - beforeRowsHeight) / gantt.parsedOptions.rowHeight));
}
}
}
} else task_index = Math.floor(y / gantt.parsedOptions.rowHeight);
return {
task_index: task_index,
sub_task_index: sub_task_index
};
}
function computeRowsCountByRecordDateForCompact(gantt, record) {
var _a;
if (!record.children || record.children.length <= 1) return 1 === (null === (_a = record.children) || void 0 === _a ? void 0 : _a.length) ? record.children[0].vtable_gantt_showIndex = 0 : record.vtable_gantt_showIndex = 0,
1;
const sortedChildren = record.children.slice().sort(((a, b) => {
const {startDate: aStartDate} = formatRecordDateConsiderHasHour(gantt, a), {startDate: bStartDate} = formatRecordDateConsiderHasHour(gantt, b);
return aStartDate.getTime() - bStartDate.getTime();
})), rows = [];
for (let i = 0; i <= sortedChildren.length - 1; i++) {
const newRecord = sortedChildren[i], {startDate: startDate, endDate: endDate} = formatRecordDateConsiderHasHour(gantt, newRecord);
let placed = !1;
for (let j = 0; j < rows.length; j++) if (startDate.getTime() > rows[j]) {
rows[j] = endDate.getTime(), placed = !0, newRecord.vtable_gantt_showIndex = j;
break;
}
placed || (rows.push(endDate.getTime()), newRecord.vtable_gantt_showIndex = rows.length - 1);
}
return rows.length;
}
function isOverlapping(startDate, endDate, rowTasks, gantt) {
return rowTasks.some((rowTask => {
const {startDate: startDate2, endDate: endDate2} = formatRecordDateConsiderHasHour(gantt, rowTask);
return startDate <= endDate2 && startDate2 <= endDate;
}));
}
function computeRowsCountByRecordDate(gantt, record) {
var _a;
if (!record.children || record.children.length <= 1) return 1 === (null === (_a = record.children) || void 0 === _a ? void 0 : _a.length) ? record.children[0].vtable_gantt_showIndex = 0 : record.vtable_gantt_showIndex = 0,
1;
const rows = [];
for (let i = 0; i <= record.children.length - 1; i++) {
const newRecord = record.children[i], {startDate: startDate, endDate: endDate} = formatRecordDateConsiderHasHour(gantt, newRecord);
let placed = !1;
for (let j = 0; j < rows.length; j++) {
if (!isOverlapping(startDate, endDate, record.children.filter((t => t !== newRecord && t.vtable_gantt_showIndex === j)), gantt)) {
rows[j] = endDate.getTime(), placed = !0, newRecord.vtable_gantt_showIndex = j;
break;
}
}
placed || (rows.push(endDate.getTime()), newRecord.vtable_gantt_showIndex = rows.length - 1);
}
return rows.length;
}
function getSubTaskRowIndexByRecordDate(record, childIndex, startDateField, endDateField) {
if (0 === childIndex) return 0;
const rows = [];
if (null == record ? void 0 : record.children) for (let i = 0; i <= record.children.length - 1; i++) {
const newRecord = record.children[i], startDate = (0, util_1.createDateAtMidnight)(newRecord[startDateField]).getTime(), endDate = (0,
util_1.createDateAtMidnight)(newRecord[endDateField]).getTime();
let placed = !1;
for (let j = 0; j < rows.length; j++) if (startDate > rows[j]) {
if (rows[j] = endDate, placed = !0, i === childIndex) return j;
break;
}
if (placed || rows.push(endDate), i === childIndex) return rows.length - 1;
}
return 0;
}
function formatRecordDateConsiderHasHour(gantt, record) {
const {timeScaleIncludeHour: timeScaleIncludeHour, startDateField: startDateField, endDateField: endDateField} = gantt.parsedOptions, startDate = record[startDateField], endDate = record[endDateField];
return timeScaleIncludeHour ? {
startDate: (0, util_1.createDateAtMidnight)(startDate),
endDate: (0, util_1.createDateAtLastHour)(endDate)
} : {
startDate: (0, util_1.createDateAtMidnight)(startDate, !0),
endDate: (0, util_1.createDateAtLastHour)(endDate, !0)
};
}
function updateOptionsWhenRecordChanged(gantt) {
var _a, _b, _c, _d, _e, _f, _g;
const options = gantt.options, {unit: minTimeUnit, startOfWeek: startOfWeek} = gantt.parsedOptions.reverseSortedTimelineScales[0];
gantt.parsedOptions.markLine = generateMarkLine(null == options ? void 0 : options.markLine),
null !== (_b = null === (_a = gantt.parsedOptions.markLine) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b && _b && ((null === (_c = gantt.parsedOptions.markLine) || void 0 === _c ? void 0 : _c.every((item => void 0 === item.scrollToMarkLine))) && (gantt.parsedOptions.markLine[0].scrollToMarkLine = !0),
(null === (_d = gantt.parsedOptions.markLine) || void 0 === _d ? void 0 : _d.find((item => item.scrollToMarkLine))) && (gantt.parsedOptions.scrollToMarkLineDate = (0,
util_1.getStartDateByTimeUnit)(new Date(null === (_e = gantt.parsedOptions.markLine) || void 0 === _e ? void 0 : _e.find((item => item.scrollToMarkLine)).date), minTimeUnit, startOfWeek))),
gantt.parsedOptions.dependencyLinks = null !== (_g = null === (_f = options.dependency) || void 0 === _f ? void 0 : _f.links) && void 0 !== _g ? _g : [];
}
function updateOptionsWhenDateRangeChanged(gantt) {
var _a, _b;
const options = gantt.options, {unit: minTimeUnit, startOfWeek: startOfWeek, step: step} = gantt.parsedOptions.reverseSortedTimelineScales[0];
gantt.parsedOptions.minDate = (null == options ? void 0 : options.minDate) ? (0,
util_1.getStartDateByTimeUnit)(new Date(options.minDate), minTimeUnit, startOfWeek) : void 0,
gantt.parsedOptions.maxDate = (null == options ? void 0 : options.maxDate) ? (0,
util_1.getEndDateByTimeUnit)(gantt.parsedOptions.minDate, new Date(options.maxDate), minTimeUnit, step) : void 0,
gantt.parsedOptions._minDateTime = null === (_a = gantt.parsedOptions.minDate) || void 0 === _a ? void 0 : _a.getTime(),
gantt.parsedOptions._maxDateTime = null === (_b = gantt.parsedOptions.maxDate) || void 0 === _b ? void 0 : _b.getTime();
}
function updateOptionsWhenMarkLineChanged(gantt) {
const options = gantt.options;
gantt.parsedOptions.markLine = generateMarkLine(null == options ? void 0 : options.markLine);
}
function _getTaskInfoByXYForCreateSchedule(eventX, eventY, gantt) {
const taskIndex = getTaskIndexsByTaskY(eventY - gantt.headerHeight + gantt.stateManager.scrollTop, gantt), recordParent = gantt.getRecordByIndex(taskIndex.task_index), dateIndex = getDateIndexByX(eventX, gantt), dateRange = gantt.getDateRangeByIndex(dateIndex);
if (null == recordParent ? void 0 : recordParent.children) {
const taskIndex = getTaskIndexsByTaskY(eventY - gantt.headerHeight + gantt.stateManager.scrollTop, gantt);
for (let i = 0; i < recordParent.children.length; i++) {
const {startDate: startDate, endDate: endDate, taskDays: taskDays, progress: progress, taskRecord: taskRecord} = gantt.getTaskInfoByTaskListIndex(taskIndex.task_index, i);
if (((gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Sub_Tasks_Compact || gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Sub_Tasks_Arrange) && taskRecord.vtable_gantt_showIndex === taskIndex.sub_task_index || gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Sub_Tasks_Inline || gantt.parsedOptions.tasksShowMode === ts_types_1.TasksShowMode.Project_Sub_Tasks_Inline && recordParent.type === ts_types_1.TaskType.PROJECT && "expand" !== recordParent.hierarchyState && !1 !== gantt.parsedOptions.projectSubTasksExpandable) && dateRange.startDate.getTime() >= startDate.getTime() && dateRange.endDate.getTime() <= endDate.getTime()) return {
startDate: startDate,
endDate: endDate,
taskDays: taskDays,
progress: progress,
taskRecord: taskRecord
};
}
}
}
function getNodeClickPos(marklineIconNode, gantt) {
return {
left: marklineIconNode.globalTransMatrix.e + gantt.taskListTableInstance.tableNoFrameWidth + gantt.taskListTableInstance.tableX + gantt.tableX,
top: marklineIconNode.globalTransMatrix.f,
width: marklineIconNode.attribute.width,
height: marklineIconNode.attribute.height
};
}
function judgeIfHasMarkLine(data, markLine) {
const beginTime = data.startDate.getTime(), endTime = data.endDate.getTime();
return markLine.some((item => {
const marklineTime = new Date(item.date).getTime();
return marklineTime >= beginTime && marklineTime <= endTime;
}));
}
function checkHasChildTasks(gantt, taskIndex, subTaskIndex) {
const taskRecord = gantt.getRecordByIndex(taskIndex, subTaskIndex);
return !!((null == taskRecord ? void 0 : taskRecord.children) && taskRecord.children.length > 0);
}
function initProjectTaskTimes(gantt) {
if (!gantt.records || 0 === gantt.records.length) return;
const startDateField = gantt.parsedOptions.startDateField, endDateField = gantt.parsedOptions.endDateField, processTasksRecursively = (records, parentIndex, parentArray) => {
let earliestStartAll = null, latestEndAll = null;
return records.forEach(((record, index) => {
var _a;
if (!record) return;
let earliestStart = null, latestEnd = null;
i