graphics-debug 0.0.88 → 0.0.89
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/lib/react.js +98 -105
- package/dist/lib/react.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/react.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
|
|
24
24
|
// site/components/InteractiveGraphics/InteractiveGraphics.tsx
|
|
25
25
|
import useResizeObserver from "@react-hook/resize-observer";
|
|
26
|
-
import { useCallback as useCallback2, useEffect as useEffect3, useMemo as
|
|
26
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo13, useState as useState7 } from "react";
|
|
27
27
|
import { SuperGrid } from "react-supergrid";
|
|
28
28
|
|
|
29
29
|
// site/utils/getGraphicsBounds.ts
|
|
@@ -958,12 +958,14 @@ var InfiniteLine = ({
|
|
|
958
958
|
|
|
959
959
|
// site/components/InteractiveGraphics/Line.tsx
|
|
960
960
|
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
961
|
-
import {
|
|
961
|
+
import { useMemo as useMemo3 } from "react";
|
|
962
962
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
963
963
|
var Line = ({
|
|
964
964
|
line,
|
|
965
965
|
index,
|
|
966
|
-
interactiveState
|
|
966
|
+
interactiveState,
|
|
967
|
+
size,
|
|
968
|
+
mousePosition
|
|
967
969
|
}) => {
|
|
968
970
|
const { activeLayers, activeStep, realToScreen, onObjectClicked } = interactiveState;
|
|
969
971
|
const {
|
|
@@ -974,63 +976,42 @@ var Line = ({
|
|
|
974
976
|
strokeWidth = 1 / realToScreen.a,
|
|
975
977
|
strokeDash
|
|
976
978
|
} = line;
|
|
977
|
-
const [isHovered, setIsHovered] = useState4(false);
|
|
978
|
-
const [mousePos, setMousePos] = useState4({ x: 0, y: 0 });
|
|
979
|
-
const svgRef = useRef3(null);
|
|
980
979
|
const screenPoints = points.map((p) => applyToPoint5(realToScreen, p));
|
|
981
|
-
const
|
|
982
|
-
const
|
|
983
|
-
const
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
const
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
const svgTop = minY - padding;
|
|
992
|
-
const svgWidth = Math.max(maxX - minX, 0) + padding * 2;
|
|
993
|
-
const svgHeight = Math.max(maxY - minY, 0) + padding * 2;
|
|
994
|
-
const localPoints = screenPoints.map((p) => ({
|
|
995
|
-
x: p.x - svgLeft,
|
|
996
|
-
y: p.y - svgTop
|
|
997
|
-
}));
|
|
998
|
-
const handleMouseMove = (e) => {
|
|
999
|
-
const rect = svgRef.current?.getBoundingClientRect() ?? e.currentTarget.ownerSVGElement?.getBoundingClientRect();
|
|
1000
|
-
if (!rect) return;
|
|
1001
|
-
const localX = e.clientX - rect.left;
|
|
1002
|
-
const localY = e.clientY - rect.top;
|
|
1003
|
-
const mouseX = localX + svgLeft;
|
|
1004
|
-
const mouseY = localY + svgTop;
|
|
1005
|
-
setMousePos({ x: localX, y: localY });
|
|
1006
|
-
let isNearLine = false;
|
|
980
|
+
const screenStrokeWidth = strokeWidth * Math.abs(realToScreen.a);
|
|
981
|
+
const hoverPadding = 3;
|
|
982
|
+
const minHoverRadius = 6;
|
|
983
|
+
const hoverRadius = Math.max(
|
|
984
|
+
screenStrokeWidth / 2 + hoverPadding,
|
|
985
|
+
minHoverRadius
|
|
986
|
+
);
|
|
987
|
+
const hitStrokeWidth = hoverRadius * 2;
|
|
988
|
+
const isHovered = useMemo3(() => {
|
|
989
|
+
if (!mousePosition) return false;
|
|
1007
990
|
for (let i = 0; i < screenPoints.length - 1; i++) {
|
|
1008
991
|
const dist = distToLineSegment(
|
|
1009
|
-
|
|
1010
|
-
|
|
992
|
+
mousePosition.x,
|
|
993
|
+
mousePosition.y,
|
|
1011
994
|
screenPoints[i].x,
|
|
1012
995
|
screenPoints[i].y,
|
|
1013
996
|
screenPoints[i + 1].x,
|
|
1014
997
|
screenPoints[i + 1].y
|
|
1015
998
|
);
|
|
1016
|
-
if (dist
|
|
1017
|
-
|
|
1018
|
-
break;
|
|
999
|
+
if (dist <= hoverRadius) {
|
|
1000
|
+
return true;
|
|
1019
1001
|
}
|
|
1020
1002
|
}
|
|
1021
|
-
|
|
1022
|
-
};
|
|
1003
|
+
return false;
|
|
1004
|
+
}, [hoverRadius, mousePosition, screenPoints]);
|
|
1023
1005
|
const baseColor = strokeColor ?? defaultColors[index % defaultColors.length];
|
|
1024
1006
|
return /* @__PURE__ */ jsxs5(
|
|
1025
1007
|
"svg",
|
|
1026
1008
|
{
|
|
1027
|
-
ref: svgRef,
|
|
1028
1009
|
style: {
|
|
1029
1010
|
position: "absolute",
|
|
1030
|
-
top:
|
|
1031
|
-
left:
|
|
1032
|
-
width:
|
|
1033
|
-
height:
|
|
1011
|
+
top: 0,
|
|
1012
|
+
left: 0,
|
|
1013
|
+
width: size.width,
|
|
1014
|
+
height: size.height,
|
|
1034
1015
|
overflow: "visible",
|
|
1035
1016
|
pointerEvents: "none"
|
|
1036
1017
|
},
|
|
@@ -1038,14 +1019,13 @@ var Line = ({
|
|
|
1038
1019
|
/* @__PURE__ */ jsx7(
|
|
1039
1020
|
"polyline",
|
|
1040
1021
|
{
|
|
1041
|
-
points:
|
|
1022
|
+
points: screenPoints.map((p) => `${p.x},${p.y}`).join(" "),
|
|
1042
1023
|
stroke: "transparent",
|
|
1043
1024
|
fill: "none",
|
|
1044
|
-
strokeWidth:
|
|
1025
|
+
strokeWidth: hitStrokeWidth,
|
|
1045
1026
|
strokeLinecap: "round",
|
|
1027
|
+
strokeLinejoin: "round",
|
|
1046
1028
|
pointerEvents: "stroke",
|
|
1047
|
-
onMouseMove: handleMouseMove,
|
|
1048
|
-
onMouseLeave: () => setIsHovered(false),
|
|
1049
1029
|
onClick: isHovered ? () => onObjectClicked?.({
|
|
1050
1030
|
type: "line",
|
|
1051
1031
|
index,
|
|
@@ -1056,20 +1036,21 @@ var Line = ({
|
|
|
1056
1036
|
/* @__PURE__ */ jsx7(
|
|
1057
1037
|
"polyline",
|
|
1058
1038
|
{
|
|
1059
|
-
points:
|
|
1039
|
+
points: screenPoints.map((p) => `${p.x},${p.y}`).join(" "),
|
|
1060
1040
|
stroke: isHovered ? safeLighten(0.2, baseColor) : baseColor,
|
|
1061
1041
|
fill: "none",
|
|
1062
|
-
strokeWidth:
|
|
1063
|
-
strokeDasharray: !strokeDash ? void 0 : typeof strokeDash === "string" ? strokeDash : `${strokeDash[0] * realToScreen.a}, ${strokeDash[1] * realToScreen.a}`,
|
|
1042
|
+
strokeWidth: screenStrokeWidth,
|
|
1043
|
+
strokeDasharray: !strokeDash ? void 0 : typeof strokeDash === "string" ? strokeDash : `${strokeDash[0] * Math.abs(realToScreen.a)}, ${strokeDash[1] * Math.abs(realToScreen.a)}`,
|
|
1064
1044
|
strokeLinecap: "round",
|
|
1045
|
+
strokeLinejoin: "round",
|
|
1065
1046
|
pointerEvents: "none"
|
|
1066
1047
|
}
|
|
1067
1048
|
),
|
|
1068
1049
|
isHovered && line.label && /* @__PURE__ */ jsx7(
|
|
1069
1050
|
"foreignObject",
|
|
1070
1051
|
{
|
|
1071
|
-
x:
|
|
1072
|
-
y:
|
|
1052
|
+
x: mousePosition?.x ?? 0,
|
|
1053
|
+
y: (mousePosition?.y ?? 0) - 40,
|
|
1073
1054
|
width: 300,
|
|
1074
1055
|
height: 40,
|
|
1075
1056
|
children: /* @__PURE__ */ jsx7(Tooltip, { text: line.label })
|
|
@@ -1113,7 +1094,7 @@ var Marker = ({ marker, transform }) => {
|
|
|
1113
1094
|
|
|
1114
1095
|
// site/components/InteractiveGraphics/Point.tsx
|
|
1115
1096
|
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
1116
|
-
import { useState as
|
|
1097
|
+
import { useState as useState4 } from "react";
|
|
1117
1098
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1118
1099
|
var Point = ({
|
|
1119
1100
|
point,
|
|
@@ -1122,7 +1103,7 @@ var Point = ({
|
|
|
1122
1103
|
}) => {
|
|
1123
1104
|
const { color, label, layer, step } = point;
|
|
1124
1105
|
const { activeLayers, activeStep, realToScreen, onObjectClicked } = interactiveState;
|
|
1125
|
-
const [isHovered, setIsHovered] =
|
|
1106
|
+
const [isHovered, setIsHovered] = useState4(false);
|
|
1126
1107
|
const screenPoint = applyToPoint7(realToScreen, point);
|
|
1127
1108
|
const size = 10;
|
|
1128
1109
|
return /* @__PURE__ */ jsx9(
|
|
@@ -1173,7 +1154,7 @@ var Point = ({
|
|
|
1173
1154
|
};
|
|
1174
1155
|
|
|
1175
1156
|
// site/components/InteractiveGraphics/Polygon.tsx
|
|
1176
|
-
import { useState as
|
|
1157
|
+
import { useState as useState5 } from "react";
|
|
1177
1158
|
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
1178
1159
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1179
1160
|
var Polygon = ({
|
|
@@ -1183,7 +1164,7 @@ var Polygon = ({
|
|
|
1183
1164
|
}) => {
|
|
1184
1165
|
const { points, fill, stroke, strokeWidth } = polygon;
|
|
1185
1166
|
const { realToScreen, onObjectClicked } = interactiveState;
|
|
1186
|
-
const [isHovered, setIsHovered] =
|
|
1167
|
+
const [isHovered, setIsHovered] = useState5(false);
|
|
1187
1168
|
if (!points || points.length === 0) return null;
|
|
1188
1169
|
const screenPoints = points.map((p) => applyToPoint8(realToScreen, p));
|
|
1189
1170
|
const xs = screenPoints.map((p) => p.x);
|
|
@@ -1258,7 +1239,7 @@ var Polygon = ({
|
|
|
1258
1239
|
|
|
1259
1240
|
// site/components/InteractiveGraphics/Rect.tsx
|
|
1260
1241
|
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
1261
|
-
import { useState as
|
|
1242
|
+
import { useState as useState6 } from "react";
|
|
1262
1243
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1263
1244
|
var Rect = ({
|
|
1264
1245
|
rect,
|
|
@@ -1268,7 +1249,7 @@ var Rect = ({
|
|
|
1268
1249
|
const defaultColor = defaultColors[index % defaultColors.length];
|
|
1269
1250
|
let { center, width, height, fill, stroke, layer, step } = rect;
|
|
1270
1251
|
const { activeLayers, activeStep, realToScreen, onObjectClicked } = interactiveState;
|
|
1271
|
-
const [isHovered, setIsHovered] =
|
|
1252
|
+
const [isHovered, setIsHovered] = useState6(false);
|
|
1272
1253
|
const screenCenter = applyToPoint9(realToScreen, center);
|
|
1273
1254
|
const screenWidth = width * realToScreen.a;
|
|
1274
1255
|
const screenHeight = height * Math.abs(realToScreen.d);
|
|
@@ -1360,14 +1341,14 @@ var Text = ({
|
|
|
1360
1341
|
|
|
1361
1342
|
// site/components/InteractiveGraphics/hooks/useIsPointOnScreen.ts
|
|
1362
1343
|
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
1363
|
-
import { useMemo as
|
|
1344
|
+
import { useMemo as useMemo5 } from "react";
|
|
1364
1345
|
|
|
1365
1346
|
// site/components/InteractiveGraphics/hooks/useDoesLineIntersectViewport.ts
|
|
1366
1347
|
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
1367
|
-
import { useMemo as
|
|
1348
|
+
import { useMemo as useMemo4 } from "react";
|
|
1368
1349
|
var OFFSCREEN_MARGIN = 5;
|
|
1369
1350
|
var useDoesLineIntersectViewport = (realToScreen, size) => {
|
|
1370
|
-
return
|
|
1351
|
+
return useMemo4(() => {
|
|
1371
1352
|
return (p1, p2) => {
|
|
1372
1353
|
const sp1 = applyToPoint11(realToScreen, p1);
|
|
1373
1354
|
const sp2 = applyToPoint11(realToScreen, p2);
|
|
@@ -1398,7 +1379,7 @@ var useDoesLineIntersectViewport = (realToScreen, size) => {
|
|
|
1398
1379
|
|
|
1399
1380
|
// site/components/InteractiveGraphics/hooks/useIsPointOnScreen.ts
|
|
1400
1381
|
var useIsPointOnScreen = (realToScreen, size) => {
|
|
1401
|
-
return
|
|
1382
|
+
return useMemo5(() => {
|
|
1402
1383
|
return (point) => {
|
|
1403
1384
|
const screenPoint = applyToPoint12(realToScreen, point);
|
|
1404
1385
|
return screenPoint.x >= -OFFSCREEN_MARGIN && screenPoint.x <= size.width + OFFSCREEN_MARGIN && screenPoint.y >= -OFFSCREEN_MARGIN && screenPoint.y <= size.height + OFFSCREEN_MARGIN;
|
|
@@ -1407,13 +1388,13 @@ var useIsPointOnScreen = (realToScreen, size) => {
|
|
|
1407
1388
|
};
|
|
1408
1389
|
|
|
1409
1390
|
// site/components/InteractiveGraphics/hooks/useFilterLines.ts
|
|
1410
|
-
import { useMemo as
|
|
1391
|
+
import { useMemo as useMemo6 } from "react";
|
|
1411
1392
|
var useFilterLines = ({
|
|
1412
1393
|
isPointOnScreen,
|
|
1413
1394
|
doesLineIntersectViewport,
|
|
1414
1395
|
filterLayerAndStep
|
|
1415
1396
|
}) => {
|
|
1416
|
-
return
|
|
1397
|
+
return useMemo6(() => {
|
|
1417
1398
|
return (line) => {
|
|
1418
1399
|
if (!filterLayerAndStep(line)) return false;
|
|
1419
1400
|
if (line.points.some((p) => isPointOnScreen(p))) {
|
|
@@ -1438,12 +1419,12 @@ var useFilterLines = ({
|
|
|
1438
1419
|
};
|
|
1439
1420
|
|
|
1440
1421
|
// site/components/InteractiveGraphics/hooks/useFilterPoints.ts
|
|
1441
|
-
import { useMemo as
|
|
1422
|
+
import { useMemo as useMemo7 } from "react";
|
|
1442
1423
|
var useFilterPoints = ({
|
|
1443
1424
|
isPointOnScreen,
|
|
1444
1425
|
filterLayerAndStep
|
|
1445
1426
|
}) => {
|
|
1446
|
-
return
|
|
1427
|
+
return useMemo7(() => {
|
|
1447
1428
|
return (point) => {
|
|
1448
1429
|
if (!filterLayerAndStep(point)) return false;
|
|
1449
1430
|
return isPointOnScreen(point);
|
|
@@ -1452,13 +1433,13 @@ var useFilterPoints = ({
|
|
|
1452
1433
|
};
|
|
1453
1434
|
|
|
1454
1435
|
// site/components/InteractiveGraphics/hooks/useFilterRects.ts
|
|
1455
|
-
import { useMemo as
|
|
1436
|
+
import { useMemo as useMemo8 } from "react";
|
|
1456
1437
|
var useFilterRects = ({
|
|
1457
1438
|
isPointOnScreen,
|
|
1458
1439
|
doesLineIntersectViewport,
|
|
1459
1440
|
filterLayerAndStep
|
|
1460
1441
|
}) => {
|
|
1461
|
-
return
|
|
1442
|
+
return useMemo8(() => {
|
|
1462
1443
|
return (rect) => {
|
|
1463
1444
|
if (!filterLayerAndStep(rect)) return false;
|
|
1464
1445
|
const { center, width, height } = rect;
|
|
@@ -1477,7 +1458,7 @@ var useFilterRects = ({
|
|
|
1477
1458
|
};
|
|
1478
1459
|
|
|
1479
1460
|
// site/components/InteractiveGraphics/hooks/useFilterCircles.ts
|
|
1480
|
-
import { useMemo as
|
|
1461
|
+
import { useMemo as useMemo9 } from "react";
|
|
1481
1462
|
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
1482
1463
|
var useFilterCircles = ({
|
|
1483
1464
|
isPointOnScreen,
|
|
@@ -1485,7 +1466,7 @@ var useFilterCircles = ({
|
|
|
1485
1466
|
realToScreen,
|
|
1486
1467
|
size
|
|
1487
1468
|
}) => {
|
|
1488
|
-
return
|
|
1469
|
+
return useMemo9(() => {
|
|
1489
1470
|
return (circle) => {
|
|
1490
1471
|
if (!filterLayerAndStep(circle)) return false;
|
|
1491
1472
|
const { center, radius } = circle;
|
|
@@ -1521,12 +1502,12 @@ var useFilterCircles = ({
|
|
|
1521
1502
|
};
|
|
1522
1503
|
|
|
1523
1504
|
// site/components/InteractiveGraphics/hooks/useFilterTexts.ts
|
|
1524
|
-
import { useMemo as
|
|
1505
|
+
import { useMemo as useMemo10 } from "react";
|
|
1525
1506
|
var useFilterTexts = ({
|
|
1526
1507
|
isPointOnScreen,
|
|
1527
1508
|
filterLayerAndStep
|
|
1528
1509
|
}) => {
|
|
1529
|
-
return
|
|
1510
|
+
return useMemo10(() => {
|
|
1530
1511
|
return (text) => {
|
|
1531
1512
|
if (!filterLayerAndStep(text)) return false;
|
|
1532
1513
|
return isPointOnScreen({ x: text.x, y: text.y });
|
|
@@ -1535,12 +1516,12 @@ var useFilterTexts = ({
|
|
|
1535
1516
|
};
|
|
1536
1517
|
|
|
1537
1518
|
// site/components/InteractiveGraphics/hooks/useFilterArrows.ts
|
|
1538
|
-
import { useMemo as
|
|
1519
|
+
import { useMemo as useMemo11 } from "react";
|
|
1539
1520
|
var useFilterArrows = ({
|
|
1540
1521
|
isPointOnScreen,
|
|
1541
1522
|
doesLineIntersectViewport
|
|
1542
1523
|
}) => {
|
|
1543
|
-
return
|
|
1524
|
+
return useMemo11(() => {
|
|
1544
1525
|
return (arrow) => {
|
|
1545
1526
|
const geometry = getArrowGeometry(arrow);
|
|
1546
1527
|
const { shaftStart, shaftEnd, heads } = geometry;
|
|
@@ -1564,13 +1545,13 @@ var useFilterArrows = ({
|
|
|
1564
1545
|
};
|
|
1565
1546
|
|
|
1566
1547
|
// site/components/InteractiveGraphics/hooks/useFilterPolygons.ts
|
|
1567
|
-
import { useMemo as
|
|
1548
|
+
import { useMemo as useMemo12 } from "react";
|
|
1568
1549
|
var useFilterPolygons = ({
|
|
1569
1550
|
isPointOnScreen,
|
|
1570
1551
|
doesLineIntersectViewport,
|
|
1571
1552
|
filterLayerAndStep
|
|
1572
1553
|
}) => {
|
|
1573
|
-
return
|
|
1554
|
+
return useMemo12(() => {
|
|
1574
1555
|
return (polygon) => {
|
|
1575
1556
|
if (!filterLayerAndStep(polygon)) return false;
|
|
1576
1557
|
if (!polygon.points || polygon.points.length === 0) return false;
|
|
@@ -1595,12 +1576,13 @@ var InteractiveGraphics = ({
|
|
|
1595
1576
|
objectLimit,
|
|
1596
1577
|
height = 600
|
|
1597
1578
|
}) => {
|
|
1598
|
-
const [activeLayers, setActiveLayers] =
|
|
1599
|
-
const [activeStep, setActiveStep] =
|
|
1600
|
-
const [showLastStep, setShowLastStep] =
|
|
1601
|
-
const [size, setSize] =
|
|
1602
|
-
const [contextMenu, setContextMenu] =
|
|
1603
|
-
const [markers, setMarkers] =
|
|
1579
|
+
const [activeLayers, setActiveLayers] = useState7(null);
|
|
1580
|
+
const [activeStep, setActiveStep] = useState7(null);
|
|
1581
|
+
const [showLastStep, setShowLastStep] = useState7(true);
|
|
1582
|
+
const [size, setSize] = useState7({ width: 600, height });
|
|
1583
|
+
const [contextMenu, setContextMenu] = useState7(null);
|
|
1584
|
+
const [markers, setMarkers] = useState7([]);
|
|
1585
|
+
const [mousePosition, setMousePosition] = useState7(null);
|
|
1604
1586
|
const availableLayers = Array.from(
|
|
1605
1587
|
/* @__PURE__ */ new Set([
|
|
1606
1588
|
...graphics.lines?.map((l) => l.layer).filter(Boolean) ?? [],
|
|
@@ -1613,7 +1595,7 @@ var InteractiveGraphics = ({
|
|
|
1613
1595
|
])
|
|
1614
1596
|
);
|
|
1615
1597
|
const maxStep = getMaxStep(graphics);
|
|
1616
|
-
const graphicsBoundsWithPadding =
|
|
1598
|
+
const graphicsBoundsWithPadding = useMemo13(() => {
|
|
1617
1599
|
const actualBounds = getGraphicsBounds(graphics);
|
|
1618
1600
|
const width = actualBounds.maxX - actualBounds.minX;
|
|
1619
1601
|
const height2 = actualBounds.maxY - actualBounds.minY;
|
|
@@ -1834,37 +1816,37 @@ var InteractiveGraphics = ({
|
|
|
1834
1816
|
const filtered = objects.map((obj, index) => ({ ...obj, originalIndex: index })).filter(filterFn);
|
|
1835
1817
|
return objectLimit ? filtered.slice(-objectLimit) : filtered;
|
|
1836
1818
|
};
|
|
1837
|
-
const filteredLines =
|
|
1819
|
+
const filteredLines = useMemo13(
|
|
1838
1820
|
() => filterAndLimit(graphics.lines, filterLines).sort(
|
|
1839
1821
|
(a, b) => (a.zIndex ?? 0) - (b.zIndex ?? 0) || a.originalIndex - b.originalIndex
|
|
1840
1822
|
),
|
|
1841
1823
|
[graphics.lines, filterLines, objectLimit]
|
|
1842
1824
|
);
|
|
1843
|
-
const filteredInfiniteLines =
|
|
1825
|
+
const filteredInfiniteLines = useMemo13(
|
|
1844
1826
|
() => filterAndLimit(graphics.infiniteLines, filterLayerAndStep),
|
|
1845
1827
|
[graphics.infiniteLines, filterLayerAndStep, objectLimit]
|
|
1846
1828
|
);
|
|
1847
|
-
const filteredRects =
|
|
1829
|
+
const filteredRects = useMemo13(
|
|
1848
1830
|
() => sortRectsByArea(filterAndLimit(graphics.rects, filterRects)),
|
|
1849
1831
|
[graphics.rects, filterRects, objectLimit]
|
|
1850
1832
|
);
|
|
1851
|
-
const filteredPolygons =
|
|
1833
|
+
const filteredPolygons = useMemo13(
|
|
1852
1834
|
() => filterAndLimit(graphics.polygons, filterPolygons),
|
|
1853
1835
|
[graphics.polygons, filterPolygons, objectLimit]
|
|
1854
1836
|
);
|
|
1855
|
-
const filteredPoints =
|
|
1837
|
+
const filteredPoints = useMemo13(
|
|
1856
1838
|
() => filterAndLimit(graphics.points, filterPoints),
|
|
1857
1839
|
[graphics.points, filterPoints, objectLimit]
|
|
1858
1840
|
);
|
|
1859
|
-
const filteredCircles =
|
|
1841
|
+
const filteredCircles = useMemo13(
|
|
1860
1842
|
() => filterAndLimit(graphics.circles, filterCircles),
|
|
1861
1843
|
[graphics.circles, filterCircles, objectLimit]
|
|
1862
1844
|
);
|
|
1863
|
-
const filteredTexts =
|
|
1845
|
+
const filteredTexts = useMemo13(
|
|
1864
1846
|
() => filterAndLimit(graphics.texts, filterTexts),
|
|
1865
1847
|
[graphics.texts, filterTexts, objectLimit]
|
|
1866
1848
|
);
|
|
1867
|
-
const filteredArrows =
|
|
1849
|
+
const filteredArrows = useMemo13(
|
|
1868
1850
|
() => filterAndLimit(graphics.arrows, filterArrows),
|
|
1869
1851
|
[graphics.arrows, filterArrows, objectLimit]
|
|
1870
1852
|
);
|
|
@@ -1959,6 +1941,15 @@ var InteractiveGraphics = ({
|
|
|
1959
1941
|
height,
|
|
1960
1942
|
overflow: "hidden"
|
|
1961
1943
|
},
|
|
1944
|
+
onMouseMove: (event) => {
|
|
1945
|
+
const rect = ref.current?.getBoundingClientRect();
|
|
1946
|
+
if (!rect) return;
|
|
1947
|
+
setMousePosition({
|
|
1948
|
+
x: event.clientX - rect.left,
|
|
1949
|
+
y: event.clientY - rect.top
|
|
1950
|
+
});
|
|
1951
|
+
},
|
|
1952
|
+
onMouseLeave: () => setMousePosition(null),
|
|
1962
1953
|
onContextMenu: handleContextMenu,
|
|
1963
1954
|
children: [
|
|
1964
1955
|
/* @__PURE__ */ jsxs8(DimensionOverlay, { transform: realToScreen, children: [
|
|
@@ -1986,7 +1977,9 @@ var InteractiveGraphics = ({
|
|
|
1986
1977
|
{
|
|
1987
1978
|
line,
|
|
1988
1979
|
index: line.originalIndex,
|
|
1989
|
-
interactiveState
|
|
1980
|
+
interactiveState,
|
|
1981
|
+
size,
|
|
1982
|
+
mousePosition
|
|
1990
1983
|
},
|
|
1991
1984
|
line.originalIndex
|
|
1992
1985
|
)),
|
|
@@ -2074,7 +2067,7 @@ var InteractiveGraphics = ({
|
|
|
2074
2067
|
};
|
|
2075
2068
|
|
|
2076
2069
|
// site/components/InteractiveGraphicsCanvas.tsx
|
|
2077
|
-
import { useRef as
|
|
2070
|
+
import { useRef as useRef3, useEffect as useEffect4, useState as useState8 } from "react";
|
|
2078
2071
|
import useMouseMatrixTransform2 from "use-mouse-matrix-transform";
|
|
2079
2072
|
import { compose as compose2, scale as scale2, translate as translate2 } from "transformation-matrix";
|
|
2080
2073
|
import useResizeObserver2 from "@react-hook/resize-observer";
|
|
@@ -2138,12 +2131,12 @@ function InteractiveGraphicsCanvas({
|
|
|
2138
2131
|
height = 500,
|
|
2139
2132
|
width = "100%"
|
|
2140
2133
|
}) {
|
|
2141
|
-
const canvasRef =
|
|
2142
|
-
const containerRef =
|
|
2143
|
-
const [size, setSize] =
|
|
2144
|
-
const [activeStep, setActiveStep] =
|
|
2145
|
-
const [showLabels, setShowLabels] =
|
|
2146
|
-
const [showLastStep, setShowLastStep] =
|
|
2134
|
+
const canvasRef = useRef3(null);
|
|
2135
|
+
const containerRef = useRef3(null);
|
|
2136
|
+
const [size, setSize] = useState8({ width: 600, height: 600 });
|
|
2137
|
+
const [activeStep, setActiveStep] = useState8(null);
|
|
2138
|
+
const [showLabels, setShowLabels] = useState8(showLabelsByDefault);
|
|
2139
|
+
const [showLastStep, setShowLastStep] = useState8(true);
|
|
2147
2140
|
const maxStep = getMaxStep(graphics);
|
|
2148
2141
|
const filteredGraphics = getGraphicsFilteredByStep(graphics, {
|
|
2149
2142
|
activeStep,
|
|
@@ -2337,7 +2330,7 @@ function InteractiveGraphicsCanvas({
|
|
|
2337
2330
|
}
|
|
2338
2331
|
|
|
2339
2332
|
// site/components/CanvasGraphics/CanvasGraphics.tsx
|
|
2340
|
-
import React2, { useRef as
|
|
2333
|
+
import React2, { useRef as useRef4, useEffect as useEffect5, useState as useState9 } from "react";
|
|
2341
2334
|
import useMouseMatrixTransform3 from "use-mouse-matrix-transform";
|
|
2342
2335
|
import { compose as compose3, scale as scale3, translate as translate3 } from "transformation-matrix";
|
|
2343
2336
|
import useResizeObserver3 from "@react-hook/resize-observer";
|
|
@@ -2374,10 +2367,10 @@ var CanvasGraphics = ({
|
|
|
2374
2367
|
disableLabels = false,
|
|
2375
2368
|
initialTransform
|
|
2376
2369
|
}) => {
|
|
2377
|
-
const canvasRef =
|
|
2378
|
-
const containerRef =
|
|
2379
|
-
const [size, setSize] =
|
|
2380
|
-
const [currentTransform, setCurrentTransform] =
|
|
2370
|
+
const canvasRef = useRef4(null);
|
|
2371
|
+
const containerRef = useRef4(null);
|
|
2372
|
+
const [size, setSize] = useState9({ width, height });
|
|
2373
|
+
const [currentTransform, setCurrentTransform] = useState9(null);
|
|
2381
2374
|
const graphicsBoundsWithPadding = React2.useMemo(() => {
|
|
2382
2375
|
const bounds = getBounds(graphics);
|
|
2383
2376
|
const bWidth = bounds.maxX - bounds.minX;
|