@baishuyun/ui-base 6.16.1 → 6.18.0
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/Amap/Amap-CNsoge6e.js +826 -0
- package/dist/Amap/index.js +3 -10
- package/dist/Calendar/Calendar-Dk6FVbJ2.js +1608 -0
- package/dist/Calendar/index.js +10 -20
- package/dist/Card/index.js +2 -2
- package/dist/CheckBox/{CheckBox-B92dxWNo.js → CheckBox-CM24-quL.js} +1 -1
- package/dist/CheckBox/index.js +3 -3
- package/dist/ColorPicker/{ColorPicker-CPr5j6ZN.js → ColorPicker-B_wLqurt.js} +5 -5
- package/dist/ColorPicker/index.js +5 -5
- package/dist/ConfigProvider/index.js +1 -1
- package/dist/DatePicker/DatePicker-CItkTpdZ.js +111 -0
- package/dist/DatePicker/{DatePickerPanel-CtLwYPmz.js → DatePickerPanel-DJXmFihs.js} +3 -4
- package/dist/DatePicker/index.js +6 -8
- package/dist/DatePicker/pickerLocale-Brf7_Tnd.js +30 -0
- package/dist/DropDown/{DropDown-Bi0TsCc_.js → DropDown-B_szM67V.js} +86 -82
- package/dist/DropDown/index.js +8 -9
- package/dist/Editor/index.js +2934 -961
- package/dist/Gantt/index.js +3055 -197
- package/dist/Icon/index.js +1 -1
- package/dist/InputTag/{InputTag-BfZycXw4.js → InputTag-C_5nm0eo.js} +2 -2
- package/dist/InputTag/index.js +4 -4
- package/dist/Loading/{Loading-DpbJSRYf.js → Loading-Cherk9Ax.js} +1 -1
- package/dist/Loading/index.js +3 -3
- package/dist/Modal/index.js +2 -2
- package/dist/NotFoundContent/index.js +2 -2
- package/dist/Overlay/index.js +1 -1
- package/dist/Radio/index.js +2 -2
- package/dist/ScrollBar/{ScrollBar-N2pOLv-8.js → ScrollBar-IMTuAOF5.js} +1 -1
- package/dist/ScrollBar/index.js +2 -2
- package/dist/Segmented/{Segmented-BCQRrc65.js → Segmented-DpmwFerw.js} +1 -1
- package/dist/Segmented/index.js +2 -2
- package/dist/Select/{Select-CB5FqBui.js → Select-VIy6OKEj.js} +257 -253
- package/dist/Select/{SelectInputSearch-DUAv2vE4.js → SelectInputSearch-MApQHnU9.js} +1 -1
- package/dist/Select/index.js +12 -13
- package/dist/Table/Table-8ac6xLZv.js +808 -0
- package/dist/Table/index.js +4 -8
- package/dist/Tabs/{Tabs-B9uCGlxM.js → Tabs-DnoZ8BO0.js} +3 -3
- package/dist/Tabs/index.js +4 -4
- package/dist/Tooltip/{Tooltip-nJU13gX4.js → Tooltip-DBrt3t2r.js} +3 -3
- package/dist/Tooltip/index.js +3 -3
- package/dist/Tree/index.js +4 -4
- package/dist/components/Editor/EditorHtmlPreview.d.ts +3 -0
- package/dist/components/Editor/Preview/EditorPreview.d.ts +1 -1
- package/dist/components/Editor/Preview/HtmlPreview.d.ts +2 -3
- package/dist/components/Editor/Preview/PolishModal.d.ts +0 -1
- package/dist/components/Editor/Preview/TypesetModal.d.ts +0 -1
- package/dist/components/Editor/Preview/useAiPreviewHtml.d.ts +8 -0
- package/dist/components/Editor/__tests__/createTestEditor.d.ts +1 -0
- package/dist/components/Editor/commands/ImageCommands.d.ts +1 -0
- package/dist/components/Editor/constants/portableEditorStyles.d.ts +2 -0
- package/dist/components/Editor/context/EditorContainerContext.d.ts +3 -2
- package/dist/components/Editor/hooks/useEditorFocus.d.ts +1 -0
- package/dist/components/Editor/hooks/useTextFormatsState.d.ts +1 -2
- package/dist/components/Editor/index.d.ts +1 -0
- package/dist/components/Editor/nodes/ExtendedLinkNode.d.ts +9 -0
- package/dist/components/Editor/nodes/ImageComponent.d.ts +1 -0
- package/dist/components/Editor/nodes/ImageNode.d.ts +5 -2
- package/dist/components/Editor/utils/getToolbarItems.d.ts +14 -0
- package/dist/components/Editor/utils/placeProgrammaticCaret.d.ts +5 -0
- package/dist/components/Editor/utils/readTextFormats.d.ts +6 -0
- package/dist/components/Editor/utils/retainCodeSelection.d.ts +3 -0
- package/dist/index.js +28 -50
- package/dist/style.css +1 -1
- package/dist/vendors/Tree-D0Q1IZ2D.js +267 -0
- package/dist/vendors/{version-Dzs4mguZ.js → version-BucxnUKs.js} +1 -1
- package/package.json +1 -1
- package/dist/Amap/Amap-BLSziesG.js +0 -77
- package/dist/Amap/AmapCircle/index.js +0 -5
- package/dist/Amap/AmapCircle-2qupysHe.js +0 -55
- package/dist/Amap/AmapContext-CJBe6lld.js +0 -11
- package/dist/Amap/AmapMarker/index.js +0 -6
- package/dist/Amap/AmapMarker-xEqoVnFR.js +0 -153
- package/dist/Amap/AmapMarkerCluster/index.js +0 -6
- package/dist/Amap/AmapMarkerCluster-CvEQa3o9.js +0 -240
- package/dist/Amap/AmapProvider/index.js +0 -7
- package/dist/Amap/AmapProvider-B-R2DrkJ.js +0 -107
- package/dist/Amap/hooks/index.js +0 -4
- package/dist/Amap/hooks-BTcFpdd0.js +0 -121
- package/dist/Amap/useMarkerInfoWindowController-Cjx0xQXw.js +0 -94
- package/dist/Calendar/AllDaySection-pO7suGJM.js +0 -53
- package/dist/Calendar/Calendar-Cjagi7mU.js +0 -795
- package/dist/Calendar/CurrentTimeIndicator-BF3_INSL.js +0 -65
- package/dist/Calendar/EventCard-DKEZQRTp.js +0 -155
- package/dist/Calendar/TimeAxis-DUc6EL-j.js +0 -13
- package/dist/Calendar/TimeGrid-BV8x9VnF.js +0 -47
- package/dist/Calendar/colorUtils-BbeSMnOs.js +0 -55
- package/dist/Calendar/context/index.js +0 -3
- package/dist/Calendar/context-CamSpkj3.js +0 -21
- package/dist/Calendar/layout-CpOabFQ2.js +0 -300
- package/dist/Calendar/subcomponents/AllDaySection/index.js +0 -11
- package/dist/Calendar/subcomponents/CurrentTimeIndicator/index.js +0 -8
- package/dist/Calendar/subcomponents/EventCard/index.js +0 -9
- package/dist/Calendar/subcomponents/TimeAxis/index.js +0 -5
- package/dist/Calendar/subcomponents/TimeGrid/index.js +0 -7
- package/dist/Calendar/theme-Dc8hjcdo.js +0 -71
- package/dist/Calendar/utils/index.js +0 -111
- package/dist/Calendar/utils/layout/index.js +0 -4
- package/dist/Calendar/utils/theme/index.js +0 -3
- package/dist/DatePicker/DatePicker-neAwNSsc.js +0 -101
- package/dist/DatePicker/ensureDayjsPlugins-CSqhjLS7.js +0 -15
- package/dist/DatePicker/pickerLocale-CcPLUbZO.js +0 -15
- package/dist/DatePicker/style/index.js +0 -3
- package/dist/DatePicker/style-W7f5wyUb.js +0 -15
- package/dist/DropDown/style/index.js +0 -3
- package/dist/DropDown/style-DZpkarne.js +0 -9
- package/dist/Editor/Buttons-OwLs5bxR.js +0 -1841
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +0 -21
- package/dist/Editor/constants/index.js +0 -61
- package/dist/Gantt/GanttChart/index.js +0 -21
- package/dist/Gantt/GanttChart-CDnF5qcc.js +0 -2292
- package/dist/Gantt/GanttHighlightContext-dtyoq-oj.js +0 -12
- package/dist/Gantt/GanttTable/index.js +0 -13
- package/dist/Gantt/GanttTable-fOv1Zn2-.js +0 -84
- package/dist/Gantt/GanttToolBar/index.js +0 -17
- package/dist/Gantt/GanttToolBar-BAoiWAHI.js +0 -120
- package/dist/Gantt/collapseKeys-BV_8sIA-.js +0 -160
- package/dist/Gantt/columnResize-Bkenlbab.js +0 -46
- package/dist/Gantt/constants-mEGQ1U1Q.js +0 -39
- package/dist/Gantt/highlightTarget-D3Nf9_7S.js +0 -25
- package/dist/Gantt/theme-B7Iap-tZ.js +0 -31
- package/dist/Gantt/timelineViewConfig-DNt7yi83.js +0 -118
- package/dist/Gantt/utils/index.js +0 -7
- package/dist/Gantt/utils/theme/index.js +0 -3
- package/dist/Select/style/index.js +0 -3
- package/dist/Select/style-C4A8kUd1.js +0 -9
- package/dist/Table/Table-3LSO0xSH.js +0 -545
- package/dist/Table/constants-D7wLH8Qy.js +0 -25
- package/dist/Table/hooks/index.js +0 -3
- package/dist/Table/hooks-DSBl2e4O.js +0 -108
- package/dist/Table/processRowspan-B6HMqw0Q.js +0 -144
- package/dist/Table/style/index.js +0 -3
- package/dist/Table/style-B8Cw8HJe.js +0 -9
- package/dist/Table/utils/index.js +0 -3
- package/dist/Tree/utils/index.js +0 -26
- package/dist/vendors/Tree-DSl4lDjx.js +0 -248
- /package/dist/Card/{Card-rJeWgxu5.js → Card-DAz0dvA3.js} +0 -0
- /package/dist/CheckBox/{CheckBox-DOK5N7z6.js → CheckBox-CcHskTz_.js} +0 -0
- /package/dist/Modal/{Modal-CRKitOOj.js → Modal-eZijJ7CB.js} +0 -0
- /package/dist/NotFoundContent/{NotFoundContent-BLmzWNBi.js → NotFoundContent-DJUQ0_2D.js} +0 -0
- /package/dist/Radio/{Radio-CX9cUqb7.js → Radio-D9jhW7K6.js} +0 -0
- /package/dist/vendors/{animations-Dn_5xJ7B.js → animations-ISccYUE3.js} +0 -0
- /package/dist/vendors/{cssVars-l4-kP_14.js → cssVars-UpriQzph.js} +0 -0
- /package/dist/vendors/{mergeRefs-TiJ0xjUN.js → mergeRefs-mEH9TBYV.js} +0 -0
- /package/dist/vendors/{useFloatingOverlay-B3M9k8nj.js → useFloatingOverlay-B66lOL8v.js} +0 -0
- /package/dist/vendors/{useFloatingPortal-VpzL-EPh.js → useFloatingPortal-DJ1iKmW-.js} +0 -0
- /package/dist/vendors/{useLatchedPopupPortalRoot-4fVhqVT4.js → useLatchedPopupPortalRoot-CC6af8t-.js} +0 -0
- /package/dist/vendors/{useLocale-D31qCCff.js → useLocale-Be4e7Xfn.js} +0 -0
package/dist/Gantt/index.js
CHANGED
|
@@ -1,50 +1,2880 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-BucxnUKs.js";
|
|
2
2
|
import "../ScrollBar/style-D26azwz6.js";
|
|
3
|
-
import "../Icon/Icon-DrdQOEJE.js";
|
|
3
|
+
import { t as e } from "../Icon/Icon-DrdQOEJE.js";
|
|
4
4
|
import "../vendors/LocaleContext-DXQoOKM2.js";
|
|
5
5
|
import "../Overlay/OverlayContext-CVSFoyqN.js";
|
|
6
|
-
import "../vendors/useLocale-
|
|
7
|
-
import "../vendors/useLatchedPopupPortalRoot-
|
|
8
|
-
import "../
|
|
9
|
-
import "../
|
|
10
|
-
import "../
|
|
11
|
-
import "../
|
|
12
|
-
import "../
|
|
13
|
-
import "../
|
|
14
|
-
import "../DropDown/
|
|
15
|
-
import "../Table/
|
|
16
|
-
import "
|
|
17
|
-
import "
|
|
18
|
-
import "
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
import { t } from "../vendors/useLocale-Be4e7Xfn.js";
|
|
7
|
+
import "../vendors/useLatchedPopupPortalRoot-CC6af8t-.js";
|
|
8
|
+
import { t as n } from "../vendors/cssVars-UpriQzph.js";
|
|
9
|
+
import { t as r } from "../Tooltip/Tooltip-DBrt3t2r.js";
|
|
10
|
+
import "../Select/SelectInputSearch-MApQHnU9.js";
|
|
11
|
+
import "../NotFoundContent/NotFoundContent-DJUQ0_2D.js";
|
|
12
|
+
import "../ScrollBar/ScrollBar-IMTuAOF5.js";
|
|
13
|
+
import "../vendors/useFloatingPortal-DJ1iKmW-.js";
|
|
14
|
+
import { t as i } from "../DropDown/DropDown-B_szM67V.js";
|
|
15
|
+
import { t as a } from "../Table/Table-8ac6xLZv.js";
|
|
16
|
+
import { isFunction as o, isNumber as s, isString as c } from "lodash-es";
|
|
17
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
18
|
+
import f, { createContext as p, forwardRef as m, memo as h, useCallback as g, useContext as _, useEffect as v, useImperativeHandle as y, useLayoutEffect as b, useMemo as x, useRef as S, useState as C } from "react";
|
|
19
|
+
import w from "clsx";
|
|
20
|
+
import { useDocumentVisibility as T, useEventListener as E, useSize as D } from "ahooks";
|
|
21
|
+
import { AnimatePresence as O, motion as ee } from "motion/react";
|
|
22
|
+
import te from "tinycolor2";
|
|
23
|
+
import { createContext as k, useContextSelector as A } from "use-context-selector";
|
|
24
|
+
import j from "dayjs";
|
|
25
|
+
import M from "dayjs/plugin/isoWeek";
|
|
26
|
+
import { useVirtualizer as N } from "@tanstack/react-virtual";
|
|
27
|
+
import P from "dayjs/plugin/quarterOfYear";
|
|
28
|
+
import { OverlayScrollbars as F } from "overlayscrollbars";
|
|
29
|
+
var I = 34, L = 68 / 34, R = 1440 * 60 * 1e3, ne = "move", re = "resize-start", z = "resize-end", B = 3e4, ie = "__empty__", V = /^#([a-f\d]{3}|[a-f\d]{6})$/i, H = {
|
|
30
|
+
bufferDaysBefore: 90,
|
|
31
|
+
bufferDaysAfter: 90
|
|
32
|
+
}, U = {
|
|
33
|
+
halfDay: 30,
|
|
34
|
+
sixHour: 14,
|
|
35
|
+
hour: 7,
|
|
36
|
+
halfHour: 3,
|
|
37
|
+
tenMinute: 2,
|
|
38
|
+
oneMinute: 0
|
|
39
|
+
}, W = {
|
|
40
|
+
week: 20,
|
|
41
|
+
month: 20,
|
|
42
|
+
quarter: 20,
|
|
43
|
+
year: 10,
|
|
44
|
+
quarterMonth: 20
|
|
45
|
+
}, G = {
|
|
46
|
+
...U,
|
|
47
|
+
week: W.week * 7,
|
|
48
|
+
month: W.month * 30,
|
|
49
|
+
quarter: W.quarter * 90,
|
|
50
|
+
year: W.year * 365,
|
|
51
|
+
quarterMonth: W.quarterMonth * 30
|
|
52
|
+
}, ae = {
|
|
53
|
+
day: 40,
|
|
54
|
+
week: 14,
|
|
55
|
+
month: 200 / 30,
|
|
56
|
+
quarter: 200 / 90,
|
|
57
|
+
year: 200 / 180,
|
|
58
|
+
halfDay: 160,
|
|
59
|
+
sixHour: 280,
|
|
60
|
+
hour: 1200,
|
|
61
|
+
halfHour: 2160,
|
|
62
|
+
tenMinute: 5760,
|
|
63
|
+
oneMinute: 57600
|
|
64
|
+
}, K = ["select"];
|
|
65
|
+
function q(e, t) {
|
|
66
|
+
return !Array.isArray(e) || Object.keys(t).length === 0 ? e : e.map((e) => {
|
|
67
|
+
if (Array.isArray(e.children) && e.children.length > 0) {
|
|
68
|
+
let n = e.children.map((e) => t[e.key] === void 0 ? e : {
|
|
69
|
+
...e,
|
|
70
|
+
width: t[e.key]
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
...e,
|
|
74
|
+
children: n,
|
|
75
|
+
width: n.reduce((e, t) => e + (t.width || 120), 0)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return t[e.key] === void 0 ? e : {
|
|
79
|
+
...e,
|
|
80
|
+
width: t[e.key]
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function J(e) {
|
|
85
|
+
let [t, n] = C({}), r = g((e, t) => {
|
|
86
|
+
n((n) => ({
|
|
87
|
+
...n,
|
|
88
|
+
[e]: t
|
|
89
|
+
}));
|
|
90
|
+
}, []);
|
|
91
|
+
return v(() => {
|
|
92
|
+
if (Object.keys(t).length === 0) return;
|
|
93
|
+
let r = new Set(e.flatMap((e) => Array.isArray(e.children) && e.children.length > 0 ? e.children.map((e) => e.key) : [e.key]));
|
|
94
|
+
Object.keys(t).some((e) => !r.has(e)) && n((e) => {
|
|
95
|
+
let t = {};
|
|
96
|
+
for (let n of Object.keys(e)) r.has(n) && (t[n] = e[n]);
|
|
97
|
+
return t;
|
|
98
|
+
});
|
|
99
|
+
}, [e]), {
|
|
100
|
+
columns: x(() => q(e, t) ?? e, [e, t]),
|
|
101
|
+
onColumnResizeEnd: r,
|
|
102
|
+
resizable: !0,
|
|
103
|
+
disabledResizeColumns: K
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/components/Gantt/GanttTable/utils/mapGanttColumns.ts
|
|
108
|
+
var Y = (e) => ({
|
|
109
|
+
key: e.key,
|
|
110
|
+
title: e.title ?? "",
|
|
111
|
+
width: e.width ?? 120,
|
|
112
|
+
align: e.align,
|
|
113
|
+
className: e.className,
|
|
114
|
+
fixed: e.fixed,
|
|
115
|
+
render: (t, n, r) => {
|
|
116
|
+
let i = t ?? (e.dataIndex !== null && e.dataIndex !== void 0 ? n?.[e.dataIndex] : n?.label);
|
|
117
|
+
return typeof e.render == "function" ? e.render({
|
|
118
|
+
item: n,
|
|
119
|
+
rowIndex: r,
|
|
120
|
+
column: e,
|
|
121
|
+
value: i
|
|
122
|
+
}) : i ?? "";
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
function X(e = []) {
|
|
126
|
+
return !Array.isArray(e) || e.length === 0 ? [{
|
|
127
|
+
key: "label",
|
|
128
|
+
title: "",
|
|
129
|
+
width: 200,
|
|
130
|
+
render: (e, t) => t?.label ?? ""
|
|
131
|
+
}] : e.map((e) => Array.isArray(e.children) && e.children.length > 0 ? {
|
|
132
|
+
key: e.key,
|
|
133
|
+
title: e.title ?? "",
|
|
134
|
+
width: e.width ?? 120,
|
|
135
|
+
align: e.align,
|
|
136
|
+
fixed: e.fixed,
|
|
137
|
+
children: e.children.map((e) => Y(e)),
|
|
138
|
+
render: () => null
|
|
139
|
+
} : Y(e));
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/components/Gantt/GanttHighlightContext.ts
|
|
143
|
+
var oe = k({
|
|
144
|
+
getHighlightTarget: () => null,
|
|
145
|
+
setHighlightTarget: () => {},
|
|
146
|
+
setTableHighlightTarget: () => {},
|
|
147
|
+
subscribeHighlight: () => () => {},
|
|
148
|
+
notifyScrollActivity: () => {},
|
|
149
|
+
getIsScrollActive: () => !1
|
|
150
|
+
});
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/components/Gantt/utils/highlightTarget.ts
|
|
153
|
+
function se(e, t) {
|
|
154
|
+
return e === t ? !0 : !e || !t ? !1 : e.type === t.type && e.id === t.id;
|
|
155
|
+
}
|
|
156
|
+
function ce(e, t) {
|
|
157
|
+
return !!e?.id && !!e?.type && t?.id === e.id && t?.type === e.type;
|
|
158
|
+
}
|
|
159
|
+
function Z(e) {
|
|
160
|
+
if (!e) return null;
|
|
161
|
+
if (e.type === "summary") return e.groupKey !== null && e.groupKey !== void 0 && e.groupKey !== "" ? {
|
|
162
|
+
type: "group",
|
|
163
|
+
id: String(e.groupKey)
|
|
164
|
+
} : null;
|
|
165
|
+
if (e.parentId !== null && e.parentId !== void 0 && e.parentId !== "") return {
|
|
166
|
+
type: "record",
|
|
167
|
+
id: String(e.parentId)
|
|
168
|
+
};
|
|
169
|
+
let t = e.recordId ?? e.id;
|
|
170
|
+
return t != null && t !== "" ? {
|
|
171
|
+
type: "record",
|
|
172
|
+
id: String(t)
|
|
173
|
+
} : null;
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/components/Gantt/GanttTable/GanttTable.tsx
|
|
177
|
+
var le = ({ data: e = [], columns: t = [], onRowClick: n, rowHeight: r = 34, tableTheme: i }) => {
|
|
178
|
+
let o = A(oe, (e) => e.setTableHighlightTarget), { columns: s, resizable: c, disabledResizeColumns: l, onColumnResizeEnd: d } = J(x(() => X(t), [t])), f = g((e) => {
|
|
179
|
+
let t = Z(e);
|
|
180
|
+
t && o?.(t);
|
|
181
|
+
}, [o]), p = g(() => {
|
|
182
|
+
o?.(null);
|
|
183
|
+
}, [o]);
|
|
184
|
+
return /* @__PURE__ */ u(a, {
|
|
185
|
+
columns: s,
|
|
186
|
+
dataSource: e,
|
|
187
|
+
rowKey: "id",
|
|
188
|
+
rowHeightStyle: "low",
|
|
189
|
+
bordered: !1,
|
|
190
|
+
hasFooter: !1,
|
|
191
|
+
resizable: c,
|
|
192
|
+
disabledResizeColumns: l,
|
|
193
|
+
onColumnResizeEnd: d,
|
|
194
|
+
scroll: { y: "100%" },
|
|
195
|
+
estimateSize: () => r,
|
|
196
|
+
headerRowSpan: L,
|
|
197
|
+
onRowClick: g((e, t, r) => {
|
|
198
|
+
n?.(e, t, r);
|
|
199
|
+
}, [n]),
|
|
200
|
+
onRow: g((e, t, n) => {
|
|
201
|
+
let r = Z(e);
|
|
202
|
+
return {
|
|
203
|
+
...n,
|
|
204
|
+
"data-highlight-id": r?.id || "",
|
|
205
|
+
"data-highlight-type": r?.type || "",
|
|
206
|
+
onMouseEnter: () => f(e),
|
|
207
|
+
onMouseLeave: p
|
|
208
|
+
};
|
|
209
|
+
}, [f, p]),
|
|
210
|
+
emptyText: " ",
|
|
211
|
+
theme: i
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
le.displayName = "GanttTable";
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/components/Gantt/interface.ts
|
|
217
|
+
var ue = [
|
|
218
|
+
"day",
|
|
219
|
+
"week",
|
|
220
|
+
"month",
|
|
221
|
+
"quarter",
|
|
222
|
+
"quarterMonth",
|
|
223
|
+
"year"
|
|
224
|
+
], de = [
|
|
225
|
+
"halfDay",
|
|
226
|
+
"sixHour",
|
|
227
|
+
"hour",
|
|
228
|
+
"halfHour",
|
|
229
|
+
"tenMinute",
|
|
230
|
+
"oneMinute"
|
|
231
|
+
], fe = [...ue, ...de], pe = [...[...de].reverse(), ...ue], me = "day";
|
|
232
|
+
function he(e) {
|
|
233
|
+
return fe.includes(e);
|
|
234
|
+
}
|
|
235
|
+
function ge(e) {
|
|
236
|
+
return de.includes(e);
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/components/Gantt/GanttChart/utils/timezoneUtils.ts
|
|
240
|
+
var _e = () => -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, ve = () => {
|
|
241
|
+
let e = _e();
|
|
242
|
+
return e === null ? 0 : ((/* @__PURE__ */ new Date()).getTimezoneOffset() + e * 60) * 60 * 1e3;
|
|
243
|
+
}, ye = (e) => e + ve(), be = (e) => e - ve(), xe = () => Date.now() + ve(), Se = (e) => be(j(ye(e)).startOf("day").valueOf()), Ce = (e, t) => be(j(ye(e)).startOf(t).valueOf()), we = (e, t) => be(j(ye(e)).endOf(t).valueOf()), Te = (e) => {
|
|
244
|
+
let t = ye(e);
|
|
245
|
+
return new Date(t).getDay();
|
|
246
|
+
}, Ee = (e) => j(ye(e)), De = (e) => e?.type === "task" && e?.draggable !== !1 && !e?.invalid, Oe = {
|
|
247
|
+
canMove: !1,
|
|
248
|
+
canResizeStart: !1,
|
|
249
|
+
canResizeEnd: !1
|
|
250
|
+
}, ke = (e) => !e || e.invalid || e.type === "summary" || e.draggable === !1 ? Oe : e.dragPermission ? {
|
|
251
|
+
canMove: e.dragPermission.canMove === !0,
|
|
252
|
+
canResizeStart: e.dragPermission.canResizeStart === !0,
|
|
253
|
+
canResizeEnd: e.dragPermission.canResizeEnd === !0
|
|
254
|
+
} : {
|
|
255
|
+
canMove: !0,
|
|
256
|
+
canResizeStart: !0,
|
|
257
|
+
canResizeEnd: !0
|
|
258
|
+
}, Ae = (e, t) => De(e) ? e?.dragPermission ? t === "move" ? e.dragPermission.canMove === !0 : t === "resize-start" ? e.dragPermission.canResizeStart === !0 : t === "resize-end" ? e.dragPermission.canResizeEnd === !0 : !1 : !0 : !1, je = (e, t) => !t || Math.abs(e) < Math.min(5, t) ? 0 : Math.round(e / t), Me = (e, t) => je(e, t), Ne = (e, t, n = "round") => {
|
|
259
|
+
if (!t || !Number.isFinite(e)) return e;
|
|
260
|
+
let r = ye(e), i = j(r).startOf("day").valueOf(), a = (r - i) / t, o;
|
|
261
|
+
return o = n === "floor" ? Math.floor(a) : n === "ceil" ? Math.ceil(a) : Math.round(a), be(i + o * t);
|
|
262
|
+
}, Pe = (e, t, n) => ({
|
|
263
|
+
startMs: e + n,
|
|
264
|
+
endMs: t + n
|
|
265
|
+
}), Fe = ({ startMs: e, endMs: t, deltaMs: n, edge: r, minDurationMs: i }) => {
|
|
266
|
+
if (r === "start") {
|
|
267
|
+
let r = t - i;
|
|
268
|
+
return {
|
|
269
|
+
startMs: Math.min(e + n, r),
|
|
270
|
+
endMs: t
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
let a = e + i;
|
|
274
|
+
return {
|
|
275
|
+
startMs: e,
|
|
276
|
+
endMs: Math.max(t + n, a)
|
|
277
|
+
};
|
|
278
|
+
}, Ie = (e, t, n, r) => {
|
|
279
|
+
let i = e.originStartMs, a = e.originEndMs, o = e.originAnchorPx ?? e.originLeftPx, s = e.originAnchorMs ?? n.timeAtX(o), c = o + t, l = n.timeAtX(c);
|
|
280
|
+
if (e.dragMode === "move") {
|
|
281
|
+
let t = Math.round((l - s) / R) * R;
|
|
282
|
+
i = e.originStartMs + t, a = e.originEndMs + t;
|
|
283
|
+
} else e.dragMode === "resize-start" ? (i = Ne(l, r, "round"), a = e.originEndMs, a - i < r && (i = a - r)) : (a = Ne(l, r, "round"), i = e.originStartMs, a - i < r && (a = i + r));
|
|
284
|
+
return {
|
|
285
|
+
deltaUnits: e.dragMode === "resize-end" ? Math.round((a - e.originEndMs) / r) : Math.round((i - e.originStartMs) / r),
|
|
286
|
+
previewStartMs: i,
|
|
287
|
+
previewEndMs: a,
|
|
288
|
+
previewLeftPx: e.dragMode === "resize-end" ? e.originLeftPx : c
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
function Le(e) {
|
|
292
|
+
let t = {
|
|
293
|
+
taskId: String(e.item.id),
|
|
294
|
+
newStart: e.startMs,
|
|
295
|
+
newEnd: e.endMs,
|
|
296
|
+
deltaMs: e.deltaMs,
|
|
297
|
+
snapUnitMs: e.snapUnitMs,
|
|
298
|
+
changeType: e.changeType,
|
|
299
|
+
viewMode: e.viewMode
|
|
300
|
+
};
|
|
301
|
+
if (ge(e.viewMode)) return {
|
|
302
|
+
taskId: t.taskId,
|
|
303
|
+
newStart: t.newStart,
|
|
304
|
+
newEnd: t.newEnd,
|
|
305
|
+
deltaMs: t.deltaMs,
|
|
306
|
+
snapUnitMs: t.snapUnitMs,
|
|
307
|
+
changeType: t.changeType,
|
|
308
|
+
viewMode: e.viewMode
|
|
309
|
+
};
|
|
310
|
+
let n = e;
|
|
311
|
+
return {
|
|
312
|
+
taskId: t.taskId,
|
|
313
|
+
newStart: t.newStart,
|
|
314
|
+
newEnd: t.newEnd,
|
|
315
|
+
deltaMs: t.deltaMs,
|
|
316
|
+
snapUnitMs: t.snapUnitMs,
|
|
317
|
+
changeType: t.changeType,
|
|
318
|
+
viewMode: n.viewMode,
|
|
319
|
+
deltaDays: n.deltaDays
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
var Re = (e) => e && o(e.then) ? e : Promise.resolve(e);
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/components/Gantt/GanttChart/hooks/useEdgeScroll.tsx
|
|
325
|
+
function ze(e, t) {
|
|
326
|
+
return e < 0 ? t * 10 : e >= 20 ? 0 : t * (2 + 8 * (1 - e / 20));
|
|
327
|
+
}
|
|
328
|
+
function Be(e, t) {
|
|
329
|
+
let n = S(null), r = S(0), i = g(() => {
|
|
330
|
+
n.current !== null && cancelAnimationFrame(n.current), n.current = null, r.current = 0;
|
|
331
|
+
}, []);
|
|
332
|
+
v(() => () => {
|
|
333
|
+
n.current !== null && cancelAnimationFrame(n.current);
|
|
334
|
+
}, []);
|
|
335
|
+
let a = g(() => {
|
|
336
|
+
if (n.current !== null) return;
|
|
337
|
+
let i = () => {
|
|
338
|
+
let a = e.current, o = r.current;
|
|
339
|
+
if (!a || o === 0) {
|
|
340
|
+
n.current = null;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
let s = a.scrollLeft, c = a.scrollWidth - a.clientWidth, l = Math.max(0, Math.min(c, s + o));
|
|
344
|
+
a.scrollLeft = l, l !== s && t?.current?.(), n.current = requestAnimationFrame(i);
|
|
345
|
+
};
|
|
346
|
+
n.current = requestAnimationFrame(i);
|
|
347
|
+
}, [e, t]);
|
|
348
|
+
return {
|
|
349
|
+
startEdgeDetection: g((t, n) => {
|
|
350
|
+
let o = e.current;
|
|
351
|
+
if (!o) return 0;
|
|
352
|
+
let s = n ?? o.getBoundingClientRect(), c = t - s.left, l = s.right - t, u = c < 20 ? ze(c, -1) : l < 20 ? ze(l, 1) : 0;
|
|
353
|
+
return r.current = u, u === 0 ? i() : a(), u;
|
|
354
|
+
}, [
|
|
355
|
+
e,
|
|
356
|
+
a,
|
|
357
|
+
i
|
|
358
|
+
]),
|
|
359
|
+
stopEdgeScroll: i
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/components/Gantt/GanttChart/utils/timelineViewConfig.ts
|
|
364
|
+
var Ve = R / 24, He = Ve / 60, Ue = {
|
|
365
|
+
hour: Ve,
|
|
366
|
+
tenMinute: 10 * He,
|
|
367
|
+
oneMinute: He
|
|
368
|
+
}, We = {
|
|
369
|
+
day: {
|
|
370
|
+
tier: "calendar",
|
|
371
|
+
headerLayout: "flat",
|
|
372
|
+
topGroup: "month",
|
|
373
|
+
bottomCellMs: R,
|
|
374
|
+
snapUnitMs: R
|
|
375
|
+
},
|
|
376
|
+
week: {
|
|
377
|
+
tier: "calendar",
|
|
378
|
+
headerLayout: "flat",
|
|
379
|
+
topGroup: "month",
|
|
380
|
+
bottomCellMs: 7 * R,
|
|
381
|
+
snapUnitMs: R
|
|
382
|
+
},
|
|
383
|
+
month: {
|
|
384
|
+
tier: "calendar",
|
|
385
|
+
headerLayout: "flat",
|
|
386
|
+
topGroup: "year",
|
|
387
|
+
bottomCellMs: 30 * R,
|
|
388
|
+
snapUnitMs: R
|
|
389
|
+
},
|
|
390
|
+
quarter: {
|
|
391
|
+
tier: "calendar",
|
|
392
|
+
headerLayout: "flat",
|
|
393
|
+
topGroup: "year",
|
|
394
|
+
bottomCellMs: 90 * R,
|
|
395
|
+
snapUnitMs: R
|
|
396
|
+
},
|
|
397
|
+
quarterMonth: {
|
|
398
|
+
tier: "calendar",
|
|
399
|
+
headerLayout: "quarterNested",
|
|
400
|
+
topGroup: "quarter",
|
|
401
|
+
bottomCellMs: 30 * R,
|
|
402
|
+
bottomCellWidthPx: 100,
|
|
403
|
+
snapUnitMs: R
|
|
404
|
+
},
|
|
405
|
+
year: {
|
|
406
|
+
tier: "calendar",
|
|
407
|
+
headerLayout: "flat",
|
|
408
|
+
topGroup: "year",
|
|
409
|
+
bottomCellMs: 180 * R,
|
|
410
|
+
snapUnitMs: R
|
|
411
|
+
},
|
|
412
|
+
halfDay: {
|
|
413
|
+
tier: "subDay",
|
|
414
|
+
headerLayout: "dayNested",
|
|
415
|
+
topGroup: "day",
|
|
416
|
+
bottomCellMs: 12 * Ve,
|
|
417
|
+
snapUnitMs: Ue.hour
|
|
418
|
+
},
|
|
419
|
+
sixHour: {
|
|
420
|
+
tier: "subDay",
|
|
421
|
+
headerLayout: "dayNested",
|
|
422
|
+
topGroup: "day",
|
|
423
|
+
bottomCellMs: 6 * Ve,
|
|
424
|
+
snapUnitMs: Ue.hour
|
|
425
|
+
},
|
|
426
|
+
hour: {
|
|
427
|
+
tier: "subDay",
|
|
428
|
+
headerLayout: "dayNested",
|
|
429
|
+
topGroup: "day",
|
|
430
|
+
bottomCellMs: Ve,
|
|
431
|
+
snapUnitMs: Ue.hour
|
|
432
|
+
},
|
|
433
|
+
halfHour: {
|
|
434
|
+
tier: "subDay",
|
|
435
|
+
headerLayout: "hourNested",
|
|
436
|
+
topGroup: "hour",
|
|
437
|
+
bottomCellMs: 30 * He,
|
|
438
|
+
snapUnitMs: Ue.tenMinute
|
|
439
|
+
},
|
|
440
|
+
tenMinute: {
|
|
441
|
+
tier: "subDay",
|
|
442
|
+
headerLayout: "hourNested",
|
|
443
|
+
topGroup: "hour",
|
|
444
|
+
bottomCellMs: 10 * He,
|
|
445
|
+
snapUnitMs: Ue.tenMinute
|
|
446
|
+
},
|
|
447
|
+
oneMinute: {
|
|
448
|
+
tier: "subDay",
|
|
449
|
+
headerLayout: "hourNested",
|
|
450
|
+
topGroup: "hour",
|
|
451
|
+
bottomCellMs: He,
|
|
452
|
+
snapUnitMs: Ue.oneMinute
|
|
453
|
+
}
|
|
454
|
+
}, Ge = (e) => We[he(e) ? e : "day"], Ke = (e) => he(e) ? ge(e) : Ge(e).tier === "subDay", qe = (e) => e === "quarterMonth", Je = (e) => Ge(e).snapUnitMs, Ye = (e) => Ge(e).bottomCellMs;
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/components/Gantt/GanttChart/hooks/useGanttDrag.tsx
|
|
457
|
+
function Xe({ pixelsPerDay: e, viewMode: t, timelineCoords: n, onTaskTimeChange: r, containerRef: i, onDragInteractionChange: a }) {
|
|
458
|
+
let o = ge(t), s = Je(t), c = s / R * e, l = S(n);
|
|
459
|
+
l.current = n;
|
|
460
|
+
let [u, d] = C({}), [f, p] = C(null), m = S(null), h = S({
|
|
461
|
+
shouldSuppressClick: !1,
|
|
462
|
+
at: 0
|
|
463
|
+
}), _ = S(0), y = S(null), { startEdgeDetection: b, stopEdgeScroll: x } = Be(i ?? { current: null }, y), w = S({});
|
|
464
|
+
v(() => {
|
|
465
|
+
m.current = f;
|
|
466
|
+
}, [f]), v(() => () => {
|
|
467
|
+
for (let e of Object.values(w.current)) e.timeoutId && clearTimeout(e.timeoutId);
|
|
468
|
+
}, []);
|
|
469
|
+
let T = g(() => {
|
|
470
|
+
d((e) => {
|
|
471
|
+
let t = Object.keys(w.current);
|
|
472
|
+
if (t.length === 0) return {};
|
|
473
|
+
let n = {};
|
|
474
|
+
for (let r of t) e[r] && (n[r] = e[r]);
|
|
475
|
+
return Object.keys(n).length === Object.keys(e).length ? e : n;
|
|
476
|
+
}), h.current = {
|
|
477
|
+
shouldSuppressClick: !1,
|
|
478
|
+
at: 0
|
|
479
|
+
};
|
|
480
|
+
}, []), E = g(() => {
|
|
481
|
+
for (let e of Object.values(w.current)) e.timeoutId && clearTimeout(e.timeoutId);
|
|
482
|
+
w.current = {}, d({}), h.current = {
|
|
483
|
+
shouldSuppressClick: !1,
|
|
484
|
+
at: 0
|
|
485
|
+
};
|
|
486
|
+
}, []), D = g((e, t, n, r, o = 1) => {
|
|
487
|
+
if (!Ae(t, r) || t.invalid) return;
|
|
488
|
+
e.preventDefault(), e.stopPropagation();
|
|
489
|
+
let s = i?.current, c = s?.scrollLeft ?? 0, u = s?.getBoundingClientRect(), d = u ? e.clientX - u.left : 0, f = t.endMs ?? 0, g = t.startMs ?? 0, _ = Math.max(1, o), v = r === "resize-end" ? n + _ : n, y = d - (v - c), b = {
|
|
490
|
+
taskId: t.id,
|
|
491
|
+
item: t,
|
|
492
|
+
startClientX: e.clientX,
|
|
493
|
+
grabOffsetInBar: y,
|
|
494
|
+
originLeftPx: n,
|
|
495
|
+
originWidthPx: _,
|
|
496
|
+
originAnchorPx: v,
|
|
497
|
+
originAnchorMs: l.current.timeAtX(v),
|
|
498
|
+
originStartMs: g,
|
|
499
|
+
originEndMs: f,
|
|
500
|
+
deltaUnits: 0,
|
|
501
|
+
dragMode: r,
|
|
502
|
+
previewLeftPx: n,
|
|
503
|
+
previewStartMs: g,
|
|
504
|
+
previewEndMs: f
|
|
505
|
+
};
|
|
506
|
+
h.current = {
|
|
507
|
+
shouldSuppressClick: !1,
|
|
508
|
+
at: 0
|
|
509
|
+
}, m.current = b, p(b), a?.(!0);
|
|
510
|
+
}, [i, a]), O = g((e, t, n, r) => {
|
|
511
|
+
D(e, t, n, ne, r);
|
|
512
|
+
}, [D]), ee = g((e, t, n, r, i) => {
|
|
513
|
+
D(e, t, n, r === "start" ? re : z, i);
|
|
514
|
+
}, [D]);
|
|
515
|
+
return v(() => {
|
|
516
|
+
if (!f?.taskId) return;
|
|
517
|
+
let e = (e, t, n = "mousemove") => {
|
|
518
|
+
let r = m.current;
|
|
519
|
+
if (!r) return;
|
|
520
|
+
let a = i?.current, u = t ?? a?.getBoundingClientRect(), d = a?.scrollLeft ?? 0, f = l.current, h = d + (u ? e - u.left : 0) - r.grabOffsetInBar, g = r.dragMode === "resize-end" ? r.originLeftPx : h;
|
|
521
|
+
if (n === "edgeScroll") {
|
|
522
|
+
let e = r.dragMode === "resize-end" ? r.originLeftPx : g;
|
|
523
|
+
if (e === r.previewLeftPx) return;
|
|
524
|
+
let t = {
|
|
525
|
+
...r,
|
|
526
|
+
previewLeftPx: e
|
|
527
|
+
};
|
|
528
|
+
m.current = t, p(t);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
let _ = h - r.originAnchorPx;
|
|
532
|
+
if (!o) {
|
|
533
|
+
let e = {
|
|
534
|
+
...Ie(r, _, f, s),
|
|
535
|
+
previewLeftPx: g
|
|
536
|
+
};
|
|
537
|
+
if (e.deltaUnits === r.deltaUnits && e.previewLeftPx === r.previewLeftPx && e.previewStartMs === r.previewStartMs && e.previewEndMs === r.previewEndMs) return;
|
|
538
|
+
let t = {
|
|
539
|
+
...r,
|
|
540
|
+
...e
|
|
541
|
+
};
|
|
542
|
+
m.current = t, p(t);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
let v = Me(_, c), y = {
|
|
546
|
+
...r,
|
|
547
|
+
deltaUnits: v,
|
|
548
|
+
previewLeftPx: g
|
|
549
|
+
};
|
|
550
|
+
if (r.dragMode === "move") {
|
|
551
|
+
let e = Pe(r.originStartMs, r.originEndMs, v * s);
|
|
552
|
+
y.previewStartMs = e.startMs, y.previewEndMs = e.endMs;
|
|
553
|
+
} else {
|
|
554
|
+
let e = Fe({
|
|
555
|
+
startMs: r.originStartMs,
|
|
556
|
+
endMs: r.originEndMs,
|
|
557
|
+
deltaMs: v * s,
|
|
558
|
+
edge: r.dragMode === "resize-start" ? "start" : "end",
|
|
559
|
+
minDurationMs: s
|
|
560
|
+
});
|
|
561
|
+
y.previewStartMs = e.startMs, y.previewEndMs = e.endMs;
|
|
562
|
+
}
|
|
563
|
+
let b = Math.round((y.previewStartMs - r.originStartMs) / s), x = {
|
|
564
|
+
...y,
|
|
565
|
+
deltaUnits: r.dragMode === "resize-end" ? Math.round((y.previewEndMs - r.originEndMs) / s) : b
|
|
566
|
+
};
|
|
567
|
+
x.deltaUnits === r.deltaUnits && x.previewLeftPx === r.previewLeftPx && x.previewStartMs === r.previewStartMs && x.previewEndMs === r.previewEndMs || (m.current = x, p(x));
|
|
568
|
+
};
|
|
569
|
+
y.current = () => {
|
|
570
|
+
let t = i?.current?.getBoundingClientRect() ?? null;
|
|
571
|
+
e(_.current, t, "edgeScroll");
|
|
572
|
+
};
|
|
573
|
+
let n = (t) => {
|
|
574
|
+
_.current = t.clientX;
|
|
575
|
+
let n = i?.current?.getBoundingClientRect() ?? null, r = b(t.clientX, n ?? void 0);
|
|
576
|
+
e(t.clientX, n, r === 0 ? "mousemove" : "edgeScroll");
|
|
577
|
+
}, u = () => {
|
|
578
|
+
x(), y.current = null, e(_.current);
|
|
579
|
+
let n = m.current;
|
|
580
|
+
if (a?.(!1), !n) return;
|
|
581
|
+
let i = n.previewStartMs !== n.originStartMs || n.previewEndMs !== n.originEndMs;
|
|
582
|
+
h.current = {
|
|
583
|
+
shouldSuppressClick: i,
|
|
584
|
+
at: Date.now()
|
|
585
|
+
};
|
|
586
|
+
let c = i;
|
|
587
|
+
if (!Ae(n.item, n.dragMode) || !c || !r) {
|
|
588
|
+
m.current = null, p(null);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
let l = n.taskId;
|
|
592
|
+
d((e) => ({
|
|
593
|
+
...e,
|
|
594
|
+
[l]: {
|
|
595
|
+
startMs: n.previewStartMs,
|
|
596
|
+
endMs: n.previewEndMs
|
|
597
|
+
}
|
|
598
|
+
})), m.current = null, p(null);
|
|
599
|
+
let u = (w.current[l]?.opId || 0) + 1;
|
|
600
|
+
w.current[l]?.timeoutId && clearTimeout(w.current[l].timeoutId);
|
|
601
|
+
let f = setTimeout(() => {
|
|
602
|
+
w.current[l]?.opId === u && (console.warn(`[GanttDrag] task ${l} op ${u} timed out (${B}ms)`), d((e) => {
|
|
603
|
+
let t = { ...e };
|
|
604
|
+
return delete t[l], t;
|
|
605
|
+
}), delete w.current[l]);
|
|
606
|
+
}, B);
|
|
607
|
+
w.current[l] = {
|
|
608
|
+
opId: u,
|
|
609
|
+
startedAt: Date.now(),
|
|
610
|
+
timeoutId: f
|
|
611
|
+
};
|
|
612
|
+
let g, v;
|
|
613
|
+
if (o) if (n.dragMode === "move") {
|
|
614
|
+
let e = Ne(n.previewStartMs, s, "round"), t = e - n.previewStartMs;
|
|
615
|
+
g = e, v = n.previewEndMs + t;
|
|
616
|
+
} else n.dragMode === "resize-start" ? (g = Ne(n.previewStartMs, s, "round"), v = n.previewEndMs) : (g = n.previewStartMs, v = Ne(n.previewEndMs, s, "round"));
|
|
617
|
+
else {
|
|
618
|
+
let e = Number.isFinite(n.item.rawStartMs) && Number.isFinite(n.item.baseStartMs) && Number.isFinite(n.previewStartMs), t = Number.isFinite(n.item.rawEndMs) && Number.isFinite(n.item.baseEndMs) && Number.isFinite(n.previewEndMs), r = e ? Math.round((n.previewStartMs - (n.item.baseStartMs ?? 0)) / R) : 0, i = t ? Math.round((n.previewEndMs - (n.item.baseEndMs ?? 0)) / R) : 0;
|
|
619
|
+
g = e ? (n.item.rawStartMs ?? 0) + r * R : n.item.rawStartMs ?? 0, v = t ? (n.item.rawEndMs ?? 0) + i * R : n.item.rawEndMs ?? 0;
|
|
620
|
+
}
|
|
621
|
+
let b;
|
|
622
|
+
b = ge(t) ? Le({
|
|
623
|
+
item: n.item,
|
|
624
|
+
startMs: g,
|
|
625
|
+
endMs: v,
|
|
626
|
+
deltaMs: n.deltaUnits * s,
|
|
627
|
+
snapUnitMs: s,
|
|
628
|
+
changeType: n.dragMode,
|
|
629
|
+
viewMode: t
|
|
630
|
+
}) : Le({
|
|
631
|
+
item: n.item,
|
|
632
|
+
startMs: g,
|
|
633
|
+
endMs: v,
|
|
634
|
+
deltaDays: n.deltaUnits,
|
|
635
|
+
deltaMs: n.deltaUnits * s,
|
|
636
|
+
snapUnitMs: s,
|
|
637
|
+
changeType: n.dragMode,
|
|
638
|
+
viewMode: t
|
|
639
|
+
}), Re(r(b)).catch((e) => {
|
|
640
|
+
console.error("[GanttChart] onTaskTimeChange rejected", e), w.current[l]?.opId === u && d((e) => {
|
|
641
|
+
let t = { ...e };
|
|
642
|
+
return delete t[l], t;
|
|
643
|
+
});
|
|
644
|
+
}).finally(() => {
|
|
645
|
+
w.current[l]?.opId === u && (clearTimeout(w.current[l].timeoutId), delete w.current[l]);
|
|
646
|
+
});
|
|
647
|
+
}, g = (e) => {
|
|
648
|
+
e.type === "visibilitychange" && document.visibilityState === "visible" || m.current && u();
|
|
649
|
+
};
|
|
650
|
+
return document.addEventListener("mousemove", n), document.addEventListener("mouseup", u), document.addEventListener("mouseleave", g), document.addEventListener("visibilitychange", g), window.addEventListener("blur", g), () => {
|
|
651
|
+
document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", u), document.removeEventListener("mouseleave", g), document.removeEventListener("visibilitychange", g), window.removeEventListener("blur", g), y.current = null;
|
|
652
|
+
};
|
|
653
|
+
}, [
|
|
654
|
+
f?.taskId,
|
|
655
|
+
o,
|
|
656
|
+
s,
|
|
657
|
+
c,
|
|
658
|
+
r,
|
|
659
|
+
e,
|
|
660
|
+
t,
|
|
661
|
+
b,
|
|
662
|
+
x,
|
|
663
|
+
i,
|
|
664
|
+
a
|
|
665
|
+
]), {
|
|
666
|
+
dragState: f,
|
|
667
|
+
committedRangeById: u,
|
|
668
|
+
resetCommittedRanges: T,
|
|
669
|
+
forceResetAllCommittedRanges: E,
|
|
670
|
+
handleTaskMouseDown: O,
|
|
671
|
+
handleResizeMouseDown: ee,
|
|
672
|
+
consumeRecentDragResult: g(() => {
|
|
673
|
+
let { shouldSuppressClick: e, at: t } = h.current;
|
|
674
|
+
return h.current = {
|
|
675
|
+
shouldSuppressClick: !1,
|
|
676
|
+
at: 0
|
|
677
|
+
}, e ? Date.now() - t <= 400 : !1;
|
|
678
|
+
}, [])
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region src/components/Gantt/GanttChart/utils/quarterMonthScale.ts
|
|
683
|
+
j.extend(P);
|
|
684
|
+
var Ze = Ge("quarterMonth").bottomCellWidthPx, Qe = (e) => {
|
|
685
|
+
if (!Number.isFinite(e)) return 0;
|
|
686
|
+
let t = Ee(e), n = Ce(e, "month"), r = Se(we(e, "month") + 1) - n, i = r > 0 ? (e - n) / r : 0;
|
|
687
|
+
return (t.year() * 12 + t.month() + i) * (Ze ?? 100);
|
|
688
|
+
}, $e = (e, t) => Math.max(0, Qe(t) - Qe(e)), et = (e, t) => {
|
|
689
|
+
let n = Ee(e), r = n.quarter();
|
|
690
|
+
return t("header.top.quarter", {
|
|
691
|
+
year: n.year(),
|
|
692
|
+
ordinal: t(`quarter.${r}`)
|
|
693
|
+
});
|
|
694
|
+
}, tt = (e, t) => t("header.lower.month", { month: Ee(e).month() + 1 }), nt = (e, t) => {
|
|
695
|
+
if (!Array.isArray(e) || e.length === 0) return null;
|
|
696
|
+
let n = 0, r = e.length - 1;
|
|
697
|
+
for (; n <= r;) {
|
|
698
|
+
let i = n + r >> 1, a = e[i];
|
|
699
|
+
if (t < a.startMs) r = i - 1;
|
|
700
|
+
else if (t >= a.endMs) n = i + 1;
|
|
701
|
+
else return a;
|
|
702
|
+
}
|
|
703
|
+
return t < e[0].startMs ? e[0] : e[e.length - 1];
|
|
704
|
+
}, rt = (e, t) => {
|
|
705
|
+
if (!t) return 0;
|
|
706
|
+
let n = t.endMs - t.startMs;
|
|
707
|
+
if (n <= 0) return t.left;
|
|
708
|
+
let r = Math.max(0, Math.min(1, (e - t.startMs) / n));
|
|
709
|
+
return t.left + r * t.width;
|
|
710
|
+
}, it = (e, t) => Number.isFinite(e) ? rt(e, nt(t, e)) : 0, at = (e, t, n) => {
|
|
711
|
+
if (!Number.isFinite(e) || !Number.isFinite(t)) return 0;
|
|
712
|
+
let r = nt(n, e), i = nt(n, t);
|
|
713
|
+
return r === i ? Math.max(0, rt(t, r) - rt(e, r)) : Math.max(0, rt(t, i) - rt(e, r));
|
|
714
|
+
}, ot = (e, t, n) => {
|
|
715
|
+
if (!Array.isArray(t) || t.length === 0) return 0;
|
|
716
|
+
if (!Number.isFinite(e) || e <= 0) return t[0].startMs;
|
|
717
|
+
let r = 0, i = t.length - 1;
|
|
718
|
+
for (; r <= i;) {
|
|
719
|
+
let a = r + i >> 1, o = t[a], s = o.left + o.width;
|
|
720
|
+
if (e < o.left) i = a - 1;
|
|
721
|
+
else if (e >= s) r = a + 1;
|
|
722
|
+
else {
|
|
723
|
+
let t = o.width > 0 ? (e - o.left) / o.width : 0, r = o.startMs + t * (o.endMs - o.startMs);
|
|
724
|
+
return Math.min(r, n);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
let a = t[t.length - 1];
|
|
728
|
+
return Math.min(a.endMs, n);
|
|
729
|
+
};
|
|
730
|
+
j.extend(M), j.extend(P);
|
|
731
|
+
var st = (e) => {
|
|
732
|
+
if (e == null || c(e) && e.trim() === "") return 0;
|
|
733
|
+
let t = Number(e);
|
|
734
|
+
return Number.isFinite(t) ? t < 0 || t > 1 ? 1 : t : 0;
|
|
735
|
+
}, ct = (e) => {
|
|
736
|
+
if (e == null) return null;
|
|
737
|
+
let t = j(e);
|
|
738
|
+
return t.isValid() ? t.valueOf() : null;
|
|
739
|
+
}, lt = (e) => Se(e), ut = (e, t = ae) => {
|
|
740
|
+
let n = Number(t?.[e]);
|
|
741
|
+
if (n > 0) return n;
|
|
742
|
+
if (qe(e)) {
|
|
743
|
+
let { bottomCellWidthPx: t, bottomCellMs: n } = Ge(e);
|
|
744
|
+
return (t ?? 100) / (n / R);
|
|
745
|
+
}
|
|
746
|
+
let r = Number(ae[e]);
|
|
747
|
+
return r > 0 ? r : ae.day;
|
|
748
|
+
}, dt = (e, t) => {
|
|
749
|
+
let n = Number(e);
|
|
750
|
+
return Number.isFinite(n) ? n : t;
|
|
751
|
+
}, ft = (e, t = H) => {
|
|
752
|
+
let n = Number(G[e]);
|
|
753
|
+
return Number.isFinite(n) && n >= 0 ? {
|
|
754
|
+
bufferDaysBefore: n,
|
|
755
|
+
bufferDaysAfter: n
|
|
756
|
+
} : {
|
|
757
|
+
bufferDaysBefore: dt(t?.bufferDaysBefore, H.bufferDaysBefore),
|
|
758
|
+
bufferDaysAfter: dt(t?.bufferDaysAfter, H.bufferDaysAfter)
|
|
759
|
+
};
|
|
760
|
+
}, pt = (e = H, t = xe()) => {
|
|
761
|
+
let n = dt(e?.bufferDaysBefore, H.bufferDaysBefore), r = dt(e?.bufferDaysAfter, H.bufferDaysAfter), i = lt(t);
|
|
762
|
+
return {
|
|
763
|
+
startMs: i - n * R,
|
|
764
|
+
endMs: i + (r + 1) * R
|
|
765
|
+
};
|
|
766
|
+
}, mt = (e, t, n) => {
|
|
767
|
+
let r = j(e).isValid() ? e : Date.now(), i = j(t).isValid() ? t : Date.now() + R;
|
|
768
|
+
switch (n) {
|
|
769
|
+
case "week": return {
|
|
770
|
+
startMs: Ce(r, "isoWeek"),
|
|
771
|
+
endMs: Se(we(i, "isoWeek") + 1)
|
|
772
|
+
};
|
|
773
|
+
case "month":
|
|
774
|
+
case "quarterMonth": return {
|
|
775
|
+
startMs: Ce(r, "month"),
|
|
776
|
+
endMs: Se(we(i, "month") + 1)
|
|
777
|
+
};
|
|
778
|
+
case "quarter": return {
|
|
779
|
+
startMs: Ce(r, "quarter"),
|
|
780
|
+
endMs: Se(we(i, "quarter") + 1)
|
|
781
|
+
};
|
|
782
|
+
case "year": return {
|
|
783
|
+
startMs: Ce(r, "year"),
|
|
784
|
+
endMs: Se(we(i, "year") + 1)
|
|
785
|
+
};
|
|
786
|
+
default: {
|
|
787
|
+
let e = lt(r), t = lt(i);
|
|
788
|
+
return {
|
|
789
|
+
startMs: e,
|
|
790
|
+
endMs: i === t ? i : t + R
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}, ht = (e, t, n, r, i) => qe(r) && Array.isArray(i) && i.length ? it(e, i) : (e - t) / R * n, gt = (e, t, n, r, i, a) => qe(r) && Array.isArray(a) && a.length ? at(e, t, a) : (t - e) / R * n, _t = (e, t, n, r, i, a) => qe(r) && Array.isArray(a) && a.length ? ot(e, a, i ?? t) : t + e / n * R, vt = ({ viewMode: e, timelineStartMs: t, timelineEndMs: n, pixelsPerDay: r, lowerSegments: i }) => ({
|
|
795
|
+
toX: (n) => ht(n, t, r, e, i),
|
|
796
|
+
toWidth: (n, a) => gt(n, a, r, e, t, i),
|
|
797
|
+
timeAtX: (a) => _t(a, t, r, e, n, i)
|
|
798
|
+
});
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region src/components/Gantt/GanttChart/utils/timelineFocus.ts
|
|
801
|
+
function yt(e, t, n) {
|
|
802
|
+
let r = Number(t) > 0 ? Number(t) : 0, i = Number(n) > 0 ? Number(n) : 0, a = Math.max(0, i - r);
|
|
803
|
+
return Number.isFinite(e) ? Math.min(Math.max(0, e), a) : 0;
|
|
804
|
+
}
|
|
805
|
+
function bt({ anchorMs: e, toX: t, viewportWidth: n, timelineWidth: r }) {
|
|
806
|
+
let i = Number(n) > 0 ? Number(n) : 0;
|
|
807
|
+
if (!Number.isFinite(e) || typeof t != "function" || i <= 0) return 0;
|
|
808
|
+
let a = t(e);
|
|
809
|
+
return Number.isFinite(a) ? yt(a - i / 2, i, r) : 0;
|
|
810
|
+
}
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/components/Gantt/GanttChart/hooks/useGanttColumnVirtual.ts
|
|
813
|
+
function xt(e) {
|
|
814
|
+
let t = Number(e);
|
|
815
|
+
return Math.max((Number.isFinite(t) && t > 0 ? t : 0) * 4, 240);
|
|
816
|
+
}
|
|
817
|
+
function St(e, t) {
|
|
818
|
+
if (!Array.isArray(e) || e.length === 0) return [];
|
|
819
|
+
let { scrollLeft: n = 0, viewportWidth: r = 0, pixelsPerDay: i } = t || {}, a = xt(Number(e[0]?.width) > 0 ? Number(e[0].width) : i), o = e[e.length - 1], s = yt(n, r, Number(o?.left) + Number(o?.width) > 0 ? Number(o.left) + Number(o.width) : 0), c = Math.max(0, s - a), l = s + r + a, u = e.length, d = 0, f = u - 1, p = u;
|
|
820
|
+
for (; d <= f;) {
|
|
821
|
+
let t = d + f >> 1, n = e[t];
|
|
822
|
+
n.left + n.width > c ? (p = t, f = t - 1) : d = t + 1;
|
|
823
|
+
}
|
|
824
|
+
d = 0, f = u - 1;
|
|
825
|
+
let m = -1;
|
|
826
|
+
for (; d <= f;) {
|
|
827
|
+
let t = d + f >> 1;
|
|
828
|
+
e[t].left < l ? (m = t, d = t + 1) : f = t - 1;
|
|
829
|
+
}
|
|
830
|
+
if (p > m) return [];
|
|
831
|
+
let h = [];
|
|
832
|
+
for (let e = p; e <= m; e += 1) h.push({ index: e });
|
|
833
|
+
return h;
|
|
834
|
+
}
|
|
835
|
+
function Ct({ lowerSegments: e, pixelsPerDay: t, scrollLeft: n, viewportWidth: r, showWeekendHighlight: i, timelineStartMs: a, timelineWidth: o, viewMode: s }) {
|
|
836
|
+
return {
|
|
837
|
+
virtualColumns: x(() => St(e, {
|
|
838
|
+
scrollLeft: n,
|
|
839
|
+
viewportWidth: r,
|
|
840
|
+
pixelsPerDay: t
|
|
841
|
+
}), [
|
|
842
|
+
e,
|
|
843
|
+
t,
|
|
844
|
+
n,
|
|
845
|
+
r
|
|
846
|
+
]),
|
|
847
|
+
weekendSegments: x(() => {
|
|
848
|
+
if (!i || o <= 0 || s !== "day") return [];
|
|
849
|
+
let e = Math.max(0, n - 120), c = n + r + 120, l = Math.max(0, Math.floor(e / t)), u = Math.ceil(c / t), d = [];
|
|
850
|
+
for (let e = l; e <= u; e += 1) {
|
|
851
|
+
let n = a + e * R, r = Te(n);
|
|
852
|
+
(r === 0 || r === 6) && d.push({
|
|
853
|
+
id: `weekend-${n}`,
|
|
854
|
+
left: e * t,
|
|
855
|
+
width: t
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
return d;
|
|
859
|
+
}, [
|
|
860
|
+
i,
|
|
861
|
+
o,
|
|
862
|
+
n,
|
|
863
|
+
r,
|
|
864
|
+
t,
|
|
865
|
+
a,
|
|
866
|
+
s
|
|
867
|
+
])
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
j.extend(M), j.extend(P);
|
|
871
|
+
var wt = {
|
|
872
|
+
day: {
|
|
873
|
+
amount: 1,
|
|
874
|
+
unit: "day"
|
|
875
|
+
},
|
|
876
|
+
week: {
|
|
877
|
+
amount: 1,
|
|
878
|
+
unit: "week"
|
|
879
|
+
},
|
|
880
|
+
month: {
|
|
881
|
+
amount: 1,
|
|
882
|
+
unit: "month"
|
|
883
|
+
},
|
|
884
|
+
quarter: {
|
|
885
|
+
amount: 1,
|
|
886
|
+
unit: "quarter"
|
|
887
|
+
},
|
|
888
|
+
quarterMonth: {
|
|
889
|
+
amount: 1,
|
|
890
|
+
unit: "month"
|
|
891
|
+
},
|
|
892
|
+
year: {
|
|
893
|
+
amount: 6,
|
|
894
|
+
unit: "month",
|
|
895
|
+
align: (e) => {
|
|
896
|
+
let t = e.month();
|
|
897
|
+
return t !== 0 && t !== 6 ? t < 6 ? e.startOf("year") : e.month(6).startOf("month") : e;
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
halfDay: {
|
|
901
|
+
amount: 12,
|
|
902
|
+
unit: "hour"
|
|
903
|
+
},
|
|
904
|
+
sixHour: {
|
|
905
|
+
amount: 6,
|
|
906
|
+
unit: "hour"
|
|
907
|
+
},
|
|
908
|
+
hour: {
|
|
909
|
+
amount: 1,
|
|
910
|
+
unit: "hour"
|
|
911
|
+
},
|
|
912
|
+
halfHour: {
|
|
913
|
+
amount: 30,
|
|
914
|
+
unit: "minute"
|
|
915
|
+
},
|
|
916
|
+
tenMinute: {
|
|
917
|
+
amount: 10,
|
|
918
|
+
unit: "minute"
|
|
919
|
+
},
|
|
920
|
+
oneMinute: {
|
|
921
|
+
amount: 1,
|
|
922
|
+
unit: "minute"
|
|
923
|
+
}
|
|
924
|
+
}, Tt = (e, t, n) => {
|
|
925
|
+
switch (t) {
|
|
926
|
+
case "halfDay": return e.hour() < 12 ? n("header.lower.halfDayAm") : n("header.lower.halfDayPm");
|
|
927
|
+
case "sixHour": {
|
|
928
|
+
let t = e.hour();
|
|
929
|
+
return n("header.lower.sixHourRange", {
|
|
930
|
+
start: t,
|
|
931
|
+
end: t + 6
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
case "hour": return String(e.hour());
|
|
935
|
+
case "halfHour": return e.format("HH:mm");
|
|
936
|
+
case "tenMinute": return String(e.minute());
|
|
937
|
+
case "oneMinute": return e.format("mm");
|
|
938
|
+
default: return e.format("DD");
|
|
939
|
+
}
|
|
940
|
+
}, Et = (e, t, n) => {
|
|
941
|
+
let r = Ee(e.valueOf());
|
|
942
|
+
switch (t) {
|
|
943
|
+
case "day": return r.format("DD");
|
|
944
|
+
case "week": return n("header.lower.week", { week: r.isoWeek() });
|
|
945
|
+
case "month":
|
|
946
|
+
case "quarterMonth": return tt(e.valueOf(), n);
|
|
947
|
+
case "quarter": return n("header.lower.quarter", { quarter: r.quarter() });
|
|
948
|
+
case "year": return r.month() < 6 ? n("firstHalf") : n("secondHalf");
|
|
949
|
+
default: return Tt(r, t, n);
|
|
950
|
+
}
|
|
951
|
+
}, Dt = (e, t) => {
|
|
952
|
+
let n = Ee(e.valueOf()), r = Ge(t).headerLayout;
|
|
953
|
+
return r === "dayNested" ? `day-${n.format("YYYY-MM-DD")}` : r === "hourNested" ? `hour-${n.format("YYYY-MM-DD-HH")}` : r === "quarterNested" ? `quarter-${n.format("YYYY")}-Q${n.quarter()}` : t === "day" || t === "week" ? `month-${n.format("YYYY-MM")}` : `year-${n.format("YYYY")}`;
|
|
954
|
+
}, Ot = (e, t, n) => {
|
|
955
|
+
let r = Ee(e.valueOf()), i = Ge(t).headerLayout;
|
|
956
|
+
if (i === "dayNested") return { label: n("header.top.monthDay", {
|
|
957
|
+
month: r.month() + 1,
|
|
958
|
+
day: r.date()
|
|
959
|
+
}) };
|
|
960
|
+
if (i === "hourNested") {
|
|
961
|
+
let e = r.hour();
|
|
962
|
+
if (e === 0) return { label: n("header.top.hourWithDate", {
|
|
963
|
+
month: r.month() + 1,
|
|
964
|
+
day: r.date(),
|
|
965
|
+
hour: 0
|
|
966
|
+
}) };
|
|
967
|
+
let i = n("header.top.hourOnly", { hour: e });
|
|
968
|
+
return t === "tenMinute" || t === "oneMinute" ? {
|
|
969
|
+
label: i,
|
|
970
|
+
dateLabel: n("header.top.monthDay", {
|
|
971
|
+
month: r.month() + 1,
|
|
972
|
+
day: r.date()
|
|
973
|
+
})
|
|
974
|
+
} : { label: i };
|
|
975
|
+
}
|
|
976
|
+
return i === "quarterNested" ? { label: et(e.valueOf(), n) } : t === "day" || t === "week" ? { label: n("header.top.yearMonth", {
|
|
977
|
+
year: r.year(),
|
|
978
|
+
month: r.month() + 1
|
|
979
|
+
}) } : { label: n("header.top.year", { year: r.year() }) };
|
|
980
|
+
}, kt = (e, t, n, r, i, a, o) => {
|
|
981
|
+
let s = qe(r), c = Ze ?? 100;
|
|
982
|
+
e.push({
|
|
983
|
+
id: `${r}-${t}`,
|
|
984
|
+
startMs: t,
|
|
985
|
+
endMs: n,
|
|
986
|
+
left: s ? e.length * c : ht(t, i, a, r),
|
|
987
|
+
width: s ? c : Math.max(1, gt(t, n, a, r)),
|
|
988
|
+
label: Et(j(t), r, o)
|
|
989
|
+
});
|
|
990
|
+
}, At = ({ viewMode: e, timelineStartMs: t, timelineEndMs: n, pixelsPerDay: r, formatMessage: i }) => {
|
|
991
|
+
let a = [], o = wt[e] || wt.day, s = j(ye(t));
|
|
992
|
+
qe(e) && (s = s.startOf("month"));
|
|
993
|
+
let c = j(ye(n));
|
|
994
|
+
for (; s.isBefore(c);) {
|
|
995
|
+
o.align && (s = o.align(s));
|
|
996
|
+
let n = s.add(o.amount, o.unit);
|
|
997
|
+
kt(a, be(s.valueOf()), be(n.valueOf()), e, t, r, i), s = n;
|
|
998
|
+
}
|
|
999
|
+
return a;
|
|
1000
|
+
}, jt = ({ lowerSegments: e, viewMode: t, formatMessage: n }) => {
|
|
1001
|
+
if (!Array.isArray(e) || e.length === 0) return [];
|
|
1002
|
+
let r = [], i = null;
|
|
1003
|
+
for (let a of e) {
|
|
1004
|
+
let e = j(a.startMs), o = Dt(e, t);
|
|
1005
|
+
if (!i || i.id !== o) {
|
|
1006
|
+
i && r.push(i), i = {
|
|
1007
|
+
id: o,
|
|
1008
|
+
left: a.left,
|
|
1009
|
+
width: a.width,
|
|
1010
|
+
...Ot(e, t, n)
|
|
1011
|
+
};
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
i.width += a.width;
|
|
1015
|
+
}
|
|
1016
|
+
return i !== null && r.push(i), r;
|
|
1017
|
+
}, Mt = (e) => Number.isFinite(e.startMs) && Number.isFinite(e.endMs) && e.startMs < e.endMs, Nt = (e) => {
|
|
1018
|
+
if (!Mt(e)) throw RangeError("Timeline range must be finite and satisfy startMs < endMs");
|
|
1019
|
+
}, Pt = (e, t) => {
|
|
1020
|
+
if (Nt(e), !Number.isFinite(t)) throw RangeError("Timeline time must be finite");
|
|
1021
|
+
return e.startMs <= t && t < e.endMs;
|
|
1022
|
+
}, Ft = (e, t) => (Nt(e), Nt(t), e.startMs < t.endMs && t.startMs < e.endMs), It = (e, t) => {
|
|
1023
|
+
Nt(e), Nt(t);
|
|
1024
|
+
let n = Math.max(e.startMs, t.startMs), r = Math.min(e.endMs, t.endMs);
|
|
1025
|
+
return n < r ? {
|
|
1026
|
+
startMs: n,
|
|
1027
|
+
endMs: r
|
|
1028
|
+
} : null;
|
|
1029
|
+
}, Lt = (e, t) => {
|
|
1030
|
+
if (!Number.isFinite(e) || e <= 0) throw RangeError(`${t} must be finite and greater than zero`);
|
|
1031
|
+
}, Rt = (e, t) => {
|
|
1032
|
+
if (Number.isFinite(e)) return e;
|
|
1033
|
+
if (Number.isFinite(t)) return t;
|
|
1034
|
+
throw RangeError("focusMs or fallbackFocusMs must be finite");
|
|
1035
|
+
}, zt = ({ startMs: e, endMs: t, viewMode: n, viewportWidth: r, pixelsPerDay: i }) => {
|
|
1036
|
+
let a = (t - e) / R;
|
|
1037
|
+
if (a * i >= r) return {
|
|
1038
|
+
startMs: e,
|
|
1039
|
+
endMs: t
|
|
1040
|
+
};
|
|
1041
|
+
let o = Math.ceil(r / i), s = Math.ceil((o - a) / 2) * R;
|
|
1042
|
+
return mt(e - s, t + s, n);
|
|
1043
|
+
}, Bt = ({ range: e, focusMs: t, viewMode: n, viewportWidth: r, pixelsPerDay: i }) => {
|
|
1044
|
+
let a = (r / 2 + 281) / i * R;
|
|
1045
|
+
return zt({
|
|
1046
|
+
...mt(Math.min(e.startMs, t - a), Math.max(e.endMs, t + a), n),
|
|
1047
|
+
viewMode: n,
|
|
1048
|
+
viewportWidth: r,
|
|
1049
|
+
pixelsPerDay: i
|
|
1050
|
+
});
|
|
1051
|
+
}, Vt = ({ renderWindow: e, timelineCoords: t, scrollLeft: n, viewportWidth: r }) => {
|
|
1052
|
+
if (!Mt(e)) throw RangeError("renderWindow must be a valid timeline range");
|
|
1053
|
+
if (!Number.isFinite(n) || n < 0) throw RangeError("scrollLeft must be finite and non-negative");
|
|
1054
|
+
Lt(r, "viewportWidth");
|
|
1055
|
+
let i = {
|
|
1056
|
+
startMs: t.timeAtX(n),
|
|
1057
|
+
endMs: t.timeAtX(n + r)
|
|
1058
|
+
};
|
|
1059
|
+
if (!Mt(i)) throw RangeError("TimelineCoords must produce an increasing finite visible range");
|
|
1060
|
+
let a = It(i, e);
|
|
1061
|
+
if (!a) throw RangeError("Visible range must intersect renderWindow");
|
|
1062
|
+
let o = t.timeAtX(n + r / 2);
|
|
1063
|
+
if (!Number.isFinite(o)) throw RangeError("TimelineCoords must produce a finite focus");
|
|
1064
|
+
return {
|
|
1065
|
+
renderWindow: e,
|
|
1066
|
+
visibleRange: a,
|
|
1067
|
+
focusMs: o
|
|
1068
|
+
};
|
|
1069
|
+
}, Ht = ({ scrollLeft: e, viewportWidth: t, timelineWidth: n, guardBandPx: r }) => {
|
|
1070
|
+
if (!Number.isFinite(e) || e < 0) throw RangeError("scrollLeft must be finite and non-negative");
|
|
1071
|
+
if (Lt(t, "viewportWidth"), Lt(n, "timelineWidth"), !Number.isFinite(r) || r < 0) throw RangeError("guardBandPx must be finite and non-negative");
|
|
1072
|
+
let i = Math.max(0, n - t);
|
|
1073
|
+
if (i === 0) return null;
|
|
1074
|
+
let a = Math.min(e, i), o = a <= r;
|
|
1075
|
+
return o === i - a <= r ? null : o ? "left" : "right";
|
|
1076
|
+
}, Ut = ({ focusMs: e, fallbackFocusMs: t, viewMode: n, timeRangeConfig: r, viewportWidth: i, pixelsPerDay: a }) => {
|
|
1077
|
+
Lt(i, "viewportWidth"), Lt(a, "pixelsPerDay");
|
|
1078
|
+
let o = Rt(e, t), s = Bt({
|
|
1079
|
+
range: pt(r, o),
|
|
1080
|
+
focusMs: o,
|
|
1081
|
+
viewMode: n,
|
|
1082
|
+
viewportWidth: i,
|
|
1083
|
+
pixelsPerDay: a
|
|
1084
|
+
});
|
|
1085
|
+
if (!Mt(s)) throw RangeError("Viewport engine produced an invalid render window");
|
|
1086
|
+
return s;
|
|
1087
|
+
}, Wt = ({ focusMs: e, fallbackFocusMs: t, timelineCoords: n, viewportWidth: r, timelineWidth: i }) => {
|
|
1088
|
+
let a = Rt(e, t);
|
|
1089
|
+
return Lt(r, "viewportWidth"), Lt(i, "timelineWidth"), {
|
|
1090
|
+
focusMs: a,
|
|
1091
|
+
scrollLeft: bt({
|
|
1092
|
+
anchorMs: a,
|
|
1093
|
+
toX: n.toX,
|
|
1094
|
+
viewportWidth: r,
|
|
1095
|
+
timelineWidth: i
|
|
1096
|
+
})
|
|
1097
|
+
};
|
|
1098
|
+
}, Gt = (e) => {
|
|
1099
|
+
if (Ke(e)) {
|
|
1100
|
+
let t = Ye(e);
|
|
1101
|
+
return Ne(Date.now(), t, "floor") + t / 2;
|
|
1102
|
+
}
|
|
1103
|
+
return lt(Date.now()) + R / 2;
|
|
1104
|
+
}, Kt = (e, t) => {
|
|
1105
|
+
if (Ke(t)) {
|
|
1106
|
+
let n = Ye(t);
|
|
1107
|
+
return Ne(e, n, "floor") + n + 1;
|
|
1108
|
+
}
|
|
1109
|
+
return lt(e) + R + 1;
|
|
1110
|
+
}, qt = (e) => {
|
|
1111
|
+
let [t, n] = C(() => Gt(e)), r = S(null), i = g(() => {
|
|
1112
|
+
r.current &&= (clearTimeout(r.current), null);
|
|
1113
|
+
}, []), a = g(() => {
|
|
1114
|
+
i();
|
|
1115
|
+
let t = Date.now(), o = Kt(t, e);
|
|
1116
|
+
r.current = setTimeout(() => {
|
|
1117
|
+
n(Gt(e)), a();
|
|
1118
|
+
}, Math.max(1, o - t));
|
|
1119
|
+
}, [i, e]);
|
|
1120
|
+
v(() => (n(Gt(e)), a(), i), [
|
|
1121
|
+
e,
|
|
1122
|
+
a,
|
|
1123
|
+
i
|
|
1124
|
+
]);
|
|
1125
|
+
let o = T();
|
|
1126
|
+
return v(() => {
|
|
1127
|
+
o === "visible" && (n(Gt(e)), a());
|
|
1128
|
+
}, [
|
|
1129
|
+
o,
|
|
1130
|
+
a,
|
|
1131
|
+
e
|
|
1132
|
+
]), t;
|
|
1133
|
+
};
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/components/Gantt/GanttChart/hooks/useTimelineViewportController.ts
|
|
1136
|
+
function Jt({ timeRangeConfig: e, pixelsPerDayConfig: t, viewMode: n, contentRef: r, contentSize: i, headerTrackRef: a, formatMessage: o, isHorizontalScrollbarInteracting: s, isTaskBarInteracting: c = !1 }) {
|
|
1137
|
+
let l = ut(n, t), u = x(() => ft(n, e), [n, e]), d = i?.width !== null && i?.width !== void 0 && Number(i.width) > 0 ? Number(i.width) : 0, f = S(!1), [p, m] = C(!1), [h, _] = C(d), y = S(null), w = S(!1), T = S(!1), E = S(null), D = S(null), O = S(null), [ee, te] = C(0), k = S(null), A = g((e) => {
|
|
1138
|
+
let t = O.current;
|
|
1139
|
+
if (!t || !e) return !1;
|
|
1140
|
+
let n = e.scrollLeft || 0;
|
|
1141
|
+
return Math.abs(n - t.targetLeft) > 1;
|
|
1142
|
+
}, []), j = g((e) => {
|
|
1143
|
+
let t = O.current;
|
|
1144
|
+
t && Math.abs(e - t.targetLeft) <= 1 && (O.current = null);
|
|
1145
|
+
}, []), M = g(() => {
|
|
1146
|
+
D.current !== null && (cancelAnimationFrame(D.current), D.current = null), E.current = null;
|
|
1147
|
+
}, []), N = g((e) => {
|
|
1148
|
+
M();
|
|
1149
|
+
let t = { left: e };
|
|
1150
|
+
E.current = t, D.current = requestAnimationFrame(() => {
|
|
1151
|
+
D.current = null, E.current === t && (E.current = null);
|
|
1152
|
+
});
|
|
1153
|
+
}, [M]), [P, F] = C(0), I = S(0), L = S(0), R = S(null), ne = g((e) => {
|
|
1154
|
+
L.current = e, R.current === null && (R.current = requestAnimationFrame(() => {
|
|
1155
|
+
R.current = null;
|
|
1156
|
+
let e = L.current;
|
|
1157
|
+
F((t) => t === e ? t : e);
|
|
1158
|
+
}));
|
|
1159
|
+
}, []), re = g(() => {
|
|
1160
|
+
k.current !== null && (cancelAnimationFrame(k.current), k.current = null);
|
|
1161
|
+
}, []);
|
|
1162
|
+
v(() => () => {
|
|
1163
|
+
R.current !== null && cancelAnimationFrame(R.current), re(), M();
|
|
1164
|
+
}, [re, M]);
|
|
1165
|
+
let [z, B] = C(null), ie = S(n), V = ie.current === n, H = V ? z : null, U = g(() => {
|
|
1166
|
+
let e = y.current;
|
|
1167
|
+
return e !== null && Number.isFinite(e) ? e : Gt(n);
|
|
1168
|
+
}, [n]), W = g((e) => {
|
|
1169
|
+
Number.isFinite(e) && (y.current = e);
|
|
1170
|
+
}, []), G = g((e) => {
|
|
1171
|
+
O.current = null;
|
|
1172
|
+
let t = Ut({
|
|
1173
|
+
focusMs: e,
|
|
1174
|
+
fallbackFocusMs: U(),
|
|
1175
|
+
viewMode: n,
|
|
1176
|
+
timeRangeConfig: u,
|
|
1177
|
+
viewportWidth: h || 1e3,
|
|
1178
|
+
pixelsPerDay: l
|
|
1179
|
+
});
|
|
1180
|
+
return B(t), w.current = !0, t;
|
|
1181
|
+
}, [
|
|
1182
|
+
u,
|
|
1183
|
+
l,
|
|
1184
|
+
U,
|
|
1185
|
+
n,
|
|
1186
|
+
h
|
|
1187
|
+
]);
|
|
1188
|
+
v(() => {
|
|
1189
|
+
ie.current = n, G(U());
|
|
1190
|
+
}, [e?.bufferDaysBefore, e?.bufferDaysAfter]), b(() => {
|
|
1191
|
+
let e = i?.width !== null && i?.width !== void 0 && Number(i.width) > 0 ? Number(i.width) : 0, t = r.current?.clientWidth !== null && r.current?.clientWidth !== void 0 && Number(r.current.clientWidth) > 0 ? Number(r.current.clientWidth) : 0, n = e > 0 ? e : f.current ? t : 0;
|
|
1192
|
+
n > 0 && n !== h && _(n);
|
|
1193
|
+
}, [
|
|
1194
|
+
r,
|
|
1195
|
+
i?.width,
|
|
1196
|
+
h
|
|
1197
|
+
]);
|
|
1198
|
+
let ae = x(() => H || Ut({
|
|
1199
|
+
focusMs: U(),
|
|
1200
|
+
viewMode: n,
|
|
1201
|
+
timeRangeConfig: u,
|
|
1202
|
+
viewportWidth: h || 1e3,
|
|
1203
|
+
pixelsPerDay: l
|
|
1204
|
+
}), [
|
|
1205
|
+
H,
|
|
1206
|
+
u,
|
|
1207
|
+
l,
|
|
1208
|
+
U,
|
|
1209
|
+
n,
|
|
1210
|
+
h
|
|
1211
|
+
]), { timelineStartMs: K, timelineEndMs: q } = x(() => ({
|
|
1212
|
+
timelineStartMs: ae.startMs,
|
|
1213
|
+
timelineEndMs: ae.endMs
|
|
1214
|
+
}), [ae]), J = x(() => At({
|
|
1215
|
+
viewMode: n,
|
|
1216
|
+
timelineStartMs: K,
|
|
1217
|
+
timelineEndMs: q,
|
|
1218
|
+
pixelsPerDay: l,
|
|
1219
|
+
formatMessage: o
|
|
1220
|
+
}), [
|
|
1221
|
+
n,
|
|
1222
|
+
K,
|
|
1223
|
+
q,
|
|
1224
|
+
l,
|
|
1225
|
+
o
|
|
1226
|
+
]), Y = x(() => vt({
|
|
1227
|
+
viewMode: n,
|
|
1228
|
+
timelineStartMs: K,
|
|
1229
|
+
timelineEndMs: q,
|
|
1230
|
+
pixelsPerDay: l,
|
|
1231
|
+
lowerSegments: J
|
|
1232
|
+
}), [
|
|
1233
|
+
n,
|
|
1234
|
+
K,
|
|
1235
|
+
q,
|
|
1236
|
+
l,
|
|
1237
|
+
J
|
|
1238
|
+
]), X = x(() => {
|
|
1239
|
+
if (J.length === 0) return 0;
|
|
1240
|
+
let e = J[J.length - 1];
|
|
1241
|
+
return e.left + e.width;
|
|
1242
|
+
}, [J]), oe = g(() => w.current ? !1 : (G(U()), !0), [U, G]);
|
|
1243
|
+
b(() => {
|
|
1244
|
+
ie.current !== n && (ie.current = n, G(U()));
|
|
1245
|
+
}, [
|
|
1246
|
+
n,
|
|
1247
|
+
U,
|
|
1248
|
+
G
|
|
1249
|
+
]);
|
|
1250
|
+
let se = qt(n), ce = x(() => X <= 0 ? null : Y.toX(se), [
|
|
1251
|
+
se,
|
|
1252
|
+
Y,
|
|
1253
|
+
X
|
|
1254
|
+
]), Z = g((e) => {
|
|
1255
|
+
let t = a?.current;
|
|
1256
|
+
t && t.style.setProperty("--gantt-scroll-left", `${e}px`);
|
|
1257
|
+
}, [a]), le = g((e, t) => {
|
|
1258
|
+
e.scrollLeft = t;
|
|
1259
|
+
let n = e.scrollLeft || 0, r = !(Math.abs(n - t) <= 1) && e.scrollWidth + 1 < X;
|
|
1260
|
+
return N(n), Z(n), F(n), I.current = n, !r;
|
|
1261
|
+
}, [
|
|
1262
|
+
Z,
|
|
1263
|
+
N,
|
|
1264
|
+
X
|
|
1265
|
+
]), ue = g(() => {
|
|
1266
|
+
let e = r.current, t = h;
|
|
1267
|
+
if (!e || t <= 0 || X <= 0) return !1;
|
|
1268
|
+
let { scrollLeft: n } = Wt({
|
|
1269
|
+
focusMs: y.current ?? NaN,
|
|
1270
|
+
fallbackFocusMs: U(),
|
|
1271
|
+
timelineCoords: Y,
|
|
1272
|
+
viewportWidth: t,
|
|
1273
|
+
timelineWidth: X
|
|
1274
|
+
});
|
|
1275
|
+
return le(e, n);
|
|
1276
|
+
}, [
|
|
1277
|
+
le,
|
|
1278
|
+
r,
|
|
1279
|
+
U,
|
|
1280
|
+
Y,
|
|
1281
|
+
X,
|
|
1282
|
+
h
|
|
1283
|
+
]), de = g(() => {
|
|
1284
|
+
w.current = !1, re(), f.current || (f.current = !0, m(!0));
|
|
1285
|
+
}, [re]), fe = g(() => ue() ? (de(), !0) : !1, [ue, de]), pe = g(() => {
|
|
1286
|
+
if (k.current !== null) return;
|
|
1287
|
+
let e = 0, t = () => {
|
|
1288
|
+
k.current = null, w.current && (fe() || (e += 1, e < 30 && (k.current = requestAnimationFrame(t))));
|
|
1289
|
+
};
|
|
1290
|
+
k.current = requestAnimationFrame(t);
|
|
1291
|
+
}, [fe]), me = g((e) => {
|
|
1292
|
+
let t = e.currentTarget.scrollLeft, n = h, r = E.current, i = r !== null && Math.abs(t - r.left) <= 1;
|
|
1293
|
+
if (w.current && fe()) return;
|
|
1294
|
+
let a = w.current, o = n > 0 && !i && !a;
|
|
1295
|
+
r && M(), !i && !a && f.current && (T.current = !0), Z(t);
|
|
1296
|
+
let s = t !== I.current;
|
|
1297
|
+
if (I.current = t, s && ne(t), o) {
|
|
1298
|
+
let e = yt(t, n, X);
|
|
1299
|
+
W(Vt({
|
|
1300
|
+
renderWindow: {
|
|
1301
|
+
startMs: K,
|
|
1302
|
+
endMs: q
|
|
1303
|
+
},
|
|
1304
|
+
timelineCoords: Y,
|
|
1305
|
+
scrollLeft: e,
|
|
1306
|
+
viewportWidth: n
|
|
1307
|
+
}).focusMs);
|
|
1308
|
+
}
|
|
1309
|
+
j(t);
|
|
1310
|
+
}, [
|
|
1311
|
+
Z,
|
|
1312
|
+
M,
|
|
1313
|
+
fe,
|
|
1314
|
+
Y,
|
|
1315
|
+
h,
|
|
1316
|
+
ne,
|
|
1317
|
+
W,
|
|
1318
|
+
j,
|
|
1319
|
+
q,
|
|
1320
|
+
K,
|
|
1321
|
+
X
|
|
1322
|
+
]), he = g(() => {
|
|
1323
|
+
let e = Gt(n);
|
|
1324
|
+
W(e), G(e);
|
|
1325
|
+
}, [
|
|
1326
|
+
G,
|
|
1327
|
+
W,
|
|
1328
|
+
n
|
|
1329
|
+
]), ge = g((e) => {
|
|
1330
|
+
let t = r.current, n = e?.targetMs;
|
|
1331
|
+
if (!t || !Number.isFinite(n)) return;
|
|
1332
|
+
let i = t.clientWidth > 0 ? t.clientWidth : h;
|
|
1333
|
+
if (n < K || n >= q) {
|
|
1334
|
+
O.current = null, W(n), G(n);
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
let a = bt({
|
|
1338
|
+
anchorMs: n,
|
|
1339
|
+
toX: Y.toX,
|
|
1340
|
+
viewportWidth: i,
|
|
1341
|
+
timelineWidth: X
|
|
1342
|
+
}), o = t.scrollLeft || 0;
|
|
1343
|
+
if (!(i > 0 && Math.abs(a - o) <= i * 1.5)) {
|
|
1344
|
+
W(n), G(n);
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
let s = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
1348
|
+
s === "smooth" ? O.current = { targetLeft: a } : (O.current = null, N(a)), t.scrollTo({
|
|
1349
|
+
left: a,
|
|
1350
|
+
behavior: s
|
|
1351
|
+
}), W(n), s === "auto" && (Z(a), F(a), I.current = a);
|
|
1352
|
+
}, [
|
|
1353
|
+
Z,
|
|
1354
|
+
r,
|
|
1355
|
+
N,
|
|
1356
|
+
G,
|
|
1357
|
+
W,
|
|
1358
|
+
Y,
|
|
1359
|
+
q,
|
|
1360
|
+
K,
|
|
1361
|
+
X,
|
|
1362
|
+
h
|
|
1363
|
+
]);
|
|
1364
|
+
v(() => {
|
|
1365
|
+
if (!f.current || !h || !X || w.current || !T.current) return;
|
|
1366
|
+
let e = r.current, t = e?.scrollLeft ?? P, n = Ht({
|
|
1367
|
+
scrollLeft: Math.max(0, t),
|
|
1368
|
+
viewportWidth: h,
|
|
1369
|
+
timelineWidth: X,
|
|
1370
|
+
guardBandPx: 280
|
|
1371
|
+
});
|
|
1372
|
+
s || c || A(e) || (e && j(e.scrollLeft || 0), n && oe());
|
|
1373
|
+
}, [
|
|
1374
|
+
P,
|
|
1375
|
+
X,
|
|
1376
|
+
h,
|
|
1377
|
+
r,
|
|
1378
|
+
A,
|
|
1379
|
+
j,
|
|
1380
|
+
oe,
|
|
1381
|
+
s,
|
|
1382
|
+
c,
|
|
1383
|
+
ee
|
|
1384
|
+
]), b(() => {
|
|
1385
|
+
!f.current || h <= 0 || G(U());
|
|
1386
|
+
}, [
|
|
1387
|
+
U,
|
|
1388
|
+
G,
|
|
1389
|
+
h
|
|
1390
|
+
]), b(() => {
|
|
1391
|
+
w.current && (h <= 0 || X <= 0 || fe() || pe());
|
|
1392
|
+
}, [
|
|
1393
|
+
fe,
|
|
1394
|
+
pe,
|
|
1395
|
+
X,
|
|
1396
|
+
h,
|
|
1397
|
+
z
|
|
1398
|
+
]), b(() => {
|
|
1399
|
+
if (!f.current && h > 0 && X > 0) {
|
|
1400
|
+
if (Number.isFinite(y.current ?? NaN) || W(Gt(n)), !z) {
|
|
1401
|
+
G(U());
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
w.current = !0, fe() || pe();
|
|
1405
|
+
}
|
|
1406
|
+
}, [
|
|
1407
|
+
U,
|
|
1408
|
+
G,
|
|
1409
|
+
fe,
|
|
1410
|
+
pe,
|
|
1411
|
+
W,
|
|
1412
|
+
z,
|
|
1413
|
+
X,
|
|
1414
|
+
h,
|
|
1415
|
+
n
|
|
1416
|
+
]);
|
|
1417
|
+
let _e = g((e) => {
|
|
1418
|
+
let t = h;
|
|
1419
|
+
t <= 0 || W(Y.timeAtX(e + t / 2));
|
|
1420
|
+
}, [
|
|
1421
|
+
h,
|
|
1422
|
+
Y,
|
|
1423
|
+
W
|
|
1424
|
+
]), ve = g(() => {
|
|
1425
|
+
let e = r.current;
|
|
1426
|
+
if (!e) return;
|
|
1427
|
+
let t = h, n = e.scrollLeft || 0, i = Math.max(0, n - t);
|
|
1428
|
+
if (Math.abs(i - n) <= 1) {
|
|
1429
|
+
O.current = null;
|
|
1430
|
+
let e = Y.timeAtX(n - t / 2);
|
|
1431
|
+
W(e), G(e);
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
O.current = { targetLeft: i }, e.scrollTo({
|
|
1435
|
+
left: i,
|
|
1436
|
+
behavior: "smooth"
|
|
1437
|
+
}), _e(i);
|
|
1438
|
+
}, [
|
|
1439
|
+
r,
|
|
1440
|
+
G,
|
|
1441
|
+
W,
|
|
1442
|
+
Y,
|
|
1443
|
+
_e,
|
|
1444
|
+
h
|
|
1445
|
+
]), ye = g(() => {
|
|
1446
|
+
let e = r.current;
|
|
1447
|
+
if (!e) return;
|
|
1448
|
+
let t = h, n = e.scrollLeft || 0, i = Math.max(0, X - t), a = yt(n + t, t, X);
|
|
1449
|
+
if (Math.abs(a - n) <= 1) {
|
|
1450
|
+
if (O.current = null, a >= i - 1) {
|
|
1451
|
+
let e = Y.timeAtX(n + t * 1.5);
|
|
1452
|
+
W(e), G(e);
|
|
1453
|
+
}
|
|
1454
|
+
return;
|
|
1455
|
+
}
|
|
1456
|
+
O.current = { targetLeft: a }, e.scrollTo({
|
|
1457
|
+
left: a,
|
|
1458
|
+
behavior: "smooth"
|
|
1459
|
+
}), _e(a);
|
|
1460
|
+
}, [
|
|
1461
|
+
r,
|
|
1462
|
+
G,
|
|
1463
|
+
W,
|
|
1464
|
+
Y,
|
|
1465
|
+
h,
|
|
1466
|
+
X,
|
|
1467
|
+
_e
|
|
1468
|
+
]);
|
|
1469
|
+
v(() => {
|
|
1470
|
+
let e = r.current;
|
|
1471
|
+
if (!e) return;
|
|
1472
|
+
let t = () => {
|
|
1473
|
+
O.current && (O.current = null, te((e) => e + 1));
|
|
1474
|
+
};
|
|
1475
|
+
return e.addEventListener("scrollend", t), () => e.removeEventListener("scrollend", t);
|
|
1476
|
+
}, [r]);
|
|
1477
|
+
let be = (!V || w.current) && X > 0 && h > 0 ? Wt({
|
|
1478
|
+
focusMs: y.current ?? NaN,
|
|
1479
|
+
fallbackFocusMs: U(),
|
|
1480
|
+
timelineCoords: Y,
|
|
1481
|
+
viewportWidth: h,
|
|
1482
|
+
timelineWidth: X
|
|
1483
|
+
}).scrollLeft : P, { visibleStartMs: xe, visibleEndMs: Se } = x(() => {
|
|
1484
|
+
if (X <= 0 || h <= 0) return {
|
|
1485
|
+
visibleStartMs: K,
|
|
1486
|
+
visibleEndMs: K
|
|
1487
|
+
};
|
|
1488
|
+
let e = yt(be, h, X), { visibleRange: t } = Vt({
|
|
1489
|
+
renderWindow: {
|
|
1490
|
+
startMs: K,
|
|
1491
|
+
endMs: q
|
|
1492
|
+
},
|
|
1493
|
+
timelineCoords: Y,
|
|
1494
|
+
scrollLeft: e,
|
|
1495
|
+
viewportWidth: h
|
|
1496
|
+
});
|
|
1497
|
+
return {
|
|
1498
|
+
visibleStartMs: t.startMs,
|
|
1499
|
+
visibleEndMs: t.endMs
|
|
1500
|
+
};
|
|
1501
|
+
}, [
|
|
1502
|
+
be,
|
|
1503
|
+
Y,
|
|
1504
|
+
q,
|
|
1505
|
+
K,
|
|
1506
|
+
X,
|
|
1507
|
+
h
|
|
1508
|
+
]);
|
|
1509
|
+
return {
|
|
1510
|
+
pixelsPerDay: l,
|
|
1511
|
+
viewportWidth: h,
|
|
1512
|
+
scrollLeft: be,
|
|
1513
|
+
timelineStartMs: K,
|
|
1514
|
+
timelineEndMs: q,
|
|
1515
|
+
visibleStartMs: xe,
|
|
1516
|
+
visibleEndMs: Se,
|
|
1517
|
+
lowerSegments: J,
|
|
1518
|
+
timelineCoords: Y,
|
|
1519
|
+
timelineWidth: X,
|
|
1520
|
+
todayCenterMs: se,
|
|
1521
|
+
todayLineLeft: ce,
|
|
1522
|
+
isInitialLayoutReady: p,
|
|
1523
|
+
handleContentScroll: me,
|
|
1524
|
+
handleTodayClick: he,
|
|
1525
|
+
handleOffscreenJump: ge,
|
|
1526
|
+
handleScrollPrev: ve,
|
|
1527
|
+
handleScrollNext: ye
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
//#endregion
|
|
1531
|
+
//#region src/components/Gantt/GanttChart/utils/dateRangeNormalizer.ts
|
|
1532
|
+
var Yt = (e) => e !== null && e !== lt(e), Xt = ({ rawStartMs: e, rawEndMs: t, baseStartMs: n, baseEndMs: r }, i) => Ke(i) && (Yt(e) || Yt(t)) ? {
|
|
1533
|
+
startMs: e,
|
|
1534
|
+
endMs: t
|
|
1535
|
+
} : {
|
|
1536
|
+
startMs: n,
|
|
1537
|
+
endMs: r
|
|
1538
|
+
}, Zt = (e, t) => {
|
|
1539
|
+
let n = ct(e), r = ct(t), i = n === null ? null : lt(n), a = r === null ? null : lt(r) + R;
|
|
1540
|
+
return {
|
|
1541
|
+
rawStartMs: n,
|
|
1542
|
+
rawEndMs: r,
|
|
1543
|
+
baseStartMs: i,
|
|
1544
|
+
baseEndMs: a,
|
|
1545
|
+
invalid: n !== null && r !== null && n > r || i === null || a === null || a <= i
|
|
1546
|
+
};
|
|
1547
|
+
};
|
|
1548
|
+
//#endregion
|
|
1549
|
+
//#region src/components/Gantt/GanttChart/hooks/useNormalizedItems.ts
|
|
1550
|
+
function Qt({ visibleItems: e, committedRangeById: t = {}, viewMode: n = "day" }) {
|
|
1551
|
+
return { normalizedItems: x(() => {
|
|
1552
|
+
let r = Array.isArray(e) ? e : [], i = [], a = he(n) ? n : "day";
|
|
1553
|
+
for (let e = 0; e < r.length; e++) {
|
|
1554
|
+
let n = r[e], o = String(n?.id ?? `row-${e}`), { rawStartMs: s, rawEndMs: c, baseStartMs: l, baseEndMs: u, invalid: d } = Zt(n?.start, n?.end), f = t[o], p = n?.type === "summary" ? !1 : d, m = Xt({
|
|
1555
|
+
rawStartMs: s,
|
|
1556
|
+
rawEndMs: c,
|
|
1557
|
+
baseStartMs: l,
|
|
1558
|
+
baseEndMs: u
|
|
1559
|
+
}, a), h = m.startMs, g = m.endMs;
|
|
1560
|
+
if (!p && f?.startMs && f?.endMs) {
|
|
1561
|
+
let e = f.startMs, t = f.endMs;
|
|
1562
|
+
Number.isFinite(e) && Number.isFinite(t) && t > e && (h = e, g = t);
|
|
1563
|
+
}
|
|
1564
|
+
i.push({
|
|
1565
|
+
...n,
|
|
1566
|
+
id: o,
|
|
1567
|
+
rowIndex: e,
|
|
1568
|
+
parentId: n?.parentId ?? void 0,
|
|
1569
|
+
groupKey: n?.groupKey ?? void 0,
|
|
1570
|
+
recordId: n?.recordId ?? void 0,
|
|
1571
|
+
rawStartMs: s,
|
|
1572
|
+
rawEndMs: c,
|
|
1573
|
+
baseStartMs: l,
|
|
1574
|
+
baseEndMs: u,
|
|
1575
|
+
startMs: h,
|
|
1576
|
+
endMs: g,
|
|
1577
|
+
invalid: p,
|
|
1578
|
+
progress: n?.progress === null || n?.progress === void 0 ? null : st(n.progress)
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
return i;
|
|
1582
|
+
}, [
|
|
1583
|
+
e,
|
|
1584
|
+
t,
|
|
1585
|
+
n
|
|
1586
|
+
]) };
|
|
1587
|
+
}
|
|
1588
|
+
//#endregion
|
|
1589
|
+
//#region src/components/Gantt/GanttChart/hooks/useGanttScrollbars.tsx
|
|
1590
|
+
function $t(e, t) {
|
|
1591
|
+
let [n, r] = C(!1);
|
|
1592
|
+
return b(() => {
|
|
1593
|
+
let n = e.current, i = t.current;
|
|
1594
|
+
if (!n || !i) return;
|
|
1595
|
+
let a = F({
|
|
1596
|
+
target: n,
|
|
1597
|
+
elements: { viewport: i }
|
|
1598
|
+
}, { scrollbars: {
|
|
1599
|
+
theme: "os-theme-bsy",
|
|
1600
|
+
autoHide: "leave",
|
|
1601
|
+
autoHideDelay: 600,
|
|
1602
|
+
clickScroll: !0
|
|
1603
|
+
} }), o = a.elements().scrollbarHorizontal.scrollbar, c = !1, l = null, u = (e) => {
|
|
1604
|
+
e.pointerType === "mouse" && e.button !== 0 || (c = !0, l = e.pointerId, r(!0));
|
|
1605
|
+
}, d = (e) => {
|
|
1606
|
+
if (!c) return;
|
|
1607
|
+
let t = e.pointerId, n = "pointerId" in e && s(t) ? t : null;
|
|
1608
|
+
n !== null && l !== null && n !== l || (c = !1, l = null, r(!1));
|
|
1609
|
+
}, f = { capture: !0 };
|
|
1610
|
+
return o.addEventListener("pointerdown", u, f), o.addEventListener("lostpointercapture", d, f), document.addEventListener("pointerup", d, f), document.addEventListener("pointercancel", d, f), document.addEventListener("lostpointercapture", d, f), window.addEventListener("blur", d), () => {
|
|
1611
|
+
o.removeEventListener("pointerdown", u, f), o.removeEventListener("lostpointercapture", d, f), document.removeEventListener("pointerup", d, f), document.removeEventListener("pointercancel", d, f), document.removeEventListener("lostpointercapture", d, f), window.removeEventListener("blur", d), a?.destroy();
|
|
1612
|
+
};
|
|
1613
|
+
}, [e, t]), n;
|
|
1614
|
+
}
|
|
1615
|
+
//#endregion
|
|
1616
|
+
//#region src/components/Gantt/GanttChart/utils/timelineMarkers.ts
|
|
1617
|
+
function en(e, t, n, r, i) {
|
|
1618
|
+
return !!e && Number.isFinite(r) && Pt(i, r) && t !== null && Number.isFinite(t) && t >= 0 && t <= n;
|
|
1619
|
+
}
|
|
1620
|
+
//#endregion
|
|
1621
|
+
//#region src/components/Gantt/utils/localeKey.ts
|
|
1622
|
+
var tn = (e) => e.startsWith("gantt.") ? e : `gantt.${e}`, nn = p(void 0), rn = nn.Provider, an = () => _(nn), on = {
|
|
1623
|
+
modeTrigger: "_modeTrigger_cbumr_1",
|
|
1624
|
+
todayBtn: "_todayBtn_cbumr_1",
|
|
1625
|
+
iconBtn: "_iconBtn_cbumr_1",
|
|
1626
|
+
root: "_root_cbumr_8",
|
|
1627
|
+
modeTriggerArrow: "_modeTriggerArrow_cbumr_29",
|
|
1628
|
+
isActive: "_isActive_cbumr_29",
|
|
1629
|
+
modeTriggerLabel: "_modeTriggerLabel_cbumr_36",
|
|
1630
|
+
divider: "_divider_cbumr_60",
|
|
1631
|
+
scrollBtns: "_scrollBtns_cbumr_67"
|
|
1632
|
+
}, sn = ".bsy-form-view-data-manager", cn = {
|
|
1633
|
+
oneMinute: "mode.oneMinute",
|
|
1634
|
+
tenMinute: "mode.tenMinute",
|
|
1635
|
+
halfHour: "mode.halfHour",
|
|
1636
|
+
hour: "mode.hour",
|
|
1637
|
+
sixHour: "mode.sixHour",
|
|
1638
|
+
halfDay: "mode.halfDay",
|
|
1639
|
+
day: "mode.day",
|
|
1640
|
+
week: "mode.week",
|
|
1641
|
+
month: "mode.month",
|
|
1642
|
+
quarter: "mode.quarter",
|
|
1643
|
+
quarterMonth: "mode.quarterMonth",
|
|
1644
|
+
year: "mode.year"
|
|
1645
|
+
}, ln = ({ viewMode: n = "day", availableModes: r, onViewModeChange: a, onTodayClick: o, onScrollPrev: s, onScrollNext: c, className: l = "" }) => {
|
|
1646
|
+
let { t: f } = t(), p = an()?.dropdownTheme, m = g((e) => f(tn(cn[e])), [f]), h = S(null), [_, v] = C(!1), y = g(() => {
|
|
1647
|
+
let e = h.current;
|
|
1648
|
+
if (!e) return document.body;
|
|
1649
|
+
let t = e.closest(sn);
|
|
1650
|
+
return t instanceof HTMLElement ? t : document.body;
|
|
1651
|
+
}, []), b = x(() => {
|
|
1652
|
+
let e = new Set(r ?? pe);
|
|
1653
|
+
return pe.filter((t) => e.has(t)).map((e) => ({
|
|
1654
|
+
key: e,
|
|
1655
|
+
label: m(e)
|
|
1656
|
+
}));
|
|
1657
|
+
}, [r, m]), T = x(() => b.find((e) => e.key === n)?.label ?? n, [b, n]), E = g((e) => {
|
|
1658
|
+
e?.key && e.key !== n && a?.(e.key);
|
|
1659
|
+
}, [a, n]);
|
|
1660
|
+
return /* @__PURE__ */ d("div", {
|
|
1661
|
+
className: w(on.root, l),
|
|
1662
|
+
"data-testid": "gantt-toolbar",
|
|
1663
|
+
ref: h,
|
|
1664
|
+
children: [
|
|
1665
|
+
/* @__PURE__ */ u(i, {
|
|
1666
|
+
menus: b,
|
|
1667
|
+
activeKey: [n],
|
|
1668
|
+
showSearch: !1,
|
|
1669
|
+
visible: _,
|
|
1670
|
+
onOpenChange: v,
|
|
1671
|
+
offset: {
|
|
1672
|
+
x: 0,
|
|
1673
|
+
y: 4
|
|
1674
|
+
},
|
|
1675
|
+
getPopupContainer: y,
|
|
1676
|
+
onClick: E,
|
|
1677
|
+
theme: p,
|
|
1678
|
+
style: {
|
|
1679
|
+
width: 100,
|
|
1680
|
+
minWidth: 100
|
|
1681
|
+
},
|
|
1682
|
+
children: /* @__PURE__ */ d("button", {
|
|
1683
|
+
type: "button",
|
|
1684
|
+
className: w(on.modeTrigger, { [on.isActive]: _ }),
|
|
1685
|
+
"data-testid": "gantt-toolbar-mode-trigger",
|
|
1686
|
+
"aria-haspopup": "listbox",
|
|
1687
|
+
"aria-expanded": _,
|
|
1688
|
+
children: [/* @__PURE__ */ u("span", {
|
|
1689
|
+
className: on.modeTriggerLabel,
|
|
1690
|
+
children: T
|
|
1691
|
+
}), /* @__PURE__ */ u("span", {
|
|
1692
|
+
className: on.modeTriggerArrow,
|
|
1693
|
+
children: /* @__PURE__ */ u(e, {
|
|
1694
|
+
name: "arrow-down",
|
|
1695
|
+
size: 16
|
|
1696
|
+
})
|
|
1697
|
+
})]
|
|
1698
|
+
})
|
|
1699
|
+
}),
|
|
1700
|
+
/* @__PURE__ */ u("span", { className: on.divider }),
|
|
1701
|
+
/* @__PURE__ */ u("button", {
|
|
1702
|
+
type: "button",
|
|
1703
|
+
className: on.todayBtn,
|
|
1704
|
+
onClick: o,
|
|
1705
|
+
children: f("gantt.today")
|
|
1706
|
+
}),
|
|
1707
|
+
/* @__PURE__ */ d("div", {
|
|
1708
|
+
className: on.scrollBtns,
|
|
1709
|
+
children: [/* @__PURE__ */ u("button", {
|
|
1710
|
+
type: "button",
|
|
1711
|
+
className: on.iconBtn,
|
|
1712
|
+
"aria-label": f("gantt.aria.scrollPrev"),
|
|
1713
|
+
onClick: s,
|
|
1714
|
+
children: /* @__PURE__ */ u(e, {
|
|
1715
|
+
name: "Pulldownleft",
|
|
1716
|
+
size: 16
|
|
1717
|
+
})
|
|
1718
|
+
}), /* @__PURE__ */ u("button", {
|
|
1719
|
+
type: "button",
|
|
1720
|
+
className: on.iconBtn,
|
|
1721
|
+
"aria-label": f("gantt.aria.scrollNext"),
|
|
1722
|
+
onClick: c,
|
|
1723
|
+
children: /* @__PURE__ */ u(e, {
|
|
1724
|
+
name: "Pulldownright",
|
|
1725
|
+
size: 16
|
|
1726
|
+
})
|
|
1727
|
+
})]
|
|
1728
|
+
})
|
|
1729
|
+
]
|
|
1730
|
+
});
|
|
1731
|
+
}, Q = {
|
|
1732
|
+
root: "_root_1ncav_1",
|
|
1733
|
+
timelineHost: "_timelineHost_1ncav_12",
|
|
1734
|
+
timelineContent: "_timelineContent_1ncav_19",
|
|
1735
|
+
canvas: "_canvas_1ncav_27",
|
|
1736
|
+
weekendBg: "_weekendBg_1ncav_33",
|
|
1737
|
+
colLine: "_colLine_1ncav_40",
|
|
1738
|
+
rowLine: "_rowLine_1ncav_49",
|
|
1739
|
+
rowHoverBg: "_rowHoverBg_1ncav_56",
|
|
1740
|
+
todayIndicator: "_todayIndicator_1ncav_65",
|
|
1741
|
+
todayIndicatorContentLine: "_todayIndicatorContentLine_1ncav_73",
|
|
1742
|
+
todayIndicatorLine: "_todayIndicatorLine_1ncav_77",
|
|
1743
|
+
todayIndicatorHeaderDot: "_todayIndicatorHeaderDot_1ncav_86",
|
|
1744
|
+
calendar: "_calendar_1ncav_98",
|
|
1745
|
+
calendarTrack: "_calendarTrack_1ncav_105",
|
|
1746
|
+
calendarToolbar: "_calendarToolbar_1ncav_112",
|
|
1747
|
+
headerCell: "_headerCell_1ncav_126",
|
|
1748
|
+
headerCellTop: "_headerCellTop_1ncav_140",
|
|
1749
|
+
headerCellBottom: "_headerCellBottom_1ncav_147",
|
|
1750
|
+
isActive: "_isActive_1ncav_152",
|
|
1751
|
+
headerColLine: "_headerColLine_1ncav_156",
|
|
1752
|
+
headerCellStickyText: "_headerCellStickyText_1ncav_164",
|
|
1753
|
+
headerCellDatePrefix: "_headerCellDatePrefix_1ncav_172",
|
|
1754
|
+
offscreenRow: "_offscreenRow_1ncav_178",
|
|
1755
|
+
offscreenTrack: "_offscreenTrack_1ncav_186",
|
|
1756
|
+
offscreenBtn: "_offscreenBtn_1ncav_192",
|
|
1757
|
+
offscreenBtnLeft: "_offscreenBtnLeft_1ncav_216",
|
|
1758
|
+
offscreenBtnRight: "_offscreenBtnRight_1ncav_221",
|
|
1759
|
+
bar: "_bar_1ncav_227",
|
|
1760
|
+
barProgress: "_barProgress_1ncav_245",
|
|
1761
|
+
barResizeHandle: "_barResizeHandle_1ncav_248",
|
|
1762
|
+
isReadonly: "_isReadonly_1ncav_258",
|
|
1763
|
+
isDragging: "_isDragging_1ncav_262",
|
|
1764
|
+
isMicro: "_isMicro_1ncav_274",
|
|
1765
|
+
isFull: "_isFull_1ncav_299",
|
|
1766
|
+
barLabel: "_barLabel_1ncav_303",
|
|
1767
|
+
isHidden: "_isHidden_1ncav_313",
|
|
1768
|
+
isOutside: "_isOutside_1ncav_317",
|
|
1769
|
+
barResizeHandleLeft: "_barResizeHandleLeft_1ncav_355",
|
|
1770
|
+
barResizeHandleRight: "_barResizeHandleRight_1ncav_363"
|
|
1771
|
+
}, un = {
|
|
1772
|
+
initial: {
|
|
1773
|
+
opacity: 0,
|
|
1774
|
+
x: -10
|
|
1775
|
+
},
|
|
1776
|
+
animate: {
|
|
1777
|
+
opacity: 1,
|
|
1778
|
+
x: 0
|
|
1779
|
+
},
|
|
1780
|
+
exit: {
|
|
1781
|
+
opacity: 0,
|
|
1782
|
+
x: -10
|
|
1783
|
+
},
|
|
1784
|
+
transition: {
|
|
1785
|
+
duration: .16,
|
|
1786
|
+
ease: "easeOut"
|
|
1787
|
+
}
|
|
1788
|
+
}, dn = {
|
|
1789
|
+
duration: .16,
|
|
1790
|
+
ease: "easeOut"
|
|
1791
|
+
}, fn = f.memo(({ label: e, dateLabel: t, isReadingAnchor: n }) => t ? /* @__PURE__ */ d("span", {
|
|
1792
|
+
className: Q.headerCellStickyText,
|
|
1793
|
+
children: [/* @__PURE__ */ u(O, {
|
|
1794
|
+
initial: !1,
|
|
1795
|
+
mode: "popLayout",
|
|
1796
|
+
children: n ? /* @__PURE__ */ u(ee.span, {
|
|
1797
|
+
className: Q.headerCellDatePrefix,
|
|
1798
|
+
initial: un.initial,
|
|
1799
|
+
animate: un.animate,
|
|
1800
|
+
exit: un.exit,
|
|
1801
|
+
transition: un.transition,
|
|
1802
|
+
children: t
|
|
1803
|
+
}, "date-prefix") : null
|
|
1804
|
+
}), /* @__PURE__ */ u(ee.span, {
|
|
1805
|
+
layout: "position",
|
|
1806
|
+
transition: dn,
|
|
1807
|
+
children: e
|
|
1808
|
+
})]
|
|
1809
|
+
}) : /* @__PURE__ */ u("span", {
|
|
1810
|
+
className: Q.headerCellStickyText,
|
|
1811
|
+
children: e
|
|
1812
|
+
})), pn = f.memo(({ timelineWidth: e, viewportWidth: t = 0, scrollLeft: n, trackRef: r, virtualColumns: i, lowerSegments: a, todayLineLeft: o, todayCenterMs: s, showTodayLine: c, viewMode: l, availableModes: p, formatMessage: m, onViewModeChange: h, onTodayClick: g, onScrollPrev: _, onScrollNext: v }) => {
|
|
1813
|
+
let y = x(() => jt({
|
|
1814
|
+
lowerSegments: a,
|
|
1815
|
+
viewMode: l,
|
|
1816
|
+
formatMessage: m
|
|
1817
|
+
}), [
|
|
1818
|
+
a,
|
|
1819
|
+
l,
|
|
1820
|
+
m
|
|
1821
|
+
]), b = yt(n, t, e), S = x(() => {
|
|
1822
|
+
let e = b - 240, n = b + t + 240;
|
|
1823
|
+
return y.filter((t) => t.left < n && t.left + t.width > e);
|
|
1824
|
+
}, [
|
|
1825
|
+
y,
|
|
1826
|
+
b,
|
|
1827
|
+
t
|
|
1828
|
+
]), C = x(() => a.length && a.find((e) => s != null && s >= e.startMs && s < e.endMs)?.id || null, [a, s]), T = a[0]?.startMs ?? 0, E = a[a.length - 1]?.endMs ?? 0, D = en(c, o, e, s ?? NaN, {
|
|
1829
|
+
startMs: T,
|
|
1830
|
+
endMs: E
|
|
1831
|
+
});
|
|
1832
|
+
return /* @__PURE__ */ d("div", {
|
|
1833
|
+
className: Q.calendar,
|
|
1834
|
+
children: [/* @__PURE__ */ d("div", {
|
|
1835
|
+
ref: r,
|
|
1836
|
+
className: Q.calendarTrack,
|
|
1837
|
+
"data-testid": "gantt-calendar-track",
|
|
1838
|
+
style: { width: e },
|
|
1839
|
+
children: [
|
|
1840
|
+
i.map((e) => {
|
|
1841
|
+
let t = a[e.index];
|
|
1842
|
+
return t ? /* @__PURE__ */ u("div", {
|
|
1843
|
+
className: Q.headerColLine,
|
|
1844
|
+
style: {
|
|
1845
|
+
left: t.left,
|
|
1846
|
+
top: 34,
|
|
1847
|
+
height: 34
|
|
1848
|
+
}
|
|
1849
|
+
}, `header-line-${t.id}`) : null;
|
|
1850
|
+
}),
|
|
1851
|
+
S.map((e) => {
|
|
1852
|
+
let t = b >= e.left && b < e.left + e.width;
|
|
1853
|
+
return /* @__PURE__ */ d(f.Fragment, { children: [/* @__PURE__ */ u("div", {
|
|
1854
|
+
className: w(Q.headerCell, Q.headerCellTop),
|
|
1855
|
+
"data-testid": "gantt-header-cell-top",
|
|
1856
|
+
style: {
|
|
1857
|
+
left: e.left,
|
|
1858
|
+
width: e.width,
|
|
1859
|
+
height: 34,
|
|
1860
|
+
"--segment-left": `${e.left}px`
|
|
1861
|
+
},
|
|
1862
|
+
children: /* @__PURE__ */ u(fn, {
|
|
1863
|
+
label: e.label,
|
|
1864
|
+
dateLabel: e.dateLabel,
|
|
1865
|
+
isReadingAnchor: t
|
|
1866
|
+
})
|
|
1867
|
+
}), /* @__PURE__ */ u("div", {
|
|
1868
|
+
className: Q.headerColLine,
|
|
1869
|
+
style: {
|
|
1870
|
+
left: e.left + e.width,
|
|
1871
|
+
top: 0,
|
|
1872
|
+
height: 34
|
|
1873
|
+
}
|
|
1874
|
+
})] }, `top-group-${e.id}`);
|
|
1875
|
+
}),
|
|
1876
|
+
i.map((e) => {
|
|
1877
|
+
let t = a[e.index];
|
|
1878
|
+
if (!t) return null;
|
|
1879
|
+
let n = t.id === C;
|
|
1880
|
+
return /* @__PURE__ */ u("div", {
|
|
1881
|
+
className: w(Q.headerCell, Q.headerCellBottom, n && Q.isActive),
|
|
1882
|
+
"data-testid": "gantt-header-cell-bottom",
|
|
1883
|
+
style: {
|
|
1884
|
+
left: t.left,
|
|
1885
|
+
width: t.width,
|
|
1886
|
+
height: 34,
|
|
1887
|
+
top: 34
|
|
1888
|
+
},
|
|
1889
|
+
children: t.label
|
|
1890
|
+
}, t.id);
|
|
1891
|
+
}),
|
|
1892
|
+
D && /* @__PURE__ */ u("span", {
|
|
1893
|
+
className: Q.todayIndicatorHeaderDot,
|
|
1894
|
+
style: { left: o ?? void 0 }
|
|
1895
|
+
})
|
|
1896
|
+
]
|
|
1897
|
+
}), /* @__PURE__ */ u("div", {
|
|
1898
|
+
className: Q.calendarToolbar,
|
|
1899
|
+
"data-testid": "gantt-calendar-toolbar",
|
|
1900
|
+
children: /* @__PURE__ */ u(ln, {
|
|
1901
|
+
viewMode: l,
|
|
1902
|
+
availableModes: p,
|
|
1903
|
+
onViewModeChange: h,
|
|
1904
|
+
onTodayClick: g,
|
|
1905
|
+
onScrollPrev: _,
|
|
1906
|
+
onScrollNext: v
|
|
1907
|
+
})
|
|
1908
|
+
})]
|
|
1909
|
+
});
|
|
1910
|
+
});
|
|
1911
|
+
//#endregion
|
|
1912
|
+
//#region src/components/Gantt/GanttChart/hooks/useGanttRowVirtualScroll.ts
|
|
1913
|
+
function mn({ items: e, contentRef: t, safeRowHeight: n, viewportHeight: r, overscan: i = 4 }) {
|
|
1914
|
+
let [a, o] = C(!1), s = N({
|
|
1915
|
+
count: e.length,
|
|
1916
|
+
getScrollElement: () => t.current,
|
|
1917
|
+
estimateSize: () => n,
|
|
1918
|
+
overscan: i,
|
|
1919
|
+
onChange: (e) => {
|
|
1920
|
+
let t = !!e?.isScrolling;
|
|
1921
|
+
o((e) => e === t ? e : t);
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
return {
|
|
1925
|
+
virtualRows: s.getVirtualItems(),
|
|
1926
|
+
canvasHeight: Math.max(s.getTotalSize(), r),
|
|
1927
|
+
isScrolling: a
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
//#endregion
|
|
1931
|
+
//#region src/components/Gantt/GanttChart/hooks/useOffscreenIndicators.ts
|
|
1932
|
+
function hn({ virtualRows: e, normalizedItems: t, visibleStartMs: n, visibleEndMs: r, enabled: i = !0, excludeTaskId: a = null }) {
|
|
1933
|
+
return x(() => {
|
|
1934
|
+
if (!i || !Array.isArray(e) || !Array.isArray(t) || !Number.isFinite(n) || !Number.isFinite(r) || n >= r) return [];
|
|
1935
|
+
let o = [];
|
|
1936
|
+
return e.forEach((e) => {
|
|
1937
|
+
let i = t[e.index];
|
|
1938
|
+
if (!i || i.invalid || a !== null && i.id === a || i.type === "summary" || i.startMs === null || i.startMs === void 0 || i.endMs === null || i.endMs === void 0) return;
|
|
1939
|
+
let s = i.endMs <= n, c = i.startMs >= r;
|
|
1940
|
+
!s && !c || o.push({
|
|
1941
|
+
rowKey: `offscreen-${i.id}-${e.key}`,
|
|
1942
|
+
rowTop: e.start,
|
|
1943
|
+
rowHeight: e.size,
|
|
1944
|
+
showLeft: s,
|
|
1945
|
+
showRight: c,
|
|
1946
|
+
targetMs: i.startMs,
|
|
1947
|
+
taskId: i.id
|
|
1948
|
+
});
|
|
1949
|
+
}), o;
|
|
1950
|
+
}, [
|
|
1951
|
+
e,
|
|
1952
|
+
t,
|
|
1953
|
+
n,
|
|
1954
|
+
r,
|
|
1955
|
+
i,
|
|
1956
|
+
a
|
|
1957
|
+
]);
|
|
1958
|
+
}
|
|
1959
|
+
//#endregion
|
|
1960
|
+
//#region src/components/Gantt/GanttChart/hooks/useRowHoverHighlight.ts
|
|
1961
|
+
function gn({ normalizedItems: e, safeRowHeight: t }) {
|
|
1962
|
+
let n = A(oe, (e) => e.setHighlightTarget), r = A(oe, (e) => e.subscribeHighlight), i = A(oe, (e) => e.getIsScrollActive), a = S(null), o = S(null), s = S(null), c = S(!1), l = x(() => {
|
|
1963
|
+
let t = /* @__PURE__ */ new Map(), n = 0;
|
|
1964
|
+
for (; n < e.length;) {
|
|
1965
|
+
let r = e[n]?.parentId;
|
|
1966
|
+
if (r) {
|
|
1967
|
+
let i = n;
|
|
1968
|
+
for (; i < e.length && e[i]?.parentId === r;) i += 1;
|
|
1969
|
+
for (let e = n; e < i; e += 1) t.set(e, {
|
|
1970
|
+
startIndex: n,
|
|
1971
|
+
endIndex: i - 1
|
|
1972
|
+
});
|
|
1973
|
+
n = i;
|
|
1974
|
+
} else t.set(n, null), n += 1;
|
|
1975
|
+
}
|
|
1976
|
+
return t;
|
|
1977
|
+
}, [e]), u = S(l);
|
|
1978
|
+
u.current = l;
|
|
1979
|
+
let d = g((e, n) => {
|
|
1980
|
+
let r = o.current;
|
|
1981
|
+
r && (r.style.top = `${e * t}px`, r.style.height = `${(n - e + 1) * t}px`, r.style.display = "block");
|
|
1982
|
+
}, [t]), f = g(() => {
|
|
1983
|
+
let e = o.current;
|
|
1984
|
+
e && (e.style.display = "none");
|
|
1985
|
+
}, []), p = g((t) => {
|
|
1986
|
+
if (!t) {
|
|
1987
|
+
f();
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
let n = t.type, r = t.id, i = -1, a = -1;
|
|
1991
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
1992
|
+
let o = Z(e[t]);
|
|
1993
|
+
o && o.type === n && o.id === r && (i === -1 && (i = t), a = t);
|
|
1994
|
+
}
|
|
1995
|
+
if (i === -1) {
|
|
1996
|
+
f();
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
d(i, a);
|
|
2000
|
+
}, [
|
|
2001
|
+
e,
|
|
2002
|
+
d,
|
|
2003
|
+
f
|
|
2004
|
+
]), m = g((r) => {
|
|
2005
|
+
if (i?.()) {
|
|
2006
|
+
a.current !== null && (a.current = null, f()), c.current = !1;
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
c.current = !0;
|
|
2010
|
+
let o = r.currentTarget, l = o.getBoundingClientRect(), p = r.clientY - l.top + o.scrollTop, m = Math.floor(p / t);
|
|
2011
|
+
if (m < 0 || m >= e.length) {
|
|
2012
|
+
a.current !== null && (a.current = null, f(), s.current !== null && (s.current = null, n?.(null)));
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
if (a.current !== m) {
|
|
2016
|
+
a.current = m;
|
|
2017
|
+
let t = u.current.get(m);
|
|
2018
|
+
d(t ? t.startIndex : m, t ? t.endIndex : m);
|
|
2019
|
+
let r = Z(e[m]);
|
|
2020
|
+
se(s.current, r) || (s.current = r, n?.(r));
|
|
2021
|
+
}
|
|
2022
|
+
}, [
|
|
2023
|
+
t,
|
|
2024
|
+
e,
|
|
2025
|
+
n,
|
|
2026
|
+
d,
|
|
2027
|
+
f,
|
|
2028
|
+
i
|
|
2029
|
+
]), h = g(() => {
|
|
2030
|
+
c.current = !1, a.current = null, f(), s.current !== null && (s.current = null, n?.(null));
|
|
2031
|
+
}, [n, f]);
|
|
2032
|
+
return v(() => {
|
|
2033
|
+
if (r) return r((e, t) => {
|
|
2034
|
+
if (t?.source === "table") {
|
|
2035
|
+
c.current = !1, a.current = null, s.current = e, p(e);
|
|
2036
|
+
return;
|
|
2037
|
+
}
|
|
2038
|
+
c.current || p(e);
|
|
2039
|
+
});
|
|
2040
|
+
}, [r, p]), {
|
|
2041
|
+
hoverBgRef: o,
|
|
2042
|
+
handleContentMouseMove: m,
|
|
2043
|
+
handleContentMouseLeave: h
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
//#endregion
|
|
2047
|
+
//#region src/components/Gantt/GanttChart/GanttInteractionContext.ts
|
|
2048
|
+
var _n = k({
|
|
2049
|
+
tooltip: null,
|
|
2050
|
+
isScrolling: !1,
|
|
2051
|
+
collapsedKeys: void 0,
|
|
2052
|
+
onBarClick: () => {},
|
|
2053
|
+
onTaskMouseDown: () => {},
|
|
2054
|
+
onResizeMouseDown: () => {}
|
|
2055
|
+
}), vn = (e) => A(_n, e), yn = k({
|
|
2056
|
+
viewMode: "day",
|
|
2057
|
+
pixelsPerDay: 1,
|
|
2058
|
+
timelineStartMs: 0,
|
|
2059
|
+
timelineEndMs: 0,
|
|
2060
|
+
visibleStartMs: 0,
|
|
2061
|
+
visibleEndMs: 0,
|
|
2062
|
+
timelineCoords: {
|
|
2063
|
+
toX: () => 0,
|
|
2064
|
+
toWidth: () => 0,
|
|
2065
|
+
timeAtX: () => 0
|
|
2066
|
+
},
|
|
2067
|
+
scrollLeft: 0,
|
|
2068
|
+
viewportWidth: 0,
|
|
2069
|
+
timelineWidth: 0,
|
|
2070
|
+
isInitialLayoutReady: !1
|
|
2071
|
+
}), $ = (e) => A(yn, e), bn = (e, t) => {
|
|
2072
|
+
let n = e.replace("#", ""), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n;
|
|
2073
|
+
return `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${t})`;
|
|
2074
|
+
}, xn = (e, t) => {
|
|
2075
|
+
if (!c(e)) return null;
|
|
2076
|
+
let n = e.trim();
|
|
2077
|
+
return V.test(n) ? bn(n, t) : null;
|
|
2078
|
+
}, Sn = (e, t = 2.5) => {
|
|
2079
|
+
if (!e || !c(e)) return "#121211";
|
|
2080
|
+
let n, r, i;
|
|
2081
|
+
if (e.startsWith("#")) {
|
|
2082
|
+
let t = e.replace("#", ""), a = t.length === 3 ? [...t].map((e) => e + e) : [
|
|
2083
|
+
t.slice(0, 2),
|
|
2084
|
+
t.slice(2, 4),
|
|
2085
|
+
t.slice(4, 6)
|
|
2086
|
+
];
|
|
2087
|
+
[n, r, i] = a.map((e) => parseInt(e, 16));
|
|
2088
|
+
} else {
|
|
2089
|
+
let t = (e.match(/\d+/g) || []).map(Number);
|
|
2090
|
+
if ([n, r, i] = t.slice(0, 3), n === void 0 || Number.isNaN(n)) return "#121211";
|
|
2091
|
+
}
|
|
2092
|
+
let a = (e) => {
|
|
2093
|
+
let t = e / 255;
|
|
2094
|
+
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
2095
|
+
};
|
|
2096
|
+
return 1.05 / (.2126 * a(n) + .7152 * a(r) + .0722 * a(i) + .05) >= t ? "#ffffff" : "#121211";
|
|
2097
|
+
}, Cn, wn = () => {
|
|
2098
|
+
if (Cn !== void 0) return Cn;
|
|
2099
|
+
try {
|
|
2100
|
+
Cn = document.createElement("canvas").getContext("2d");
|
|
2101
|
+
} catch {
|
|
2102
|
+
Cn = null;
|
|
2103
|
+
}
|
|
2104
|
+
return Cn;
|
|
2105
|
+
}, Tn = (e, t = "12px -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, PingFang SC, Noto Sans, Noto Sans CJK SC, Microsoft YaHei, \"微软雅黑\", sans-serif") => {
|
|
2106
|
+
if (!e) return 0;
|
|
2107
|
+
let n = String(e), r = wn();
|
|
2108
|
+
return r ? (r.font = t, r.measureText(n).width + 20) : n.length * 12 + 20;
|
|
2109
|
+
};
|
|
2110
|
+
//#endregion
|
|
2111
|
+
//#region src/components/Gantt/GanttChart/hooks/useBarTooltipHover.ts
|
|
2112
|
+
function En() {
|
|
2113
|
+
let [e, t] = C(null), n = S("idle"), r = g((e) => {
|
|
2114
|
+
n.current === "frozen" && (n.current = "open");
|
|
2115
|
+
let r = e.currentTarget.getBoundingClientRect();
|
|
2116
|
+
t({
|
|
2117
|
+
x: e.clientX,
|
|
2118
|
+
y: r.y,
|
|
2119
|
+
top: r.top,
|
|
2120
|
+
bottom: r.bottom,
|
|
2121
|
+
height: r.height
|
|
2122
|
+
});
|
|
2123
|
+
}, []), i = g(() => {
|
|
2124
|
+
n.current === "open" ? n.current = "frozen" : t(null);
|
|
2125
|
+
}, []), a = g((e) => {
|
|
2126
|
+
n.current = e ? "open" : "idle", e || t(null);
|
|
2127
|
+
}, []);
|
|
2128
|
+
return {
|
|
2129
|
+
virtualReference: x(() => {
|
|
2130
|
+
if (e) return { getBoundingClientRect: () => ({
|
|
2131
|
+
width: 0,
|
|
2132
|
+
height: e.height,
|
|
2133
|
+
x: e.x,
|
|
2134
|
+
y: e.y,
|
|
2135
|
+
top: e.top,
|
|
2136
|
+
bottom: e.bottom,
|
|
2137
|
+
left: e.x,
|
|
2138
|
+
right: e.x,
|
|
2139
|
+
toJSON: () => ({})
|
|
2140
|
+
}) };
|
|
2141
|
+
}, [e]),
|
|
2142
|
+
handleMouseMove: r,
|
|
2143
|
+
handleMouseLeave: i,
|
|
2144
|
+
handleTooltipVisibleChange: a
|
|
2145
|
+
};
|
|
2146
|
+
}
|
|
2147
|
+
//#endregion
|
|
2148
|
+
//#region src/components/Gantt/GanttChart/GanttBarTooltip/GanttBarTooltip.tsx
|
|
2149
|
+
var Dn = {
|
|
2150
|
+
borderRadius: "10px",
|
|
2151
|
+
padding: 0,
|
|
2152
|
+
backgroundColor: "#fff",
|
|
2153
|
+
boxShadow: "0 0 12px 0 rgba(0, 0, 0, 0.08)"
|
|
2154
|
+
}, On = ({ item: e, tooltip: t, disabled: n = !1, children: i }) => {
|
|
2155
|
+
let { virtualReference: a, handleMouseMove: o, handleMouseLeave: s, handleTooltipVisibleChange: c } = En(), d = x(() => n || !t ? null : t(e), [
|
|
2156
|
+
n,
|
|
2157
|
+
t,
|
|
2158
|
+
e
|
|
2159
|
+
]);
|
|
2160
|
+
return d ? /* @__PURE__ */ u(r, {
|
|
2161
|
+
content: d,
|
|
2162
|
+
placement: "bottom",
|
|
2163
|
+
showArrow: !1,
|
|
2164
|
+
hoverDelay: 300,
|
|
2165
|
+
moveToFloatingKeepOpen: !0,
|
|
2166
|
+
widthMode: "manual",
|
|
2167
|
+
maxWidth: 400,
|
|
2168
|
+
offset: 5,
|
|
2169
|
+
virtualReference: a,
|
|
2170
|
+
onVisibleChange: c,
|
|
2171
|
+
style: Dn,
|
|
2172
|
+
children: i({
|
|
2173
|
+
onMouseMove: o,
|
|
2174
|
+
onMouseLeave: s
|
|
2175
|
+
})
|
|
2176
|
+
}) : /* @__PURE__ */ u(l, { children: i({
|
|
2177
|
+
onMouseMove: () => {},
|
|
2178
|
+
onMouseLeave: () => {}
|
|
2179
|
+
}) });
|
|
2180
|
+
}, kn = (e, t, n) => ({
|
|
2181
|
+
...e,
|
|
2182
|
+
clientX: t,
|
|
2183
|
+
clientY: n,
|
|
2184
|
+
preventDefault: () => e.preventDefault(),
|
|
2185
|
+
stopPropagation: () => e.stopPropagation()
|
|
2186
|
+
});
|
|
2187
|
+
function An({ enabled: e, onTaskMouseDown: t, onBarClick: n }) {
|
|
2188
|
+
let r = S(null), i = S(null), a = S(t), o = S(n);
|
|
2189
|
+
v(() => {
|
|
2190
|
+
a.current = t, o.current = n;
|
|
2191
|
+
}, [t, n]);
|
|
2192
|
+
let s = g(() => {
|
|
2193
|
+
r.current = null;
|
|
2194
|
+
let e = i.current;
|
|
2195
|
+
e && (document.removeEventListener("mousemove", e.move), document.removeEventListener("mouseup", e.up), i.current = null);
|
|
2196
|
+
}, []);
|
|
2197
|
+
return v(() => () => s(), [s]), { handlePointerMouseDown: g((t, n, c, l = 1) => {
|
|
2198
|
+
if (!e) return;
|
|
2199
|
+
s();
|
|
2200
|
+
let u = {
|
|
2201
|
+
item: n,
|
|
2202
|
+
baseLeft: c,
|
|
2203
|
+
width: l,
|
|
2204
|
+
startClientX: t.clientX,
|
|
2205
|
+
startClientY: t.clientY,
|
|
2206
|
+
dragStarted: !1
|
|
2207
|
+
};
|
|
2208
|
+
r.current = u;
|
|
2209
|
+
let d = (e) => {
|
|
2210
|
+
if (r.current !== u || u.dragStarted) return;
|
|
2211
|
+
let t = e.clientX - u.startClientX, i = e.clientY - u.startClientY;
|
|
2212
|
+
Math.hypot(t, i) < 5 || (u.dragStarted = !0, s(), a.current?.(kn(e, u.startClientX, u.startClientY), n, c, u.width));
|
|
2213
|
+
}, f = (e) => {
|
|
2214
|
+
r.current === u && (s(), u.dragStarted || o.current?.(e, n));
|
|
2215
|
+
};
|
|
2216
|
+
i.current = {
|
|
2217
|
+
move: d,
|
|
2218
|
+
up: f
|
|
2219
|
+
}, document.addEventListener("mousemove", d), document.addEventListener("mouseup", f);
|
|
2220
|
+
}, [e, s]) };
|
|
2221
|
+
}
|
|
2222
|
+
var jn = f.memo(({ item: e, barTop: n, dragTaskId: r, dragPreview: i, dragPermission: a }) => {
|
|
2223
|
+
let { t: o } = t(), s = $((e) => e.viewMode), c = $((e) => e.timelineCoords), f = $((e) => e.timelineStartMs), p = $((e) => e.timelineEndMs), m = $((e) => e.timelineWidth), h = vn((e) => e.tooltip), g = vn((e) => e.isScrolling), _ = vn((e) => e.onBarClick), v = vn((e) => e.onTaskMouseDown), y = vn((e) => e.onResizeMouseDown), b = g ? null : h, S = r === e.id, C = S && i ? i.previewStartMs : e.startMs, T = S && i ? i.previewEndMs : e.endMs, E = x(() => {
|
|
2224
|
+
let t = e.color;
|
|
2225
|
+
return {
|
|
2226
|
+
baseColor: t,
|
|
2227
|
+
containerBgColor: xn(t, .2) || t,
|
|
2228
|
+
hoverBorderColor: xn(t, .5) || "transparent",
|
|
2229
|
+
insideLabelColor: Sn(t)
|
|
2230
|
+
};
|
|
2231
|
+
}, [e.color]), D = x(() => {
|
|
2232
|
+
if (C == null || T == null || C >= T || f >= p) return null;
|
|
2233
|
+
let e = It({
|
|
2234
|
+
startMs: C,
|
|
2235
|
+
endMs: T
|
|
2236
|
+
}, {
|
|
2237
|
+
startMs: f,
|
|
2238
|
+
endMs: p
|
|
2239
|
+
});
|
|
2240
|
+
if (!e) return null;
|
|
2241
|
+
let t = c.toX(e.startMs), n = c.toWidth(e.startMs, e.endMs), r = t + n, a = e.startMs !== C, o = e.endMs !== T, s = S && i && Number.isFinite(i.previewLeftPx), l = s ? c.toWidth(C, T) : n, u = s ? i.previewLeftPx : t, d = s ? u + l : r, h = s ? u : Math.max(0, u), g = Math.min(m, d);
|
|
2242
|
+
return g <= 0 || h >= m || h >= g ? null : {
|
|
2243
|
+
clippedRange: e,
|
|
2244
|
+
rawBarLeft: u,
|
|
2245
|
+
calculatedBarLeft: h,
|
|
2246
|
+
calculatedBarWidth: g - h,
|
|
2247
|
+
clippedStart: s ? !1 : a || h !== u,
|
|
2248
|
+
clippedEnd: o || g !== d
|
|
2249
|
+
};
|
|
2250
|
+
}, [
|
|
2251
|
+
C,
|
|
2252
|
+
T,
|
|
2253
|
+
f,
|
|
2254
|
+
p,
|
|
2255
|
+
m,
|
|
2256
|
+
c,
|
|
2257
|
+
S,
|
|
2258
|
+
i
|
|
2259
|
+
]), { baseColor: O, containerBgColor: ee, hoverBorderColor: te, insideLabelColor: k } = E, A = D?.calculatedBarWidth ?? 0, j = e.progress === null, M = !D || C === null || T === null ? 0 : Math.max(0, Math.min(1, (D.rawBarLeft + c.toWidth(D.clippedRange.startMs, Math.min(D.clippedRange.endMs, Math.max(D.clippedRange.startMs, C + (T - C) * Math.max(0, e.progress ?? 0)))) - D.calculatedBarLeft) / D.calculatedBarWidth)), N = j || M >= 1, P = N ? "100%" : `${M * 100}%`, F = a || Oe, I = F.canMove, L = e.label ?? "", R = typeof L == "string" ? L : "", ne = A < 40, re = Math.max(0, A - 10), z = x(() => R ? Tn(R) : 0, [R]), B = !!R && z > re && !!D && D.calculatedBarLeft + D.calculatedBarWidth + 4 + z <= m, { handlePointerMouseDown: ie } = An({
|
|
2260
|
+
enabled: I,
|
|
2261
|
+
onTaskMouseDown: v,
|
|
2262
|
+
onBarClick: _
|
|
2263
|
+
});
|
|
2264
|
+
if (!D) return null;
|
|
2265
|
+
let { calculatedBarLeft: V, clippedStart: H, clippedEnd: U } = D, W = V + A, G = V + Math.max(40, A + 12) <= m, ae = C !== null && T !== null ? s === "quarterMonth" ? $e(C, T) : c.toWidth(C, T) : A, K = ae < 40 ? Math.max(40, ae + 12) : ae, q = W + 4 <= m, J = {
|
|
2266
|
+
left: V,
|
|
2267
|
+
top: n,
|
|
2268
|
+
width: `var(--bsy-gantt-bar-actual-width, ${A}px)`,
|
|
2269
|
+
height: 26,
|
|
2270
|
+
background: ee,
|
|
2271
|
+
cursor: I ? "move" : "default",
|
|
2272
|
+
"--bsy-gantt-bar-fill-color": O,
|
|
2273
|
+
"--bsy-gantt-bar-hover-border-color": te,
|
|
2274
|
+
"--bsy-gantt-bar-calc-width": `${A}px`,
|
|
2275
|
+
"--bsy-gantt-bar-label-color": k
|
|
2276
|
+
};
|
|
2277
|
+
return /* @__PURE__ */ u(On, {
|
|
2278
|
+
item: e,
|
|
2279
|
+
tooltip: b,
|
|
2280
|
+
disabled: S,
|
|
2281
|
+
children: ({ onMouseMove: t, onMouseLeave: n }) => /* @__PURE__ */ d("div", {
|
|
2282
|
+
className: w(Q.bar, {
|
|
2283
|
+
[Q.isReadonly]: !I,
|
|
2284
|
+
[Q.isDragging]: S,
|
|
2285
|
+
[Q.isMicro]: ne && G
|
|
2286
|
+
}),
|
|
2287
|
+
"data-testid": "gantt-bar",
|
|
2288
|
+
style: J,
|
|
2289
|
+
onMouseDown: (t) => {
|
|
2290
|
+
I && ie(t, e, V, K);
|
|
2291
|
+
},
|
|
2292
|
+
onClick: (t) => {
|
|
2293
|
+
I || _(t, e);
|
|
2294
|
+
},
|
|
2295
|
+
onMouseMove: t,
|
|
2296
|
+
onMouseLeave: n,
|
|
2297
|
+
children: [
|
|
2298
|
+
e.type === "task" ? /* @__PURE__ */ u("div", {
|
|
2299
|
+
className: w(Q.barProgress, { [Q.isFull]: N }),
|
|
2300
|
+
"data-testid": "gantt-bar-progress",
|
|
2301
|
+
style: { width: P }
|
|
2302
|
+
}) : null,
|
|
2303
|
+
/* @__PURE__ */ u("span", {
|
|
2304
|
+
className: w(Q.barLabel, { [Q.isHidden]: B }),
|
|
2305
|
+
style: { color: "var(--bsy-gantt-bar-label-color)" },
|
|
2306
|
+
children: L
|
|
2307
|
+
}),
|
|
2308
|
+
B ? /* @__PURE__ */ u("span", {
|
|
2309
|
+
className: w(Q.barLabel, Q.isOutside),
|
|
2310
|
+
"data-testid": "gantt-bar-label-outside",
|
|
2311
|
+
children: L
|
|
2312
|
+
}) : null,
|
|
2313
|
+
F.canResizeStart && !H || F.canResizeEnd && !U && q ? /* @__PURE__ */ d(l, { children: [F.canResizeStart && !H ? /* @__PURE__ */ u("button", {
|
|
2314
|
+
type: "button",
|
|
2315
|
+
className: w(Q.barResizeHandle, Q.barResizeHandleLeft),
|
|
2316
|
+
"data-testid": "gantt-bar-resize-left",
|
|
2317
|
+
onMouseDown: (t) => y(t, e, V, "start", A),
|
|
2318
|
+
"aria-label": o("gantt.timeBegin")
|
|
2319
|
+
}) : null, F.canResizeEnd && !U && q ? /* @__PURE__ */ u("button", {
|
|
2320
|
+
type: "button",
|
|
2321
|
+
className: w(Q.barResizeHandle, Q.barResizeHandleRight),
|
|
2322
|
+
"data-testid": "gantt-bar-resize-right",
|
|
2323
|
+
onMouseDown: (t) => y(t, e, V, "end", A),
|
|
2324
|
+
"aria-label": o("gantt.timeEnd")
|
|
2325
|
+
}) : null] }) : null
|
|
2326
|
+
]
|
|
2327
|
+
}, `bar-${e.id}`)
|
|
2328
|
+
});
|
|
2329
|
+
}, (e, t) => {
|
|
2330
|
+
if (e.barTop !== t.barTop || e.dragTaskId !== t.dragTaskId || e.dragPermission?.canMove !== t.dragPermission?.canMove || e.dragPermission?.canResizeStart !== t.dragPermission?.canResizeStart || e.dragPermission?.canResizeEnd !== t.dragPermission?.canResizeEnd || e.item !== t.item) return !1;
|
|
2331
|
+
let n = e.dragPreview, r = t.dragPreview;
|
|
2332
|
+
return !(n !== r && (!n || !r || n.previewStartMs !== r.previewStartMs || n.previewEndMs !== r.previewEndMs || n.previewLeftPx !== r.previewLeftPx));
|
|
2333
|
+
}), Mn = {
|
|
2334
|
+
root: "_root_1g3ub_1",
|
|
2335
|
+
arrow: "_arrow_1g3ub_9",
|
|
2336
|
+
label: "_label_1g3ub_13",
|
|
2337
|
+
isCollapsed: "_isCollapsed_1g3ub_29",
|
|
2338
|
+
labelText: "_labelText_1g3ub_33",
|
|
2339
|
+
track: "_track_1g3ub_40",
|
|
2340
|
+
progress: "_progress_1g3ub_49",
|
|
2341
|
+
summaryTooltip: "_summaryTooltip_1g3ub_59",
|
|
2342
|
+
summaryTooltipLine: "_summaryTooltipLine_1g3ub_69"
|
|
2343
|
+
}, Nn = (e) => String(e).padStart(2, "0");
|
|
2344
|
+
function Pn(e, t) {
|
|
2345
|
+
if (e == null) return t("summary.empty");
|
|
2346
|
+
let n = Ee(e);
|
|
2347
|
+
return t("summary.datetime", {
|
|
2348
|
+
year: n.year(),
|
|
2349
|
+
month: Nn(n.month() + 1),
|
|
2350
|
+
day: Nn(n.date()),
|
|
2351
|
+
hour: Nn(n.hour()),
|
|
2352
|
+
minute: Nn(n.minute()),
|
|
2353
|
+
second: Nn(n.second())
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
function Fn(e, t) {
|
|
2357
|
+
let n = s(e?.progress), r = n ? Math.max(0, Math.min(1, e.progress ?? 0)) : 0, i = Pn(e?.rawStartMs, t), a = Pn(e?.rawEndMs, t);
|
|
2358
|
+
return /* @__PURE__ */ d("div", {
|
|
2359
|
+
className: Mn.summaryTooltip,
|
|
2360
|
+
children: [
|
|
2361
|
+
/* @__PURE__ */ u("p", {
|
|
2362
|
+
className: Mn.summaryTooltipLine,
|
|
2363
|
+
children: t("summary.startTime", { datetime: i })
|
|
2364
|
+
}),
|
|
2365
|
+
/* @__PURE__ */ u("p", {
|
|
2366
|
+
className: Mn.summaryTooltipLine,
|
|
2367
|
+
children: t("summary.endTime", { datetime: a })
|
|
2368
|
+
}),
|
|
2369
|
+
n ? /* @__PURE__ */ u("p", {
|
|
2370
|
+
className: Mn.summaryTooltipLine,
|
|
2371
|
+
children: t("summary.progress", { percent: Math.round(r * 100) })
|
|
2372
|
+
}) : null
|
|
2373
|
+
]
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
//#endregion
|
|
2377
|
+
//#region src/components/Gantt/utils/collapseKeys.ts
|
|
2378
|
+
function In(e, t) {
|
|
2379
|
+
if (t == null || t === "" || !e) return !1;
|
|
2380
|
+
let n = String(t);
|
|
2381
|
+
return e instanceof Set ? e.has(n) : Array.isArray(e) ? e.includes(n) : !1;
|
|
2382
|
+
}
|
|
2383
|
+
function Ln(e, t) {
|
|
2384
|
+
let n = String(t), r = e instanceof Set ? e : new Set(Array.isArray(e) ? e : []), i = new Set(r);
|
|
2385
|
+
return i.has(n) ? i.delete(n) : i.add(n), i;
|
|
2386
|
+
}
|
|
2387
|
+
//#endregion
|
|
2388
|
+
//#region src/components/Gantt/GanttChart/GanttSummaryBar/GanttSummaryBar.tsx
|
|
2389
|
+
var Rn = 24, zn = {
|
|
2390
|
+
borderRadius: "6px",
|
|
2391
|
+
padding: 0,
|
|
2392
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
2393
|
+
boxShadow: "none"
|
|
2394
|
+
};
|
|
2395
|
+
function Bn(e, t) {
|
|
2396
|
+
return e == null || e === "__empty__" ? t : e;
|
|
2397
|
+
}
|
|
2398
|
+
var Vn = ({ item: n, barTop: i }) => {
|
|
2399
|
+
let { t: a } = t(), o = g((e, t) => a(tn(e), t), [a]), c = $((e) => e.timelineCoords), l = $((e) => e.timelineStartMs), f = $((e) => e.timelineEndMs), p = $((e) => e.timelineWidth), m = vn((e) => e.collapsedKeys), h = vn((e) => e.onBarClick), { virtualReference: _, handleMouseMove: v, handleMouseLeave: y, handleTooltipVisibleChange: b } = En(), S = s(n.progress) ? Math.max(0, Math.min(1, n.progress ?? 0)) : 0, C = x(() => Fn({
|
|
2400
|
+
rawStartMs: n.rawStartMs,
|
|
2401
|
+
rawEndMs: n.rawEndMs,
|
|
2402
|
+
progress: n.progress
|
|
2403
|
+
}, o), [
|
|
2404
|
+
n.rawStartMs,
|
|
2405
|
+
n.rawEndMs,
|
|
2406
|
+
n.progress,
|
|
2407
|
+
o
|
|
2408
|
+
]), T = x(() => {
|
|
2409
|
+
if (n.startMs === null || n.endMs === null || n.startMs >= n.endMs || l >= f) return null;
|
|
2410
|
+
let e = It({
|
|
2411
|
+
startMs: n.startMs,
|
|
2412
|
+
endMs: n.endMs
|
|
2413
|
+
}, {
|
|
2414
|
+
startMs: l,
|
|
2415
|
+
endMs: f
|
|
2416
|
+
});
|
|
2417
|
+
return e ? {
|
|
2418
|
+
barLeft: c.toX(e.startMs),
|
|
2419
|
+
barWidth: c.toWidth(e.startMs, e.endMs),
|
|
2420
|
+
wrapperTop: i + (26 - Rn) / 2,
|
|
2421
|
+
clippedRange: e,
|
|
2422
|
+
itemStartMs: n.startMs,
|
|
2423
|
+
itemEndMs: n.endMs
|
|
2424
|
+
} : null;
|
|
2425
|
+
}, [
|
|
2426
|
+
n.startMs,
|
|
2427
|
+
n.endMs,
|
|
2428
|
+
l,
|
|
2429
|
+
f,
|
|
2430
|
+
c,
|
|
2431
|
+
i
|
|
2432
|
+
]);
|
|
2433
|
+
if (!T) return null;
|
|
2434
|
+
let { barLeft: E, barWidth: D, wrapperTop: O, clippedRange: ee, itemStartMs: te, itemEndMs: k } = T, A = te + (k - te) * S, j = Math.min(ee.endMs, Math.max(ee.startMs, A)), M = c.toWidth(ee.startMs, j), N = `${Math.max(0, Math.min(1, M / D)) * 100}%`, P = Math.max(0, p - E), F = Bn(n.label, a("gantt.emptyGroup")), I = In(m, n.groupKey);
|
|
2435
|
+
return /* @__PURE__ */ u(r, {
|
|
2436
|
+
content: C,
|
|
2437
|
+
placement: "bottom-start",
|
|
2438
|
+
showArrow: !1,
|
|
2439
|
+
hoverDelay: 300,
|
|
2440
|
+
moveToFloatingKeepOpen: !1,
|
|
2441
|
+
widthMode: "content",
|
|
2442
|
+
offset: 5,
|
|
2443
|
+
virtualReference: _,
|
|
2444
|
+
onVisibleChange: b,
|
|
2445
|
+
style: zn,
|
|
2446
|
+
children: /* @__PURE__ */ d("div", {
|
|
2447
|
+
className: Mn.root,
|
|
2448
|
+
"data-testid": "gantt-summary-bar",
|
|
2449
|
+
style: {
|
|
2450
|
+
left: E,
|
|
2451
|
+
top: O,
|
|
2452
|
+
width: D
|
|
2453
|
+
},
|
|
2454
|
+
onClick: (e) => h?.(e, n),
|
|
2455
|
+
onMouseMove: v,
|
|
2456
|
+
onMouseLeave: y,
|
|
2457
|
+
children: [/* @__PURE__ */ d("div", {
|
|
2458
|
+
className: Mn.label,
|
|
2459
|
+
"data-testid": "gantt-summary-bar-label",
|
|
2460
|
+
style: {
|
|
2461
|
+
maxWidth: P,
|
|
2462
|
+
overflow: "hidden"
|
|
2463
|
+
},
|
|
2464
|
+
children: [/* @__PURE__ */ u(e, {
|
|
2465
|
+
name: "xiangxiazhankai1",
|
|
2466
|
+
size: 16,
|
|
2467
|
+
className: w(Mn.arrow, { [Mn.isCollapsed]: I })
|
|
2468
|
+
}), /* @__PURE__ */ u("span", {
|
|
2469
|
+
className: Mn.labelText,
|
|
2470
|
+
children: F
|
|
2471
|
+
})]
|
|
2472
|
+
}), /* @__PURE__ */ u("div", {
|
|
2473
|
+
className: Mn.track,
|
|
2474
|
+
children: /* @__PURE__ */ u("div", {
|
|
2475
|
+
className: Mn.progress,
|
|
2476
|
+
"data-testid": "gantt-summary-bar-progress",
|
|
2477
|
+
style: { width: N }
|
|
2478
|
+
})
|
|
2479
|
+
})]
|
|
2480
|
+
})
|
|
2481
|
+
});
|
|
2482
|
+
};
|
|
2483
|
+
function Hn(e, t) {
|
|
2484
|
+
return e.barTop === t.barTop && e.item === t.item;
|
|
2485
|
+
}
|
|
2486
|
+
var Un = f.memo(Vn, Hn), Wn = f.memo(({ indicators: n = [], onJump: r }) => {
|
|
2487
|
+
let { t: i } = t();
|
|
2488
|
+
if (!Array.isArray(n) || n.length === 0) return null;
|
|
2489
|
+
let a = (e, t) => {
|
|
2490
|
+
e.preventDefault(), e.stopPropagation(), r?.({
|
|
2491
|
+
targetMs: t.targetMs,
|
|
2492
|
+
taskId: t.taskId
|
|
2493
|
+
});
|
|
2494
|
+
};
|
|
2495
|
+
return /* @__PURE__ */ u(l, { children: n.map((t) => /* @__PURE__ */ u("div", {
|
|
2496
|
+
className: Q.offscreenRow,
|
|
2497
|
+
style: {
|
|
2498
|
+
top: t.rowTop,
|
|
2499
|
+
height: t.rowHeight
|
|
2500
|
+
},
|
|
2501
|
+
children: /* @__PURE__ */ d("div", {
|
|
2502
|
+
className: Q.offscreenTrack,
|
|
2503
|
+
children: [t.showLeft ? /* @__PURE__ */ u("button", {
|
|
2504
|
+
type: "button",
|
|
2505
|
+
className: w(Q.offscreenBtn, Q.offscreenBtnLeft),
|
|
2506
|
+
"data-testid": "gantt-offscreen-btn-left",
|
|
2507
|
+
"aria-label": i("gantt.aria.jumpLeft"),
|
|
2508
|
+
onClick: (e) => a(e, t),
|
|
2509
|
+
children: /* @__PURE__ */ u(e, {
|
|
2510
|
+
name: "left",
|
|
2511
|
+
size: 16
|
|
2512
|
+
})
|
|
2513
|
+
}) : null, t.showRight ? /* @__PURE__ */ u("button", {
|
|
2514
|
+
type: "button",
|
|
2515
|
+
className: w(Q.offscreenBtn, Q.offscreenBtnRight),
|
|
2516
|
+
"data-testid": "gantt-offscreen-btn-right",
|
|
2517
|
+
"aria-label": i("gantt.aria.jumpRight"),
|
|
2518
|
+
onClick: (e) => a(e, t),
|
|
2519
|
+
children: /* @__PURE__ */ u(e, {
|
|
2520
|
+
name: "arrow-right",
|
|
2521
|
+
size: 16
|
|
2522
|
+
})
|
|
2523
|
+
}) : null]
|
|
2524
|
+
})
|
|
2525
|
+
}, t.rowKey)) });
|
|
2526
|
+
}), Gn = ({ left: e, height: t, className: n = "" }) => /* @__PURE__ */ u("div", {
|
|
2527
|
+
className: w(Q.todayIndicator, n),
|
|
2528
|
+
"data-testid": "gantt-today-indicator-content-line",
|
|
2529
|
+
style: {
|
|
2530
|
+
left: e,
|
|
2531
|
+
height: t
|
|
2532
|
+
},
|
|
2533
|
+
children: /* @__PURE__ */ u("span", { className: Q.todayIndicatorLine })
|
|
2534
|
+
}), Kn = h(function({ canvasHeight: e, weekendSegments: t, virtualColumns: n, lowerSegments: r, shouldShowTodayMarker: i, todayLineLeft: a }) {
|
|
2535
|
+
return /* @__PURE__ */ d(l, { children: [
|
|
2536
|
+
t.map((t) => /* @__PURE__ */ u("div", {
|
|
2537
|
+
className: Q.weekendBg,
|
|
2538
|
+
style: {
|
|
2539
|
+
left: t.left,
|
|
2540
|
+
width: t.width,
|
|
2541
|
+
height: e
|
|
2542
|
+
}
|
|
2543
|
+
}, t.id)),
|
|
2544
|
+
n.map((t) => {
|
|
2545
|
+
let n = r[t.index];
|
|
2546
|
+
return n ? /* @__PURE__ */ u("div", {
|
|
2547
|
+
className: Q.colLine,
|
|
2548
|
+
style: {
|
|
2549
|
+
left: n.left,
|
|
2550
|
+
height: e
|
|
2551
|
+
}
|
|
2552
|
+
}, `line-${n.id}`) : null;
|
|
2553
|
+
}),
|
|
2554
|
+
i ? /* @__PURE__ */ u(Gn, {
|
|
2555
|
+
left: a ?? 0,
|
|
2556
|
+
height: e,
|
|
2557
|
+
className: Q.todayIndicatorContentLine
|
|
2558
|
+
}) : null
|
|
2559
|
+
] });
|
|
2560
|
+
}), qn = ({ virtualRows: e, normalizedItems: t, dragState: n, dragPermissionById: r, timelineStartMs: i, timelineEndMs: a }) => {
|
|
2561
|
+
let o = n?.taskId ?? null;
|
|
2562
|
+
return e.map((e) => {
|
|
2563
|
+
let s = t[e.index];
|
|
2564
|
+
if (!s || s.invalid) return null;
|
|
2565
|
+
let c = o === s.id;
|
|
2566
|
+
if (!c && (s.startMs === null || s.endMs === null || s.startMs >= s.endMs || !Ft({
|
|
2567
|
+
startMs: s.startMs,
|
|
2568
|
+
endMs: s.endMs
|
|
2569
|
+
}, {
|
|
2570
|
+
startMs: i,
|
|
2571
|
+
endMs: a
|
|
2572
|
+
}))) return null;
|
|
2573
|
+
let l = e.start + (e.size - 26) / 2;
|
|
2574
|
+
return s.type === "summary" ? /* @__PURE__ */ u(Un, {
|
|
2575
|
+
item: s,
|
|
2576
|
+
barTop: l
|
|
2577
|
+
}, `summary-${s.id}`) : /* @__PURE__ */ u(jn, {
|
|
2578
|
+
item: s,
|
|
2579
|
+
barTop: l,
|
|
2580
|
+
dragTaskId: o,
|
|
2581
|
+
dragPreview: c ? n : null,
|
|
2582
|
+
dragPermission: r[s.id]
|
|
2583
|
+
}, `bar-${s.id}`);
|
|
2584
|
+
});
|
|
2585
|
+
}, Jn = h(function({ virtualRows: e, normalizedItems: t, dragState: n, dragPermissionById: r, handleOffscreenJump: i, hoverBgRef: a }) {
|
|
2586
|
+
let o = $((e) => e.timelineStartMs), s = $((e) => e.timelineEndMs), c = $((e) => e.visibleStartMs), f = $((e) => e.visibleEndMs), p = $((e) => e.isInitialLayoutReady), m = hn({
|
|
2587
|
+
virtualRows: e,
|
|
2588
|
+
normalizedItems: t,
|
|
2589
|
+
visibleStartMs: c,
|
|
2590
|
+
visibleEndMs: f,
|
|
2591
|
+
enabled: p,
|
|
2592
|
+
excludeTaskId: n?.taskId ?? null
|
|
2593
|
+
});
|
|
2594
|
+
return /* @__PURE__ */ d(l, { children: [
|
|
2595
|
+
e.map((e) => /* @__PURE__ */ u("div", {
|
|
2596
|
+
className: Q.rowLine,
|
|
2597
|
+
"data-testid": "gantt-row-line",
|
|
2598
|
+
style: {
|
|
2599
|
+
top: e.start,
|
|
2600
|
+
height: e.size
|
|
2601
|
+
}
|
|
2602
|
+
}, `row-line-${e.key}`)),
|
|
2603
|
+
/* @__PURE__ */ u("div", {
|
|
2604
|
+
ref: a,
|
|
2605
|
+
className: Q.rowHoverBg,
|
|
2606
|
+
"data-testid": "gantt-row-hover-bg",
|
|
2607
|
+
style: { display: "none" }
|
|
2608
|
+
}),
|
|
2609
|
+
p && qn({
|
|
2610
|
+
virtualRows: e,
|
|
2611
|
+
normalizedItems: t,
|
|
2612
|
+
dragState: n,
|
|
2613
|
+
dragPermissionById: r,
|
|
2614
|
+
timelineStartMs: o,
|
|
2615
|
+
timelineEndMs: s
|
|
2616
|
+
}),
|
|
2617
|
+
p ? /* @__PURE__ */ u(Wn, {
|
|
2618
|
+
indicators: m,
|
|
2619
|
+
onJump: i
|
|
2620
|
+
}) : null
|
|
2621
|
+
] });
|
|
2622
|
+
}), Yn = h(function({ contentRef: e, normalizedItems: t, safeRowHeight: n, viewportHeight: r, lowerSegments: i, virtualColumns: a, weekendSegments: o, dragState: s, dragPermissionById: c, tooltip: l, handleTaskMouseDown: f, handleResizeMouseDown: p, handleBarClick: m, collapsedKeys: h, handleOffscreenJump: g, todayLineLeft: _, shouldShowTodayMarker: v }) {
|
|
2623
|
+
let y = $((e) => e.timelineWidth), { virtualRows: b, canvasHeight: S, isScrolling: C } = mn({
|
|
2624
|
+
items: t,
|
|
2625
|
+
contentRef: e,
|
|
2626
|
+
safeRowHeight: n,
|
|
2627
|
+
viewportHeight: r
|
|
2628
|
+
}), { hoverBgRef: w, handleContentMouseMove: T, handleContentMouseLeave: E } = gn({
|
|
2629
|
+
normalizedItems: t,
|
|
2630
|
+
safeRowHeight: n
|
|
2631
|
+
}), D = x(() => ({
|
|
2632
|
+
width: y,
|
|
2633
|
+
height: S
|
|
2634
|
+
}), [y, S]), O = x(() => ({
|
|
2635
|
+
tooltip: l ?? null,
|
|
2636
|
+
isScrolling: C,
|
|
2637
|
+
collapsedKeys: h,
|
|
2638
|
+
onBarClick: m,
|
|
2639
|
+
onTaskMouseDown: f,
|
|
2640
|
+
onResizeMouseDown: p
|
|
2641
|
+
}), [
|
|
2642
|
+
l,
|
|
2643
|
+
C,
|
|
2644
|
+
h,
|
|
2645
|
+
m,
|
|
2646
|
+
f,
|
|
2647
|
+
p
|
|
2648
|
+
]);
|
|
2649
|
+
return /* @__PURE__ */ d("div", {
|
|
2650
|
+
className: Q.canvas,
|
|
2651
|
+
"data-testid": "gantt-canvas",
|
|
2652
|
+
style: D,
|
|
2653
|
+
onMouseMove: T,
|
|
2654
|
+
onMouseLeave: E,
|
|
2655
|
+
children: [/* @__PURE__ */ u(Kn, {
|
|
2656
|
+
canvasHeight: S,
|
|
2657
|
+
weekendSegments: o,
|
|
2658
|
+
virtualColumns: a,
|
|
2659
|
+
lowerSegments: i,
|
|
2660
|
+
shouldShowTodayMarker: v,
|
|
2661
|
+
todayLineLeft: _
|
|
2662
|
+
}), /* @__PURE__ */ u(_n.Provider, {
|
|
2663
|
+
value: O,
|
|
2664
|
+
children: /* @__PURE__ */ u(Jn, {
|
|
2665
|
+
virtualRows: b,
|
|
2666
|
+
normalizedItems: t,
|
|
2667
|
+
dragState: s,
|
|
2668
|
+
dragPermissionById: c,
|
|
2669
|
+
handleOffscreenJump: g,
|
|
2670
|
+
hoverBgRef: w
|
|
2671
|
+
})
|
|
2672
|
+
})]
|
|
2673
|
+
});
|
|
2674
|
+
});
|
|
2675
|
+
//#endregion
|
|
2676
|
+
//#region src/components/Gantt/GanttChart/GanttChart.tsx
|
|
2677
|
+
function Xn({ items: e = [], viewMode: n = "day", availableModes: r, onViewModeChange: i, timeRangeConfig: a = H, pixelsPerDayConfig: o = ae, onTaskTimeChange: s, onRowClick: c, tooltip: l, verticalScrollController: f, showWeekendHighlight: p = !0, showTodayLine: m = !0, collapsedKeys: h, onToggleCollapse: _ }, b) {
|
|
2678
|
+
let { t: w } = t(), T = g((e, t) => w(tn(e), t), [w]), E = S(null), O = S(null), ee = S(null), te = D(O), k = S(null), A = $t(E, O), [j, M] = C(!1), { pixelsPerDay: N, viewportWidth: P, scrollLeft: F, timelineStartMs: I, timelineEndMs: L, visibleStartMs: R, visibleEndMs: ne, lowerSegments: re, timelineCoords: z, timelineWidth: B, todayCenterMs: ie, todayLineLeft: V, isInitialLayoutReady: U, handleContentScroll: W, handleTodayClick: G, handleOffscreenJump: K, handleScrollPrev: q, handleScrollNext: J } = Jt({
|
|
2679
|
+
timeRangeConfig: a,
|
|
2680
|
+
pixelsPerDayConfig: o,
|
|
2681
|
+
viewMode: n,
|
|
2682
|
+
contentRef: O,
|
|
2683
|
+
contentSize: te,
|
|
2684
|
+
headerTrackRef: ee,
|
|
2685
|
+
formatMessage: T,
|
|
2686
|
+
isHorizontalScrollbarInteracting: A,
|
|
2687
|
+
isTaskBarInteracting: j
|
|
2688
|
+
});
|
|
2689
|
+
y(b, () => ({
|
|
2690
|
+
scrollToToday: G,
|
|
2691
|
+
scrollPrev: q,
|
|
2692
|
+
scrollNext: J
|
|
2693
|
+
}), [
|
|
2694
|
+
G,
|
|
2695
|
+
q,
|
|
2696
|
+
J
|
|
2697
|
+
]);
|
|
2698
|
+
let { dragState: Y, committedRangeById: X, resetCommittedRanges: oe, forceResetAllCommittedRanges: se, handleTaskMouseDown: ce, handleResizeMouseDown: Z, consumeRecentDragResult: le } = Xe({
|
|
2699
|
+
pixelsPerDay: N,
|
|
2700
|
+
viewMode: n,
|
|
2701
|
+
timelineCoords: z,
|
|
2702
|
+
onTaskTimeChange: s,
|
|
2703
|
+
containerRef: O,
|
|
2704
|
+
onDragInteractionChange: M
|
|
2705
|
+
});
|
|
2706
|
+
v(() => {
|
|
2707
|
+
let t = new Set((e || []).map((e) => String(e?.id ?? ""))), n = k.current, r = !1;
|
|
2708
|
+
if (n) {
|
|
2709
|
+
if (n.size !== t.size) r = !0;
|
|
2710
|
+
else for (let e of n) if (!t.has(e)) {
|
|
2711
|
+
r = !0;
|
|
2712
|
+
break;
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
if (k.current = t, r) {
|
|
2716
|
+
se();
|
|
2717
|
+
return;
|
|
2718
|
+
}
|
|
2719
|
+
oe();
|
|
2720
|
+
}, [
|
|
2721
|
+
e,
|
|
2722
|
+
oe,
|
|
2723
|
+
se
|
|
2724
|
+
]);
|
|
2725
|
+
let { normalizedItems: ue } = Qt({
|
|
2726
|
+
visibleItems: e,
|
|
2727
|
+
committedRangeById: X,
|
|
2728
|
+
viewMode: n
|
|
2729
|
+
}), de = x(() => {
|
|
2730
|
+
let e = {};
|
|
2731
|
+
return ue.forEach((t) => {
|
|
2732
|
+
e[t.id] = ke(t);
|
|
2733
|
+
}), e;
|
|
2734
|
+
}, [ue]), fe = g((e, t, n, r) => {
|
|
2735
|
+
let i = de[t.id];
|
|
2736
|
+
i?.canMove && ce(e, {
|
|
2737
|
+
...t,
|
|
2738
|
+
dragPermission: i
|
|
2739
|
+
}, n, r);
|
|
2740
|
+
}, [de, ce]), pe = g((e, t, n, r, i) => {
|
|
2741
|
+
let a = de[t.id];
|
|
2742
|
+
(r === "start" ? a?.canResizeStart : a?.canResizeEnd) && Z(e, {
|
|
2743
|
+
...t,
|
|
2744
|
+
dragPermission: a
|
|
2745
|
+
}, n, r, i);
|
|
2746
|
+
}, [de, Z]);
|
|
2747
|
+
v(() => {
|
|
2748
|
+
if (!f || !O.current) return;
|
|
2749
|
+
let e = O.current;
|
|
2750
|
+
return f.registerTimelineScroller({ setScrollTop: (t) => {
|
|
2751
|
+
e.scrollTop = t;
|
|
2752
|
+
} });
|
|
2753
|
+
}, [f]);
|
|
2754
|
+
let me = te?.height || 0, { virtualColumns: he, weekendSegments: ge } = Ct({
|
|
2755
|
+
lowerSegments: re,
|
|
2756
|
+
pixelsPerDay: N,
|
|
2757
|
+
scrollLeft: F,
|
|
2758
|
+
viewportWidth: P,
|
|
2759
|
+
showWeekendHighlight: p,
|
|
2760
|
+
timelineStartMs: I,
|
|
2761
|
+
timelineWidth: B,
|
|
2762
|
+
viewMode: n
|
|
2763
|
+
}), _e = en(m, V, B, ie, {
|
|
2764
|
+
startMs: I,
|
|
2765
|
+
endMs: L
|
|
2766
|
+
}), ve = g((e, t) => {
|
|
2767
|
+
if (!(e.target instanceof Element && e.target.closest(`.${Q.barResizeHandle}`)) && !le()) {
|
|
2768
|
+
if (t?.type === "summary") {
|
|
2769
|
+
let e = t.groupKey;
|
|
2770
|
+
if (!e || !_) return;
|
|
2771
|
+
_(String(e));
|
|
2772
|
+
return;
|
|
2773
|
+
}
|
|
2774
|
+
c && c(t, t.rowIndex, e);
|
|
2775
|
+
}
|
|
2776
|
+
}, [
|
|
2777
|
+
le,
|
|
2778
|
+
c,
|
|
2779
|
+
_
|
|
2780
|
+
]), ye = x(() => ({
|
|
2781
|
+
viewMode: n,
|
|
2782
|
+
pixelsPerDay: N,
|
|
2783
|
+
timelineStartMs: I,
|
|
2784
|
+
timelineEndMs: L,
|
|
2785
|
+
visibleStartMs: R,
|
|
2786
|
+
visibleEndMs: ne,
|
|
2787
|
+
timelineCoords: z,
|
|
2788
|
+
scrollLeft: F,
|
|
2789
|
+
viewportWidth: P,
|
|
2790
|
+
timelineWidth: B,
|
|
2791
|
+
isInitialLayoutReady: U
|
|
2792
|
+
}), [
|
|
2793
|
+
n,
|
|
2794
|
+
N,
|
|
2795
|
+
I,
|
|
2796
|
+
L,
|
|
2797
|
+
R,
|
|
2798
|
+
ne,
|
|
2799
|
+
z,
|
|
2800
|
+
F,
|
|
2801
|
+
P,
|
|
2802
|
+
B,
|
|
2803
|
+
U
|
|
2804
|
+
]);
|
|
2805
|
+
return /* @__PURE__ */ u(yn.Provider, {
|
|
2806
|
+
value: ye,
|
|
2807
|
+
children: /* @__PURE__ */ d("div", {
|
|
2808
|
+
className: Q.root,
|
|
2809
|
+
"data-testid": "gantt-chart",
|
|
2810
|
+
style: { visibility: U ? "visible" : "hidden" },
|
|
2811
|
+
children: [/* @__PURE__ */ u(pn, {
|
|
2812
|
+
timelineWidth: B,
|
|
2813
|
+
viewportWidth: P,
|
|
2814
|
+
scrollLeft: F,
|
|
2815
|
+
trackRef: ee,
|
|
2816
|
+
virtualColumns: he,
|
|
2817
|
+
lowerSegments: re,
|
|
2818
|
+
todayLineLeft: V,
|
|
2819
|
+
todayCenterMs: ie,
|
|
2820
|
+
showTodayLine: m,
|
|
2821
|
+
viewMode: n,
|
|
2822
|
+
availableModes: r,
|
|
2823
|
+
formatMessage: T,
|
|
2824
|
+
onViewModeChange: i,
|
|
2825
|
+
onTodayClick: G,
|
|
2826
|
+
onScrollPrev: q,
|
|
2827
|
+
onScrollNext: J
|
|
2828
|
+
}), /* @__PURE__ */ u("div", {
|
|
2829
|
+
ref: E,
|
|
2830
|
+
className: Q.timelineHost,
|
|
2831
|
+
children: /* @__PURE__ */ u("div", {
|
|
2832
|
+
ref: O,
|
|
2833
|
+
className: Q.timelineContent,
|
|
2834
|
+
"data-testid": "gantt-timeline-content",
|
|
2835
|
+
role: "region",
|
|
2836
|
+
"aria-label": w("gantt.aria.timeline"),
|
|
2837
|
+
onScroll: (e) => {
|
|
2838
|
+
W(e), f && f.sync("timeline", e.currentTarget.scrollTop);
|
|
2839
|
+
},
|
|
2840
|
+
children: /* @__PURE__ */ u(Yn, {
|
|
2841
|
+
contentRef: O,
|
|
2842
|
+
normalizedItems: ue,
|
|
2843
|
+
safeRowHeight: 34,
|
|
2844
|
+
viewportHeight: me,
|
|
2845
|
+
lowerSegments: re,
|
|
2846
|
+
virtualColumns: he,
|
|
2847
|
+
weekendSegments: ge,
|
|
2848
|
+
dragState: Y,
|
|
2849
|
+
dragPermissionById: de,
|
|
2850
|
+
tooltip: l,
|
|
2851
|
+
handleTaskMouseDown: fe,
|
|
2852
|
+
handleResizeMouseDown: pe,
|
|
2853
|
+
handleBarClick: ve,
|
|
2854
|
+
collapsedKeys: h,
|
|
2855
|
+
handleOffscreenJump: K,
|
|
2856
|
+
todayLineLeft: V,
|
|
2857
|
+
shouldShowTodayMarker: _e
|
|
2858
|
+
})
|
|
2859
|
+
})
|
|
2860
|
+
})]
|
|
2861
|
+
})
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
var Zn = m(Xn), Qn = {
|
|
35
2865
|
root: "_root_1p401_1",
|
|
36
2866
|
body: "_body_1p401_11",
|
|
37
2867
|
chartSlot: "_chartSlot_1p401_19",
|
|
38
2868
|
resizeIndicator: "_resizeIndicator_1p401_25",
|
|
39
2869
|
resizeIndicatorBar: "_resizeIndicatorBar_1p401_35"
|
|
40
|
-
},
|
|
41
|
-
let [i, a] =
|
|
42
|
-
|
|
43
|
-
|
|
2870
|
+
}, $n = ({ tableWidth: e, onWidthChange: t, onResizeEnd: n, containerRef: r }) => {
|
|
2871
|
+
let [i, a] = C(!1), [o, s] = C(!1), c = S(0), l = S(0), d = S(e);
|
|
2872
|
+
v(() => {
|
|
2873
|
+
d.current = e;
|
|
44
2874
|
}, [e]);
|
|
45
|
-
let
|
|
46
|
-
s(!0), c.current = e.clientX, l.current =
|
|
47
|
-
}, []),
|
|
2875
|
+
let f = i || o, p = g((e) => {
|
|
2876
|
+
s(!0), c.current = e.clientX, l.current = d.current, e.preventDefault();
|
|
2877
|
+
}, []), m = g((e) => {
|
|
48
2878
|
if (!o) return;
|
|
49
2879
|
let n = e.clientX - c.current, i = l.current + n, a = (r.current?.offsetWidth || 1e3) - 300;
|
|
50
2880
|
i < 200 ? i = 200 : i > a && (i = a), t(i);
|
|
@@ -52,70 +2882,70 @@ var N = {
|
|
|
52
2882
|
o,
|
|
53
2883
|
r,
|
|
54
2884
|
t
|
|
55
|
-
]),
|
|
56
|
-
o && (s(!1), n?.(
|
|
2885
|
+
]), h = g(() => {
|
|
2886
|
+
o && (s(!1), n?.(d.current));
|
|
57
2887
|
}, [o, n]);
|
|
58
|
-
return
|
|
59
|
-
className:
|
|
2888
|
+
return E("mousemove", m, { target: () => document }), E("mouseup", h, { target: () => document }), /* @__PURE__ */ u("div", {
|
|
2889
|
+
className: Qn.resizeIndicator,
|
|
60
2890
|
"data-testid": "gantt-resize-indicator",
|
|
61
2891
|
style: { left: `${e}px` },
|
|
62
2892
|
onMouseEnter: () => a(!0),
|
|
63
2893
|
onMouseLeave: () => a(!1),
|
|
64
|
-
onMouseDown:
|
|
65
|
-
children:
|
|
2894
|
+
onMouseDown: p,
|
|
2895
|
+
children: f ? /* @__PURE__ */ u("div", { className: Qn.resizeIndicatorBar }) : null
|
|
66
2896
|
});
|
|
67
|
-
},
|
|
68
|
-
function
|
|
69
|
-
let e =
|
|
2897
|
+
}, er = Object.freeze({ source: "table" });
|
|
2898
|
+
function tr() {
|
|
2899
|
+
let e = S(null), t = S(void 0), n = S(/* @__PURE__ */ new Set()), r = S(!1), i = S(null), a = g(() => e.current, []), o = g((r) => (n.current.add(r), r(e.current, { source: t.current }), () => {
|
|
70
2900
|
n.current.delete(r);
|
|
71
|
-
}), []), s =
|
|
72
|
-
let r = t === "table" ?
|
|
2901
|
+
}), []), s = g((e, t) => {
|
|
2902
|
+
let r = t === "table" ? er : { source: t };
|
|
73
2903
|
n.current.forEach((t) => t(e, r));
|
|
74
|
-
}, []), c =
|
|
2904
|
+
}, []), c = g(() => {
|
|
75
2905
|
e.current !== null && (e.current = null, t.current = void 0, s(null, void 0));
|
|
76
|
-
}, [s]),
|
|
2906
|
+
}, [s]), l = g(() => {
|
|
77
2907
|
r.current || (r.current = !0, c()), i.current && clearTimeout(i.current), i.current = setTimeout(() => {
|
|
78
2908
|
r.current = !1, i.current = null;
|
|
79
2909
|
}, 150);
|
|
80
|
-
}, [c]),
|
|
2910
|
+
}, [c]), u = g((n, i) => {
|
|
81
2911
|
if (r.current) return;
|
|
82
2912
|
let a = i?.source;
|
|
83
|
-
|
|
84
|
-
}, [s]),
|
|
85
|
-
|
|
86
|
-
}, [
|
|
87
|
-
return
|
|
2913
|
+
se(e.current, n) && (a !== "table" || t.current === "table") || (e.current = n, t.current = a, s(n, a));
|
|
2914
|
+
}, [s]), d = g((e) => {
|
|
2915
|
+
u(e, er);
|
|
2916
|
+
}, [u]), f = g(() => r.current, []);
|
|
2917
|
+
return v(() => () => {
|
|
88
2918
|
i.current && clearTimeout(i.current);
|
|
89
2919
|
}, []), {
|
|
90
|
-
highlightContextValue:
|
|
2920
|
+
highlightContextValue: x(() => ({
|
|
91
2921
|
getHighlightTarget: a,
|
|
92
|
-
setHighlightTarget:
|
|
93
|
-
setTableHighlightTarget:
|
|
2922
|
+
setHighlightTarget: u,
|
|
2923
|
+
setTableHighlightTarget: d,
|
|
94
2924
|
subscribeHighlight: o,
|
|
95
|
-
notifyScrollActivity:
|
|
96
|
-
getIsScrollActive:
|
|
2925
|
+
notifyScrollActivity: l,
|
|
2926
|
+
getIsScrollActive: f
|
|
97
2927
|
}), [
|
|
98
2928
|
a,
|
|
2929
|
+
u,
|
|
99
2930
|
d,
|
|
100
|
-
f,
|
|
101
2931
|
o,
|
|
102
|
-
|
|
103
|
-
|
|
2932
|
+
l,
|
|
2933
|
+
f
|
|
104
2934
|
]),
|
|
105
|
-
setHighlightTarget:
|
|
106
|
-
setTableHighlightTarget:
|
|
107
|
-
notifyScrollActivity:
|
|
2935
|
+
setHighlightTarget: u,
|
|
2936
|
+
setTableHighlightTarget: d,
|
|
2937
|
+
notifyScrollActivity: l
|
|
108
2938
|
};
|
|
109
2939
|
}
|
|
110
2940
|
//#endregion
|
|
111
2941
|
//#region src/components/Gantt/utils/tableWidthStorage.ts
|
|
112
|
-
function
|
|
2942
|
+
function nr(e) {
|
|
113
2943
|
return `gantt_view_${e}`;
|
|
114
2944
|
}
|
|
115
|
-
function
|
|
2945
|
+
function rr(e) {
|
|
116
2946
|
if (!e) return null;
|
|
117
2947
|
try {
|
|
118
|
-
let t = localStorage.getItem(
|
|
2948
|
+
let t = localStorage.getItem(nr(e));
|
|
119
2949
|
if (t === null || t === "") return null;
|
|
120
2950
|
let n = parseInt(t, 10);
|
|
121
2951
|
return Number.isNaN(n) ? null : n;
|
|
@@ -123,64 +2953,64 @@ function I(e) {
|
|
|
123
2953
|
return null;
|
|
124
2954
|
}
|
|
125
2955
|
}
|
|
126
|
-
function
|
|
2956
|
+
function ir(e, t) {
|
|
127
2957
|
if (!(!e || !Number.isFinite(t))) try {
|
|
128
|
-
localStorage.setItem(
|
|
2958
|
+
localStorage.setItem(nr(e), String(Math.round(t)));
|
|
129
2959
|
} catch {}
|
|
130
2960
|
}
|
|
131
2961
|
//#endregion
|
|
132
2962
|
//#region src/components/Gantt/hooks/useGanttLayout.ts
|
|
133
|
-
var
|
|
2963
|
+
var ar = (e) => e > 0 ? e / 3 : 333, or = (e, t) => {
|
|
134
2964
|
if (!t) return e;
|
|
135
2965
|
let n = Math.max(200, t - 300);
|
|
136
2966
|
return Math.min(Math.max(e, 200), n);
|
|
137
2967
|
};
|
|
138
|
-
function
|
|
139
|
-
let t =
|
|
140
|
-
return
|
|
141
|
-
!o || a.current || (i(
|
|
142
|
-
}, [o, e]),
|
|
2968
|
+
function sr({ id: e } = {}) {
|
|
2969
|
+
let t = S(null), n = D(t), [r, i] = C(300), a = S(!1), o = n?.width || t.current?.offsetWidth || 0;
|
|
2970
|
+
return v(() => {
|
|
2971
|
+
!o || a.current || (i(or((e ? rr(e) : null) ?? ar(o), o)), a.current = !0);
|
|
2972
|
+
}, [o, e]), v(() => {
|
|
143
2973
|
a.current = !1;
|
|
144
2974
|
}, [e]), {
|
|
145
2975
|
containerRef: t,
|
|
146
|
-
resolvedTableWidth:
|
|
147
|
-
handleTableWidthChange:
|
|
2976
|
+
resolvedTableWidth: x(() => o ? or(r, o) : r, [o, r]),
|
|
2977
|
+
handleTableWidthChange: g((e) => {
|
|
148
2978
|
i(e);
|
|
149
2979
|
}, []),
|
|
150
|
-
handleResizeEnd:
|
|
151
|
-
e &&
|
|
2980
|
+
handleResizeEnd: g((t) => {
|
|
2981
|
+
e && ir(e, o ? or(t, o) : t);
|
|
152
2982
|
}, [e, o])
|
|
153
2983
|
};
|
|
154
2984
|
}
|
|
155
2985
|
//#endregion
|
|
156
2986
|
//#region src/components/Gantt/hooks/useGanttCollapseState.ts
|
|
157
|
-
function
|
|
158
|
-
let [n, r] =
|
|
2987
|
+
function cr({ collapsedKeys: e, onToggleCollapse: t } = {}) {
|
|
2988
|
+
let [n, r] = C(() => /* @__PURE__ */ new Set()), i = e !== void 0;
|
|
159
2989
|
return {
|
|
160
2990
|
collapsedKeys: i ? e : n,
|
|
161
|
-
onToggleCollapse:
|
|
162
|
-
e && (t?.(e), i || r((t) =>
|
|
2991
|
+
onToggleCollapse: g((e) => {
|
|
2992
|
+
e && (t?.(e), i || r((t) => Ln(t, e)));
|
|
163
2993
|
}, [i, t]),
|
|
164
2994
|
isControlled: i
|
|
165
2995
|
};
|
|
166
2996
|
}
|
|
167
2997
|
//#endregion
|
|
168
2998
|
//#region src/components/Gantt/hooks/useLinkedVerticalScroll.ts
|
|
169
|
-
function
|
|
170
|
-
let { onScrollActivity: t } = e, n =
|
|
2999
|
+
function lr(e = {}) {
|
|
3000
|
+
let { onScrollActivity: t } = e, n = S(t);
|
|
171
3001
|
n.current = t;
|
|
172
|
-
let r =
|
|
3002
|
+
let r = S(null), i = S(null), a = S(null), o = g((e) => (i.current = e, () => {
|
|
173
3003
|
i.current = null;
|
|
174
|
-
}), []), s =
|
|
3004
|
+
}), []), s = g((e) => (a.current = e, () => {
|
|
175
3005
|
a.current = null;
|
|
176
|
-
}), []), c =
|
|
3006
|
+
}), []), c = g((e, t) => {
|
|
177
3007
|
if (r.current === e) return;
|
|
178
3008
|
let o = e === "timeline" ? "table" : "timeline", s = o === "timeline" ? i.current : a.current;
|
|
179
3009
|
s?.setScrollTop && (r.current = o, s.setScrollTop(t), n.current?.(), requestAnimationFrame(() => {
|
|
180
3010
|
r.current === o && (r.current = null);
|
|
181
3011
|
}));
|
|
182
3012
|
}, []);
|
|
183
|
-
return
|
|
3013
|
+
return x(() => ({
|
|
184
3014
|
registerTimelineScroller: o,
|
|
185
3015
|
registerTableScroller: s,
|
|
186
3016
|
sync: c
|
|
@@ -192,7 +3022,7 @@ function H(e = {}) {
|
|
|
192
3022
|
}
|
|
193
3023
|
//#endregion
|
|
194
3024
|
//#region src/components/Gantt/utils/filterItemsByCollapse.ts
|
|
195
|
-
function
|
|
3025
|
+
function ur(e, t) {
|
|
196
3026
|
if (!Array.isArray(e) || e.length === 0) return e || [];
|
|
197
3027
|
if (!t || !(t instanceof Set ? t.size > 0 : Array.isArray(t) && t.length > 0)) return e;
|
|
198
3028
|
let n = [], r = null;
|
|
@@ -200,7 +3030,7 @@ function U(e, t) {
|
|
|
200
3030
|
if (i?.type === "summary") {
|
|
201
3031
|
let e = i.depth ?? 0;
|
|
202
3032
|
if (r !== null && e > r) continue;
|
|
203
|
-
r !== null && e <= r && (r = null), n.push(i),
|
|
3033
|
+
r !== null && e <= r && (r = null), n.push(i), In(t, i.groupKey) && (r = e);
|
|
204
3034
|
continue;
|
|
205
3035
|
}
|
|
206
3036
|
r === null && n.push(i);
|
|
@@ -208,14 +3038,42 @@ function U(e, t) {
|
|
|
208
3038
|
return n;
|
|
209
3039
|
}
|
|
210
3040
|
//#endregion
|
|
3041
|
+
//#region src/components/Gantt/utils/theme/resolveGanttTheme.ts
|
|
3042
|
+
var dr = "#0265ff", fr = "#121111", pr = "#fff", mr = (e) => {
|
|
3043
|
+
if (!e) return;
|
|
3044
|
+
let t = e.colorPrimary ?? dr, n = te(t), r = (e) => n.isValid() ? n.clone().setAlpha(e).toRgbString() : void 0, i = { ...e };
|
|
3045
|
+
i.todayLineColor === void 0 && (i.todayLineColor = r(.2)), i.toolbarTodayHoverBg === void 0 && (i.toolbarTodayHoverBg = r(.1));
|
|
3046
|
+
let a = e.colorText ?? fr, o = {
|
|
3047
|
+
colorBgContainer: e.toolbarBg ?? e.colorBgContainer ?? pr,
|
|
3048
|
+
colorText: a,
|
|
3049
|
+
itemActiveBg: t,
|
|
3050
|
+
itemActiveColor: a,
|
|
3051
|
+
itemHoverBg: r(.3)
|
|
3052
|
+
};
|
|
3053
|
+
return i.dropdownTheme = e.dropdownTheme === void 0 ? o : {
|
|
3054
|
+
...o,
|
|
3055
|
+
...e.dropdownTheme
|
|
3056
|
+
}, i;
|
|
3057
|
+
}, hr = (e) => {
|
|
3058
|
+
let t = {};
|
|
3059
|
+
return n(t, "--bsy-gantt-color-text", e.colorText), n(t, "--bsy-gantt-color-text-secondary", e.colorTextSecondary), n(t, "--bsy-gantt-color-split", e.colorSplit), n(t, "--bsy-gantt-color-border", e.colorBorder), n(t, "--bsy-gantt-color-primary", e.colorPrimary), n(t, "--bsy-gantt-color-bg-container", e.colorBgContainer), n(t, "--bsy-gantt-color-bg-weekend", e.colorBgWeekend), n(t, "--bsy-gantt-color-bg-row-hover", e.colorBgRowHover), n(t, "--bsy-gantt-color-today-line", e.todayLineColor), n(t, "--bsy-gantt-toolbar-today-hover-bg", e.toolbarTodayHoverBg), n(t, "--bsy-gantt-toolbar-icon-color", e.toolbarIconColor), n(t, "--bsy-gantt-toolbar-icon-hover-color", e.toolbarIconHoverColor), n(t, "--bsy-gantt-arrow-bg", e.arrowBg), n(t, "--bsy-gantt-toolbar-bg", e.toolbarBg), t;
|
|
3060
|
+
}, gr = (e) => {
|
|
3061
|
+
let t = mr(e);
|
|
3062
|
+
return t ? hr(t) : {};
|
|
3063
|
+
}, _r = (e) => e.colorBorder !== void 0 || e.colorBgContainer !== void 0 || e.colorText !== void 0 || e.colorBgRowHover !== void 0, vr = (e) => {
|
|
3064
|
+
if (!e || !_r(e)) return;
|
|
3065
|
+
let t = {};
|
|
3066
|
+
return e.colorBorder !== void 0 && (t.colorBorder = e.colorBorder), e.colorBgContainer !== void 0 && (t.colorBgContainer = e.colorBgContainer, t.colorBgHeader = e.colorBgContainer), e.colorText !== void 0 && (t.colorText = e.colorText, t.colorTextHeading = e.colorText), e.colorBgRowHover !== void 0 && (t.colorBgRowHover = e.colorBgRowHover), t;
|
|
3067
|
+
};
|
|
3068
|
+
//#endregion
|
|
211
3069
|
//#region src/components/Gantt/GanttTable/hooks/useGanttTableHighlightDomSync.ts
|
|
212
|
-
function
|
|
213
|
-
let t =
|
|
3070
|
+
function yr(e) {
|
|
3071
|
+
let t = A(oe, (e) => e.getHighlightTarget), n = A(oe, (e) => e.subscribeHighlight), r = S(null), i = g((e, t) => {
|
|
214
3072
|
if (!e || !t?.id || !t?.type) return [];
|
|
215
3073
|
let n = CSS.escape(String(t.id)), r = CSS.escape(String(t.type));
|
|
216
3074
|
return Array.from(e.querySelectorAll(`[data-highlight-id="${n}"][data-highlight-type="${r}"]`));
|
|
217
|
-
}, []), a =
|
|
218
|
-
if (
|
|
3075
|
+
}, []), a = g((t, n) => {
|
|
3076
|
+
if (se(t, n)) return;
|
|
219
3077
|
let r = e.current;
|
|
220
3078
|
r && (t?.id && i(r, t).forEach((e) => {
|
|
221
3079
|
e.classList.remove("table-row-hover");
|
|
@@ -223,7 +3081,7 @@ function W(e) {
|
|
|
223
3081
|
e.classList.add("table-row-hover");
|
|
224
3082
|
}));
|
|
225
3083
|
}, [i, e]);
|
|
226
|
-
|
|
3084
|
+
v(() => {
|
|
227
3085
|
let e = t?.() || null;
|
|
228
3086
|
return r.current = e, a(null, e), n?.((e) => {
|
|
229
3087
|
let t = r.current;
|
|
@@ -237,8 +3095,8 @@ function W(e) {
|
|
|
237
3095
|
}
|
|
238
3096
|
//#endregion
|
|
239
3097
|
//#region src/components/Gantt/GanttTable/hooks/useGanttTableLinkedScroll.ts
|
|
240
|
-
function
|
|
241
|
-
|
|
3098
|
+
function br({ tableRef: e, verticalScrollController: t, dataLength: n }) {
|
|
3099
|
+
v(() => {
|
|
242
3100
|
if (!t || !e.current) return;
|
|
243
3101
|
let n = e.current.querySelector(".custom-table-wrapper");
|
|
244
3102
|
if (n) return t.registerTableScroller({ setScrollTop: (e) => {
|
|
@@ -248,7 +3106,7 @@ function G({ tableRef: e, verticalScrollController: t, dataLength: n }) {
|
|
|
248
3106
|
t,
|
|
249
3107
|
n,
|
|
250
3108
|
e
|
|
251
|
-
]),
|
|
3109
|
+
]), E("scroll", () => {
|
|
252
3110
|
let n = e.current?.querySelector(".custom-table-wrapper");
|
|
253
3111
|
n && t && t.sync("table", n.scrollTop);
|
|
254
3112
|
}, {
|
|
@@ -256,125 +3114,125 @@ function G({ tableRef: e, verticalScrollController: t, dataLength: n }) {
|
|
|
256
3114
|
passive: !0
|
|
257
3115
|
});
|
|
258
3116
|
}
|
|
259
|
-
var
|
|
3117
|
+
var xr = {
|
|
260
3118
|
root: "_root_1rdh6_1",
|
|
261
3119
|
emptyOverlay: "_emptyOverlay_1rdh6_25",
|
|
262
3120
|
emptyOverlayInner: "_emptyOverlayInner_1rdh6_37"
|
|
263
|
-
},
|
|
264
|
-
let o =
|
|
3121
|
+
}, Sr = m(function({ width: e, verticalScrollController: t, dataLength: n = 0, emptyOverlay: r = null, children: i }, a) {
|
|
3122
|
+
let o = S(null), s = g((e) => {
|
|
265
3123
|
o.current = e, typeof a == "function" ? a(e) : a && (a.current = e);
|
|
266
3124
|
}, [a]);
|
|
267
|
-
return
|
|
3125
|
+
return yr(o), br({
|
|
268
3126
|
tableRef: o,
|
|
269
3127
|
verticalScrollController: t,
|
|
270
3128
|
dataLength: n
|
|
271
|
-
}), /* @__PURE__ */
|
|
3129
|
+
}), /* @__PURE__ */ d("div", {
|
|
272
3130
|
ref: s,
|
|
273
|
-
className:
|
|
3131
|
+
className: xr.root,
|
|
274
3132
|
"data-testid": "gantt-table",
|
|
275
3133
|
style: { width: e ? `${e}px` : void 0 },
|
|
276
|
-
children: [i, r ? /* @__PURE__ */
|
|
277
|
-
className:
|
|
3134
|
+
children: [i, r ? /* @__PURE__ */ u("div", {
|
|
3135
|
+
className: xr.emptyOverlay,
|
|
278
3136
|
style: { top: 68 },
|
|
279
|
-
children: /* @__PURE__ */
|
|
280
|
-
className:
|
|
3137
|
+
children: /* @__PURE__ */ u("div", {
|
|
3138
|
+
className: xr.emptyOverlayInner,
|
|
281
3139
|
children: r
|
|
282
3140
|
})
|
|
283
3141
|
}) : null]
|
|
284
3142
|
});
|
|
285
3143
|
});
|
|
286
|
-
|
|
3144
|
+
Sr.displayName = "GanttTableShell";
|
|
287
3145
|
//#endregion
|
|
288
3146
|
//#region src/components/Gantt/internal/GanttLayout.tsx
|
|
289
|
-
function
|
|
290
|
-
let { highlightContextValue:
|
|
291
|
-
r === void 0 &&
|
|
292
|
-
}, [r, a]), { collapsedKeys:
|
|
3147
|
+
function Cr({ data: e = [], tableData: t, columns: n, mode: r, availableModes: i, onModeChange: a, id: o, onRowClick: s, onTaskTimeChange: c, tooltip: l, className: f, style: p, renderTable: m, collapsedKeys: h, onToggleCollapse: _, emptyOverlay: v = null, theme: y }, b) {
|
|
3148
|
+
let { highlightContextValue: S, setTableHighlightTarget: T, notifyScrollActivity: E } = tr(), D = lr({ onScrollActivity: E }), [O, ee] = C("day"), te = r ?? O, { containerRef: k, resolvedTableWidth: A, handleTableWidthChange: j, handleResizeEnd: M } = sr({ id: o }), N = g((e) => {
|
|
3149
|
+
r === void 0 && ee(e), a?.(e);
|
|
3150
|
+
}, [r, a]), { collapsedKeys: P, onToggleCollapse: F, isControlled: I } = cr({
|
|
293
3151
|
collapsedKeys: h,
|
|
294
|
-
onToggleCollapse:
|
|
295
|
-
}),
|
|
3152
|
+
onToggleCollapse: _
|
|
3153
|
+
}), L = x(() => I ? e : ur(e, P), [
|
|
296
3154
|
e,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
]),
|
|
300
|
-
|
|
3155
|
+
I,
|
|
3156
|
+
P
|
|
3157
|
+
]), R = typeof m == "function", ne = x(() => R ? t ?? [] : L, [
|
|
3158
|
+
R,
|
|
301
3159
|
t,
|
|
302
|
-
|
|
303
|
-
]),
|
|
304
|
-
let e = y
|
|
3160
|
+
L
|
|
3161
|
+
]), re = ne.length, { resolvedTheme: z, themeStyle: B, tableTheme: ie } = x(() => {
|
|
3162
|
+
let e = mr(y);
|
|
305
3163
|
return {
|
|
306
3164
|
resolvedTheme: e,
|
|
307
|
-
themeStyle: e ?
|
|
308
|
-
tableTheme:
|
|
3165
|
+
themeStyle: e ? hr(e) : {},
|
|
3166
|
+
tableTheme: vr(e)
|
|
309
3167
|
};
|
|
310
|
-
}, [
|
|
3168
|
+
}, [y]), V = x(() => R ? m({
|
|
311
3169
|
columns: n,
|
|
312
|
-
tableData:
|
|
313
|
-
setHighlightTarget:
|
|
3170
|
+
tableData: ne,
|
|
3171
|
+
setHighlightTarget: T,
|
|
314
3172
|
rowHeight: 34,
|
|
315
|
-
collapsedKeys:
|
|
316
|
-
onToggleCollapse:
|
|
317
|
-
tableTheme:
|
|
318
|
-
}) : /* @__PURE__ */
|
|
319
|
-
data:
|
|
3173
|
+
collapsedKeys: P ?? void 0,
|
|
3174
|
+
onToggleCollapse: F,
|
|
3175
|
+
tableTheme: ie
|
|
3176
|
+
}) : /* @__PURE__ */ u(le, {
|
|
3177
|
+
data: L,
|
|
320
3178
|
columns: n,
|
|
321
|
-
onRowClick:
|
|
3179
|
+
onRowClick: s,
|
|
322
3180
|
rowHeight: 34,
|
|
323
|
-
tableTheme:
|
|
3181
|
+
tableTheme: ie
|
|
324
3182
|
}), [
|
|
325
|
-
|
|
3183
|
+
R,
|
|
326
3184
|
m,
|
|
327
3185
|
n,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
]),
|
|
336
|
-
...
|
|
3186
|
+
ne,
|
|
3187
|
+
T,
|
|
3188
|
+
P,
|
|
3189
|
+
F,
|
|
3190
|
+
ie,
|
|
3191
|
+
L,
|
|
3192
|
+
s
|
|
3193
|
+
]), H = x(() => ({
|
|
3194
|
+
...B,
|
|
337
3195
|
...p
|
|
338
|
-
}), [
|
|
339
|
-
return /* @__PURE__ */
|
|
340
|
-
value:
|
|
341
|
-
children: /* @__PURE__ */
|
|
342
|
-
value:
|
|
343
|
-
children: /* @__PURE__ */
|
|
344
|
-
className:
|
|
3196
|
+
}), [B, p]);
|
|
3197
|
+
return /* @__PURE__ */ u(rn, {
|
|
3198
|
+
value: z,
|
|
3199
|
+
children: /* @__PURE__ */ u(oe.Provider, {
|
|
3200
|
+
value: S,
|
|
3201
|
+
children: /* @__PURE__ */ u("div", {
|
|
3202
|
+
className: w(Qn.root, f),
|
|
345
3203
|
"data-testid": "gantt-root",
|
|
346
|
-
style:
|
|
347
|
-
children: /* @__PURE__ */
|
|
348
|
-
ref:
|
|
349
|
-
className:
|
|
3204
|
+
style: H,
|
|
3205
|
+
children: /* @__PURE__ */ d("div", {
|
|
3206
|
+
ref: k,
|
|
3207
|
+
className: Qn.body,
|
|
350
3208
|
children: [
|
|
351
|
-
/* @__PURE__ */
|
|
352
|
-
ref:
|
|
353
|
-
width:
|
|
354
|
-
verticalScrollController:
|
|
355
|
-
dataLength:
|
|
356
|
-
emptyOverlay:
|
|
357
|
-
children:
|
|
3209
|
+
/* @__PURE__ */ u(Sr, {
|
|
3210
|
+
ref: b,
|
|
3211
|
+
width: A,
|
|
3212
|
+
verticalScrollController: D,
|
|
3213
|
+
dataLength: re,
|
|
3214
|
+
emptyOverlay: v,
|
|
3215
|
+
children: V
|
|
358
3216
|
}),
|
|
359
|
-
/* @__PURE__ */
|
|
360
|
-
tableWidth:
|
|
361
|
-
onWidthChange:
|
|
362
|
-
onResizeEnd:
|
|
363
|
-
containerRef:
|
|
3217
|
+
/* @__PURE__ */ u($n, {
|
|
3218
|
+
tableWidth: A,
|
|
3219
|
+
onWidthChange: j,
|
|
3220
|
+
onResizeEnd: M,
|
|
3221
|
+
containerRef: k
|
|
364
3222
|
}),
|
|
365
|
-
/* @__PURE__ */
|
|
366
|
-
className:
|
|
367
|
-
children: /* @__PURE__ */
|
|
368
|
-
items:
|
|
369
|
-
viewMode:
|
|
3223
|
+
/* @__PURE__ */ u("div", {
|
|
3224
|
+
className: Qn.chartSlot,
|
|
3225
|
+
children: /* @__PURE__ */ u(Zn, {
|
|
3226
|
+
items: L,
|
|
3227
|
+
viewMode: te,
|
|
370
3228
|
availableModes: i,
|
|
371
|
-
onViewModeChange:
|
|
372
|
-
verticalScrollController:
|
|
373
|
-
onRowClick:
|
|
374
|
-
onTaskTimeChange:
|
|
375
|
-
tooltip:
|
|
376
|
-
collapsedKeys:
|
|
377
|
-
onToggleCollapse:
|
|
3229
|
+
onViewModeChange: N,
|
|
3230
|
+
verticalScrollController: D,
|
|
3231
|
+
onRowClick: s,
|
|
3232
|
+
onTaskTimeChange: c,
|
|
3233
|
+
tooltip: l,
|
|
3234
|
+
collapsedKeys: P,
|
|
3235
|
+
onToggleCollapse: F
|
|
378
3236
|
})
|
|
379
3237
|
})
|
|
380
3238
|
]
|
|
@@ -383,12 +3241,12 @@ function J({ data: e = [], tableData: t, columns: n, mode: r, availableModes: i,
|
|
|
383
3241
|
})
|
|
384
3242
|
});
|
|
385
3243
|
}
|
|
386
|
-
var
|
|
3244
|
+
var wr = m(Cr);
|
|
387
3245
|
//#endregion
|
|
388
3246
|
//#region src/components/Gantt/Gantt.tsx
|
|
389
|
-
function
|
|
390
|
-
return /* @__PURE__ */
|
|
391
|
-
ref:
|
|
3247
|
+
function Tr({ data: e, columns: t, mode: n, availableModes: r, onModeChange: i, id: a, onRowClick: o, onTaskTimeChange: s, tooltip: c, className: l, style: d, tableData: f, renderTable: p, collapsedKeys: m, onToggleCollapse: h, emptyOverlay: g, theme: _ }, v) {
|
|
3248
|
+
return /* @__PURE__ */ u(wr, {
|
|
3249
|
+
ref: v,
|
|
392
3250
|
data: e,
|
|
393
3251
|
columns: t,
|
|
394
3252
|
mode: n,
|
|
@@ -399,15 +3257,15 @@ function X({ data: e, columns: t, mode: n, availableModes: r, onModeChange: i, i
|
|
|
399
3257
|
onTaskTimeChange: s,
|
|
400
3258
|
tooltip: c,
|
|
401
3259
|
className: l,
|
|
402
|
-
style:
|
|
403
|
-
tableData:
|
|
404
|
-
renderTable:
|
|
405
|
-
collapsedKeys:
|
|
406
|
-
onToggleCollapse:
|
|
407
|
-
emptyOverlay:
|
|
408
|
-
theme:
|
|
3260
|
+
style: d,
|
|
3261
|
+
tableData: f,
|
|
3262
|
+
renderTable: p,
|
|
3263
|
+
collapsedKeys: m,
|
|
3264
|
+
onToggleCollapse: h,
|
|
3265
|
+
emptyOverlay: g,
|
|
3266
|
+
theme: _
|
|
409
3267
|
});
|
|
410
3268
|
}
|
|
411
|
-
var
|
|
3269
|
+
var Er = m(Tr);
|
|
412
3270
|
//#endregion
|
|
413
|
-
export {
|
|
3271
|
+
export { fe as ALL_GANTT_MODES, ue as CALENDAR_TIER_MODES, me as DEFAULT_GANTT_MODE, ne as DRAG_MODE_MOVE, z as DRAG_MODE_RESIZE_END, re as DRAG_MODE_RESIZE_START, ie as EMPTY_GROUP_VALUE, I as GANTT_DEFAULT_ROW_HEIGHT, L as GANTT_TABLE_HEADER_ROW_SPAN, Er as default, In as isGroupCollapsed, ce as isHighlightMatch, Ke as isSubDayViewMode, Zt as normalizeTaskDateRange, mr as resolveGanttTheme, gr as resolveGanttThemeVars, vr as resolveTableThemeFromGantt, J as useGanttTableColumnResize };
|