Title a collapsed Variables or Properties node by what it does
Collapsed, the node reads "Set 2 variables", "Get width" or "No properties"; expanded it is always "Variables" / "Properties". The Properties node shows its object type (and behavior) as a line under the title instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
58f19a3451
commit
0376ae175d
11 files changed
+182
-69
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import { PROPERTIES } from '../../nested';
|
||||
import { collapsedTitle, PROPERTIES } from '../../nested';
|
||||
import type { NodeDef } from '../../NodeRegistry';
|
||||
import {
|
||||
OBJECT_BEHAVIOR_SETTING,
|
||||
OBJECT_TYPE_SETTING,
|
||||
propertiesTitle,
|
||||
propertyPort,
|
||||
propertyTargetOf,
|
||||
} from '../../propertyPorts';
|
||||
import { asEntity, writeTyped } from '../../values';
|
||||
import { exec, obj } from '../shared';
|
||||
@@ -19,13 +19,13 @@ export const Properties: NodeDef = {
|
||||
inputs: [obj('object')],
|
||||
outputs: [],
|
||||
params: [OBJECT_TYPE_SETTING, OBJECT_BEHAVIOR_SETTING],
|
||||
// The title names both ("Sprite properties", "Game properties").
|
||||
hiddenParams: () => [OBJECT_TYPE_SETTING.key, OBJECT_BEHAVIOR_SETTING.key],
|
||||
hiddenParams: (params) => (propertyTargetOf(params) === 'behavior' ? [] : [OBJECT_BEHAVIOR_SETTING.key]),
|
||||
declaresPorts: 'both',
|
||||
declaredPort: (port, node) => propertyPort(port, node.params),
|
||||
derivePorts: ({ node, behaviors }) => {
|
||||
const label = propertiesTitle(node, behaviors);
|
||||
return (node.ports ?? []).some((p) => p.write) ? { label, inputs: [exec()], outputs: [exec()] } : { label };
|
||||
derivePorts: ({ node }) => {
|
||||
const ports = node.ports ?? [];
|
||||
const shape = ports.some((p) => p.write) ? { inputs: [exec()], outputs: [exec()] } : {};
|
||||
return node.collapsed ? { ...shape, label: collapsedTitle(ports, 'properties') } : shape;
|
||||
},
|
||||
read: (_ctx, _params, input) => asEntity(input('object'))?.props ?? {},
|
||||
run: (_ctx, inputs, _params, def) => {
|
||||
|
||||
Reference in new issue
Block a user