mantine-gantt 0.6.1 → 0.8.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/README.md +43 -166
- package/dist/cjs/Gantt/DependencyLinks.cjs +25 -8
- package/dist/cjs/Gantt/DependencyLinks.cjs.map +1 -1
- package/dist/cjs/Gantt/Gantt.cjs +139 -64
- package/dist/cjs/Gantt/Gantt.cjs.map +1 -1
- package/dist/cjs/Gantt/TaskBar.cjs +19 -23
- package/dist/cjs/Gantt/TaskBar.cjs.map +1 -1
- package/dist/cjs/Gantt/TaskList.cjs +17 -14
- package/dist/cjs/Gantt/TaskList.cjs.map +1 -1
- package/dist/cjs/Gantt/TimelineGrid.cjs +9 -6
- package/dist/cjs/Gantt/TimelineGrid.cjs.map +1 -1
- package/dist/cjs/Gantt/TimelineHeader.cjs +21 -13
- package/dist/cjs/Gantt/TimelineHeader.cjs.map +1 -1
- package/dist/cjs/Gantt/labels.cjs +36 -0
- package/dist/cjs/Gantt/labels.cjs.map +1 -0
- package/dist/cjs/Gantt/use-gantt-drag.cjs +27 -23
- package/dist/cjs/Gantt/use-gantt-drag.cjs.map +1 -1
- package/dist/cjs/Gantt/utils.cjs +72 -29
- package/dist/cjs/Gantt/utils.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/Gantt/DependencyLinks.mjs +26 -9
- package/dist/esm/Gantt/DependencyLinks.mjs.map +1 -1
- package/dist/esm/Gantt/Gantt.mjs +141 -66
- package/dist/esm/Gantt/Gantt.mjs.map +1 -1
- package/dist/esm/Gantt/TaskBar.mjs +20 -24
- package/dist/esm/Gantt/TaskBar.mjs.map +1 -1
- package/dist/esm/Gantt/TaskList.mjs +17 -14
- package/dist/esm/Gantt/TaskList.mjs.map +1 -1
- package/dist/esm/Gantt/TimelineGrid.mjs +9 -6
- package/dist/esm/Gantt/TimelineGrid.mjs.map +1 -1
- package/dist/esm/Gantt/TimelineHeader.mjs +21 -13
- package/dist/esm/Gantt/TimelineHeader.mjs.map +1 -1
- package/dist/esm/Gantt/labels.mjs +34 -0
- package/dist/esm/Gantt/labels.mjs.map +1 -0
- package/dist/esm/Gantt/use-gantt-drag.mjs +27 -23
- package/dist/esm/Gantt/use-gantt-drag.mjs.map +1 -1
- package/dist/esm/Gantt/utils.mjs +72 -30
- package/dist/esm/Gantt/utils.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/styles.css +2 -2
- package/dist/styles.layer.css +2 -2
- package/dist/types/Gantt/DependencyLinks.d.ts +6 -6
- package/dist/types/Gantt/TaskBar.d.ts +5 -2
- package/dist/types/Gantt/TaskList.d.ts +5 -5
- package/dist/types/Gantt/TimelineGrid.d.ts +5 -4
- package/dist/types/Gantt/TimelineHeader.d.ts +10 -6
- package/dist/types/Gantt/index.d.ts +2 -2
- package/dist/types/Gantt/labels.d.ts +2 -0
- package/dist/types/Gantt/types.d.ts +45 -2
- package/dist/types/Gantt/use-gantt-drag.d.ts +2 -1
- package/dist/types/Gantt/utils.d.ts +13 -5
- package/dist/types/index.d.mts +1 -3
- package/dist/types/index.d.ts +1 -3
- package/package.json +5 -6
package/dist/cjs/Gantt/Gantt.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var core = require('@mantine/core');
|
|
7
7
|
var hooks = require('@mantine/hooks');
|
|
8
8
|
var DependencyLinks = require('./DependencyLinks.cjs');
|
|
9
|
+
var labels = require('./labels.cjs');
|
|
9
10
|
var TaskBar = require('./TaskBar.cjs');
|
|
10
11
|
var TaskList = require('./TaskList.cjs');
|
|
11
12
|
var TimelineGrid = require('./TimelineGrid.cjs');
|
|
@@ -15,7 +16,11 @@ var utils = require('./utils.cjs');
|
|
|
15
16
|
var Gantt_module = require('./Gantt.module.css.cjs');
|
|
16
17
|
|
|
17
18
|
const DRAG_BUFFER_DAYS = 30;
|
|
19
|
+
const PAN_CAPTURE_DISTANCE = 3;
|
|
18
20
|
const MIN_TIMELINE_WIDTH = 240;
|
|
21
|
+
const UNMEASURED_VIEWPORT_HEIGHT = 1200;
|
|
22
|
+
const SCROLL_LEFT_STEP = 200;
|
|
23
|
+
const DAY_OVERSCAN_PX = 400;
|
|
19
24
|
const EMPTY_CRITICAL = /* @__PURE__ */ new Set();
|
|
20
25
|
const FLEX_COLUMN_WIDTH = 200;
|
|
21
26
|
const FLEX_COLUMN_MIN_WIDTH = 100;
|
|
@@ -37,12 +42,15 @@ const defaultProps = {
|
|
|
37
42
|
criticalPathColor: "red",
|
|
38
43
|
showBaselines: true,
|
|
39
44
|
autoSchedule: false,
|
|
40
|
-
showDragLabel: true
|
|
45
|
+
showDragLabel: true,
|
|
46
|
+
withLinkDelete: true
|
|
41
47
|
};
|
|
42
48
|
const varsResolver = core.createVarsResolver(
|
|
43
49
|
(theme, { columnWidth, rowHeight, taskListWidth, columns, criticalPathColor }) => ({
|
|
44
50
|
root: {
|
|
45
|
-
|
|
51
|
+
// Same ≥1px floor as effectiveColumnWidth: the day header cells and the day-line mask
|
|
52
|
+
// size themselves from this variable.
|
|
53
|
+
"--gantt-column-width": `${Math.max(columnWidth ?? 40, 1)}px`,
|
|
46
54
|
"--gantt-row-height": `${rowHeight}px`,
|
|
47
55
|
"--gantt-header-height": "50px",
|
|
48
56
|
"--gantt-task-list-width": `${resolveTaskListWidth(taskListWidth, columns)}px`,
|
|
@@ -50,7 +58,7 @@ const varsResolver = core.createVarsResolver(
|
|
|
50
58
|
}
|
|
51
59
|
})
|
|
52
60
|
);
|
|
53
|
-
const Gantt = core.factory((_props
|
|
61
|
+
const Gantt = core.factory((_props) => {
|
|
54
62
|
const props = core.useProps("Gantt", defaultProps, _props);
|
|
55
63
|
const theme = core.useMantineTheme();
|
|
56
64
|
const {
|
|
@@ -69,6 +77,7 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
69
77
|
onTaskClick,
|
|
70
78
|
onLinkCreate,
|
|
71
79
|
onLinkDelete,
|
|
80
|
+
withLinkDelete,
|
|
72
81
|
columnWidth = 40,
|
|
73
82
|
rowHeight = 44,
|
|
74
83
|
taskListWidth,
|
|
@@ -83,6 +92,7 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
83
92
|
viewMode = "day",
|
|
84
93
|
weekStart = 1,
|
|
85
94
|
locale = "en",
|
|
95
|
+
labels: labelsProp,
|
|
86
96
|
highlightCriticalPath,
|
|
87
97
|
criticalPathColor,
|
|
88
98
|
showBaselines,
|
|
@@ -96,6 +106,7 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
96
106
|
workingDays,
|
|
97
107
|
onColumnWidthChange,
|
|
98
108
|
showDragLabel,
|
|
109
|
+
ref,
|
|
99
110
|
...others
|
|
100
111
|
} = props;
|
|
101
112
|
const [zoomWidth, setZoomWidth] = React.useState(null);
|
|
@@ -114,6 +125,12 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
114
125
|
attributes,
|
|
115
126
|
varsResolver
|
|
116
127
|
});
|
|
128
|
+
const getStylesRef = React.useRef(getStyles);
|
|
129
|
+
getStylesRef.current = getStyles;
|
|
130
|
+
const stableGetStyles = React.useCallback(
|
|
131
|
+
(...args) => getStylesRef.current(...args),
|
|
132
|
+
[classNames, styles, unstyled, vars, attributes, theme]
|
|
133
|
+
);
|
|
117
134
|
const effectiveColumnWidth = React.useMemo(() => {
|
|
118
135
|
switch (viewMode) {
|
|
119
136
|
case "month":
|
|
@@ -127,13 +144,15 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
127
144
|
return Math.max(baseColumnWidth, 1);
|
|
128
145
|
}
|
|
129
146
|
}, [viewMode, baseColumnWidth]);
|
|
147
|
+
const labels$1 = React.useMemo(() => ({ ...labels.defaultLabels, ...labelsProp }), [labelsProp]);
|
|
130
148
|
const calendar = workingDays ? isNonWorkingDay ?? utils.isWeekend : void 0;
|
|
131
|
-
const [tasks,
|
|
149
|
+
const [tasks, setTasksUnstable] = hooks.useUncontrolled({
|
|
132
150
|
value: tasksProp,
|
|
133
151
|
defaultValue: defaultTasks,
|
|
134
152
|
finalValue: [],
|
|
135
153
|
onChange: onTasksChange
|
|
136
154
|
});
|
|
155
|
+
const setTasks = hooks.useCallbackRef(setTasksUnstable);
|
|
137
156
|
const [collapsedIds, setCollapsedIds] = React.useState(() => {
|
|
138
157
|
if (!defaultExpandedIds) {
|
|
139
158
|
return /* @__PURE__ */ new Set();
|
|
@@ -169,13 +188,19 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
169
188
|
const [announcement, setAnnouncement] = React.useState("");
|
|
170
189
|
const [viewport, setViewport] = React.useState({ width: 0, height: 0 });
|
|
171
190
|
const [scrollTop, setScrollTop] = React.useState(0);
|
|
191
|
+
const [scrollLeft, setScrollLeft] = React.useState(0);
|
|
172
192
|
const [narrow, setNarrow] = React.useState(false);
|
|
173
|
-
const [collapsedChoice,
|
|
193
|
+
const [collapsedChoice, setCollapsedChoiceUnstable] = hooks.useUncontrolled({
|
|
174
194
|
value: taskListCollapsed,
|
|
175
195
|
defaultValue: defaultTaskListCollapsed,
|
|
176
196
|
onChange: onTaskListCollapsedChange
|
|
177
197
|
});
|
|
198
|
+
const setCollapsedChoice = hooks.useCallbackRef(setCollapsedChoiceUnstable);
|
|
178
199
|
const listCollapsed = collapsedChoice ?? narrow;
|
|
200
|
+
const toggleListCollapsed = React.useCallback(
|
|
201
|
+
() => setCollapsedChoice(!listCollapsed),
|
|
202
|
+
[listCollapsed, setCollapsedChoice]
|
|
203
|
+
);
|
|
179
204
|
const listWidth = resolveTaskListWidth(taskListWidth, columns);
|
|
180
205
|
const timelineBodyRef = React.useRef(null);
|
|
181
206
|
const taskListBodyRef = React.useRef(null);
|
|
@@ -193,7 +218,8 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
193
218
|
onLinkCreate,
|
|
194
219
|
autoSchedule,
|
|
195
220
|
isNonWorkingDay: calendar,
|
|
196
|
-
announce: setAnnouncement
|
|
221
|
+
announce: setAnnouncement,
|
|
222
|
+
labels: labels$1
|
|
197
223
|
});
|
|
198
224
|
const active = drag.state;
|
|
199
225
|
const handleLinkDelete = React.useCallback(
|
|
@@ -235,10 +261,27 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
235
261
|
}, [calculatedBounds, active, tasks, effectiveColumnWidth, calendar]);
|
|
236
262
|
const fillDays = effectiveColumnWidth > 0 ? Math.ceil(viewport.width / effectiveColumnWidth) : 0;
|
|
237
263
|
const totalDays = Math.max(bounds.end.diff(bounds.start, "day") + 1, fillDays);
|
|
238
|
-
const displayEnd =
|
|
264
|
+
const displayEnd = React.useMemo(
|
|
265
|
+
() => bounds.start.add(totalDays - 1, "day"),
|
|
266
|
+
[bounds.start, totalDays]
|
|
267
|
+
);
|
|
239
268
|
const timelineWidth = totalDays * effectiveColumnWidth;
|
|
240
|
-
const [
|
|
241
|
-
|
|
269
|
+
const [firstDay, lastDay] = viewMode === "day" && viewport.width > 0 ? [
|
|
270
|
+
Math.max(0, Math.floor((scrollLeft - DAY_OVERSCAN_PX) / effectiveColumnWidth)),
|
|
271
|
+
Math.min(
|
|
272
|
+
totalDays,
|
|
273
|
+
Math.ceil(
|
|
274
|
+
(scrollLeft + SCROLL_LEFT_STEP + viewport.width + DAY_OVERSCAN_PX) / effectiveColumnWidth
|
|
275
|
+
)
|
|
276
|
+
)
|
|
277
|
+
] : [0, totalDays];
|
|
278
|
+
const [firstRow, lastRow] = utils.visibleRowRange(
|
|
279
|
+
scrollTop,
|
|
280
|
+
viewport.height || UNMEASURED_VIEWPORT_HEIGHT,
|
|
281
|
+
rowHeight,
|
|
282
|
+
rows.length
|
|
283
|
+
);
|
|
284
|
+
const visibleRows = React.useMemo(() => rows.slice(firstRow, lastRow), [rows, firstRow, lastRow]);
|
|
242
285
|
const handleTimelineScroll = React.useCallback(() => {
|
|
243
286
|
const body = timelineBodyRef.current;
|
|
244
287
|
if (!body) {
|
|
@@ -250,14 +293,15 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
250
293
|
if (timelineHeaderRef.current) {
|
|
251
294
|
timelineHeaderRef.current.scrollLeft = body.scrollLeft;
|
|
252
295
|
}
|
|
253
|
-
setScrollTop(body.scrollTop);
|
|
254
|
-
|
|
296
|
+
setScrollTop(Math.floor(body.scrollTop / rowHeight) * rowHeight);
|
|
297
|
+
setScrollLeft(Math.floor(body.scrollLeft / SCROLL_LEFT_STEP) * SCROLL_LEFT_STEP);
|
|
298
|
+
}, [rowHeight]);
|
|
255
299
|
const handleTaskListScroll = React.useCallback(() => {
|
|
256
300
|
if (taskListBodyRef.current && timelineBodyRef.current) {
|
|
257
301
|
timelineBodyRef.current.scrollTop = taskListBodyRef.current.scrollTop;
|
|
258
302
|
}
|
|
259
303
|
}, []);
|
|
260
|
-
React.
|
|
304
|
+
React.useLayoutEffect(() => {
|
|
261
305
|
const node = timelineBodyRef.current;
|
|
262
306
|
const root = rootRef.current;
|
|
263
307
|
if (!node || !root) {
|
|
@@ -316,6 +360,7 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
316
360
|
if (body) {
|
|
317
361
|
const anchor = zoomAnchorRef.current;
|
|
318
362
|
body.scrollLeft = (body.scrollLeft + anchor) * (effectiveColumnWidth / prev) - anchor;
|
|
363
|
+
handleTimelineScroll();
|
|
319
364
|
}
|
|
320
365
|
zoomAnchorRef.current = 0;
|
|
321
366
|
}, [effectiveColumnWidth]);
|
|
@@ -343,9 +388,12 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
343
388
|
body.scrollTop = Math.max(0, rowIndex * rowHeight - (body.clientHeight - rowHeight) / 2);
|
|
344
389
|
}
|
|
345
390
|
}, [scrollToKey]);
|
|
391
|
+
const rowsRef = React.useRef(rows);
|
|
392
|
+
rowsRef.current = rows;
|
|
346
393
|
const handleTaskClick = React.useCallback(
|
|
347
394
|
(task) => {
|
|
348
|
-
|
|
395
|
+
const row = rowsRef.current.find((r) => r.task.id === task.id);
|
|
396
|
+
onTaskClick?.(row ? utils.getEffectiveTask(row) : task);
|
|
349
397
|
},
|
|
350
398
|
[onTaskClick]
|
|
351
399
|
);
|
|
@@ -361,6 +409,18 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
361
409
|
body.scrollTop += speed(pan.top - pan.y);
|
|
362
410
|
pan.raf = requestAnimationFrame(autoScrollTick);
|
|
363
411
|
}, []);
|
|
412
|
+
const handlePanEnd = React.useCallback(function end() {
|
|
413
|
+
document.removeEventListener("pointerup", end);
|
|
414
|
+
document.removeEventListener("pointercancel", end);
|
|
415
|
+
if (panRef.current?.raf !== null && panRef.current?.raf !== void 0) {
|
|
416
|
+
cancelAnimationFrame(panRef.current.raf);
|
|
417
|
+
}
|
|
418
|
+
panRef.current = null;
|
|
419
|
+
document.body.style.userSelect = "";
|
|
420
|
+
if (timelineBodyRef.current) {
|
|
421
|
+
timelineBodyRef.current.style.cursor = "";
|
|
422
|
+
}
|
|
423
|
+
}, []);
|
|
364
424
|
const handlePanStart = React.useCallback(
|
|
365
425
|
(e) => {
|
|
366
426
|
const body = timelineBodyRef.current;
|
|
@@ -369,22 +429,28 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
369
429
|
}
|
|
370
430
|
e.preventDefault();
|
|
371
431
|
const auto = e.button === 1;
|
|
372
|
-
panRef.current =
|
|
432
|
+
panRef.current = {
|
|
373
433
|
x: e.clientX,
|
|
374
434
|
y: e.clientY,
|
|
375
|
-
left: body.scrollLeft,
|
|
376
|
-
top: body.scrollTop,
|
|
435
|
+
left: auto ? e.clientX : body.scrollLeft,
|
|
436
|
+
top: auto ? e.clientY : body.scrollTop,
|
|
377
437
|
auto,
|
|
378
|
-
raf: null
|
|
438
|
+
raf: null,
|
|
439
|
+
pointerId: e.pointerId,
|
|
440
|
+
captured: auto
|
|
379
441
|
};
|
|
380
|
-
|
|
442
|
+
if (auto) {
|
|
443
|
+
body.setPointerCapture?.(e.pointerId);
|
|
444
|
+
}
|
|
381
445
|
body.style.cursor = auto ? "all-scroll" : "grabbing";
|
|
382
446
|
document.body.style.userSelect = "none";
|
|
447
|
+
document.addEventListener("pointerup", handlePanEnd);
|
|
448
|
+
document.addEventListener("pointercancel", handlePanEnd);
|
|
383
449
|
if (auto) {
|
|
384
450
|
panRef.current.raf = requestAnimationFrame(autoScrollTick);
|
|
385
451
|
}
|
|
386
452
|
},
|
|
387
|
-
[autoScrollTick]
|
|
453
|
+
[autoScrollTick, handlePanEnd]
|
|
388
454
|
);
|
|
389
455
|
const handlePanMove = React.useCallback((e) => {
|
|
390
456
|
const pan = panRef.current;
|
|
@@ -397,19 +463,13 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
397
463
|
pan.top = e.clientY;
|
|
398
464
|
return;
|
|
399
465
|
}
|
|
466
|
+
if (!pan.captured && Math.hypot(e.clientX - pan.x, e.clientY - pan.y) >= PAN_CAPTURE_DISTANCE) {
|
|
467
|
+
pan.captured = true;
|
|
468
|
+
body.setPointerCapture?.(pan.pointerId);
|
|
469
|
+
}
|
|
400
470
|
body.scrollLeft = pan.left - (e.clientX - pan.x);
|
|
401
471
|
body.scrollTop = pan.top - (e.clientY - pan.y);
|
|
402
472
|
}, []);
|
|
403
|
-
const handlePanEnd = React.useCallback(() => {
|
|
404
|
-
if (panRef.current?.raf !== null && panRef.current?.raf !== void 0) {
|
|
405
|
-
cancelAnimationFrame(panRef.current.raf);
|
|
406
|
-
}
|
|
407
|
-
panRef.current = null;
|
|
408
|
-
document.body.style.userSelect = "";
|
|
409
|
-
if (timelineBodyRef.current) {
|
|
410
|
-
timelineBodyRef.current.style.cursor = "";
|
|
411
|
-
}
|
|
412
|
-
}, []);
|
|
413
473
|
React.useEffect(() => handlePanEnd, [handlePanEnd]);
|
|
414
474
|
const prevStartRef = React.useRef(bounds.start);
|
|
415
475
|
React.useLayoutEffect(() => {
|
|
@@ -423,6 +483,7 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
423
483
|
if (timelineHeaderRef.current) {
|
|
424
484
|
timelineHeaderRef.current.scrollLeft += px;
|
|
425
485
|
}
|
|
486
|
+
handleTimelineScroll();
|
|
426
487
|
prevStartRef.current = bounds.start;
|
|
427
488
|
}
|
|
428
489
|
});
|
|
@@ -441,14 +502,15 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
441
502
|
}, [active, rows, bounds.start, effectiveColumnWidth, rowHeight]);
|
|
442
503
|
const today = dayjs();
|
|
443
504
|
const todayPosition = utils.dateToPixel(today, bounds.start, effectiveColumnWidth);
|
|
444
|
-
const showTodayLine = showTodayMarker && today.
|
|
505
|
+
const showTodayLine = showTodayMarker && !today.isBefore(bounds.start, "day") && !today.isAfter(displayEnd, "day");
|
|
445
506
|
return /* @__PURE__ */ React.createElement(core.Box, { ref: mergedRootRef, ...getStyles("root"), ...others }, /* @__PURE__ */ React.createElement(
|
|
446
507
|
TaskList.TaskList,
|
|
447
508
|
{
|
|
448
509
|
rows: visibleRows,
|
|
449
510
|
columns,
|
|
450
511
|
locale,
|
|
451
|
-
|
|
512
|
+
labels: labels$1,
|
|
513
|
+
getStyles: stableGetStyles,
|
|
452
514
|
bodyRef: taskListBodyRef,
|
|
453
515
|
onScroll: handleTaskListScroll,
|
|
454
516
|
collapsedIds,
|
|
@@ -457,7 +519,7 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
457
519
|
contentHeight: rows.length * rowHeight,
|
|
458
520
|
selectedTaskId,
|
|
459
521
|
collapsed: listCollapsed,
|
|
460
|
-
onToggleCollapsed:
|
|
522
|
+
onToggleCollapsed: toggleListCollapsed
|
|
461
523
|
}
|
|
462
524
|
), /* @__PURE__ */ React.createElement("div", { ...getStyles("timeline") }, /* @__PURE__ */ React.createElement("div", { ...getStyles("timelineHeader"), ref: timelineHeaderRef }, /* @__PURE__ */ React.createElement(
|
|
463
525
|
TimelineHeader.TimelineHeader,
|
|
@@ -465,12 +527,16 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
465
527
|
startDate: bounds.start,
|
|
466
528
|
endDate: displayEnd,
|
|
467
529
|
columnWidth: effectiveColumnWidth,
|
|
468
|
-
getStyles,
|
|
530
|
+
getStyles: stableGetStyles,
|
|
469
531
|
totalWidth: timelineWidth,
|
|
470
532
|
viewMode,
|
|
471
533
|
weekStart,
|
|
534
|
+
today: today.format("YYYY-MM-DD"),
|
|
472
535
|
locale,
|
|
473
|
-
|
|
536
|
+
labels: labels$1,
|
|
537
|
+
isNonWorkingDay,
|
|
538
|
+
firstDay,
|
|
539
|
+
lastDay
|
|
474
540
|
}
|
|
475
541
|
)), /* @__PURE__ */ React.createElement(
|
|
476
542
|
"div",
|
|
@@ -479,16 +545,15 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
479
545
|
ref: timelineBodyRef,
|
|
480
546
|
onScroll: handleTimelineScroll,
|
|
481
547
|
onPointerDown: handlePanStart,
|
|
482
|
-
onPointerMove: handlePanMove
|
|
483
|
-
onPointerUp: handlePanEnd,
|
|
484
|
-
onPointerCancel: handlePanEnd
|
|
548
|
+
onPointerMove: handlePanMove
|
|
485
549
|
},
|
|
486
550
|
/* @__PURE__ */ React.createElement(
|
|
487
551
|
"div",
|
|
488
552
|
{
|
|
489
|
-
...getStyles("timelineContent"
|
|
490
|
-
|
|
491
|
-
|
|
553
|
+
...getStyles("timelineContent", {
|
|
554
|
+
style: { width: timelineWidth, height: rows.length * rowHeight }
|
|
555
|
+
}),
|
|
556
|
+
ref: timelineContentRef
|
|
492
557
|
},
|
|
493
558
|
/* @__PURE__ */ React.createElement(
|
|
494
559
|
TimelineGrid.TimelineGrid,
|
|
@@ -498,14 +563,16 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
498
563
|
columnWidth: effectiveColumnWidth,
|
|
499
564
|
rowCount: rows.length,
|
|
500
565
|
rowHeight,
|
|
501
|
-
getStyles,
|
|
566
|
+
getStyles: stableGetStyles,
|
|
502
567
|
viewMode,
|
|
503
568
|
weekStart,
|
|
504
|
-
isNonWorkingDay
|
|
569
|
+
isNonWorkingDay,
|
|
570
|
+
firstDay,
|
|
571
|
+
lastDay
|
|
505
572
|
}
|
|
506
573
|
),
|
|
507
574
|
showTodayLine && /* @__PURE__ */ React.createElement("div", { ...getStyles("todayLine", { style: { left: todayPosition } }) }),
|
|
508
|
-
markers?.map((marker) => {
|
|
575
|
+
markers?.map((marker, index) => {
|
|
509
576
|
const date = dayjs(marker.date);
|
|
510
577
|
if (date.isBefore(bounds.start) || date.isAfter(displayEnd)) {
|
|
511
578
|
return null;
|
|
@@ -513,7 +580,7 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
513
580
|
return /* @__PURE__ */ React.createElement(
|
|
514
581
|
"div",
|
|
515
582
|
{
|
|
516
|
-
key:
|
|
583
|
+
key: index,
|
|
517
584
|
...getStyles("marker", {
|
|
518
585
|
style: {
|
|
519
586
|
left: utils.dateToPixel(date, bounds.start, effectiveColumnWidth),
|
|
@@ -527,14 +594,14 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
527
594
|
visibleRows.map((row, i) => {
|
|
528
595
|
const index = firstRow + i;
|
|
529
596
|
const task = utils.getEffectiveTask(row);
|
|
597
|
+
const isLocked = readOnly || task.locked;
|
|
530
598
|
return /* @__PURE__ */ React.createElement(
|
|
531
599
|
"div",
|
|
532
600
|
{
|
|
533
601
|
key: task.id,
|
|
534
|
-
...getStyles("timelineRow"),
|
|
602
|
+
...getStyles("timelineRow", { style: { top: index * rowHeight } }),
|
|
535
603
|
"data-first": index === Math.floor(scrollTop / rowHeight) || void 0,
|
|
536
|
-
title: showTitle ? task.label : void 0
|
|
537
|
-
style: { top: index * rowHeight }
|
|
604
|
+
title: showTitle ? task.label : void 0
|
|
538
605
|
},
|
|
539
606
|
/* @__PURE__ */ React.createElement(
|
|
540
607
|
TaskBar.TaskBar,
|
|
@@ -542,11 +609,11 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
542
609
|
task,
|
|
543
610
|
startDate: bounds.start,
|
|
544
611
|
columnWidth: effectiveColumnWidth,
|
|
545
|
-
getStyles,
|
|
612
|
+
getStyles: stableGetStyles,
|
|
546
613
|
span: row.span,
|
|
547
614
|
isNonWorkingDay: calendar,
|
|
548
615
|
isSummary: row.hasChildren,
|
|
549
|
-
isLocked
|
|
616
|
+
isLocked,
|
|
550
617
|
isDragging: active?.taskId === task.id && active.type !== "link",
|
|
551
618
|
isLinkTarget: active?.type === "link" && active.dropTargetId === task.id,
|
|
552
619
|
dragType: active?.taskId === task.id ? active.type : null,
|
|
@@ -555,6 +622,12 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
555
622
|
didDrag: drag.didDrag,
|
|
556
623
|
nudge: drag.nudge,
|
|
557
624
|
locale,
|
|
625
|
+
labels: labels$1,
|
|
626
|
+
ariaLabel: labels$1.taskBar(
|
|
627
|
+
task,
|
|
628
|
+
row.hasChildren ? "summary" : task.type === "milestone" ? "milestone" : "task",
|
|
629
|
+
!row.hasChildren && !isLocked
|
|
630
|
+
),
|
|
558
631
|
onTaskClick: handleTaskClick,
|
|
559
632
|
isCritical: criticalIds.has(task.id),
|
|
560
633
|
isSelected: task.id === selectedTaskId,
|
|
@@ -565,19 +638,20 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
565
638
|
showBaselines && task.baseline && /* @__PURE__ */ React.createElement(
|
|
566
639
|
"div",
|
|
567
640
|
{
|
|
568
|
-
...getStyles("baselineBar"
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
641
|
+
...getStyles("baselineBar", {
|
|
642
|
+
style: {
|
|
643
|
+
left: utils.dateToPixel(
|
|
644
|
+
task.baseline.startDate,
|
|
645
|
+
bounds.start,
|
|
646
|
+
effectiveColumnWidth
|
|
647
|
+
),
|
|
648
|
+
width: utils.durationToPixels(
|
|
649
|
+
utils.getTaskSpan(task.baseline.startDate, task.baseline.duration, calendar),
|
|
650
|
+
effectiveColumnWidth
|
|
651
|
+
)
|
|
652
|
+
}
|
|
653
|
+
}),
|
|
654
|
+
"data-task-id": task.id
|
|
581
655
|
}
|
|
582
656
|
)
|
|
583
657
|
);
|
|
@@ -589,7 +663,7 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
589
663
|
startDate: bounds.start,
|
|
590
664
|
columnWidth: effectiveColumnWidth,
|
|
591
665
|
rowHeight,
|
|
592
|
-
getStyles,
|
|
666
|
+
getStyles: stableGetStyles,
|
|
593
667
|
activeDragId: active && active.type !== "link" ? active.taskId : null,
|
|
594
668
|
activeDragType: active && active.type !== "link" ? active.type : null,
|
|
595
669
|
dragDelta: active && active.type !== "link" ? active.deltaX : 0,
|
|
@@ -597,7 +671,8 @@ const Gantt = core.factory((_props, ref) => {
|
|
|
597
671
|
criticalIds,
|
|
598
672
|
firstRow,
|
|
599
673
|
lastRow,
|
|
600
|
-
|
|
674
|
+
labels: labels$1,
|
|
675
|
+
onLinkClick: readOnly || !withLinkDelete ? void 0 : handleLinkDelete
|
|
601
676
|
}
|
|
602
677
|
)
|
|
603
678
|
)
|