From 65c62dcaa9c1acf3c463ac5a3735691f20e972a9 Mon Sep 17 00:00:00 2001 From: Jo-Byr Date: Tue, 16 Jun 2026 15:04:22 +0200 Subject: [PATCH] fix: fix connection-mode Move connection-mode attribute from Handle to NodeEditor Add isValidConnection to Handle --- pyproject.toml | 2 +- src/trame_flow/widgets/flow/node_editor.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7388146..9cc5d60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "trame-flow" version = "2.2.0" description = "A node editor for trame using VueFlow" authors = [ - {name = "Trame Developer"}, + {name = "Kitware Inc."}, ] dependencies = [ "trame_client>=3.10", diff --git a/src/trame_flow/widgets/flow/node_editor.py b/src/trame_flow/widgets/flow/node_editor.py index 4c15b11..82211f9 100644 --- a/src/trame_flow/widgets/flow/node_editor.py +++ b/src/trame_flow/widgets/flow/node_editor.py @@ -45,14 +45,14 @@ def __init__( :param type: Type of the handle. :param connectable: (Optional) Boolean, integer for maximum connection number or function that returns a boolean. :param id: (Optional) ID of the handle. Useful when using multiple source handles or target handles. - :param connection_mode: (Optional) Defines if a handle can be connected to another handle with the same type. "loose" (default) or "strict". + :param is_valid_connection: (Optional) Must be a JS function expression that takes a connection object and returns a bool indicating if it is valid. """ super().__init__("Handle", position=position, type=type, **kwargs) self._attr_names += [ "connectable", - ("connection_mode", "connection-mode"), "id", + ("is_valid_connection", "isValidConnection"), "position", "type", ] @@ -64,11 +64,20 @@ class NodeEditor(HtmlElement): _next_id = 0 def __init__(self, **kwargs): + """ + :param connection_mode: (Optional) Defines if a handle can be connected to another handle with the same type. "loose" (default) or "strict". + :param is_valid_connection: (Optional) Must be a JS function expression that takes a connection object and returns a bool indicating if it is valid. + """ super().__init__( "node-editor", **kwargs, ) + self._attr_names += [ + ("connection_mode", "connectionMode"), + ("is_valid_connection", "isValidConnection"), + ] + self._event_names += [ ("click_connect_end", "clickConnectEnd"), ("click_connect_start", "clickConnectStart"),