@designa8/vibedesign-stripe-deepseek-85ea 0.1.2 → 0.1.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/README.md +1 -1
- package/dist/index.cjs +294 -52
- package/dist/index.js +294 -52
- package/dist/styles.css +3 -0
- package/package.json +1 -1
- package/src/atoms/PaymentRoutingCanvas/PaymentRoutingCanvas.tsx +417 -49
- package/src/atoms/PaymentRoutingCanvas/preview.tsx +26 -10
- package/src/atoms/RoutingNode/RoutingNode.tsx +18 -13
package/dist/index.js
CHANGED
|
@@ -11718,7 +11718,7 @@ var RoutingNode = React60.forwardRef(
|
|
|
11718
11718
|
...rest
|
|
11719
11719
|
}, ref) => {
|
|
11720
11720
|
const glyph5 = icon ?? defaultIconByType[type];
|
|
11721
|
-
const
|
|
11721
|
+
const highlighted = selected || active;
|
|
11722
11722
|
return /* @__PURE__ */ jsxs57(
|
|
11723
11723
|
"div",
|
|
11724
11724
|
{
|
|
@@ -11727,6 +11727,7 @@ var RoutingNode = React60.forwardRef(
|
|
|
11727
11727
|
style: { width: NODE_WIDTH, ...style },
|
|
11728
11728
|
"data-node-type": type,
|
|
11729
11729
|
"data-selected": selected || void 0,
|
|
11730
|
+
"data-active": active || void 0,
|
|
11730
11731
|
...rest,
|
|
11731
11732
|
children: [
|
|
11732
11733
|
/* @__PURE__ */ jsxs57(
|
|
@@ -11735,8 +11736,8 @@ var RoutingNode = React60.forwardRef(
|
|
|
11735
11736
|
className: cn52(
|
|
11736
11737
|
"flex items-stretch overflow-hidden rounded-md border bg-surface",
|
|
11737
11738
|
"transition duration-150 ease-out",
|
|
11738
|
-
disabled ? "border-hairline-soft opacity-50" : unreachable ? "border-dashed border-semantic-warning" : selected
|
|
11739
|
-
dragging ? "shadow-lg" :
|
|
11739
|
+
disabled ? "border-hairline-soft opacity-50" : selected && unreachable ? "border-dashed border-semantic-warning ring-2 ring-primary" : selected ? "border-primary ring-2 ring-primary" : unreachable ? "border-dashed border-semantic-warning" : active ? "border-primary ring-2 ring-primary/25" : conflict ? "border-semantic-error/50" : "border-hairline",
|
|
11740
|
+
dragging ? "shadow-lg" : highlighted ? "shadow-md" : "shadow-sm",
|
|
11740
11741
|
disabled ? "" : "group-hover/node:border-hairline-strong group-hover/node:shadow-md"
|
|
11741
11742
|
),
|
|
11742
11743
|
children: [
|
|
@@ -11792,7 +11793,7 @@ var RoutingNode = React60.forwardRef(
|
|
|
11792
11793
|
"aria-hidden": "true",
|
|
11793
11794
|
className: cn52(
|
|
11794
11795
|
"absolute -left-xs top-1/2 size-sm -translate-y-1/2 rounded-full border-2 transition-colors duration-150 ease-out",
|
|
11795
|
-
|
|
11796
|
+
highlighted ? "border-primary bg-primary" : "border-hairline-strong bg-surface"
|
|
11796
11797
|
)
|
|
11797
11798
|
}
|
|
11798
11799
|
),
|
|
@@ -11802,7 +11803,7 @@ var RoutingNode = React60.forwardRef(
|
|
|
11802
11803
|
"aria-hidden": "true",
|
|
11803
11804
|
className: cn52(
|
|
11804
11805
|
"absolute -right-xs top-1/2 size-sm -translate-y-1/2 rounded-full border-2 transition-colors duration-150 ease-out",
|
|
11805
|
-
|
|
11806
|
+
highlighted ? "border-primary bg-primary" : "border-hairline-strong bg-surface"
|
|
11806
11807
|
)
|
|
11807
11808
|
}
|
|
11808
11809
|
),
|
|
@@ -11825,7 +11826,7 @@ var RoutingNode = React60.forwardRef(
|
|
|
11825
11826
|
size: "inline",
|
|
11826
11827
|
disabled,
|
|
11827
11828
|
"aria-label": ariaLabel ?? `${eyebrowByType2[type]}, ${title}`,
|
|
11828
|
-
"aria-
|
|
11829
|
+
"aria-pressed": selected,
|
|
11829
11830
|
onClick: onNodeSelect,
|
|
11830
11831
|
className: "absolute inset-0 rounded-md focus-visible:ring-focus-blue focus-visible:ring-offset-0",
|
|
11831
11832
|
children: /* @__PURE__ */ jsx60("span", { className: "sr-only", children: title })
|
|
@@ -11970,6 +11971,10 @@ var SCENE_H = 342;
|
|
|
11970
11971
|
var PLANE_H = 372;
|
|
11971
11972
|
var PLANE_PAD = 18;
|
|
11972
11973
|
var PANEL_W = 296;
|
|
11974
|
+
var SNAP = 8;
|
|
11975
|
+
var MARQUEE_MIN = 4;
|
|
11976
|
+
var clampTo = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
11977
|
+
var boxesIntersect = (a, b) => a.x < b.x + b.w && a.x + a.w > b.x && a.y < b.y + b.h && a.y + a.h > b.y;
|
|
11973
11978
|
var DEFAULT_NODES = [
|
|
11974
11979
|
{
|
|
11975
11980
|
id: "source",
|
|
@@ -12082,6 +12087,7 @@ var DEFAULT_SAMPLES = [
|
|
|
12082
12087
|
]
|
|
12083
12088
|
}
|
|
12084
12089
|
];
|
|
12090
|
+
var DEFAULT_SELECTION = ["brand"];
|
|
12085
12091
|
var computeIssues = (nodes, edges) => {
|
|
12086
12092
|
const issues = [];
|
|
12087
12093
|
const seenFields = /* @__PURE__ */ new Map();
|
|
@@ -12120,6 +12126,7 @@ var computeIssues = (nodes, edges) => {
|
|
|
12120
12126
|
});
|
|
12121
12127
|
return issues;
|
|
12122
12128
|
};
|
|
12129
|
+
var sameIds = (a, b) => a.length === b.length && a.every((id, index) => id === b[index]);
|
|
12123
12130
|
var PaymentRoutingCanvas = React62.forwardRef(
|
|
12124
12131
|
({
|
|
12125
12132
|
nodes,
|
|
@@ -12127,6 +12134,9 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12127
12134
|
onNodesChange,
|
|
12128
12135
|
onEdgesChange,
|
|
12129
12136
|
onNodeSelect,
|
|
12137
|
+
selectedNodeIds,
|
|
12138
|
+
defaultSelectedNodeIds,
|
|
12139
|
+
onSelectionChange,
|
|
12130
12140
|
sampleTransaction,
|
|
12131
12141
|
onSimulationStep,
|
|
12132
12142
|
onValidationChange,
|
|
@@ -12137,7 +12147,7 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12137
12147
|
const graphEdges = edges ?? DEFAULT_EDGES;
|
|
12138
12148
|
const samples = sampleTransaction ?? DEFAULT_SAMPLES;
|
|
12139
12149
|
const [localNodes, setLocalNodes] = React62.useState(incomingNodes);
|
|
12140
|
-
const [
|
|
12150
|
+
const [panelNodeId, setPanelNodeId] = React62.useState("brand");
|
|
12141
12151
|
const [panelOpen, setPanelOpen] = React62.useState(true);
|
|
12142
12152
|
const [zoom, setZoom] = React62.useState(1);
|
|
12143
12153
|
const [fit, setFit] = React62.useState(1);
|
|
@@ -12155,15 +12165,42 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12155
12165
|
const [replaying, setReplaying] = React62.useState(false);
|
|
12156
12166
|
const [focusedId, setFocusedId] = React62.useState(null);
|
|
12157
12167
|
const [anchor, setAnchor] = React62.useState({ top: 0, right: 16 });
|
|
12168
|
+
const controlledSelection = selectedNodeIds !== void 0;
|
|
12169
|
+
const [internalSelection, setInternalSelection] = React62.useState(
|
|
12170
|
+
() => defaultSelectedNodeIds ?? DEFAULT_SELECTION
|
|
12171
|
+
);
|
|
12172
|
+
const selection = controlledSelection ? selectedNodeIds : internalSelection;
|
|
12173
|
+
const selectionRef = React62.useRef(selection);
|
|
12174
|
+
selectionRef.current = selection;
|
|
12175
|
+
const onSelectionChangeRef = React62.useRef(onSelectionChange);
|
|
12176
|
+
onSelectionChangeRef.current = onSelectionChange;
|
|
12177
|
+
const [marqueeBox, setMarqueeBox] = React62.useState(null);
|
|
12178
|
+
const [marqueeIds, setMarqueeIds] = React62.useState(null);
|
|
12179
|
+
const marqueeRef = React62.useRef(null);
|
|
12180
|
+
const [modifierHeld, setModifierHeld] = React62.useState(false);
|
|
12158
12181
|
const rootRef = React62.useRef(null);
|
|
12159
12182
|
const planeRef = React62.useRef(null);
|
|
12160
12183
|
const triggerRef = React62.useRef(null);
|
|
12161
12184
|
const nodeRefs = React62.useRef({});
|
|
12162
12185
|
const suppressClick = React62.useRef(false);
|
|
12163
12186
|
const nodeDragActive = React62.useRef(false);
|
|
12187
|
+
const nodesRef = React62.useRef(localNodes);
|
|
12188
|
+
nodesRef.current = localNodes;
|
|
12164
12189
|
React62.useEffect(() => {
|
|
12165
12190
|
setLocalNodes(incomingNodes);
|
|
12166
12191
|
}, [incomingNodes]);
|
|
12192
|
+
React62.useEffect(() => {
|
|
12193
|
+
const syncModifier = (event) => setModifierHeld(Boolean(event.metaKey || event.ctrlKey));
|
|
12194
|
+
const releaseModifier = () => setModifierHeld(false);
|
|
12195
|
+
window.addEventListener("keydown", syncModifier);
|
|
12196
|
+
window.addEventListener("keyup", syncModifier);
|
|
12197
|
+
window.addEventListener("blur", releaseModifier);
|
|
12198
|
+
return () => {
|
|
12199
|
+
window.removeEventListener("keydown", syncModifier);
|
|
12200
|
+
window.removeEventListener("keyup", syncModifier);
|
|
12201
|
+
window.removeEventListener("blur", releaseModifier);
|
|
12202
|
+
};
|
|
12203
|
+
}, []);
|
|
12167
12204
|
React62.useEffect(() => {
|
|
12168
12205
|
const plane = planeRef.current;
|
|
12169
12206
|
if (!plane) return;
|
|
@@ -12231,56 +12268,127 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12231
12268
|
x: node.x + (side === "out" ? NODE_W : 0),
|
|
12232
12269
|
y: node.y + (node.h ?? NODE_H) / 2
|
|
12233
12270
|
});
|
|
12234
|
-
const focusedNode =
|
|
12271
|
+
const focusedNode = panelNodeId ? nodeById.get(panelNodeId) : void 0;
|
|
12272
|
+
const selectionSet = React62.useMemo(() => new Set(selection), [selection]);
|
|
12273
|
+
const marqueeSet = React62.useMemo(() => new Set(marqueeIds ?? []), [marqueeIds]);
|
|
12274
|
+
const commitSelection = React62.useCallback(
|
|
12275
|
+
(next) => {
|
|
12276
|
+
const unique = next.filter((id, index) => next.indexOf(id) === index);
|
|
12277
|
+
if (sameIds(unique, selectionRef.current)) return;
|
|
12278
|
+
selectionRef.current = unique;
|
|
12279
|
+
if (!controlledSelection) setInternalSelection(unique);
|
|
12280
|
+
onSelectionChangeRef.current?.(unique);
|
|
12281
|
+
},
|
|
12282
|
+
[controlledSelection]
|
|
12283
|
+
);
|
|
12284
|
+
const openNodePanel = (node) => {
|
|
12285
|
+
commitSelection([node.id]);
|
|
12286
|
+
setPanelNodeId(node.id);
|
|
12287
|
+
setPanelOpen(true);
|
|
12288
|
+
onNodeSelect?.(node);
|
|
12289
|
+
};
|
|
12235
12290
|
const selectNode = (node) => {
|
|
12236
12291
|
if (suppressClick.current) {
|
|
12237
12292
|
suppressClick.current = false;
|
|
12238
12293
|
return;
|
|
12239
12294
|
}
|
|
12240
|
-
|
|
12241
|
-
setPanelOpen(true);
|
|
12242
|
-
onNodeSelect?.(node);
|
|
12295
|
+
openNodePanel(node);
|
|
12243
12296
|
};
|
|
12244
12297
|
const closePanel = () => {
|
|
12245
|
-
const previous =
|
|
12298
|
+
const previous = panelNodeId;
|
|
12246
12299
|
setPanelOpen(false);
|
|
12247
|
-
|
|
12300
|
+
setPanelNodeId(null);
|
|
12248
12301
|
onNodeSelect?.(null);
|
|
12249
12302
|
if (previous) nodeRefs.current[previous]?.querySelector("button")?.focus();
|
|
12250
12303
|
};
|
|
12304
|
+
const clearSelection = () => {
|
|
12305
|
+
commitSelection([]);
|
|
12306
|
+
if (panelOpen) {
|
|
12307
|
+
setPanelOpen(false);
|
|
12308
|
+
setPanelNodeId(null);
|
|
12309
|
+
onNodeSelect?.(null);
|
|
12310
|
+
}
|
|
12311
|
+
};
|
|
12312
|
+
const nudgeSelection = (key) => {
|
|
12313
|
+
const ids = new Set(selectionRef.current);
|
|
12314
|
+
if (ids.size === 0) return;
|
|
12315
|
+
const dx = key === "ArrowLeft" ? -SNAP : key === "ArrowRight" ? SNAP : 0;
|
|
12316
|
+
const dy = key === "ArrowUp" ? -SNAP : key === "ArrowDown" ? SNAP : 0;
|
|
12317
|
+
if (!dx && !dy) return;
|
|
12318
|
+
const next = nodesRef.current.map(
|
|
12319
|
+
(node) => ids.has(node.id) ? { ...node, x: node.x + dx, y: node.y + dy } : node
|
|
12320
|
+
);
|
|
12321
|
+
setLocalNodes(next);
|
|
12322
|
+
onNodesChange?.(next);
|
|
12323
|
+
onEdgesChange?.(graphEdges);
|
|
12324
|
+
};
|
|
12251
12325
|
const beginDrag = (event, node) => {
|
|
12252
12326
|
if (event.button !== 0) return;
|
|
12253
12327
|
event.stopPropagation();
|
|
12328
|
+
suppressClick.current = false;
|
|
12254
12329
|
nodeDragActive.current = true;
|
|
12330
|
+
const additive = event.metaKey || event.ctrlKey;
|
|
12331
|
+
const current = selectionRef.current;
|
|
12332
|
+
const isIn = current.includes(node.id);
|
|
12333
|
+
let dragIds;
|
|
12334
|
+
let deselectOnClick = false;
|
|
12335
|
+
let openOnClick = false;
|
|
12336
|
+
if (additive) {
|
|
12337
|
+
if (isIn) {
|
|
12338
|
+
dragIds = current;
|
|
12339
|
+
deselectOnClick = true;
|
|
12340
|
+
} else {
|
|
12341
|
+
dragIds = [...current, node.id];
|
|
12342
|
+
commitSelection(dragIds);
|
|
12343
|
+
}
|
|
12344
|
+
} else if (isIn && current.length > 1) {
|
|
12345
|
+
dragIds = current;
|
|
12346
|
+
openOnClick = true;
|
|
12347
|
+
} else {
|
|
12348
|
+
dragIds = [node.id];
|
|
12349
|
+
if (!(current.length === 1 && current[0] === node.id)) commitSelection([node.id]);
|
|
12350
|
+
openOnClick = true;
|
|
12351
|
+
}
|
|
12352
|
+
const dragged = new Set(dragIds);
|
|
12353
|
+
const origins = /* @__PURE__ */ new Map();
|
|
12354
|
+
nodesRef.current.forEach((item) => {
|
|
12355
|
+
if (dragged.has(item.id)) origins.set(item.id, { x: item.x, y: item.y });
|
|
12356
|
+
});
|
|
12255
12357
|
const startX = event.clientX;
|
|
12256
12358
|
const startY = event.clientY;
|
|
12257
12359
|
const scale2 = fit * zoom || 1;
|
|
12258
12360
|
let moved = false;
|
|
12361
|
+
let finalNodes = null;
|
|
12259
12362
|
const move = (moveEvent) => {
|
|
12260
|
-
const
|
|
12261
|
-
const
|
|
12262
|
-
if (!moved && Math.abs(
|
|
12363
|
+
const rawX = (moveEvent.clientX - startX) / scale2;
|
|
12364
|
+
const rawY = (moveEvent.clientY - startY) / scale2;
|
|
12365
|
+
if (!moved && Math.abs(rawX) + Math.abs(rawY) < 4) return;
|
|
12263
12366
|
moved = true;
|
|
12264
|
-
|
|
12265
|
-
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
);
|
|
12367
|
+
const dx = Math.round(rawX / SNAP) * SNAP;
|
|
12368
|
+
const dy = Math.round(rawY / SNAP) * SNAP;
|
|
12369
|
+
const next = nodesRef.current.map((item) => {
|
|
12370
|
+
const origin = origins.get(item.id);
|
|
12371
|
+
return origin ? { ...item, x: origin.x + dx, y: origin.y + dy } : item;
|
|
12372
|
+
});
|
|
12373
|
+
finalNodes = next;
|
|
12374
|
+
setLocalNodes(next);
|
|
12273
12375
|
};
|
|
12274
12376
|
const end = () => {
|
|
12275
12377
|
nodeDragActive.current = false;
|
|
12276
12378
|
window.removeEventListener("pointermove", move);
|
|
12277
|
-
if (!moved) return;
|
|
12278
12379
|
suppressClick.current = true;
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12380
|
+
if (moved) {
|
|
12381
|
+
if (finalNodes) {
|
|
12382
|
+
onNodesChange?.(finalNodes);
|
|
12383
|
+
onEdgesChange?.(graphEdges);
|
|
12384
|
+
}
|
|
12385
|
+
return;
|
|
12386
|
+
}
|
|
12387
|
+
if (deselectOnClick) {
|
|
12388
|
+
commitSelection(selectionRef.current.filter((id) => id !== node.id));
|
|
12389
|
+
return;
|
|
12390
|
+
}
|
|
12391
|
+
if (openOnClick) openNodePanel(node);
|
|
12284
12392
|
};
|
|
12285
12393
|
window.addEventListener("pointermove", move);
|
|
12286
12394
|
window.addEventListener("pointerup", end, { once: true });
|
|
@@ -12291,16 +12399,106 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12291
12399
|
const startX = event.clientX;
|
|
12292
12400
|
const startY = event.clientY;
|
|
12293
12401
|
const origin = pan;
|
|
12402
|
+
let moved = false;
|
|
12294
12403
|
const move = (moveEvent) => {
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12404
|
+
const dx = moveEvent.clientX - startX;
|
|
12405
|
+
const dy = moveEvent.clientY - startY;
|
|
12406
|
+
if (!moved && Math.abs(dx) + Math.abs(dy) < 4) return;
|
|
12407
|
+
moved = true;
|
|
12408
|
+
setPan({ x: origin.x + dx, y: origin.y + dy });
|
|
12409
|
+
};
|
|
12410
|
+
const end = () => {
|
|
12411
|
+
window.removeEventListener("pointermove", move);
|
|
12412
|
+
if (!moved) clearSelection();
|
|
12299
12413
|
};
|
|
12300
|
-
const end = () => window.removeEventListener("pointermove", move);
|
|
12301
12414
|
window.addEventListener("pointermove", move);
|
|
12302
12415
|
window.addEventListener("pointerup", end, { once: true });
|
|
12303
12416
|
};
|
|
12417
|
+
const beginMarquee = (event) => {
|
|
12418
|
+
if (event.button !== 0) return;
|
|
12419
|
+
if (nodeDragActive.current) return;
|
|
12420
|
+
const plane = planeRef.current;
|
|
12421
|
+
if (!plane) return;
|
|
12422
|
+
const box = plane.getBoundingClientRect();
|
|
12423
|
+
if (!box.width || !box.height) return;
|
|
12424
|
+
const gestureScale = fit * zoom || 1;
|
|
12425
|
+
const originX = clampTo(event.clientX - box.left, 0, box.width);
|
|
12426
|
+
const originY = clampTo(event.clientY - box.top, 0, box.height);
|
|
12427
|
+
const gesture = {
|
|
12428
|
+
originX,
|
|
12429
|
+
originY,
|
|
12430
|
+
box: { left: box.left, top: box.top, width: box.width, height: box.height },
|
|
12431
|
+
offsetX: PLANE_PAD + pan.x,
|
|
12432
|
+
offsetY: Math.max((planeHeight - SCENE_H * gestureScale) / 2, 0) + pan.y,
|
|
12433
|
+
scale: gestureScale,
|
|
12434
|
+
base: selectionRef.current,
|
|
12435
|
+
rect: { x: originX, y: originY, w: 0, h: 0 }
|
|
12436
|
+
};
|
|
12437
|
+
marqueeRef.current = gesture;
|
|
12438
|
+
setMarqueeBox(gesture.rect);
|
|
12439
|
+
setMarqueeIds([]);
|
|
12440
|
+
const hitsFor = (rect) => {
|
|
12441
|
+
const scene = {
|
|
12442
|
+
x: (rect.x - gesture.offsetX) / gesture.scale,
|
|
12443
|
+
y: (rect.y - gesture.offsetY) / gesture.scale,
|
|
12444
|
+
w: rect.w / gesture.scale,
|
|
12445
|
+
h: rect.h / gesture.scale
|
|
12446
|
+
};
|
|
12447
|
+
return nodesRef.current.filter(
|
|
12448
|
+
(node) => boxesIntersect(scene, {
|
|
12449
|
+
x: node.x,
|
|
12450
|
+
y: node.y,
|
|
12451
|
+
w: NODE_W,
|
|
12452
|
+
h: node.h ?? NODE_H
|
|
12453
|
+
})
|
|
12454
|
+
).map((node) => node.id);
|
|
12455
|
+
};
|
|
12456
|
+
const cleanup = () => {
|
|
12457
|
+
window.removeEventListener("pointermove", move);
|
|
12458
|
+
window.removeEventListener("pointerup", end);
|
|
12459
|
+
window.removeEventListener("pointercancel", cancel);
|
|
12460
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
12461
|
+
};
|
|
12462
|
+
const settle = () => {
|
|
12463
|
+
cleanup();
|
|
12464
|
+
marqueeRef.current = null;
|
|
12465
|
+
setMarqueeBox(null);
|
|
12466
|
+
setMarqueeIds(null);
|
|
12467
|
+
};
|
|
12468
|
+
function cancel() {
|
|
12469
|
+
settle();
|
|
12470
|
+
}
|
|
12471
|
+
function onKeyDown(keyEvent) {
|
|
12472
|
+
if (keyEvent.key !== "Escape") return;
|
|
12473
|
+
keyEvent.preventDefault();
|
|
12474
|
+
cancel();
|
|
12475
|
+
}
|
|
12476
|
+
function move(moveEvent) {
|
|
12477
|
+
const x = clampTo(moveEvent.clientX - gesture.box.left, 0, gesture.box.width);
|
|
12478
|
+
const y = clampTo(moveEvent.clientY - gesture.box.top, 0, gesture.box.height);
|
|
12479
|
+
const rect = {
|
|
12480
|
+
x: Math.min(gesture.originX, x),
|
|
12481
|
+
y: Math.min(gesture.originY, y),
|
|
12482
|
+
w: Math.abs(x - gesture.originX),
|
|
12483
|
+
h: Math.abs(y - gesture.originY)
|
|
12484
|
+
};
|
|
12485
|
+
gesture.rect = rect;
|
|
12486
|
+
setMarqueeBox(rect);
|
|
12487
|
+
setMarqueeIds(hitsFor(rect));
|
|
12488
|
+
}
|
|
12489
|
+
function end() {
|
|
12490
|
+
const rect = gesture.rect;
|
|
12491
|
+
settle();
|
|
12492
|
+
if (Math.max(rect.w, rect.h) < MARQUEE_MIN) return;
|
|
12493
|
+
const hits = hitsFor(rect);
|
|
12494
|
+
if (hits.length === 0) return;
|
|
12495
|
+
commitSelection([...gesture.base, ...hits]);
|
|
12496
|
+
}
|
|
12497
|
+
window.addEventListener("pointermove", move);
|
|
12498
|
+
window.addEventListener("pointerup", end);
|
|
12499
|
+
window.addEventListener("pointercancel", cancel);
|
|
12500
|
+
window.addEventListener("keydown", onKeyDown);
|
|
12501
|
+
};
|
|
12304
12502
|
const moveFocus = (node, key) => {
|
|
12305
12503
|
const column = localNodes.filter((item) => Math.abs(item.x - node.x) < 1).sort((a, b) => a.y - b.y);
|
|
12306
12504
|
let target;
|
|
@@ -12325,7 +12523,7 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12325
12523
|
y: Math.min(Math.max(node.y / SCENE_H * 100 + 2, 2), 82),
|
|
12326
12524
|
w: 21,
|
|
12327
12525
|
h: 18,
|
|
12328
|
-
highlighted: node.id
|
|
12526
|
+
highlighted: selectionSet.has(node.id) || traversed.has(node.id)
|
|
12329
12527
|
}));
|
|
12330
12528
|
const issueByNode = (nodeId) => issues.filter((issue) => issue.nodeId === nodeId);
|
|
12331
12529
|
const currentStep = steps[stepIndex];
|
|
@@ -12417,12 +12615,30 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12417
12615
|
ref: planeRef,
|
|
12418
12616
|
role: "application",
|
|
12419
12617
|
"aria-label": "Payment routing graph",
|
|
12618
|
+
"aria-describedby": "routing-selection-status",
|
|
12420
12619
|
tabIndex: 0,
|
|
12421
|
-
onPointerDown:
|
|
12620
|
+
onPointerDown: (event) => {
|
|
12621
|
+
if (event.metaKey || event.ctrlKey) beginMarquee(event);
|
|
12622
|
+
else beginPan(event);
|
|
12623
|
+
},
|
|
12422
12624
|
onKeyDown: (event) => {
|
|
12625
|
+
const modifier = event.metaKey || event.ctrlKey;
|
|
12626
|
+
if (modifier && (event.key === "a" || event.key === "A")) {
|
|
12627
|
+
event.preventDefault();
|
|
12628
|
+
commitSelection(localNodes.map((item) => item.id));
|
|
12629
|
+
return;
|
|
12630
|
+
}
|
|
12423
12631
|
if (event.key === "Escape") {
|
|
12632
|
+
event.preventDefault();
|
|
12633
|
+
if (marqueeRef.current) return;
|
|
12424
12634
|
setIssuesOpen(false);
|
|
12425
|
-
|
|
12635
|
+
clearSelection();
|
|
12636
|
+
return;
|
|
12637
|
+
}
|
|
12638
|
+
if (event.shiftKey && (event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "ArrowLeft" || event.key === "ArrowRight")) {
|
|
12639
|
+
event.preventDefault();
|
|
12640
|
+
nudgeSelection(event.key);
|
|
12641
|
+
return;
|
|
12426
12642
|
}
|
|
12427
12643
|
if (event.key === "+" || event.key === "=") {
|
|
12428
12644
|
setZoom((current) => Math.min(current + 0.1, 1.6));
|
|
@@ -12436,7 +12652,9 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12436
12652
|
}
|
|
12437
12653
|
},
|
|
12438
12654
|
className: cn54(
|
|
12439
|
-
"relative min-h-0 min-w-0 flex-1
|
|
12655
|
+
"relative min-h-0 min-w-0 flex-1 overflow-hidden bg-canvas",
|
|
12656
|
+
// Held Cmd / Ctrl over the background means "drag to select".
|
|
12657
|
+
modifierHeld || marqueeBox ? "cursor-crosshair" : "cursor-grab",
|
|
12440
12658
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue focus-visible:ring-inset"
|
|
12441
12659
|
),
|
|
12442
12660
|
style: {
|
|
@@ -12447,6 +12665,7 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12447
12665
|
backgroundSize: "16px 16px"
|
|
12448
12666
|
},
|
|
12449
12667
|
children: [
|
|
12668
|
+
/* @__PURE__ */ jsx62("p", { id: "routing-selection-status", role: "status", "aria-live": "polite", className: "sr-only", children: selection.length === 0 ? "No nodes selected" : `${selection.length} node${selection.length === 1 ? "" : "s"} selected` }),
|
|
12450
12669
|
/* @__PURE__ */ jsxs59(
|
|
12451
12670
|
"div",
|
|
12452
12671
|
{
|
|
@@ -12491,6 +12710,7 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12491
12710
|
(issue) => issue.kind === "no-fallback"
|
|
12492
12711
|
);
|
|
12493
12712
|
const active = traversed.has(node.id);
|
|
12713
|
+
const isSelected = selectionSet.has(node.id) || marqueeSet.has(node.id);
|
|
12494
12714
|
return /* @__PURE__ */ jsx62(
|
|
12495
12715
|
"div",
|
|
12496
12716
|
{
|
|
@@ -12508,31 +12728,35 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12508
12728
|
metric: node.metric,
|
|
12509
12729
|
trailing: node.trailing,
|
|
12510
12730
|
icon: node.icon,
|
|
12511
|
-
selected:
|
|
12731
|
+
selected: isSelected,
|
|
12512
12732
|
active: active && !unreachable,
|
|
12513
12733
|
unreachable,
|
|
12514
12734
|
noFallback,
|
|
12515
12735
|
conflict: conflict ? "Conflicts with Priority 2" : void 0,
|
|
12516
12736
|
disabled: node.disabled,
|
|
12517
|
-
showHint: focusedId === node.id &&
|
|
12518
|
-
ariaLabel: `${node.type}, ${node.title}${node.metric ? `, ${node.metric}` : ""}${unreachable ? ", unreachable" : ""}`,
|
|
12737
|
+
showHint: focusedId === node.id && isSelected,
|
|
12738
|
+
ariaLabel: `${node.type}, ${node.title}${node.metric ? `, ${node.metric}` : ""}${isSelected ? ", selected" : ""}${unreachable ? ", unreachable" : ""}`,
|
|
12519
12739
|
onNodeSelect: () => selectNode(node),
|
|
12520
12740
|
onFocus: () => setFocusedId(node.id),
|
|
12521
12741
|
onKeyDown: (event) => {
|
|
12742
|
+
if (event.shiftKey && (event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "ArrowLeft" || event.key === "ArrowRight")) {
|
|
12743
|
+
return;
|
|
12744
|
+
}
|
|
12522
12745
|
if (event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
12523
12746
|
event.preventDefault();
|
|
12524
12747
|
moveFocus(node, event.key);
|
|
12748
|
+
return;
|
|
12525
12749
|
}
|
|
12526
|
-
if (event.key === "
|
|
12750
|
+
if (event.key === " " || event.shiftKey && event.key === "Enter") {
|
|
12527
12751
|
event.preventDefault();
|
|
12528
|
-
|
|
12529
|
-
|
|
12530
|
-
|
|
12752
|
+
commitSelection(
|
|
12753
|
+
selectionRef.current.includes(node.id) ? selectionRef.current.filter((id) => id !== node.id) : [...selectionRef.current, node.id]
|
|
12754
|
+
);
|
|
12755
|
+
return;
|
|
12531
12756
|
}
|
|
12532
|
-
if (event.key === "
|
|
12757
|
+
if (event.key === "Enter") {
|
|
12533
12758
|
event.preventDefault();
|
|
12534
|
-
|
|
12535
|
-
if (panelOpen) closePanel();
|
|
12759
|
+
openNodePanel(node);
|
|
12536
12760
|
}
|
|
12537
12761
|
}
|
|
12538
12762
|
}
|
|
@@ -12544,6 +12768,25 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12544
12768
|
]
|
|
12545
12769
|
}
|
|
12546
12770
|
),
|
|
12771
|
+
/* @__PURE__ */ jsx62(
|
|
12772
|
+
"div",
|
|
12773
|
+
{
|
|
12774
|
+
"aria-hidden": "true",
|
|
12775
|
+
"data-state": marqueeBox ? "active" : "idle",
|
|
12776
|
+
className: cn54(
|
|
12777
|
+
"pointer-events-none absolute rounded-xs border border-dashed border-primary bg-primary/10",
|
|
12778
|
+
"transition-opacity duration-150 ease-out",
|
|
12779
|
+
marqueeBox ? "opacity-100" : "opacity-0"
|
|
12780
|
+
),
|
|
12781
|
+
style: {
|
|
12782
|
+
left: marqueeBox?.x ?? 0,
|
|
12783
|
+
top: marqueeBox?.y ?? 0,
|
|
12784
|
+
width: marqueeBox?.w ?? 0,
|
|
12785
|
+
height: marqueeBox?.h ?? 0,
|
|
12786
|
+
zIndex: "var(--z-sticky, 1100)"
|
|
12787
|
+
}
|
|
12788
|
+
}
|
|
12789
|
+
),
|
|
12547
12790
|
/* @__PURE__ */ jsx62("ol", { className: "sr-only", children: graphEdges.map((edge) => {
|
|
12548
12791
|
const from = nodeById.get(edge.from);
|
|
12549
12792
|
const to = nodeById.get(edge.to);
|
|
@@ -12568,8 +12811,7 @@ var PaymentRoutingCanvas = React62.forwardRef(
|
|
|
12568
12811
|
onJump: (id) => {
|
|
12569
12812
|
const target = localNodes.find((node) => node.title === id);
|
|
12570
12813
|
if (!target) return;
|
|
12571
|
-
|
|
12572
|
-
setPanelOpen(true);
|
|
12814
|
+
openNodePanel(target);
|
|
12573
12815
|
setPan({ x: PLANE_PAD - target.x, y: -target.y });
|
|
12574
12816
|
}
|
|
12575
12817
|
}
|
package/dist/styles.css
CHANGED
package/package.json
CHANGED