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