@dcg-overseas/number-line 0.1.27 → 0.1.28
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.cjs +8 -9
- package/dist/index.js +8 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -353,11 +353,7 @@ function NumberLineProvider({
|
|
|
353
353
|
const onArcClick = React.useCallback(
|
|
354
354
|
(groupIndex, e) => {
|
|
355
355
|
e.stopPropagation();
|
|
356
|
-
if (drawing.tool === "
|
|
357
|
-
const strokesBefore = drawing.strokes;
|
|
358
|
-
setDeletedArcIndices((prev) => /* @__PURE__ */ new Set([...prev, groupIndex]));
|
|
359
|
-
history.push({ type: "delete", strokesBefore, arcIndices: [groupIndex] });
|
|
360
|
-
} else if (drawing.tool === "none") {
|
|
356
|
+
if (drawing.tool === "none") {
|
|
361
357
|
setSelectedArcIndices((prev) => {
|
|
362
358
|
const next = new Set(prev);
|
|
363
359
|
if (next.has(groupIndex)) next.delete(groupIndex);
|
|
@@ -366,7 +362,7 @@ function NumberLineProvider({
|
|
|
366
362
|
});
|
|
367
363
|
}
|
|
368
364
|
},
|
|
369
|
-
[drawing.tool
|
|
365
|
+
[drawing.tool]
|
|
370
366
|
);
|
|
371
367
|
const clearArcSelection = React.useCallback(() => setSelectedArcIndices(/* @__PURE__ */ new Set()), []);
|
|
372
368
|
const onDelete = React.useCallback(() => {
|
|
@@ -890,7 +886,7 @@ const GroupArcsLayer = React.memo(function GroupArcsLayer2({
|
|
|
890
886
|
);
|
|
891
887
|
const arcPath = buildArcPath({ x1, x2, y: axisY, rx, ry });
|
|
892
888
|
const isSelected = selectedArcIndices.has(g);
|
|
893
|
-
const hitCursor = tool === "
|
|
889
|
+
const hitCursor = tool === "none" ? "pointer" : "default";
|
|
894
890
|
arcs.push(
|
|
895
891
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
896
892
|
AnimatedArc,
|
|
@@ -908,7 +904,7 @@ const GroupArcsLayer = React.memo(function GroupArcsLayer2({
|
|
|
908
904
|
hitCursor,
|
|
909
905
|
shouldAnimate,
|
|
910
906
|
onArcClick: (index, e) => {
|
|
911
|
-
if (tool === "
|
|
907
|
+
if (tool === "none") {
|
|
912
908
|
e.stopPropagation();
|
|
913
909
|
onArcClick(index, e);
|
|
914
910
|
}
|
|
@@ -921,9 +917,10 @@ const GroupArcsLayer = React.memo(function GroupArcsLayer2({
|
|
|
921
917
|
return /* @__PURE__ */ jsxRuntime.jsx("g", { className: "nl-arcs-layer", children: arcs });
|
|
922
918
|
});
|
|
923
919
|
function DrawingLayer({ strokes, liveStroke, tool, width, height, onStrokeClick }) {
|
|
920
|
+
const [hoveredId, setHoveredId] = React.useState(null);
|
|
924
921
|
return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "nl-drawing-layer", transform: `scale(${width} ${height})`, children: [
|
|
925
922
|
strokes.map((s) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
926
|
-
s.selected && /* @__PURE__ */ jsxRuntime.jsx(
|
|
923
|
+
(s.selected || tool === "eraser" && s.id === hoveredId) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
927
924
|
"path",
|
|
928
925
|
{
|
|
929
926
|
d: s.d,
|
|
@@ -948,6 +945,8 @@ function DrawingLayer({ strokes, liveStroke, tool, width, height, onStrokeClick
|
|
|
948
945
|
vectorEffect: "non-scaling-stroke",
|
|
949
946
|
pointerEvents: "stroke",
|
|
950
947
|
style: { cursor: tool === "eraser" ? "cell" : tool === "none" ? "pointer" : "default" },
|
|
948
|
+
onPointerEnter: () => setHoveredId(s.id),
|
|
949
|
+
onPointerLeave: () => setHoveredId((prev) => prev === s.id ? null : prev),
|
|
951
950
|
onClick: (e) => {
|
|
952
951
|
if (tool === "eraser" || tool === "none") {
|
|
953
952
|
e.stopPropagation();
|
package/dist/index.js
CHANGED
|
@@ -351,11 +351,7 @@ function NumberLineProvider({
|
|
|
351
351
|
const onArcClick = useCallback(
|
|
352
352
|
(groupIndex, e) => {
|
|
353
353
|
e.stopPropagation();
|
|
354
|
-
if (drawing.tool === "
|
|
355
|
-
const strokesBefore = drawing.strokes;
|
|
356
|
-
setDeletedArcIndices((prev) => /* @__PURE__ */ new Set([...prev, groupIndex]));
|
|
357
|
-
history.push({ type: "delete", strokesBefore, arcIndices: [groupIndex] });
|
|
358
|
-
} else if (drawing.tool === "none") {
|
|
354
|
+
if (drawing.tool === "none") {
|
|
359
355
|
setSelectedArcIndices((prev) => {
|
|
360
356
|
const next = new Set(prev);
|
|
361
357
|
if (next.has(groupIndex)) next.delete(groupIndex);
|
|
@@ -364,7 +360,7 @@ function NumberLineProvider({
|
|
|
364
360
|
});
|
|
365
361
|
}
|
|
366
362
|
},
|
|
367
|
-
[drawing.tool
|
|
363
|
+
[drawing.tool]
|
|
368
364
|
);
|
|
369
365
|
const clearArcSelection = useCallback(() => setSelectedArcIndices(/* @__PURE__ */ new Set()), []);
|
|
370
366
|
const onDelete = useCallback(() => {
|
|
@@ -888,7 +884,7 @@ const GroupArcsLayer = memo(function GroupArcsLayer2({
|
|
|
888
884
|
);
|
|
889
885
|
const arcPath = buildArcPath({ x1, x2, y: axisY, rx, ry });
|
|
890
886
|
const isSelected = selectedArcIndices.has(g);
|
|
891
|
-
const hitCursor = tool === "
|
|
887
|
+
const hitCursor = tool === "none" ? "pointer" : "default";
|
|
892
888
|
arcs.push(
|
|
893
889
|
/* @__PURE__ */ jsx(
|
|
894
890
|
AnimatedArc,
|
|
@@ -906,7 +902,7 @@ const GroupArcsLayer = memo(function GroupArcsLayer2({
|
|
|
906
902
|
hitCursor,
|
|
907
903
|
shouldAnimate,
|
|
908
904
|
onArcClick: (index, e) => {
|
|
909
|
-
if (tool === "
|
|
905
|
+
if (tool === "none") {
|
|
910
906
|
e.stopPropagation();
|
|
911
907
|
onArcClick(index, e);
|
|
912
908
|
}
|
|
@@ -919,9 +915,10 @@ const GroupArcsLayer = memo(function GroupArcsLayer2({
|
|
|
919
915
|
return /* @__PURE__ */ jsx("g", { className: "nl-arcs-layer", children: arcs });
|
|
920
916
|
});
|
|
921
917
|
function DrawingLayer({ strokes, liveStroke, tool, width, height, onStrokeClick }) {
|
|
918
|
+
const [hoveredId, setHoveredId] = useState(null);
|
|
922
919
|
return /* @__PURE__ */ jsxs("g", { className: "nl-drawing-layer", transform: `scale(${width} ${height})`, children: [
|
|
923
920
|
strokes.map((s) => /* @__PURE__ */ jsxs("g", { children: [
|
|
924
|
-
s.selected && /* @__PURE__ */ jsx(
|
|
921
|
+
(s.selected || tool === "eraser" && s.id === hoveredId) && /* @__PURE__ */ jsx(
|
|
925
922
|
"path",
|
|
926
923
|
{
|
|
927
924
|
d: s.d,
|
|
@@ -946,6 +943,8 @@ function DrawingLayer({ strokes, liveStroke, tool, width, height, onStrokeClick
|
|
|
946
943
|
vectorEffect: "non-scaling-stroke",
|
|
947
944
|
pointerEvents: "stroke",
|
|
948
945
|
style: { cursor: tool === "eraser" ? "cell" : tool === "none" ? "pointer" : "default" },
|
|
946
|
+
onPointerEnter: () => setHoveredId(s.id),
|
|
947
|
+
onPointerLeave: () => setHoveredId((prev) => prev === s.id ? null : prev),
|
|
949
948
|
onClick: (e) => {
|
|
950
949
|
if (tool === "eraser" || tool === "none") {
|
|
951
950
|
e.stopPropagation();
|