gantt-task-react-v 1.2.13 → 1.3.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/gantt-task-react.es.js +55 -44
- package/dist/gantt-task-react.umd.js +55 -44
- package/package.json +1 -1
|
@@ -4684,11 +4684,14 @@ const getStartAndEnd = (containerEl, property, cellSize) => {
|
|
|
4684
4684
|
if (!containerEl) {
|
|
4685
4685
|
return null;
|
|
4686
4686
|
}
|
|
4687
|
-
const
|
|
4688
|
-
const
|
|
4689
|
-
const
|
|
4690
|
-
const
|
|
4691
|
-
const
|
|
4687
|
+
const el = containerEl;
|
|
4688
|
+
const scrollValue = property === "scrollLeft" ? el.scrollLeft : el.scrollTop;
|
|
4689
|
+
const maxScrollValue = property === "scrollLeft" ? el.scrollWidth : el.scrollHeight;
|
|
4690
|
+
const fullValue = property === "scrollLeft" ? el.clientWidth : el.clientHeight;
|
|
4691
|
+
const firstIndex = Math.max(0, Math.floor(scrollValue / cellSize));
|
|
4692
|
+
const visibleCount = Math.max(1, Math.ceil(fullValue / cellSize));
|
|
4693
|
+
const overscan = Math.min(100, Math.max(10, Math.ceil(visibleCount * 0.5)));
|
|
4694
|
+
const lastIndex = Math.floor((scrollValue + fullValue) / cellSize) + overscan;
|
|
4692
4695
|
const isStartOfScroll = scrollValue < DELTA;
|
|
4693
4696
|
const isEndOfScroll = scrollValue + fullValue > maxScrollValue - DELTA;
|
|
4694
4697
|
return [firstIndex, lastIndex, isStartOfScroll, isEndOfScroll, fullValue];
|
|
@@ -4697,31 +4700,49 @@ const useOptimizedList = (containerRef, property, cellSize) => {
|
|
|
4697
4700
|
const [indexes, setIndexes] = useState(
|
|
4698
4701
|
() => getStartAndEnd(containerRef.current, property, cellSize)
|
|
4699
4702
|
);
|
|
4703
|
+
const rafRef = useRef(null);
|
|
4704
|
+
const pendingRef = useRef(false);
|
|
4705
|
+
const update = useMemo(() => {
|
|
4706
|
+
const fn = () => {
|
|
4707
|
+
pendingRef.current = false;
|
|
4708
|
+
const next = getStartAndEnd(containerRef.current, property, cellSize);
|
|
4709
|
+
setIndexes((prev) => {
|
|
4710
|
+
const changed = !prev || !next || next.some((v, i) => prev ? prev[i] !== v : true);
|
|
4711
|
+
return changed ? next : prev;
|
|
4712
|
+
});
|
|
4713
|
+
rafRef.current = null;
|
|
4714
|
+
};
|
|
4715
|
+
return fn;
|
|
4716
|
+
}, [cellSize, containerRef, property]);
|
|
4700
4717
|
useEffect(() => {
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
) : true : Boolean(nextIndexes);
|
|
4712
|
-
if (isChanged) {
|
|
4713
|
-
prevIndexes = nextIndexes;
|
|
4714
|
-
setIndexes(nextIndexes);
|
|
4715
|
-
}
|
|
4716
|
-
rafId = requestAnimationFrame(handler);
|
|
4718
|
+
const el = containerRef.current;
|
|
4719
|
+
if (!el) {
|
|
4720
|
+
return void 0;
|
|
4721
|
+
}
|
|
4722
|
+
setIndexes(getStartAndEnd(el, property, cellSize));
|
|
4723
|
+
const onScroll = () => {
|
|
4724
|
+
if (pendingRef.current)
|
|
4725
|
+
return;
|
|
4726
|
+
pendingRef.current = true;
|
|
4727
|
+
rafRef.current = requestAnimationFrame(update);
|
|
4717
4728
|
};
|
|
4718
|
-
|
|
4729
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
4730
|
+
if (pendingRef.current)
|
|
4731
|
+
return;
|
|
4732
|
+
pendingRef.current = true;
|
|
4733
|
+
rafRef.current = requestAnimationFrame(update);
|
|
4734
|
+
});
|
|
4735
|
+
resizeObserver.observe(el);
|
|
4736
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
4719
4737
|
return () => {
|
|
4720
|
-
|
|
4721
|
-
|
|
4738
|
+
el.removeEventListener("scroll", onScroll);
|
|
4739
|
+
resizeObserver.disconnect();
|
|
4740
|
+
if (rafRef.current !== null) {
|
|
4741
|
+
cancelAnimationFrame(rafRef.current);
|
|
4722
4742
|
}
|
|
4743
|
+
pendingRef.current = false;
|
|
4723
4744
|
};
|
|
4724
|
-
}, [cellSize, containerRef,
|
|
4745
|
+
}, [cellSize, containerRef, property, update]);
|
|
4725
4746
|
return indexes;
|
|
4726
4747
|
};
|
|
4727
4748
|
const taskListNameWrapper = "_taskListNameWrapper_16z6n_1";
|
|
@@ -11031,20 +11052,13 @@ const GanttTodayInner = ({
|
|
|
11031
11052
|
}
|
|
11032
11053
|
};
|
|
11033
11054
|
const tickX = dataIndex * columnWidth * extraMultiplier();
|
|
11034
|
-
const
|
|
11055
|
+
const x = rtl ? tickX + columnWidth : tickX;
|
|
11035
11056
|
const color = dataDateColor || "var(--gantt-calendar-today-color)";
|
|
11036
|
-
const size = 12;
|
|
11037
|
-
const half = size / 2;
|
|
11038
|
-
const centerX = baseX + 1;
|
|
11039
|
-
const centerY = 6;
|
|
11040
|
-
const rectX = centerX - half;
|
|
11041
|
-
const rectY = centerY - half;
|
|
11042
|
-
const rightEdgeX = centerX + half * Math.SQRT2;
|
|
11043
11057
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11044
11058
|
/* @__PURE__ */ jsx(
|
|
11045
11059
|
"rect",
|
|
11046
11060
|
{
|
|
11047
|
-
x: additionalLeftSpace +
|
|
11061
|
+
x: additionalLeftSpace + x,
|
|
11048
11062
|
y: 0,
|
|
11049
11063
|
width: 2,
|
|
11050
11064
|
height: ganttFullHeight,
|
|
@@ -11053,22 +11067,19 @@ const GanttTodayInner = ({
|
|
|
11053
11067
|
}
|
|
11054
11068
|
),
|
|
11055
11069
|
/* @__PURE__ */ jsx(
|
|
11056
|
-
"
|
|
11070
|
+
"circle",
|
|
11057
11071
|
{
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
fill: color
|
|
11063
|
-
transform: `rotate(45 ${additionalLeftSpace + centerX} ${centerY})`,
|
|
11064
|
-
rx: 2,
|
|
11065
|
-
ry: 2
|
|
11072
|
+
className: styles$c.ganttTodayCircle,
|
|
11073
|
+
cx: x + 1,
|
|
11074
|
+
cy: 6,
|
|
11075
|
+
r: 6,
|
|
11076
|
+
fill: color
|
|
11066
11077
|
}
|
|
11067
11078
|
),
|
|
11068
11079
|
/* @__PURE__ */ jsx(
|
|
11069
11080
|
"text",
|
|
11070
11081
|
{
|
|
11071
|
-
x: additionalLeftSpace +
|
|
11082
|
+
x: additionalLeftSpace + x + 8,
|
|
11072
11083
|
y: 10,
|
|
11073
11084
|
fill: color,
|
|
11074
11085
|
fontSize: 12,
|
|
@@ -4701,11 +4701,14 @@
|
|
|
4701
4701
|
if (!containerEl) {
|
|
4702
4702
|
return null;
|
|
4703
4703
|
}
|
|
4704
|
-
const
|
|
4705
|
-
const
|
|
4706
|
-
const
|
|
4707
|
-
const
|
|
4708
|
-
const
|
|
4704
|
+
const el = containerEl;
|
|
4705
|
+
const scrollValue = property === "scrollLeft" ? el.scrollLeft : el.scrollTop;
|
|
4706
|
+
const maxScrollValue = property === "scrollLeft" ? el.scrollWidth : el.scrollHeight;
|
|
4707
|
+
const fullValue = property === "scrollLeft" ? el.clientWidth : el.clientHeight;
|
|
4708
|
+
const firstIndex = Math.max(0, Math.floor(scrollValue / cellSize));
|
|
4709
|
+
const visibleCount = Math.max(1, Math.ceil(fullValue / cellSize));
|
|
4710
|
+
const overscan = Math.min(100, Math.max(10, Math.ceil(visibleCount * 0.5)));
|
|
4711
|
+
const lastIndex = Math.floor((scrollValue + fullValue) / cellSize) + overscan;
|
|
4709
4712
|
const isStartOfScroll = scrollValue < DELTA;
|
|
4710
4713
|
const isEndOfScroll = scrollValue + fullValue > maxScrollValue - DELTA;
|
|
4711
4714
|
return [firstIndex, lastIndex, isStartOfScroll, isEndOfScroll, fullValue];
|
|
@@ -4714,31 +4717,49 @@
|
|
|
4714
4717
|
const [indexes, setIndexes] = React.useState(
|
|
4715
4718
|
() => getStartAndEnd(containerRef.current, property, cellSize)
|
|
4716
4719
|
);
|
|
4720
|
+
const rafRef = React.useRef(null);
|
|
4721
|
+
const pendingRef = React.useRef(false);
|
|
4722
|
+
const update = React.useMemo(() => {
|
|
4723
|
+
const fn = () => {
|
|
4724
|
+
pendingRef.current = false;
|
|
4725
|
+
const next = getStartAndEnd(containerRef.current, property, cellSize);
|
|
4726
|
+
setIndexes((prev) => {
|
|
4727
|
+
const changed = !prev || !next || next.some((v, i) => prev ? prev[i] !== v : true);
|
|
4728
|
+
return changed ? next : prev;
|
|
4729
|
+
});
|
|
4730
|
+
rafRef.current = null;
|
|
4731
|
+
};
|
|
4732
|
+
return fn;
|
|
4733
|
+
}, [cellSize, containerRef, property]);
|
|
4717
4734
|
React.useEffect(() => {
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
) : true : Boolean(nextIndexes);
|
|
4729
|
-
if (isChanged) {
|
|
4730
|
-
prevIndexes = nextIndexes;
|
|
4731
|
-
setIndexes(nextIndexes);
|
|
4732
|
-
}
|
|
4733
|
-
rafId = requestAnimationFrame(handler);
|
|
4735
|
+
const el = containerRef.current;
|
|
4736
|
+
if (!el) {
|
|
4737
|
+
return void 0;
|
|
4738
|
+
}
|
|
4739
|
+
setIndexes(getStartAndEnd(el, property, cellSize));
|
|
4740
|
+
const onScroll = () => {
|
|
4741
|
+
if (pendingRef.current)
|
|
4742
|
+
return;
|
|
4743
|
+
pendingRef.current = true;
|
|
4744
|
+
rafRef.current = requestAnimationFrame(update);
|
|
4734
4745
|
};
|
|
4735
|
-
|
|
4746
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
4747
|
+
if (pendingRef.current)
|
|
4748
|
+
return;
|
|
4749
|
+
pendingRef.current = true;
|
|
4750
|
+
rafRef.current = requestAnimationFrame(update);
|
|
4751
|
+
});
|
|
4752
|
+
resizeObserver.observe(el);
|
|
4753
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
4736
4754
|
return () => {
|
|
4737
|
-
|
|
4738
|
-
|
|
4755
|
+
el.removeEventListener("scroll", onScroll);
|
|
4756
|
+
resizeObserver.disconnect();
|
|
4757
|
+
if (rafRef.current !== null) {
|
|
4758
|
+
cancelAnimationFrame(rafRef.current);
|
|
4739
4759
|
}
|
|
4760
|
+
pendingRef.current = false;
|
|
4740
4761
|
};
|
|
4741
|
-
}, [cellSize, containerRef,
|
|
4762
|
+
}, [cellSize, containerRef, property, update]);
|
|
4742
4763
|
return indexes;
|
|
4743
4764
|
};
|
|
4744
4765
|
const taskListNameWrapper = "_taskListNameWrapper_16z6n_1";
|
|
@@ -11048,20 +11069,13 @@
|
|
|
11048
11069
|
}
|
|
11049
11070
|
};
|
|
11050
11071
|
const tickX = dataIndex * columnWidth * extraMultiplier();
|
|
11051
|
-
const
|
|
11072
|
+
const x = rtl ? tickX + columnWidth : tickX;
|
|
11052
11073
|
const color = dataDateColor || "var(--gantt-calendar-today-color)";
|
|
11053
|
-
const size = 12;
|
|
11054
|
-
const half = size / 2;
|
|
11055
|
-
const centerX = baseX + 1;
|
|
11056
|
-
const centerY = 6;
|
|
11057
|
-
const rectX = centerX - half;
|
|
11058
|
-
const rectY = centerY - half;
|
|
11059
|
-
const rightEdgeX = centerX + half * Math.SQRT2;
|
|
11060
11074
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
11061
11075
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11062
11076
|
"rect",
|
|
11063
11077
|
{
|
|
11064
|
-
x: additionalLeftSpace +
|
|
11078
|
+
x: additionalLeftSpace + x,
|
|
11065
11079
|
y: 0,
|
|
11066
11080
|
width: 2,
|
|
11067
11081
|
height: ganttFullHeight,
|
|
@@ -11070,22 +11084,19 @@
|
|
|
11070
11084
|
}
|
|
11071
11085
|
),
|
|
11072
11086
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11073
|
-
"
|
|
11087
|
+
"circle",
|
|
11074
11088
|
{
|
|
11075
|
-
|
|
11076
|
-
|
|
11077
|
-
|
|
11078
|
-
|
|
11079
|
-
fill: color
|
|
11080
|
-
transform: `rotate(45 ${additionalLeftSpace + centerX} ${centerY})`,
|
|
11081
|
-
rx: 2,
|
|
11082
|
-
ry: 2
|
|
11089
|
+
className: styles$c.ganttTodayCircle,
|
|
11090
|
+
cx: x + 1,
|
|
11091
|
+
cy: 6,
|
|
11092
|
+
r: 6,
|
|
11093
|
+
fill: color
|
|
11083
11094
|
}
|
|
11084
11095
|
),
|
|
11085
11096
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11086
11097
|
"text",
|
|
11087
11098
|
{
|
|
11088
|
-
x: additionalLeftSpace +
|
|
11099
|
+
x: additionalLeftSpace + x + 8,
|
|
11089
11100
|
y: 10,
|
|
11090
11101
|
fill: color,
|
|
11091
11102
|
fontSize: 12,
|
package/package.json
CHANGED