@uipath/apollo-react 4.49.0 → 4.51.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/canvas/components/AgentCanvas/agent-flow.manifest.d.ts +1 -0
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.cjs +1 -0
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +1 -0
- package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +16 -6
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts +5 -2
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.js +16 -6
- package/dist/canvas/components/ButtonHandle/HandleButton.cjs +21 -10
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts +2 -1
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/HandleButton.js +21 -10
- package/dist/canvas/components/ButtonHandle/HandleLabel.cjs +3 -2
- package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts +2 -1
- package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/HandleLabel.js +3 -2
- package/dist/canvas/components/CaseFlow/case-flow.manifest.d.ts +1 -0
- package/dist/canvas/components/CaseFlow/case-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/ProbeCard/ProbeCard.cjs +482 -0
- package/dist/canvas/components/ProbeCard/ProbeCard.d.ts +48 -0
- package/dist/canvas/components/ProbeCard/ProbeCard.d.ts.map +1 -0
- package/dist/canvas/components/ProbeCard/ProbeCard.js +448 -0
- package/dist/canvas/components/ProbeCard/ProbeResizeHandles.cjs +118 -0
- package/dist/canvas/components/ProbeCard/ProbeResizeHandles.d.ts +18 -0
- package/dist/canvas/components/ProbeCard/ProbeResizeHandles.d.ts.map +1 -0
- package/dist/canvas/components/ProbeCard/ProbeResizeHandles.js +84 -0
- package/dist/canvas/components/ProbeCard/index.cjs +36 -0
- package/dist/canvas/components/ProbeCard/index.d.ts +4 -0
- package/dist/canvas/components/ProbeCard/index.d.ts.map +1 -0
- package/dist/canvas/components/ProbeCard/index.js +2 -0
- package/dist/canvas/components/ProbeCard/useDragSession.cjs +79 -0
- package/dist/canvas/components/ProbeCard/useDragSession.d.ts +11 -0
- package/dist/canvas/components/ProbeCard/useDragSession.d.ts.map +1 -0
- package/dist/canvas/components/ProbeCard/useDragSession.js +45 -0
- package/dist/canvas/components/ProbeCard/useLatestRef.cjs +46 -0
- package/dist/canvas/components/ProbeCard/useLatestRef.d.ts +2 -0
- package/dist/canvas/components/ProbeCard/useLatestRef.d.ts.map +1 -0
- package/dist/canvas/components/ProbeCard/useLatestRef.js +12 -0
- package/dist/canvas/components/index.cjs +61 -54
- package/dist/canvas/components/index.d.ts +1 -0
- package/dist/canvas/components/index.d.ts.map +1 -1
- package/dist/canvas/components/index.js +1 -0
- package/dist/canvas/locales/de.cjs +1 -1
- package/dist/canvas/locales/de.d.ts.map +1 -1
- package/dist/canvas/locales/de.js +1 -1
- package/dist/canvas/locales/es-MX.cjs +1 -1
- package/dist/canvas/locales/es-MX.d.ts.map +1 -1
- package/dist/canvas/locales/es-MX.js +1 -1
- package/dist/canvas/locales/es.cjs +1 -1
- package/dist/canvas/locales/es.d.ts.map +1 -1
- package/dist/canvas/locales/es.js +1 -1
- package/dist/canvas/locales/fr.cjs +1 -1
- package/dist/canvas/locales/fr.d.ts.map +1 -1
- package/dist/canvas/locales/fr.js +1 -1
- package/dist/canvas/locales/ja.cjs +1 -1
- package/dist/canvas/locales/ja.d.ts.map +1 -1
- package/dist/canvas/locales/ja.js +1 -1
- package/dist/canvas/locales/ko.cjs +1 -1
- package/dist/canvas/locales/ko.d.ts.map +1 -1
- package/dist/canvas/locales/ko.js +1 -1
- package/dist/canvas/locales/pt-BR.cjs +1 -1
- package/dist/canvas/locales/pt-BR.d.ts.map +1 -1
- package/dist/canvas/locales/pt-BR.js +1 -1
- package/dist/canvas/locales/pt.cjs +1 -1
- package/dist/canvas/locales/pt.d.ts.map +1 -1
- package/dist/canvas/locales/pt.js +1 -1
- package/dist/canvas/locales/tr.cjs +1 -1
- package/dist/canvas/locales/tr.d.ts.map +1 -1
- package/dist/canvas/locales/tr.js +1 -1
- package/dist/canvas/locales/zh-CN.cjs +1 -1
- package/dist/canvas/locales/zh-CN.d.ts.map +1 -1
- package/dist/canvas/locales/zh-CN.js +1 -1
- package/dist/canvas/locales/zh-TW.cjs +1 -1
- package/dist/canvas/locales/zh-TW.d.ts.map +1 -1
- package/dist/canvas/locales/zh-TW.js +1 -1
- package/dist/canvas/schema/node-definition/handle.cjs +8 -0
- package/dist/canvas/schema/node-definition/handle.d.ts +17 -0
- package/dist/canvas/schema/node-definition/handle.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/handle.js +6 -1
- package/dist/canvas/schema/node-definition/node-manifest.d.ts +4 -0
- package/dist/canvas/schema/node-definition/node-manifest.d.ts.map +1 -1
- package/dist/canvas/schema/node-instance/node.d.ts +4 -0
- package/dist/canvas/schema/node-instance/node.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/components/StoryInfoPanel.d.ts +1 -1
- package/dist/canvas/storybook-utils/components/StoryInfoPanel.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/manifests/index.d.ts +1 -0
- package/dist/canvas/storybook-utils/manifests/index.d.ts.map +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/de.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/de.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/de.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/es-MX.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/es-MX.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/es-MX.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/es.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/es.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/es.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/fr.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/fr.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/fr.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/ja.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/ja.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/ja.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/ko.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/ko.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/ko.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/pt-BR.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/pt-BR.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/pt-BR.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/pt.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/pt.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/pt.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/tr.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/tr.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/tr.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/zh-CN.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/zh-CN.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/zh-CN.js +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/zh-TW.cjs +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/zh-TW.d.ts.map +1 -1
- package/dist/material/components/ap-rich-text-editor/locales/zh-TW.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { Button } from "@uipath/apollo-wind";
|
|
4
|
+
import { ChevronDown, ChevronLeft, ChevronRight, Plus, X } from "lucide-react";
|
|
5
|
+
import { ProbeResizeHandles } from "./ProbeResizeHandles.js";
|
|
6
|
+
import { useDragSession } from "./useDragSession.js";
|
|
7
|
+
import { useLatestRef } from "./useLatestRef.js";
|
|
8
|
+
function WatchValueView({ value, depth = 0 }) {
|
|
9
|
+
if (null === value) return /*#__PURE__*/ jsx("span", {
|
|
10
|
+
className: "text-[11px] font-mono text-foreground-subtle italic",
|
|
11
|
+
children: "null"
|
|
12
|
+
});
|
|
13
|
+
if (void 0 === value) return /*#__PURE__*/ jsx("span", {
|
|
14
|
+
className: "text-[11px] font-mono text-foreground-subtle italic",
|
|
15
|
+
children: "undefined"
|
|
16
|
+
});
|
|
17
|
+
if ('string' == typeof value) return /*#__PURE__*/ jsxs("span", {
|
|
18
|
+
className: "text-[11px] font-mono text-emerald-600 dark:text-emerald-400",
|
|
19
|
+
children: [
|
|
20
|
+
'"',
|
|
21
|
+
value,
|
|
22
|
+
'"'
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
if ('number' == typeof value) return /*#__PURE__*/ jsx("span", {
|
|
26
|
+
className: "text-[11px] font-mono text-blue-600 dark:text-blue-400",
|
|
27
|
+
children: String(value)
|
|
28
|
+
});
|
|
29
|
+
if ('boolean' == typeof value) return /*#__PURE__*/ jsx("span", {
|
|
30
|
+
className: "text-[11px] font-mono text-violet-600 dark:text-violet-400",
|
|
31
|
+
children: String(value)
|
|
32
|
+
});
|
|
33
|
+
if ('object' == typeof value) {
|
|
34
|
+
const isArray = Array.isArray(value);
|
|
35
|
+
const entries = isArray ? value.map((v, i)=>[
|
|
36
|
+
String(i),
|
|
37
|
+
v
|
|
38
|
+
]) : Object.entries(value);
|
|
39
|
+
if (0 === entries.length) return /*#__PURE__*/ jsx("span", {
|
|
40
|
+
className: "text-[11px] font-mono text-foreground-subtle",
|
|
41
|
+
children: isArray ? '[]' : '{}'
|
|
42
|
+
});
|
|
43
|
+
if (depth >= 3) return /*#__PURE__*/ jsx("span", {
|
|
44
|
+
className: "text-[11px] font-mono text-foreground-subtle",
|
|
45
|
+
children: isArray ? `[…${entries.length}]` : '{…}'
|
|
46
|
+
});
|
|
47
|
+
return /*#__PURE__*/ jsx("div", {
|
|
48
|
+
className: "pl-2 space-y-0.5",
|
|
49
|
+
children: entries.map(([k, v])=>/*#__PURE__*/ jsxs("div", {
|
|
50
|
+
className: "flex gap-1 text-[11px] font-mono min-w-0",
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ jsxs("span", {
|
|
53
|
+
className: "text-foreground-muted shrink-0",
|
|
54
|
+
children: [
|
|
55
|
+
k,
|
|
56
|
+
":"
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ jsx(WatchValueView, {
|
|
60
|
+
value: v,
|
|
61
|
+
depth: depth + 1
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}, k))
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return /*#__PURE__*/ jsx("span", {
|
|
68
|
+
className: "text-[11px] font-mono text-foreground-muted",
|
|
69
|
+
children: String(value)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function RemoveButton({ onRemove, label }) {
|
|
73
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
74
|
+
variant: "ghost",
|
|
75
|
+
size: "3xs",
|
|
76
|
+
icon: true,
|
|
77
|
+
onMouseDown: (e)=>e.stopPropagation(),
|
|
78
|
+
onClick: onRemove,
|
|
79
|
+
className: "opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity shrink-0 self-center",
|
|
80
|
+
title: label,
|
|
81
|
+
"aria-label": label,
|
|
82
|
+
children: /*#__PURE__*/ jsx(X, {})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function DisclosureButton({ expanded, onToggle, label }) {
|
|
86
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
87
|
+
variant: "ghost",
|
|
88
|
+
size: "3xs",
|
|
89
|
+
icon: true,
|
|
90
|
+
onMouseDown: (e)=>e.stopPropagation(),
|
|
91
|
+
onClick: onToggle,
|
|
92
|
+
title: label,
|
|
93
|
+
"aria-label": label,
|
|
94
|
+
"aria-expanded": expanded,
|
|
95
|
+
children: expanded ? /*#__PURE__*/ jsx(ChevronDown, {}) : /*#__PURE__*/ jsx(ChevronRight, {})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function WatchRow({ watch, onChange, onRemove }) {
|
|
99
|
+
const [expr, setExpr] = useState(watch.expression);
|
|
100
|
+
const [expanded, setExpanded] = useState(true);
|
|
101
|
+
useEffect(()=>{
|
|
102
|
+
setExpr(watch.expression);
|
|
103
|
+
}, [
|
|
104
|
+
watch.expression
|
|
105
|
+
]);
|
|
106
|
+
const commit = ()=>{
|
|
107
|
+
if (expr !== watch.expression) onChange(expr);
|
|
108
|
+
};
|
|
109
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
110
|
+
className: "group px-2 py-1 border-b border-border-subtle last:border-b-0",
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ jsxs("div", {
|
|
113
|
+
className: "flex items-center gap-1 min-w-0",
|
|
114
|
+
children: [
|
|
115
|
+
/*#__PURE__*/ jsx(DisclosureButton, {
|
|
116
|
+
expanded: expanded,
|
|
117
|
+
onToggle: ()=>setExpanded((e)=>!e),
|
|
118
|
+
label: "Toggle value"
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ jsx("input", {
|
|
121
|
+
value: expr,
|
|
122
|
+
onChange: (e)=>setExpr(e.target.value),
|
|
123
|
+
onBlur: commit,
|
|
124
|
+
onKeyDown: (e)=>{
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
if ('Enter' === e.key) commit();
|
|
127
|
+
},
|
|
128
|
+
placeholder: "e.g. output.items[0].id",
|
|
129
|
+
"aria-label": "Watch expression",
|
|
130
|
+
"data-probe-watch-input": "true",
|
|
131
|
+
className: "flex-1 min-w-0 text-sm font-mono text-foreground-secondary bg-transparent outline-none border-b border-transparent focus:border-foreground-accent"
|
|
132
|
+
}),
|
|
133
|
+
/*#__PURE__*/ jsx(RemoveButton, {
|
|
134
|
+
onRemove: onRemove,
|
|
135
|
+
label: "Remove watch"
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
expanded && watch.hasValue && /*#__PURE__*/ jsx("div", {
|
|
140
|
+
className: "pl-2 pt-0.5",
|
|
141
|
+
children: /*#__PURE__*/ jsx(WatchValueView, {
|
|
142
|
+
value: watch.value
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const PAN_ON_SCROLL_SPEED = 0.5;
|
|
149
|
+
function ProbeCardComponent({ watches, iterationControl, onAddWatch, onUpdateWatch, onRemoveWatch, onDragStart, onDrag, onDragEnd, onResizeStart, onResize, onResizeEnd, onClose, onCanvasPan, onCanvasZoom }) {
|
|
150
|
+
const [hovered, setHovered] = useState(false);
|
|
151
|
+
const cardRef = useRef(null);
|
|
152
|
+
const watchListRef = useRef(null);
|
|
153
|
+
const pendingFocusNewWatchRef = useRef(false);
|
|
154
|
+
const previousWatchCountRef = useRef(watches.length);
|
|
155
|
+
const onCloseRef = useLatestRef(onClose);
|
|
156
|
+
const onCanvasPanRef = useLatestRef(onCanvasPan);
|
|
157
|
+
const onCanvasZoomRef = useLatestRef(onCanvasZoom);
|
|
158
|
+
const isSpacePressedRef = useRef(false);
|
|
159
|
+
const canvasPanCleanupRef = useRef(null);
|
|
160
|
+
const canvasPanLastPointRef = useRef(null);
|
|
161
|
+
const suppressNextClickRef = useRef(false);
|
|
162
|
+
const handleHeaderMouseDown = useDragSession({
|
|
163
|
+
onStart: onDragStart,
|
|
164
|
+
onMove: onDrag,
|
|
165
|
+
onEnd: onDragEnd
|
|
166
|
+
});
|
|
167
|
+
const handleAddWatch = ()=>{
|
|
168
|
+
pendingFocusNewWatchRef.current = true;
|
|
169
|
+
onAddWatch();
|
|
170
|
+
};
|
|
171
|
+
useLayoutEffect(()=>{
|
|
172
|
+
const previousCount = previousWatchCountRef.current;
|
|
173
|
+
previousWatchCountRef.current = watches.length;
|
|
174
|
+
if (!pendingFocusNewWatchRef.current || watches.length <= previousCount) return;
|
|
175
|
+
pendingFocusNewWatchRef.current = false;
|
|
176
|
+
const inputs = watchListRef.current?.querySelectorAll('[data-probe-watch-input="true"]');
|
|
177
|
+
const input = inputs?.[inputs.length - 1];
|
|
178
|
+
if (!input) return;
|
|
179
|
+
input.scrollIntoView({
|
|
180
|
+
block: 'nearest'
|
|
181
|
+
});
|
|
182
|
+
input.focus({
|
|
183
|
+
preventScroll: true
|
|
184
|
+
});
|
|
185
|
+
}, [
|
|
186
|
+
watches.length
|
|
187
|
+
]);
|
|
188
|
+
useEffect(()=>{
|
|
189
|
+
const handler = (e)=>{
|
|
190
|
+
const card = cardRef.current;
|
|
191
|
+
if (!card || !card.contains(document.activeElement)) return;
|
|
192
|
+
if ('Escape' === e.key) {
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
onCloseRef.current();
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if ('ArrowDown' === e.key || 'ArrowUp' === e.key) {
|
|
199
|
+
const inputs = Array.from(card.querySelectorAll('[data-probe-watch-input="true"]'));
|
|
200
|
+
const idx = inputs.indexOf(document.activeElement);
|
|
201
|
+
if (-1 === idx) return;
|
|
202
|
+
const next = inputs['ArrowDown' === e.key ? idx + 1 : idx - 1];
|
|
203
|
+
if (next) {
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
e.stopPropagation();
|
|
206
|
+
next.focus();
|
|
207
|
+
next.select();
|
|
208
|
+
}
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if ('Delete' !== e.key && 'Backspace' !== e.key) return;
|
|
212
|
+
const active = document.activeElement;
|
|
213
|
+
const isEditable = !!active && ('INPUT' === active.tagName || 'TEXTAREA' === active.tagName || active.isContentEditable);
|
|
214
|
+
if (isEditable) return;
|
|
215
|
+
e.stopPropagation();
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
onCloseRef.current();
|
|
218
|
+
};
|
|
219
|
+
window.addEventListener('keydown', handler, true);
|
|
220
|
+
return ()=>window.removeEventListener('keydown', handler, true);
|
|
221
|
+
}, [
|
|
222
|
+
onCloseRef
|
|
223
|
+
]);
|
|
224
|
+
useEffect(()=>{
|
|
225
|
+
const handleKeyDown = (e)=>{
|
|
226
|
+
if (' ' === e.key || 'Space' === e.code) isSpacePressedRef.current = true;
|
|
227
|
+
};
|
|
228
|
+
const handleKeyUp = (e)=>{
|
|
229
|
+
if (' ' === e.key || 'Space' === e.code) isSpacePressedRef.current = false;
|
|
230
|
+
};
|
|
231
|
+
window.addEventListener('keydown', handleKeyDown, true);
|
|
232
|
+
window.addEventListener('keyup', handleKeyUp, true);
|
|
233
|
+
return ()=>{
|
|
234
|
+
window.removeEventListener('keydown', handleKeyDown, true);
|
|
235
|
+
window.removeEventListener('keyup', handleKeyUp, true);
|
|
236
|
+
canvasPanCleanupRef.current?.();
|
|
237
|
+
};
|
|
238
|
+
}, []);
|
|
239
|
+
const startCanvasPan = (e)=>{
|
|
240
|
+
if (!onCanvasPanRef.current) return;
|
|
241
|
+
e.stopPropagation();
|
|
242
|
+
e.preventDefault();
|
|
243
|
+
suppressNextClickRef.current = true;
|
|
244
|
+
canvasPanCleanupRef.current?.();
|
|
245
|
+
canvasPanLastPointRef.current = {
|
|
246
|
+
x: e.clientX,
|
|
247
|
+
y: e.clientY
|
|
248
|
+
};
|
|
249
|
+
const handleMove = (ev)=>{
|
|
250
|
+
const last = canvasPanLastPointRef.current;
|
|
251
|
+
if (!last) return;
|
|
252
|
+
const next = {
|
|
253
|
+
x: ev.clientX,
|
|
254
|
+
y: ev.clientY
|
|
255
|
+
};
|
|
256
|
+
canvasPanLastPointRef.current = next;
|
|
257
|
+
onCanvasPanRef.current?.({
|
|
258
|
+
x: next.x - last.x,
|
|
259
|
+
y: next.y - last.y
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
const handleUp = ()=>{
|
|
263
|
+
window.removeEventListener('mousemove', handleMove);
|
|
264
|
+
window.removeEventListener('mouseup', handleUp);
|
|
265
|
+
canvasPanCleanupRef.current = null;
|
|
266
|
+
canvasPanLastPointRef.current = null;
|
|
267
|
+
window.setTimeout(()=>{
|
|
268
|
+
suppressNextClickRef.current = false;
|
|
269
|
+
}, 0);
|
|
270
|
+
};
|
|
271
|
+
canvasPanCleanupRef.current = handleUp;
|
|
272
|
+
window.addEventListener('mousemove', handleMove);
|
|
273
|
+
window.addEventListener('mouseup', handleUp);
|
|
274
|
+
};
|
|
275
|
+
const handleMouseDownCapture = (e)=>{
|
|
276
|
+
const target = e.target instanceof Element ? e.target : null;
|
|
277
|
+
const startedMiddlePan = 1 === e.button;
|
|
278
|
+
const startedSpacePan = 0 === e.button && isSpacePressedRef.current && !isInteractiveTarget(target);
|
|
279
|
+
if (startedMiddlePan || startedSpacePan) return void startCanvasPan(e);
|
|
280
|
+
if (0 === e.button && !isInteractiveTarget(target)) cardRef.current?.focus();
|
|
281
|
+
};
|
|
282
|
+
const handleClickCapture = (e)=>{
|
|
283
|
+
if (!suppressNextClickRef.current) return;
|
|
284
|
+
suppressNextClickRef.current = false;
|
|
285
|
+
e.stopPropagation();
|
|
286
|
+
e.preventDefault();
|
|
287
|
+
};
|
|
288
|
+
useEffect(()=>{
|
|
289
|
+
const card = cardRef.current;
|
|
290
|
+
if (!card) return;
|
|
291
|
+
const onWheel = (e)=>{
|
|
292
|
+
if (e.ctrlKey) {
|
|
293
|
+
if (onCanvasZoomRef.current) {
|
|
294
|
+
e.stopPropagation();
|
|
295
|
+
e.preventDefault();
|
|
296
|
+
onCanvasZoomRef.current({
|
|
297
|
+
clientX: e.clientX,
|
|
298
|
+
clientY: e.clientY,
|
|
299
|
+
deltaY: e.deltaY,
|
|
300
|
+
deltaMode: e.deltaMode,
|
|
301
|
+
ctrlKey: e.ctrlKey
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const target = e.target instanceof Node ? e.target : null;
|
|
307
|
+
if (target && watchListRef.current?.contains(target) && canScrollVertically(watchListRef.current, e.deltaY)) return void e.stopPropagation();
|
|
308
|
+
if (onCanvasPanRef.current) {
|
|
309
|
+
e.stopPropagation();
|
|
310
|
+
e.preventDefault();
|
|
311
|
+
const deltaNormalize = 1 === e.deltaMode ? 20 : 1;
|
|
312
|
+
let deltaX = e.deltaX * deltaNormalize;
|
|
313
|
+
let deltaY = e.deltaY * deltaNormalize;
|
|
314
|
+
if (!isMac() && e.shiftKey) {
|
|
315
|
+
deltaX = e.deltaY * deltaNormalize;
|
|
316
|
+
deltaY = 0;
|
|
317
|
+
}
|
|
318
|
+
onCanvasPanRef.current({
|
|
319
|
+
x: -deltaX * PAN_ON_SCROLL_SPEED,
|
|
320
|
+
y: -deltaY * PAN_ON_SCROLL_SPEED
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
card.addEventListener('wheel', onWheel, {
|
|
325
|
+
passive: false
|
|
326
|
+
});
|
|
327
|
+
return ()=>card.removeEventListener('wheel', onWheel);
|
|
328
|
+
}, [
|
|
329
|
+
onCanvasZoomRef,
|
|
330
|
+
onCanvasPanRef
|
|
331
|
+
]);
|
|
332
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
333
|
+
ref: cardRef,
|
|
334
|
+
tabIndex: 0,
|
|
335
|
+
role: "group",
|
|
336
|
+
"aria-label": "Probe",
|
|
337
|
+
className: "relative h-full flex flex-col rounded-[20px] border border-dashed border-border bg-surface-raised shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-foreground-accent-muted nodrag",
|
|
338
|
+
onMouseDownCapture: handleMouseDownCapture,
|
|
339
|
+
onClickCapture: handleClickCapture,
|
|
340
|
+
onMouseDown: (e)=>e.stopPropagation(),
|
|
341
|
+
onClick: (e)=>e.stopPropagation(),
|
|
342
|
+
onKeyDown: (e)=>e.stopPropagation(),
|
|
343
|
+
onMouseEnter: ()=>setHovered(true),
|
|
344
|
+
onMouseLeave: ()=>setHovered(false),
|
|
345
|
+
children: [
|
|
346
|
+
/*#__PURE__*/ jsxs("div", {
|
|
347
|
+
onMouseDown: handleHeaderMouseDown,
|
|
348
|
+
className: "flex items-center gap-2 px-3 py-2 border-b border-border-subtle bg-surface-overlay/30 cursor-move select-none shrink-0",
|
|
349
|
+
children: [
|
|
350
|
+
/*#__PURE__*/ jsx("span", {
|
|
351
|
+
className: "min-w-0 flex-1 truncate text-xs font-semibold text-foreground",
|
|
352
|
+
children: "Probe"
|
|
353
|
+
}),
|
|
354
|
+
iterationControl && /*#__PURE__*/ jsxs("div", {
|
|
355
|
+
className: "flex items-center gap-0.5 shrink-0",
|
|
356
|
+
children: [
|
|
357
|
+
/*#__PURE__*/ jsx(Button, {
|
|
358
|
+
variant: "ghost",
|
|
359
|
+
size: "3xs",
|
|
360
|
+
icon: true,
|
|
361
|
+
disabled: 0 === iterationControl.current,
|
|
362
|
+
onMouseDown: (e)=>e.stopPropagation(),
|
|
363
|
+
onClick: iterationControl.onPrev,
|
|
364
|
+
title: "Previous iteration",
|
|
365
|
+
"aria-label": "Previous iteration",
|
|
366
|
+
children: /*#__PURE__*/ jsx(ChevronLeft, {})
|
|
367
|
+
}),
|
|
368
|
+
/*#__PURE__*/ jsxs("span", {
|
|
369
|
+
className: "text-[10px] font-mono text-foreground-subtle tabular-nums select-none",
|
|
370
|
+
children: [
|
|
371
|
+
iterationControl.current + 1,
|
|
372
|
+
"/",
|
|
373
|
+
iterationControl.total
|
|
374
|
+
]
|
|
375
|
+
}),
|
|
376
|
+
/*#__PURE__*/ jsx(Button, {
|
|
377
|
+
variant: "ghost",
|
|
378
|
+
size: "3xs",
|
|
379
|
+
icon: true,
|
|
380
|
+
disabled: iterationControl.current === iterationControl.total - 1,
|
|
381
|
+
onMouseDown: (e)=>e.stopPropagation(),
|
|
382
|
+
onClick: iterationControl.onNext,
|
|
383
|
+
title: "Next iteration",
|
|
384
|
+
"aria-label": "Next iteration",
|
|
385
|
+
children: /*#__PURE__*/ jsx(ChevronRight, {})
|
|
386
|
+
})
|
|
387
|
+
]
|
|
388
|
+
}),
|
|
389
|
+
/*#__PURE__*/ jsx(Button, {
|
|
390
|
+
variant: "ghost",
|
|
391
|
+
size: "3xs",
|
|
392
|
+
icon: true,
|
|
393
|
+
onMouseDown: (e)=>e.stopPropagation(),
|
|
394
|
+
onClick: handleAddWatch,
|
|
395
|
+
title: "Add watch",
|
|
396
|
+
"aria-label": "Add watch",
|
|
397
|
+
children: /*#__PURE__*/ jsx(Plus, {})
|
|
398
|
+
}),
|
|
399
|
+
/*#__PURE__*/ jsx(Button, {
|
|
400
|
+
variant: "ghost",
|
|
401
|
+
size: "3xs",
|
|
402
|
+
icon: true,
|
|
403
|
+
onMouseDown: (e)=>e.stopPropagation(),
|
|
404
|
+
onClick: onClose,
|
|
405
|
+
title: "Remove probe",
|
|
406
|
+
"aria-label": "Remove probe",
|
|
407
|
+
children: /*#__PURE__*/ jsx(X, {})
|
|
408
|
+
})
|
|
409
|
+
]
|
|
410
|
+
}),
|
|
411
|
+
/*#__PURE__*/ jsx("div", {
|
|
412
|
+
ref: watchListRef,
|
|
413
|
+
className: "flex-1 min-h-0 overflow-y-auto",
|
|
414
|
+
children: 0 === watches.length ? /*#__PURE__*/ jsx("div", {
|
|
415
|
+
className: "flex items-center justify-center h-full px-4",
|
|
416
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
417
|
+
className: "text-[11px] text-foreground-subtle text-center leading-relaxed",
|
|
418
|
+
children: "No watches — use + to add one"
|
|
419
|
+
})
|
|
420
|
+
}) : watches.map((w)=>/*#__PURE__*/ jsx(WatchRow, {
|
|
421
|
+
watch: w,
|
|
422
|
+
onChange: (expr)=>onUpdateWatch(w.id, expr),
|
|
423
|
+
onRemove: ()=>onRemoveWatch(w.id)
|
|
424
|
+
}, w.id))
|
|
425
|
+
}),
|
|
426
|
+
/*#__PURE__*/ jsx(ProbeResizeHandles, {
|
|
427
|
+
active: hovered,
|
|
428
|
+
onResizeStart: onResizeStart,
|
|
429
|
+
onResize: onResize,
|
|
430
|
+
onResizeEnd: onResizeEnd
|
|
431
|
+
})
|
|
432
|
+
]
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
const ProbeCard = /*#__PURE__*/ memo(ProbeCardComponent);
|
|
436
|
+
function isInteractiveTarget(target) {
|
|
437
|
+
return !!target?.closest('input, textarea, select, button, a, [contenteditable], [role="button"], [role="menuitem"]');
|
|
438
|
+
}
|
|
439
|
+
function isMac() {
|
|
440
|
+
return "u" > typeof navigator && navigator.userAgent.includes('Mac');
|
|
441
|
+
}
|
|
442
|
+
function canScrollVertically(element, deltaY) {
|
|
443
|
+
if (0 === deltaY) return false;
|
|
444
|
+
const maxScrollTop = element.scrollHeight - element.clientHeight;
|
|
445
|
+
if (maxScrollTop <= 0) return false;
|
|
446
|
+
return deltaY < 0 ? element.scrollTop > 0 : element.scrollTop < maxScrollTop;
|
|
447
|
+
}
|
|
448
|
+
export { ProbeCard };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
ProbeResizeHandles: ()=>ProbeResizeHandles
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_useDragSession_cjs_namespaceObject = require("./useDragSession.cjs");
|
|
31
|
+
const HANDLES = [
|
|
32
|
+
{
|
|
33
|
+
edges: {
|
|
34
|
+
top: true,
|
|
35
|
+
left: true
|
|
36
|
+
},
|
|
37
|
+
style: {
|
|
38
|
+
top: -4,
|
|
39
|
+
left: -4
|
|
40
|
+
},
|
|
41
|
+
cursor: 'nwse-resize'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
edges: {
|
|
45
|
+
top: true,
|
|
46
|
+
right: true
|
|
47
|
+
},
|
|
48
|
+
style: {
|
|
49
|
+
top: -4,
|
|
50
|
+
right: -4
|
|
51
|
+
},
|
|
52
|
+
cursor: 'nesw-resize'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
edges: {
|
|
56
|
+
bottom: true,
|
|
57
|
+
right: true
|
|
58
|
+
},
|
|
59
|
+
style: {
|
|
60
|
+
bottom: -4,
|
|
61
|
+
right: -4
|
|
62
|
+
},
|
|
63
|
+
cursor: 'nwse-resize'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
edges: {
|
|
67
|
+
bottom: true,
|
|
68
|
+
left: true
|
|
69
|
+
},
|
|
70
|
+
style: {
|
|
71
|
+
bottom: -4,
|
|
72
|
+
left: -4
|
|
73
|
+
},
|
|
74
|
+
cursor: 'nesw-resize'
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
function ProbeResizeHandles({ active, onResizeStart, onResize, onResizeEnd }) {
|
|
78
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
79
|
+
"aria-hidden": true,
|
|
80
|
+
className: `pointer-events-none absolute inset-0 transition-opacity duration-100 ${active ? 'opacity-100' : 'opacity-0'}`,
|
|
81
|
+
children: [
|
|
82
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
83
|
+
className: "absolute inset-0 rounded-[20px] outline outline-2 outline-foreground-accent-muted"
|
|
84
|
+
}),
|
|
85
|
+
HANDLES.map((h, i)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ResizeHandle, {
|
|
86
|
+
edges: h.edges,
|
|
87
|
+
style: h.style,
|
|
88
|
+
cursor: h.cursor,
|
|
89
|
+
onResizeStart: onResizeStart,
|
|
90
|
+
onResize: onResize,
|
|
91
|
+
onResizeEnd: onResizeEnd
|
|
92
|
+
}, i))
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function ResizeHandle({ edges, style, cursor, onResizeStart, onResize, onResizeEnd }) {
|
|
97
|
+
const handleMouseDown = (0, external_useDragSession_cjs_namespaceObject.useDragSession)({
|
|
98
|
+
onStart: onResizeStart,
|
|
99
|
+
onMove: (delta)=>onResize(delta, edges),
|
|
100
|
+
onEnd: onResizeEnd
|
|
101
|
+
});
|
|
102
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
103
|
+
onMouseDown: handleMouseDown,
|
|
104
|
+
style: {
|
|
105
|
+
...style,
|
|
106
|
+
cursor,
|
|
107
|
+
position: 'absolute'
|
|
108
|
+
},
|
|
109
|
+
className: "pointer-events-auto h-2 w-2 rounded-full bg-brand"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
exports.ProbeResizeHandles = __webpack_exports__.ProbeResizeHandles;
|
|
113
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
114
|
+
"ProbeResizeHandles"
|
|
115
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
116
|
+
Object.defineProperty(exports, '__esModule', {
|
|
117
|
+
value: true
|
|
118
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ResizeEdges {
|
|
2
|
+
left?: boolean;
|
|
3
|
+
right?: boolean;
|
|
4
|
+
top?: boolean;
|
|
5
|
+
bottom?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ProbeResizeHandlesProps {
|
|
8
|
+
active: boolean;
|
|
9
|
+
onResizeStart: () => void;
|
|
10
|
+
onResize: (cumulativeDelta: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}, edges: ResizeEdges) => void;
|
|
14
|
+
onResizeEnd: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function ProbeResizeHandles({ active, onResizeStart, onResize, onResizeEnd, }: ProbeResizeHandlesProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=ProbeResizeHandles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProbeResizeHandles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ProbeCard/ProbeResizeHandles.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,uBAAuB;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,EAAE,CAAC,eAAe,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAClF,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AASD,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,aAAa,EACb,QAAQ,EACR,WAAW,GACZ,EAAE,uBAAuB,2CAoBzB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useDragSession } from "./useDragSession.js";
|
|
3
|
+
const HANDLES = [
|
|
4
|
+
{
|
|
5
|
+
edges: {
|
|
6
|
+
top: true,
|
|
7
|
+
left: true
|
|
8
|
+
},
|
|
9
|
+
style: {
|
|
10
|
+
top: -4,
|
|
11
|
+
left: -4
|
|
12
|
+
},
|
|
13
|
+
cursor: 'nwse-resize'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
edges: {
|
|
17
|
+
top: true,
|
|
18
|
+
right: true
|
|
19
|
+
},
|
|
20
|
+
style: {
|
|
21
|
+
top: -4,
|
|
22
|
+
right: -4
|
|
23
|
+
},
|
|
24
|
+
cursor: 'nesw-resize'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
edges: {
|
|
28
|
+
bottom: true,
|
|
29
|
+
right: true
|
|
30
|
+
},
|
|
31
|
+
style: {
|
|
32
|
+
bottom: -4,
|
|
33
|
+
right: -4
|
|
34
|
+
},
|
|
35
|
+
cursor: 'nwse-resize'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
edges: {
|
|
39
|
+
bottom: true,
|
|
40
|
+
left: true
|
|
41
|
+
},
|
|
42
|
+
style: {
|
|
43
|
+
bottom: -4,
|
|
44
|
+
left: -4
|
|
45
|
+
},
|
|
46
|
+
cursor: 'nesw-resize'
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
function ProbeResizeHandles({ active, onResizeStart, onResize, onResizeEnd }) {
|
|
50
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
51
|
+
"aria-hidden": true,
|
|
52
|
+
className: `pointer-events-none absolute inset-0 transition-opacity duration-100 ${active ? 'opacity-100' : 'opacity-0'}`,
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ jsx("div", {
|
|
55
|
+
className: "absolute inset-0 rounded-[20px] outline outline-2 outline-foreground-accent-muted"
|
|
56
|
+
}),
|
|
57
|
+
HANDLES.map((h, i)=>/*#__PURE__*/ jsx(ResizeHandle, {
|
|
58
|
+
edges: h.edges,
|
|
59
|
+
style: h.style,
|
|
60
|
+
cursor: h.cursor,
|
|
61
|
+
onResizeStart: onResizeStart,
|
|
62
|
+
onResize: onResize,
|
|
63
|
+
onResizeEnd: onResizeEnd
|
|
64
|
+
}, i))
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function ResizeHandle({ edges, style, cursor, onResizeStart, onResize, onResizeEnd }) {
|
|
69
|
+
const handleMouseDown = useDragSession({
|
|
70
|
+
onStart: onResizeStart,
|
|
71
|
+
onMove: (delta)=>onResize(delta, edges),
|
|
72
|
+
onEnd: onResizeEnd
|
|
73
|
+
});
|
|
74
|
+
return /*#__PURE__*/ jsx("div", {
|
|
75
|
+
onMouseDown: handleMouseDown,
|
|
76
|
+
style: {
|
|
77
|
+
...style,
|
|
78
|
+
cursor,
|
|
79
|
+
position: 'absolute'
|
|
80
|
+
},
|
|
81
|
+
className: "pointer-events-auto h-2 w-2 rounded-full bg-brand"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export { ProbeResizeHandles };
|