gantt-lib 0.3.3 → 0.3.4
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/index.css.map +1 -1
- package/dist/index.js +5 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -30
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +24 -264
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1322,7 +1322,7 @@ var TodayIndicator_default = TodayIndicator;
|
|
|
1322
1322
|
import React4, { useMemo as useMemo4 } from "react";
|
|
1323
1323
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1324
1324
|
var arePropsEqual2 = (prevProps, nextProps) => {
|
|
1325
|
-
return prevProps.dayWidth === nextProps.dayWidth && prevProps.dateRange.length === nextProps.dateRange.length && prevProps.totalHeight
|
|
1325
|
+
return prevProps.dayWidth === nextProps.dayWidth && prevProps.dateRange.length === nextProps.dateRange.length && prevProps.totalHeight === nextProps.totalHeight;
|
|
1326
1326
|
};
|
|
1327
1327
|
var GridBackground = React4.memo(
|
|
1328
1328
|
({ dateRange, dayWidth, totalHeight }) => {
|
|
@@ -2551,7 +2551,7 @@ var GanttChart = forwardRef(({
|
|
|
2551
2551
|
const todayOffset = todayIndex * dayWidth;
|
|
2552
2552
|
const containerWidth = container.clientWidth;
|
|
2553
2553
|
const scrollLeft = Math.round(todayOffset - containerWidth / 2 + dayWidth / 2);
|
|
2554
|
-
container.
|
|
2554
|
+
container.scrollTo({ left: Math.max(0, scrollLeft), behavior: "smooth" });
|
|
2555
2555
|
}, [dateRange, dayWidth]);
|
|
2556
2556
|
const scrollToTask = useCallback6((taskId) => {
|
|
2557
2557
|
const container = scrollContainerRef.current;
|
|
@@ -2568,7 +2568,7 @@ var GanttChart = forwardRef(({
|
|
|
2568
2568
|
if (taskIndex === -1) return;
|
|
2569
2569
|
const taskOffset = taskIndex * dayWidth;
|
|
2570
2570
|
const scrollLeft = Math.round(taskOffset - dayWidth * 2);
|
|
2571
|
-
container.
|
|
2571
|
+
container.scrollTo({ left: Math.max(0, scrollLeft), behavior: "smooth" });
|
|
2572
2572
|
}, [tasks, dateRange, dayWidth]);
|
|
2573
2573
|
useImperativeHandle(
|
|
2574
2574
|
ref,
|
|
@@ -2596,41 +2596,16 @@ var GanttChart = forwardRef(({
|
|
|
2596
2596
|
const newStart = new Date(updatedTask.startDate);
|
|
2597
2597
|
const newEnd = new Date(updatedTask.endDate);
|
|
2598
2598
|
const datesChanged = origStart.getTime() !== newStart.getTime() || origEnd.getTime() !== newEnd.getTime();
|
|
2599
|
-
const now = /* @__PURE__ */ new Date();
|
|
2600
|
-
const today = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()));
|
|
2601
|
-
const msPerDay = 1e3 * 60 * 60 * 24;
|
|
2602
|
-
let tasksToProcess;
|
|
2603
|
-
let cascadedTasksForCallback = [];
|
|
2604
2599
|
if (!datesChanged) {
|
|
2605
2600
|
onChange?.((currentTasks) => currentTasks.map((t) => t.id === updatedTask.id ? updatedTask : t));
|
|
2606
2601
|
return;
|
|
2607
2602
|
}
|
|
2603
|
+
let cascadedTasksForCallback;
|
|
2608
2604
|
if (disableConstraints) {
|
|
2609
|
-
tasksToProcess = [updatedTask];
|
|
2610
2605
|
cascadedTasksForCallback = [updatedTask];
|
|
2611
2606
|
} else {
|
|
2612
|
-
const cascadedTask = updatedTask;
|
|
2613
2607
|
const cascadedChain = cascadeByLinks(updatedTask.id, newStart, newEnd, tasks);
|
|
2614
|
-
|
|
2615
|
-
cascadedTasksForCallback = tasksToProcess;
|
|
2616
|
-
}
|
|
2617
|
-
console.log("[GanttChart handleTaskChange] IsExpired calculation:");
|
|
2618
|
-
for (const t of tasksToProcess) {
|
|
2619
|
-
const taskStart = new Date(t.startDate);
|
|
2620
|
-
const taskEnd = new Date(t.endDate);
|
|
2621
|
-
const actualProgress = t.progress ?? 0;
|
|
2622
|
-
if (actualProgress >= 100) {
|
|
2623
|
-
console.log(` [${t.id}] START=${t.startDate} END=${t.endDate} TODAY=${today.toISOString().split("T")[0]} PROGRESS=${actualProgress}% EXPECTED=N/A (completed) EXPIRED=NO`);
|
|
2624
|
-
continue;
|
|
2625
|
-
}
|
|
2626
|
-
const duration = taskEnd.getTime() - taskStart.getTime() + msPerDay;
|
|
2627
|
-
const elapsedFromToday = today.getTime() - taskStart.getTime();
|
|
2628
|
-
const elapsed = Math.min(Math.max(0, elapsedFromToday), duration);
|
|
2629
|
-
const expectedProgress = Math.min(100, Math.max(0, elapsed / duration * 100));
|
|
2630
|
-
const isExpired = actualProgress < expectedProgress;
|
|
2631
|
-
const durationDays = Math.round(duration / msPerDay);
|
|
2632
|
-
const elapsedDays = Math.round(elapsed / msPerDay);
|
|
2633
|
-
console.log(` [${t.id}] START=${t.startDate} END=${t.endDate} TODAY=${today.toISOString().split("T")[0]} PROGRESS=${actualProgress}% DURATION=${durationDays}d ELAPSED=${elapsedDays}d EXPECTED=${expectedProgress.toFixed(1)}% EXPIRED=${isExpired ? "YES" : "NO"}`);
|
|
2608
|
+
cascadedTasksForCallback = [updatedTask, ...cascadedChain];
|
|
2634
2609
|
}
|
|
2635
2610
|
if (disableConstraints) {
|
|
2636
2611
|
onChange?.((currentTasks) => currentTasks.map((t) => t.id === updatedTask.id ? updatedTask : t));
|