@uipath/apollo-react 7.15.3 → 7.16.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/Edges/CanvasEdge.cjs +4 -2
- package/dist/canvas/components/Edges/CanvasEdge.d.ts.map +1 -1
- package/dist/canvas/components/Edges/CanvasEdge.js +4 -2
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.cjs +8 -3
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts +2 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.js +9 -4
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.cjs +63 -37
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts +2 -0
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.js +64 -38
- package/dist/canvas/components/Edges/shared/waypoints.cjs +149 -5
- package/dist/canvas/components/Edges/shared/waypoints.d.ts +5 -0
- package/dist/canvas/components/Edges/shared/waypoints.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/waypoints.js +133 -1
- package/dist/canvas/components/JsonTree/index.cjs +4 -0
- package/dist/canvas/components/JsonTree/index.d.ts +2 -2
- package/dist/canvas/components/JsonTree/index.d.ts.map +1 -1
- package/dist/canvas/components/JsonTree/index.js +2 -2
- package/dist/canvas/components/NodeIOView/NodeIOView.cjs +2 -1
- package/dist/canvas/components/NodeIOView/NodeIOView.d.ts +1 -1
- package/dist/canvas/components/NodeIOView/NodeIOView.d.ts.map +1 -1
- package/dist/canvas/components/NodeIOView/NodeIOView.js +2 -1
- package/dist/canvas/components/NodeIOView/NodeIOView.types.d.ts +2 -1
- package/dist/canvas/components/NodeIOView/NodeIOView.types.d.ts.map +1 -1
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.cjs +503 -327
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.d.ts +2 -2
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.d.ts.map +1 -1
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.js +503 -327
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.strings.cjs +168 -0
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.strings.d.ts +3 -0
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.strings.d.ts.map +1 -0
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.strings.js +134 -0
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.d.ts +58 -16
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.d.ts.map +1 -1
- package/dist/canvas/components/NodeVariablesPanel/index.d.ts +1 -1
- package/dist/canvas/components/NodeVariablesPanel/index.d.ts.map +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
- package/package.json +5 -5
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Collapsible, CollapsibleContent, CollapsibleTrigger, cn } from "@uipath/apollo-wind";
|
|
3
3
|
import { ArrowDown, ArrowUp, ChevronDown, MousePointerClick, Pencil, Plus, SquareStack, Trash2, Variable } from "lucide-react";
|
|
4
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
-
import { useSafeLingui } from "../../../i18n/index.js";
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
6
5
|
import { Asset } from "../../../icons/index.js";
|
|
7
6
|
import { CanvasTooltip } from "../CanvasTooltip.js";
|
|
8
|
-
import { JsonTreeToolbar, JsonTreeView, appendPathSegment, buildJsonTree, collectContainerPaths, flattenJsonTree, isArrayItemTemplateRoot, isPathCollapsed, schemaDisplayType } from "../JsonTree/index.js";
|
|
7
|
+
import { JsonTreeToolbar, JsonTreeView, appendPathSegment, buildJsonTree, collectContainerPaths, flattenJsonTree, hasVisibleRows, isArrayItemTemplateRoot, isPathCollapsed, schemaDisplayType } from "../JsonTree/index.js";
|
|
9
8
|
import { NodeVariableEditDialog } from "./NodeVariableEditDialog.js";
|
|
9
|
+
import { useNodeVariablesPanelStrings } from "./NodeVariablesPanel.strings.js";
|
|
10
10
|
import { isAddableSection } from "./NodeVariablesPanel.types.js";
|
|
11
11
|
const SECTIONS = [
|
|
12
12
|
'inputs',
|
|
@@ -40,7 +40,64 @@ const SECTION_ICONS = {
|
|
|
40
40
|
};
|
|
41
41
|
const COUNT_CLASS = 'ml-auto shrink-0 font-mono text-[10px] text-foreground-muted';
|
|
42
42
|
const EMPTY_MESSAGE_CLASS = 'px-3 py-6 text-center text-xs text-foreground-muted';
|
|
43
|
+
const DEFAULT_EXPANDED_SECTIONS = [
|
|
44
|
+
'nodes'
|
|
45
|
+
];
|
|
46
|
+
const REVEAL_HIGHLIGHT_MS = 1500;
|
|
47
|
+
const mapSections = (fn)=>Object.fromEntries(SECTIONS.map((section)=>[
|
|
48
|
+
section,
|
|
49
|
+
fn(section)
|
|
50
|
+
]));
|
|
51
|
+
const NO_PATHS = {
|
|
52
|
+
inputs: {},
|
|
53
|
+
outputs: {},
|
|
54
|
+
variables: {},
|
|
55
|
+
assets: {},
|
|
56
|
+
nodes: {}
|
|
57
|
+
};
|
|
58
|
+
const NO_OVERLAY = {
|
|
59
|
+
closedSections: [],
|
|
60
|
+
collapsedPaths: NO_PATHS
|
|
61
|
+
};
|
|
62
|
+
const inSectionOrder = (sections)=>{
|
|
63
|
+
const set = new Set(sections);
|
|
64
|
+
return SECTIONS.filter((section)=>set.has(section));
|
|
65
|
+
};
|
|
66
|
+
const definedFields = (value)=>Object.fromEntries(Object.entries(value ?? {}).filter(([, field])=>void 0 !== field));
|
|
67
|
+
function mergeDecoration(builtIn, host) {
|
|
68
|
+
if (!builtIn || !host) return host ?? builtIn;
|
|
69
|
+
const badge = builtIn.badge || host.badge ? {
|
|
70
|
+
...builtIn.badge,
|
|
71
|
+
...definedFields(host.badge)
|
|
72
|
+
} : void 0;
|
|
73
|
+
return {
|
|
74
|
+
...builtIn,
|
|
75
|
+
...definedFields(host),
|
|
76
|
+
badge
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function findByReference(nodes, matches) {
|
|
80
|
+
const stack = nodes.map((node)=>({
|
|
81
|
+
node,
|
|
82
|
+
ancestors: []
|
|
83
|
+
}));
|
|
84
|
+
while(stack.length > 0){
|
|
85
|
+
const { node, ancestors } = stack.pop();
|
|
86
|
+
if (matches(node)) return {
|
|
87
|
+
node,
|
|
88
|
+
ancestors
|
|
89
|
+
};
|
|
90
|
+
for (const child of node.children ?? [])stack.push({
|
|
91
|
+
node: child,
|
|
92
|
+
ancestors: [
|
|
93
|
+
...ancestors,
|
|
94
|
+
node.path
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
43
99
|
const countEntries = (nodes)=>nodes?.filter((node)=>!isArrayItemTemplateRoot(node)).length ?? 0;
|
|
100
|
+
const outputCountOf = (source, node)=>source?.outputCount ?? countEntries(node.children);
|
|
44
101
|
const VIRTUALIZE_THRESHOLD = 500;
|
|
45
102
|
function exceedsVirtualizeThreshold(nodes) {
|
|
46
103
|
let count = 0;
|
|
@@ -134,21 +191,99 @@ function useScrollEdges() {
|
|
|
134
191
|
onScroll: update
|
|
135
192
|
};
|
|
136
193
|
}
|
|
194
|
+
function useSectionShape(tree, openPaths) {
|
|
195
|
+
const containerPaths = useMemo(()=>collectContainerPaths(tree), [
|
|
196
|
+
tree
|
|
197
|
+
]);
|
|
198
|
+
const collapsed = useMemo(()=>Object.fromEntries(containerPaths.map(({ path })=>[
|
|
199
|
+
path,
|
|
200
|
+
!isPathCollapsed(openPaths, path)
|
|
201
|
+
])), [
|
|
202
|
+
containerPaths,
|
|
203
|
+
openPaths
|
|
204
|
+
]);
|
|
205
|
+
const virtualize = useMemo(()=>exceedsVirtualizeThreshold(tree), [
|
|
206
|
+
tree
|
|
207
|
+
]);
|
|
208
|
+
const expandablePaths = useMemo(()=>objectPaths(tree), [
|
|
209
|
+
tree
|
|
210
|
+
]);
|
|
211
|
+
return {
|
|
212
|
+
collapsed,
|
|
213
|
+
virtualize,
|
|
214
|
+
expandablePaths
|
|
215
|
+
};
|
|
216
|
+
}
|
|
137
217
|
function variableTypeOf(schema, value) {
|
|
138
218
|
const declared = schemaDisplayType(schema);
|
|
139
219
|
const type = declared && 'null' !== declared ? declared : Array.isArray(value) ? 'array' : null === value ? 'string' : typeof value;
|
|
140
220
|
return 'number' === type || 'boolean' === type || 'object' === type || 'array' === type ? type : 'string';
|
|
141
221
|
}
|
|
142
|
-
|
|
143
|
-
|
|
222
|
+
const nodeIdOf = (section, node)=>isSourceSection(section) ? String(node.segments[0]) : void 0;
|
|
223
|
+
function rowFor(section, node, toReference) {
|
|
224
|
+
const displayPath = toReference(node.path, node.segments);
|
|
225
|
+
const nodeId = nodeIdOf(section, node);
|
|
226
|
+
return void 0 === nodeId ? {
|
|
144
227
|
section,
|
|
145
|
-
|
|
146
|
-
|
|
228
|
+
node,
|
|
229
|
+
displayPath
|
|
147
230
|
} : {
|
|
148
231
|
section,
|
|
149
|
-
|
|
232
|
+
nodeId,
|
|
233
|
+
node,
|
|
234
|
+
displayPath
|
|
150
235
|
};
|
|
151
236
|
}
|
|
237
|
+
const sourcesByIdOf = (sources)=>new Map((sources ?? []).map((source)=>[
|
|
238
|
+
source.id,
|
|
239
|
+
source
|
|
240
|
+
]));
|
|
241
|
+
function sourceDecorator(sourcesById, strings) {
|
|
242
|
+
return (node)=>{
|
|
243
|
+
if (1 !== node.segments.length) return;
|
|
244
|
+
const source = sourcesById.get(String(node.segments[0]));
|
|
245
|
+
if (!source) return;
|
|
246
|
+
const count = outputCountOf(source, node);
|
|
247
|
+
const countLabel = strings.nodeOutputCount(count);
|
|
248
|
+
return {
|
|
249
|
+
label: source.label,
|
|
250
|
+
sublabel: source.id,
|
|
251
|
+
sublabelOnHover: true,
|
|
252
|
+
badge: {
|
|
253
|
+
icon: source.icon
|
|
254
|
+
},
|
|
255
|
+
hideCount: true,
|
|
256
|
+
hideValue: true,
|
|
257
|
+
meta: /*#__PURE__*/ jsx(CanvasTooltip, {
|
|
258
|
+
content: countLabel,
|
|
259
|
+
placement: "top",
|
|
260
|
+
delay: true,
|
|
261
|
+
children: /*#__PURE__*/ jsxs("span", {
|
|
262
|
+
role: "img",
|
|
263
|
+
"aria-label": countLabel,
|
|
264
|
+
className: COUNT_CLASS,
|
|
265
|
+
children: [
|
|
266
|
+
"(",
|
|
267
|
+
count,
|
|
268
|
+
")"
|
|
269
|
+
]
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function useSectionDecorator(section, builtIn, decorateNode, referenceFor) {
|
|
276
|
+
return useMemo(()=>{
|
|
277
|
+
if (!decorateNode) return builtIn;
|
|
278
|
+
const toReference = referenceFor(section);
|
|
279
|
+
return (node)=>mergeDecoration(builtIn?.(node), decorateNode(rowFor(section, node, toReference)));
|
|
280
|
+
}, [
|
|
281
|
+
section,
|
|
282
|
+
builtIn,
|
|
283
|
+
decorateNode,
|
|
284
|
+
referenceFor
|
|
285
|
+
]);
|
|
286
|
+
}
|
|
152
287
|
const isTopLevelAsset = ({ section, node })=>'assets' === section && 1 === node.segments.length && 'string' == typeof node.segments[0];
|
|
153
288
|
const isTopLevelVariable = ({ section, node })=>('outputs' === section || 'variables' === section) && 1 === node.segments.length && 'string' == typeof node.segments[0];
|
|
154
289
|
function siblingKeys(tree, targetPath) {
|
|
@@ -165,10 +300,16 @@ function siblingKeys(tree, targetPath) {
|
|
|
165
300
|
}
|
|
166
301
|
return new Set();
|
|
167
302
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
303
|
+
function NodeVariablesPanelRender({ inputs, outputs, variables, assets, nodes, outputsBasePath, variablesBasePath, assetsBasePath, referencePrefix = '$vars', assetsReferencePrefix = '$assets', pathForCopy, expandedSections: expandedSectionsProp, onExpandedSectionsChange, filters, activeFilterId: activeFilterIdProp, onActiveFilterChange, onFocusNode, onAdd, addState, isVariableRow = isTopLevelVariable, canEdit, canDelete, canCopy, onEditVariable, onRequestEditVariable, onDeleteVariable, onCopy, decorateNode, nodeActions, leading, rowWrapper, deriveTypeIcon, deriveTypeLabel, strings: stringOverrides, treeStrings, children, className }, ref) {
|
|
304
|
+
const strings = useNodeVariablesPanelStrings(stringOverrides);
|
|
305
|
+
const sectionData = {
|
|
306
|
+
inputs,
|
|
307
|
+
outputs,
|
|
308
|
+
variables,
|
|
309
|
+
assets,
|
|
310
|
+
nodes
|
|
311
|
+
};
|
|
312
|
+
const present = SECTIONS.filter((section)=>void 0 !== sectionData[section]);
|
|
172
313
|
const basePaths = useMemo(()=>new Map([
|
|
173
314
|
[
|
|
174
315
|
'outputs',
|
|
@@ -187,72 +328,73 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
187
328
|
variablesBasePath,
|
|
188
329
|
assetsBasePath
|
|
189
330
|
]);
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}),
|
|
197
|
-
variables: buildJsonTree({
|
|
198
|
-
schema: variables?.schema,
|
|
199
|
-
value: variables?.value,
|
|
200
|
-
basePath: basePaths.get('variables')
|
|
201
|
-
}),
|
|
202
|
-
assets: buildJsonTree({
|
|
203
|
-
schema: assets?.schema,
|
|
204
|
-
value: assets?.value,
|
|
205
|
-
basePath: basePaths.get('assets')
|
|
206
|
-
}),
|
|
207
|
-
nodes: buildSourceTree(nodes)
|
|
331
|
+
const inputsTree = useMemo(()=>buildSourceTree(inputs ?? []), [
|
|
332
|
+
inputs
|
|
333
|
+
]);
|
|
334
|
+
const outputsTree = useMemo(()=>buildJsonTree({
|
|
335
|
+
...outputs,
|
|
336
|
+
basePath: outputsBasePath
|
|
208
337
|
}), [
|
|
209
|
-
inputs,
|
|
210
338
|
outputs,
|
|
339
|
+
outputsBasePath
|
|
340
|
+
]);
|
|
341
|
+
const variablesTree = useMemo(()=>buildJsonTree({
|
|
342
|
+
...variables,
|
|
343
|
+
basePath: variablesBasePath
|
|
344
|
+
}), [
|
|
211
345
|
variables,
|
|
212
|
-
|
|
213
|
-
nodes,
|
|
214
|
-
basePaths
|
|
346
|
+
variablesBasePath
|
|
215
347
|
]);
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
source
|
|
220
|
-
])),
|
|
221
|
-
nodes: new Map(nodes.map((source)=>[
|
|
222
|
-
source.id,
|
|
223
|
-
source
|
|
224
|
-
]))
|
|
348
|
+
const assetsTree = useMemo(()=>buildJsonTree({
|
|
349
|
+
...assets,
|
|
350
|
+
basePath: assetsBasePath
|
|
225
351
|
}), [
|
|
226
|
-
|
|
352
|
+
assets,
|
|
353
|
+
assetsBasePath
|
|
354
|
+
]);
|
|
355
|
+
const nodesTree = useMemo(()=>buildSourceTree(nodes ?? []), [
|
|
227
356
|
nodes
|
|
228
357
|
]);
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
!isPathCollapsed(openPaths[section], path)
|
|
242
|
-
]))
|
|
243
|
-
])), [
|
|
244
|
-
trees,
|
|
245
|
-
openPaths
|
|
358
|
+
const trees = useMemo(()=>({
|
|
359
|
+
inputs: inputsTree,
|
|
360
|
+
outputs: outputsTree,
|
|
361
|
+
variables: variablesTree,
|
|
362
|
+
assets: assetsTree,
|
|
363
|
+
nodes: nodesTree
|
|
364
|
+
}), [
|
|
365
|
+
inputsTree,
|
|
366
|
+
outputsTree,
|
|
367
|
+
variablesTree,
|
|
368
|
+
assetsTree,
|
|
369
|
+
nodesTree
|
|
246
370
|
]);
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
exceedsVirtualizeThreshold(trees[section])
|
|
250
|
-
])), [
|
|
251
|
-
trees
|
|
371
|
+
const inputsById = useMemo(()=>sourcesByIdOf(inputs), [
|
|
372
|
+
inputs
|
|
252
373
|
]);
|
|
374
|
+
const nodesById = useMemo(()=>sourcesByIdOf(nodes), [
|
|
375
|
+
nodes
|
|
376
|
+
]);
|
|
377
|
+
const sourcesById = {
|
|
378
|
+
inputs: inputsById,
|
|
379
|
+
nodes: nodesById
|
|
380
|
+
};
|
|
381
|
+
const [uncontrolledSections, setUncontrolledSections] = useState(DEFAULT_EXPANDED_SECTIONS);
|
|
382
|
+
const baseSections = expandedSectionsProp ?? uncontrolledSections;
|
|
383
|
+
const setBaseSections = (next)=>{
|
|
384
|
+
if (void 0 === expandedSectionsProp) setUncontrolledSections(next);
|
|
385
|
+
onExpandedSectionsChange?.(next);
|
|
386
|
+
};
|
|
387
|
+
const [openPaths, setOpenPaths] = useState(NO_PATHS);
|
|
388
|
+
const shapes = {
|
|
389
|
+
inputs: useSectionShape(inputsTree, openPaths.inputs),
|
|
390
|
+
outputs: useSectionShape(outputsTree, openPaths.outputs),
|
|
391
|
+
variables: useSectionShape(variablesTree, openPaths.variables),
|
|
392
|
+
assets: useSectionShape(assetsTree, openPaths.assets),
|
|
393
|
+
nodes: useSectionShape(nodesTree, openPaths.nodes)
|
|
394
|
+
};
|
|
253
395
|
const [scroller, setScroller] = useState(null);
|
|
254
396
|
const [query, setQuery] = useState('');
|
|
255
|
-
const [uncontrolledFilterId, setUncontrolledFilterId] = useState(
|
|
397
|
+
const [uncontrolledFilterId, setUncontrolledFilterId] = useState(null);
|
|
256
398
|
const activeFilterId = void 0 !== activeFilterIdProp ? activeFilterIdProp : uncontrolledFilterId;
|
|
257
399
|
const changeFilter = (id)=>{
|
|
258
400
|
if (void 0 === activeFilterIdProp) setUncontrolledFilterId(id);
|
|
@@ -270,7 +412,8 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
270
412
|
]);
|
|
271
413
|
const search = query.trim();
|
|
272
414
|
const activeFilter = filters?.find((filter)=>filter.id === activeFilterId);
|
|
273
|
-
const
|
|
415
|
+
const filterPredicate = activeFilter?.predicate;
|
|
416
|
+
const narrowing = !!search || !!filterPredicate;
|
|
274
417
|
const toolbarFilters = useMemo(()=>filters?.map(({ id, label })=>({
|
|
275
418
|
id,
|
|
276
419
|
label,
|
|
@@ -278,159 +421,153 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
278
421
|
})), [
|
|
279
422
|
filters
|
|
280
423
|
]);
|
|
281
|
-
const filterPredicates = useMemo(()=>
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
424
|
+
const filterPredicates = useMemo(()=>filterPredicate ? mapSections((section)=>{
|
|
425
|
+
const toReference = referenceFor(section);
|
|
426
|
+
return (node)=>filterPredicate(rowFor(section, node, toReference));
|
|
427
|
+
}) : void 0, [
|
|
428
|
+
filterPredicate,
|
|
429
|
+
referenceFor
|
|
286
430
|
]);
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const source = sourcesById[section].get(String(node.segments[0]));
|
|
291
|
-
if (!source) return;
|
|
292
|
-
const count = source.outputCount ?? countEntries(node.children);
|
|
293
|
-
const countLabel = _({
|
|
294
|
-
id: 'canvas.node_variables_panel.node_output_count',
|
|
295
|
-
message: 'Outputs: {count}',
|
|
296
|
-
values: {
|
|
297
|
-
count
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
return {
|
|
301
|
-
label: source.label,
|
|
302
|
-
sublabel: source.id,
|
|
303
|
-
sublabelOnHover: true,
|
|
304
|
-
badge: {
|
|
305
|
-
icon: source.icon
|
|
306
|
-
},
|
|
307
|
-
hideCount: true,
|
|
308
|
-
hideValue: true,
|
|
309
|
-
meta: /*#__PURE__*/ jsx(CanvasTooltip, {
|
|
310
|
-
content: countLabel,
|
|
311
|
-
placement: "top",
|
|
312
|
-
delay: true,
|
|
313
|
-
children: /*#__PURE__*/ jsxs("span", {
|
|
314
|
-
role: "img",
|
|
315
|
-
"aria-label": countLabel,
|
|
316
|
-
className: COUNT_CLASS,
|
|
317
|
-
children: [
|
|
318
|
-
"(",
|
|
319
|
-
count,
|
|
320
|
-
")"
|
|
321
|
-
]
|
|
322
|
-
})
|
|
323
|
-
})
|
|
324
|
-
};
|
|
325
|
-
};
|
|
326
|
-
return {
|
|
327
|
-
inputs: decorate('inputs'),
|
|
328
|
-
nodes: decorate('nodes')
|
|
329
|
-
};
|
|
330
|
-
}, [
|
|
331
|
-
sourcesById,
|
|
332
|
-
_
|
|
431
|
+
const decorateInputs = useMemo(()=>sourceDecorator(inputsById, strings), [
|
|
432
|
+
inputsById,
|
|
433
|
+
strings
|
|
333
434
|
]);
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
435
|
+
const decorateNodes = useMemo(()=>sourceDecorator(nodesById, strings), [
|
|
436
|
+
nodesById,
|
|
437
|
+
strings
|
|
438
|
+
]);
|
|
439
|
+
const decorateInputsRow = useSectionDecorator('inputs', decorateInputs, decorateNode, referenceFor);
|
|
440
|
+
const decorateOutputsRow = useSectionDecorator('outputs', void 0, decorateNode, referenceFor);
|
|
441
|
+
const decorateVariablesRow = useSectionDecorator('variables', void 0, decorateNode, referenceFor);
|
|
442
|
+
const decorateAssetsRow = useSectionDecorator('assets', void 0, decorateNode, referenceFor);
|
|
443
|
+
const decorateNodesRow = useSectionDecorator('nodes', decorateNodes, decorateNode, referenceFor);
|
|
444
|
+
const decorators = useMemo(()=>({
|
|
445
|
+
inputs: decorateInputsRow,
|
|
446
|
+
outputs: decorateOutputsRow,
|
|
447
|
+
variables: decorateVariablesRow,
|
|
448
|
+
assets: decorateAssetsRow,
|
|
449
|
+
nodes: decorateNodesRow
|
|
450
|
+
}), [
|
|
451
|
+
decorateInputsRow,
|
|
452
|
+
decorateOutputsRow,
|
|
453
|
+
decorateVariablesRow,
|
|
454
|
+
decorateAssetsRow,
|
|
455
|
+
decorateNodesRow
|
|
456
|
+
]);
|
|
457
|
+
const hasMatches = useMemo(()=>mapSections((section)=>!narrowing || hasVisibleRows(trees[section], {
|
|
458
|
+
query: search,
|
|
459
|
+
filterPredicate: filterPredicates?.[section],
|
|
460
|
+
displayTexts: decorators[section]
|
|
461
|
+
})), [
|
|
343
462
|
narrowing,
|
|
344
463
|
trees,
|
|
345
464
|
search,
|
|
346
465
|
filterPredicates,
|
|
347
|
-
|
|
466
|
+
decorators
|
|
348
467
|
]);
|
|
349
468
|
const totalCount = {
|
|
350
|
-
inputs: inputs.
|
|
469
|
+
inputs: trees.inputs.reduce((sum, node)=>sum + outputCountOf(sourcesById.inputs.get(String(node.segments[0])), node), 0),
|
|
351
470
|
outputs: countEntries(trees.outputs),
|
|
352
471
|
variables: countEntries(trees.variables),
|
|
353
472
|
assets: countEntries(trees.assets),
|
|
354
|
-
nodes: nodes
|
|
473
|
+
nodes: nodes?.length ?? 0
|
|
355
474
|
};
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
475
|
+
const narrowKey = narrowing ? JSON.stringify([
|
|
476
|
+
search,
|
|
477
|
+
filterPredicate && activeFilterId
|
|
478
|
+
]) : null;
|
|
479
|
+
const [narrowed, setNarrowed] = useState(null);
|
|
480
|
+
if (narrowed && narrowed.key !== narrowKey) setNarrowed(null);
|
|
481
|
+
const overlay = narrowKey && narrowed?.key === narrowKey ? narrowed : NO_OVERLAY;
|
|
482
|
+
const updateOverlay = (change)=>{
|
|
483
|
+
if (!narrowKey) return;
|
|
484
|
+
setNarrowed((previous)=>{
|
|
485
|
+
const current = previous?.key === narrowKey ? previous : {
|
|
486
|
+
key: narrowKey,
|
|
487
|
+
...NO_OVERLAY
|
|
488
|
+
};
|
|
489
|
+
return {
|
|
490
|
+
...current,
|
|
491
|
+
...change(current)
|
|
492
|
+
};
|
|
362
493
|
});
|
|
363
|
-
|
|
494
|
+
};
|
|
495
|
+
const openSections = narrowKey ? present.filter((section)=>hasMatches[section] && !overlay.closedSections.includes(section)) : baseSections;
|
|
496
|
+
const setOpenSections = (next)=>{
|
|
497
|
+
if (!narrowKey) return setBaseSections(inSectionOrder(next));
|
|
498
|
+
updateOverlay(()=>({
|
|
499
|
+
closedSections: present.filter((section)=>!next.includes(section))
|
|
500
|
+
}));
|
|
501
|
+
};
|
|
502
|
+
const setSectionOpen = (section, open)=>setOpenSections(open ? [
|
|
503
|
+
...openSections,
|
|
504
|
+
section
|
|
505
|
+
] : openSections.filter((item)=>item !== section));
|
|
506
|
+
const collapsedIn = (section)=>search ? overlay.collapsedPaths[section] : shapes[section].collapsed;
|
|
507
|
+
const toggleCollapsed = (section)=>(path)=>{
|
|
508
|
+
if (search) return void updateOverlay(({ collapsedPaths })=>({
|
|
509
|
+
collapsedPaths: {
|
|
510
|
+
...collapsedPaths,
|
|
511
|
+
[section]: {
|
|
512
|
+
...collapsedPaths[section],
|
|
513
|
+
[path]: !isPathCollapsed(collapsedPaths[section], path)
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}));
|
|
517
|
+
setOpenPaths((current)=>({
|
|
364
518
|
...current,
|
|
365
519
|
[section]: {
|
|
366
520
|
...current[section],
|
|
367
|
-
[path]: isPathCollapsed(
|
|
521
|
+
[path]: isPathCollapsed(shapes[section].collapsed, path)
|
|
368
522
|
}
|
|
369
523
|
}));
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
]);
|
|
377
|
-
const allExpanded = expandableSections.length > 0 && expandableSections.every((section)=>openSections.has(section)) && SECTIONS.every((section)=>expandablePaths[section].every((path)=>!isPathCollapsed(collapsed[section], path)));
|
|
524
|
+
};
|
|
525
|
+
const expandableSections = present.filter((section)=>{
|
|
526
|
+
if (narrowing) return hasMatches[section];
|
|
527
|
+
return isSourceSection(section) ? trees[section].length > 0 : totalCount[section] > 0;
|
|
528
|
+
});
|
|
529
|
+
const allExpanded = expandableSections.length > 0 && expandableSections.every((section)=>openSections.includes(section)) && present.every((section)=>shapes[section].expandablePaths.every((path)=>!isPathCollapsed(collapsedIn(section), path)));
|
|
378
530
|
const toggleAll = ()=>{
|
|
379
531
|
const open = !allExpanded;
|
|
380
|
-
setOpenSections(open ?
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
532
|
+
setOpenSections(open ? expandableSections : []);
|
|
533
|
+
const pathsFor = (section, collapse)=>Object.fromEntries(shapes[section].expandablePaths.map((path)=>[
|
|
534
|
+
path,
|
|
535
|
+
collapse
|
|
536
|
+
]));
|
|
537
|
+
if (search) return void updateOverlay(({ collapsedPaths })=>({
|
|
538
|
+
collapsedPaths: mapSections((section)=>({
|
|
539
|
+
...collapsedPaths[section],
|
|
540
|
+
...pathsFor(section, !open)
|
|
541
|
+
}))
|
|
542
|
+
}));
|
|
543
|
+
setOpenPaths((current)=>mapSections((section)=>({
|
|
544
|
+
...current[section],
|
|
545
|
+
...pathsFor(section, open)
|
|
546
|
+
})));
|
|
547
|
+
};
|
|
548
|
+
const sourceActions = (section, node)=>{
|
|
549
|
+
const source = sourcesById[section].get(String(node.segments[0]));
|
|
550
|
+
const label = source?.label ?? node.key;
|
|
551
|
+
const actions = [];
|
|
552
|
+
if (onAdd && source?.addable !== false) actions.push({
|
|
553
|
+
id: 'add-to-node',
|
|
554
|
+
icon: /*#__PURE__*/ jsx(Plus, {}),
|
|
555
|
+
label: strings.addFromNode(label),
|
|
556
|
+
tooltip: strings.addToNode,
|
|
557
|
+
persistent: true,
|
|
558
|
+
onSelect: ()=>onAdd(section, node.key)
|
|
559
|
+
});
|
|
560
|
+
if (onFocusNode) actions.unshift({
|
|
561
|
+
id: 'focus-node',
|
|
562
|
+
icon: /*#__PURE__*/ jsx(MousePointerClick, {}),
|
|
563
|
+
label: strings.focusNodeLabel(label),
|
|
564
|
+
tooltip: strings.focusNode,
|
|
565
|
+
persistent: true,
|
|
566
|
+
placement: 'start',
|
|
567
|
+
onSelect: ()=>onFocusNode(node.key)
|
|
568
|
+
});
|
|
569
|
+
return actions;
|
|
391
570
|
};
|
|
392
|
-
const sourceActions = (section)=>(node, ctx)=>{
|
|
393
|
-
if (1 !== node.segments.length) return ctx.defaultActions;
|
|
394
|
-
const source = sourcesById[section].get(String(node.segments[0]));
|
|
395
|
-
const label = source?.label ?? node.key;
|
|
396
|
-
const actions = [];
|
|
397
|
-
if (onAdd && source?.addable !== false) actions.push({
|
|
398
|
-
id: 'add-to-node',
|
|
399
|
-
icon: /*#__PURE__*/ jsx(Plus, {}),
|
|
400
|
-
label: _({
|
|
401
|
-
id: 'canvas.node_variables_panel.add_to_node_label',
|
|
402
|
-
message: 'Add from {label}',
|
|
403
|
-
values: {
|
|
404
|
-
label
|
|
405
|
-
}
|
|
406
|
-
}),
|
|
407
|
-
tooltip: _({
|
|
408
|
-
id: 'canvas.node_variables_panel.add_to_node',
|
|
409
|
-
message: 'Add'
|
|
410
|
-
}),
|
|
411
|
-
persistent: true,
|
|
412
|
-
onSelect: ()=>onAdd(section, node.key)
|
|
413
|
-
});
|
|
414
|
-
if (onFocusNode) actions.unshift({
|
|
415
|
-
id: 'focus-node',
|
|
416
|
-
icon: /*#__PURE__*/ jsx(MousePointerClick, {}),
|
|
417
|
-
label: _({
|
|
418
|
-
id: 'canvas.node_variables_panel.focus_node_label',
|
|
419
|
-
message: 'Focus on {label}',
|
|
420
|
-
values: {
|
|
421
|
-
label
|
|
422
|
-
}
|
|
423
|
-
}),
|
|
424
|
-
tooltip: _({
|
|
425
|
-
id: 'canvas.node_variables_panel.focus_node',
|
|
426
|
-
message: 'Focus on node'
|
|
427
|
-
}),
|
|
428
|
-
persistent: true,
|
|
429
|
-
placement: 'start',
|
|
430
|
-
onSelect: ()=>onFocusNode(node.key)
|
|
431
|
-
});
|
|
432
|
-
return actions;
|
|
433
|
-
};
|
|
434
571
|
const openEditDialog = (row)=>{
|
|
435
572
|
const { schema, value } = row.node;
|
|
436
573
|
setEditing({
|
|
@@ -443,46 +580,56 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
443
580
|
}
|
|
444
581
|
});
|
|
445
582
|
};
|
|
446
|
-
const variableActions = (row,
|
|
583
|
+
const variableActions = (row, defaultActions)=>{
|
|
447
584
|
const { node } = row;
|
|
448
585
|
const actions = [
|
|
449
|
-
...
|
|
586
|
+
...defaultActions
|
|
450
587
|
];
|
|
451
588
|
const builtIn = Boolean(onEditVariable) && 'assets' !== row.section;
|
|
452
|
-
if (builtIn || onRequestEditVariable) actions.push({
|
|
589
|
+
if ((builtIn || onRequestEditVariable) && canEdit?.(row) !== false) actions.push({
|
|
453
590
|
id: 'edit-variable',
|
|
454
591
|
icon: /*#__PURE__*/ jsx(Pencil, {}),
|
|
455
|
-
label:
|
|
456
|
-
id: 'canvas.node_variables_panel.edit_variable',
|
|
457
|
-
message: 'Edit {name}',
|
|
458
|
-
values: {
|
|
459
|
-
name: node.key
|
|
460
|
-
}
|
|
461
|
-
}),
|
|
592
|
+
label: strings.editVariable(node.key),
|
|
462
593
|
onSelect: ()=>builtIn ? openEditDialog(row) : onRequestEditVariable?.(row)
|
|
463
594
|
});
|
|
464
|
-
if (onDeleteVariable) actions.push({
|
|
595
|
+
if (onDeleteVariable && canDelete?.(row) !== false) actions.push({
|
|
465
596
|
id: 'delete-variable',
|
|
466
597
|
icon: /*#__PURE__*/ jsx(Trash2, {}),
|
|
467
|
-
label:
|
|
468
|
-
id: 'canvas.node_variables_panel.delete_variable',
|
|
469
|
-
message: 'Delete {name}',
|
|
470
|
-
values: {
|
|
471
|
-
name: node.key
|
|
472
|
-
}
|
|
473
|
-
}),
|
|
598
|
+
label: strings.deleteVariable(node.key),
|
|
474
599
|
tone: 'error',
|
|
475
600
|
onSelect: ()=>onDeleteVariable(row)
|
|
476
601
|
});
|
|
477
602
|
return actions;
|
|
478
603
|
};
|
|
604
|
+
const builtInActions = (row, defaultActions)=>{
|
|
605
|
+
const { section, node } = row;
|
|
606
|
+
if (isSourceSection(section) && 1 === node.segments.length) return sourceActions(section, node);
|
|
607
|
+
if (node.isArrayItemTemplate) return defaultActions;
|
|
608
|
+
if ('assets' === section) return isTopLevelAsset(row) ? variableActions(row, defaultActions) : defaultActions;
|
|
609
|
+
return isVariableRow(row) ? variableActions(row, defaultActions) : defaultActions;
|
|
610
|
+
};
|
|
479
611
|
const actionsFor = (section)=>(node, ctx)=>{
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
612
|
+
const row = rowFor(section, node, referenceFor(section));
|
|
613
|
+
const defaultActions = canCopy?.(row) === false ? ctx.defaultActions.filter((action)=>'copy-value' !== action.id) : ctx.defaultActions;
|
|
614
|
+
const actions = builtInActions(row, defaultActions);
|
|
615
|
+
return nodeActions?.(row, {
|
|
616
|
+
defaultActions: actions
|
|
617
|
+
}) ?? actions;
|
|
485
618
|
};
|
|
619
|
+
const sectionRowWrappers = useMemo(()=>{
|
|
620
|
+
if (!rowWrapper) return;
|
|
621
|
+
const HostRow = rowWrapper;
|
|
622
|
+
return mapSections((section)=>{
|
|
623
|
+
const SectionRow = (props)=>/*#__PURE__*/ jsx(HostRow, {
|
|
624
|
+
...props,
|
|
625
|
+
section: section,
|
|
626
|
+
nodeId: nodeIdOf(section, props.node)
|
|
627
|
+
});
|
|
628
|
+
return SectionRow;
|
|
629
|
+
});
|
|
630
|
+
}, [
|
|
631
|
+
rowWrapper
|
|
632
|
+
]);
|
|
486
633
|
const renamedReference = ({ section, node })=>(id)=>{
|
|
487
634
|
const basePath = basePaths.get(section) ?? '';
|
|
488
635
|
const parentSegments = node.segments.slice(0, -1);
|
|
@@ -496,99 +643,142 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
496
643
|
]);
|
|
497
644
|
};
|
|
498
645
|
const sectionName = {
|
|
499
|
-
inputs:
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
id: 'canvas.node_variables_panel.section_outputs',
|
|
505
|
-
message: 'Outputs'
|
|
506
|
-
}),
|
|
507
|
-
variables: _({
|
|
508
|
-
id: 'canvas.node_variables_panel.section_variables',
|
|
509
|
-
message: 'Variables'
|
|
510
|
-
}),
|
|
511
|
-
assets: _({
|
|
512
|
-
id: 'canvas.node_variables_panel.section_assets',
|
|
513
|
-
message: 'Assets'
|
|
514
|
-
}),
|
|
515
|
-
nodes: _({
|
|
516
|
-
id: 'canvas.node_variables_panel.section_nodes',
|
|
517
|
-
message: 'Nodes'
|
|
518
|
-
})
|
|
646
|
+
inputs: strings.sectionInputs,
|
|
647
|
+
outputs: strings.sectionOutputs,
|
|
648
|
+
variables: strings.sectionVariables,
|
|
649
|
+
assets: strings.sectionAssets,
|
|
650
|
+
nodes: strings.sectionNodes
|
|
519
651
|
};
|
|
520
652
|
const sectionCountLabel = (section, count)=>({
|
|
521
|
-
inputs:
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
653
|
+
inputs: strings.inputsCount,
|
|
654
|
+
outputs: strings.outputsCount,
|
|
655
|
+
variables: strings.variablesCount,
|
|
656
|
+
assets: strings.assetsCount,
|
|
657
|
+
nodes: strings.nodesCount
|
|
658
|
+
})[section](count);
|
|
659
|
+
const addLabel = {
|
|
660
|
+
outputs: strings.addOutputs,
|
|
661
|
+
variables: strings.addVariables,
|
|
662
|
+
assets: strings.addAssets
|
|
663
|
+
};
|
|
664
|
+
const { ref: scrollRef, contentRef, edges, onScroll } = useScrollEdges();
|
|
665
|
+
const [pendingReveal, setPendingReveal] = useState(null);
|
|
666
|
+
useEffect(()=>{
|
|
667
|
+
if (!pendingReveal) return;
|
|
668
|
+
const sectionElement = contentRef.current?.querySelector(`[data-section="${pendingReveal.section}"]`);
|
|
669
|
+
const row = Array.from(sectionElement?.querySelectorAll('[role="row"]') ?? []).find((element)=>element.dataset.path === pendingReveal.path);
|
|
670
|
+
(row ?? sectionElement)?.scrollIntoView?.({
|
|
671
|
+
block: 'nearest'
|
|
672
|
+
});
|
|
673
|
+
if (!row) return;
|
|
674
|
+
row.setAttribute('data-revealed', '');
|
|
675
|
+
const timer = setTimeout(()=>row.removeAttribute('data-revealed'), REVEAL_HIGHLIGHT_MS);
|
|
676
|
+
return ()=>{
|
|
677
|
+
clearTimeout(timer);
|
|
678
|
+
row.removeAttribute('data-revealed');
|
|
679
|
+
};
|
|
680
|
+
}, [
|
|
681
|
+
pendingReveal,
|
|
682
|
+
contentRef
|
|
683
|
+
]);
|
|
684
|
+
const revealPath = (reference)=>{
|
|
685
|
+
for (const section of present){
|
|
686
|
+
const toReference = referenceFor(section);
|
|
687
|
+
const found = findByReference(trees[section], (node)=>toReference(node.path, node.segments) === reference);
|
|
688
|
+
if (!found) continue;
|
|
689
|
+
const { node, ancestors } = found;
|
|
690
|
+
const shows = (rowQuery, filterPredicate)=>flattenJsonTree(trees[section], {
|
|
691
|
+
collapsed: {},
|
|
692
|
+
query: rowQuery,
|
|
693
|
+
filterPredicate,
|
|
694
|
+
displayTexts: decorators[section]
|
|
695
|
+
}).some((row)=>row.node.path === node.path);
|
|
696
|
+
const clearsFilter = !!filterPredicate && !shows('', filterPredicates?.[section]);
|
|
697
|
+
const clearsSearch = !!search && !shows(search);
|
|
698
|
+
if (clearsFilter) changeFilter(null);
|
|
699
|
+
if (clearsSearch) setQuery('');
|
|
700
|
+
if (!baseSections.includes(section)) setBaseSections(inSectionOrder([
|
|
701
|
+
...baseSections,
|
|
702
|
+
section
|
|
703
|
+
]));
|
|
704
|
+
setOpenPaths((current)=>({
|
|
705
|
+
...current,
|
|
706
|
+
[section]: {
|
|
707
|
+
...current[section],
|
|
708
|
+
...Object.fromEntries(ancestors.map((path)=>[
|
|
709
|
+
path,
|
|
710
|
+
true
|
|
711
|
+
]))
|
|
712
|
+
}
|
|
713
|
+
}));
|
|
714
|
+
if (!clearsFilter && !clearsSearch) updateOverlay(({ closedSections, collapsedPaths })=>({
|
|
715
|
+
closedSections: closedSections.filter((item)=>item !== section),
|
|
716
|
+
collapsedPaths: {
|
|
717
|
+
...collapsedPaths,
|
|
718
|
+
[section]: {
|
|
719
|
+
...collapsedPaths[section],
|
|
720
|
+
...Object.fromEntries(ancestors.map((path)=>[
|
|
721
|
+
path,
|
|
722
|
+
false
|
|
723
|
+
]))
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}));
|
|
727
|
+
setPendingReveal({
|
|
728
|
+
section,
|
|
729
|
+
path: node.path
|
|
730
|
+
});
|
|
731
|
+
return true;
|
|
732
|
+
}
|
|
733
|
+
return false;
|
|
734
|
+
};
|
|
735
|
+
useImperativeHandle(ref, ()=>({
|
|
736
|
+
revealPath
|
|
737
|
+
}));
|
|
571
738
|
const renderTree = (section)=>/*#__PURE__*/ jsx(JsonTreeView, {
|
|
572
739
|
nodes: trees[section],
|
|
573
|
-
collapsed:
|
|
574
|
-
onToggleCollapsed:
|
|
740
|
+
collapsed: collapsedIn(section),
|
|
741
|
+
onToggleCollapsed: toggleCollapsed(section),
|
|
575
742
|
query: search,
|
|
576
743
|
filterPredicate: filterPredicates?.[section],
|
|
577
744
|
readOnly: true,
|
|
578
|
-
decorateNode:
|
|
745
|
+
decorateNode: decorators[section],
|
|
579
746
|
deriveTypeIcon: deriveTypeIcon,
|
|
580
|
-
|
|
747
|
+
deriveTypeLabel: deriveTypeLabel,
|
|
748
|
+
rowWrapper: sectionRowWrappers?.[section],
|
|
581
749
|
nodeActions: actionsFor(section),
|
|
582
750
|
maxInlineActions: 4,
|
|
583
751
|
pathForCopy: referenceFor(section),
|
|
752
|
+
canCopyPath: canCopy ? (node)=>canCopy(rowFor(section, node, referenceFor(section))) : void 0,
|
|
584
753
|
onCopy: onCopy,
|
|
585
|
-
virtualized:
|
|
586
|
-
scrollElement:
|
|
754
|
+
virtualized: shapes[section].virtualize,
|
|
755
|
+
scrollElement: shapes[section].virtualize ? scroller : void 0,
|
|
756
|
+
strings: treeStrings,
|
|
587
757
|
className: "h-auto py-1"
|
|
588
758
|
});
|
|
759
|
+
const renderAddButton = (section)=>{
|
|
760
|
+
const { disabled = false, tooltip } = addState?.[section] ?? {};
|
|
761
|
+
const button = /*#__PURE__*/ jsx(Button, {
|
|
762
|
+
variant: "ghost",
|
|
763
|
+
size: "4xs",
|
|
764
|
+
icon: true,
|
|
765
|
+
"aria-label": addLabel[section],
|
|
766
|
+
"aria-disabled": disabled || void 0,
|
|
767
|
+
onClick: ()=>{
|
|
768
|
+
if (!disabled) onAdd?.(section);
|
|
769
|
+
},
|
|
770
|
+
className: "shrink-0 rounded text-foreground-subtle hover:bg-surface-raised hover:text-foreground aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent aria-disabled:hover:text-foreground-subtle [&_svg]:size-2.75",
|
|
771
|
+
children: /*#__PURE__*/ jsx(Plus, {})
|
|
772
|
+
});
|
|
773
|
+
return tooltip ? /*#__PURE__*/ jsx(CanvasTooltip, {
|
|
774
|
+
content: tooltip,
|
|
775
|
+
placement: "top",
|
|
776
|
+
children: button
|
|
777
|
+
}) : button;
|
|
778
|
+
};
|
|
589
779
|
const renderSection = (section)=>{
|
|
590
|
-
if (
|
|
591
|
-
const open =
|
|
780
|
+
if (!hasMatches[section]) return null;
|
|
781
|
+
const open = openSections.includes(section);
|
|
592
782
|
const name = sectionName[section];
|
|
593
783
|
const count = totalCount[section];
|
|
594
784
|
const { Icon, className: iconClassName } = SECTION_ICONS[section];
|
|
@@ -596,17 +786,17 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
596
786
|
return /*#__PURE__*/ jsx(Collapsible, {
|
|
597
787
|
open: open,
|
|
598
788
|
onOpenChange: (next)=>setSectionOpen(section, next),
|
|
599
|
-
disabled: narrowing,
|
|
600
789
|
asChild: true,
|
|
601
790
|
children: /*#__PURE__*/ jsxs("section", {
|
|
602
791
|
"aria-label": name,
|
|
792
|
+
"data-section": section,
|
|
603
793
|
className: "mb-2 overflow-hidden rounded-lg border border-surface-overlay bg-surface-overlay/40",
|
|
604
794
|
children: [
|
|
605
795
|
/*#__PURE__*/ jsxs("div", {
|
|
606
796
|
className: cn('flex h-9 items-center gap-2 pr-1 pl-2', open && trees[section].length > 0 && 'border-b border-surface-overlay/80'),
|
|
607
797
|
children: [
|
|
608
798
|
/*#__PURE__*/ jsxs(CollapsibleTrigger, {
|
|
609
|
-
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left
|
|
799
|
+
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left",
|
|
610
800
|
children: [
|
|
611
801
|
/*#__PURE__*/ jsx(ChevronDown, {
|
|
612
802
|
size: 10,
|
|
@@ -640,15 +830,7 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
640
830
|
]
|
|
641
831
|
})
|
|
642
832
|
}),
|
|
643
|
-
addable &&
|
|
644
|
-
variant: "ghost",
|
|
645
|
-
size: "4xs",
|
|
646
|
-
icon: true,
|
|
647
|
-
"aria-label": addLabel(addable),
|
|
648
|
-
onClick: ()=>onAdd?.(addable),
|
|
649
|
-
className: "shrink-0 rounded text-foreground-subtle hover:bg-surface-raised hover:text-foreground [&_svg]:size-2.75",
|
|
650
|
-
children: /*#__PURE__*/ jsx(Plus, {})
|
|
651
|
-
}),
|
|
833
|
+
addable && renderAddButton(addable),
|
|
652
834
|
onAdd && !addable && /*#__PURE__*/ jsx("span", {
|
|
653
835
|
"aria-hidden": "true",
|
|
654
836
|
className: "size-5 shrink-0"
|
|
@@ -663,30 +845,27 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
663
845
|
})
|
|
664
846
|
}, section);
|
|
665
847
|
};
|
|
666
|
-
const { ref: scrollRef, contentRef, edges, onScroll } = useScrollEdges();
|
|
667
848
|
const setScrollRef = useCallback((element)=>{
|
|
668
849
|
scrollRef.current = element;
|
|
669
850
|
setScroller(element);
|
|
670
851
|
}, [
|
|
671
852
|
scrollRef
|
|
672
853
|
]);
|
|
673
|
-
const nothingVisible = narrowing &&
|
|
854
|
+
const nothingVisible = narrowing && !present.some((section)=>hasMatches[section]);
|
|
674
855
|
return /*#__PURE__*/ jsxs("div", {
|
|
675
856
|
className: cn('flex min-h-0 flex-1 flex-col', className),
|
|
676
857
|
children: [
|
|
677
858
|
/*#__PURE__*/ jsx(JsonTreeToolbar, {
|
|
678
859
|
query: query,
|
|
679
860
|
onQueryChange: setQuery,
|
|
680
|
-
searchPlaceholder:
|
|
681
|
-
id: 'canvas.node_variables_panel.search_placeholder',
|
|
682
|
-
message: 'Search variables'
|
|
683
|
-
}),
|
|
861
|
+
searchPlaceholder: strings.searchPlaceholder,
|
|
684
862
|
filters: toolbarFilters,
|
|
685
863
|
activeFilterId: activeFilter ? activeFilterId : null,
|
|
686
864
|
onFilterChange: changeFilter,
|
|
687
865
|
allCollapsed: !allExpanded,
|
|
688
|
-
onToggleAll:
|
|
866
|
+
onToggleAll: toggleAll,
|
|
689
867
|
leading: leading,
|
|
868
|
+
strings: treeStrings,
|
|
690
869
|
className: "shrink-0 pt-4 pb-2 [padding-inline:var(--mf-content-inset,1rem)]"
|
|
691
870
|
}),
|
|
692
871
|
/*#__PURE__*/ jsx("div", {
|
|
@@ -710,17 +889,12 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
710
889
|
className: "h-full min-h-0 overflow-y-auto rounded-lg pb-1",
|
|
711
890
|
children: /*#__PURE__*/ jsxs("div", {
|
|
712
891
|
ref: contentRef,
|
|
892
|
+
className: "[&_[role=row]]:transition-colors [&_[role=row][data-revealed]]:bg-brand/15",
|
|
713
893
|
children: [
|
|
714
|
-
|
|
894
|
+
present.map(renderSection),
|
|
715
895
|
nothingVisible && /*#__PURE__*/ jsx("p", {
|
|
716
896
|
className: EMPTY_MESSAGE_CLASS,
|
|
717
|
-
children: search ?
|
|
718
|
-
id: 'canvas.node_variables_panel.no_matches',
|
|
719
|
-
message: 'No variables match your search.'
|
|
720
|
-
}) : activeFilter?.emptyMessage ?? _({
|
|
721
|
-
id: 'canvas.node_variables_panel.filter_empty',
|
|
722
|
-
message: 'No variables match this filter.'
|
|
723
|
-
})
|
|
897
|
+
children: search ? strings.noMatches : activeFilter?.emptyMessage ?? strings.filterEmpty
|
|
724
898
|
}),
|
|
725
899
|
children
|
|
726
900
|
]
|
|
@@ -742,4 +916,6 @@ function NodeVariablesPanel({ inputs = [], outputs, variables, assets, nodes = [
|
|
|
742
916
|
]
|
|
743
917
|
});
|
|
744
918
|
}
|
|
919
|
+
const NodeVariablesPanel = /*#__PURE__*/ forwardRef(NodeVariablesPanelRender);
|
|
920
|
+
NodeVariablesPanel.displayName = 'NodeVariablesPanel';
|
|
745
921
|
export { NodeVariablesPanel };
|