panel-reactflow 0.4.1__tar.gz → 0.5.0b0__tar.gz

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.
Files changed (97) hide show
  1. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.github/workflows/build.yml +5 -5
  2. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.github/workflows/docs.yml +6 -6
  3. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.github/workflows/test.yml +13 -13
  4. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/PKG-INFO +30 -2
  5. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/README.md +28 -0
  6. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/how-to/declare-types.md +56 -6
  7. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/how-to/define-nodes-edges.md +53 -11
  8. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/how-to/react-to-events.md +1 -0
  9. panel_reactflow-0.5.0b0/docs/how-to/recover-from-errors.md +121 -0
  10. panel_reactflow-0.5.0b0/docs/how-to/validate-connections.md +82 -0
  11. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/index.md +1 -0
  12. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/releases.md +73 -0
  13. panel_reactflow-0.5.0b0/examples/connection_validation.py +89 -0
  14. panel_reactflow-0.5.0b0/examples/port_value_inspection.py +123 -0
  15. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/pixi.lock +5810 -5952
  16. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/src/panel_reactflow/base.py +814 -200
  17. panel_reactflow-0.5.0b0/src/panel_reactflow/dist/css/reactflow.css +273 -0
  18. panel_reactflow-0.5.0b0/src/panel_reactflow/dist/panel-reactflow.bundle.js +88 -0
  19. panel_reactflow-0.5.0b0/src/panel_reactflow/models/reactflow.jsx +1655 -0
  20. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/test_api.py +782 -0
  21. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/test_core.py +2 -0
  22. panel_reactflow-0.5.0b0/tests/test_error_recovery.py +128 -0
  23. panel_reactflow-0.5.0b0/tests/ui/test_error_recovery.py +161 -0
  24. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/ui/test_ui.py +431 -1
  25. panel_reactflow-0.5.0b0/tests/ui/test_value_popup.py +239 -0
  26. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/zensical.toml +3 -1
  27. panel_reactflow-0.4.1/src/panel_reactflow/dist/css/reactflow.css +0 -117
  28. panel_reactflow-0.4.1/src/panel_reactflow/dist/panel-reactflow.bundle.js +0 -88
  29. panel_reactflow-0.4.1/src/panel_reactflow/models/reactflow.jsx +0 -789
  30. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.copier-answers.yml +0 -0
  31. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.gitattributes +0 -0
  32. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.github/CODEOWNERS +0 -0
  33. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.github/dependabot.yml +0 -0
  34. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.gitignore +0 -0
  35. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.pre-commit-config.yaml +0 -0
  36. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/.prettierrc +0 -0
  37. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/LICENSE.txt +0 -0
  38. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/MANIFEST.in +0 -0
  39. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/logo.svg +0 -0
  40. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/declare-types.png +0 -0
  41. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/define-editors-edge.png +0 -0
  42. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/define-editors-node.png +0 -0
  43. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/define-nodes-edges.png +0 -0
  44. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/embed-views-in-nodes.png +0 -0
  45. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/examples/advanced.png +0 -0
  46. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/examples/custom_editor.png +0 -0
  47. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/examples/edge_editors.png +0 -0
  48. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/examples/node_edge_instances.png +0 -0
  49. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/examples/schema_types.png +0 -0
  50. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/examples/simple.png +0 -0
  51. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/examples/threejs_viewer.png +0 -0
  52. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/examples/threejs_viewer_instances.png +0 -0
  53. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/quickstart.png +0 -0
  54. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/react-to-events.png +0 -0
  55. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/assets/screenshots/style-nodes-edges.png +0 -0
  56. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/advanced.md +0 -0
  57. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/custom-editor.md +0 -0
  58. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/edge-editors.md +0 -0
  59. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/index.md +0 -0
  60. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/node-edge-instances.md +0 -0
  61. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/schema-types.md +0 -0
  62. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/simple.md +0 -0
  63. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/threejs-viewer-instances.md +0 -0
  64. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/examples/threejs-viewer.md +0 -0
  65. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/how-to/context-menu.md +0 -0
  66. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/how-to/control-handle-connectivity.md +0 -0
  67. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/how-to/define-editors.md +0 -0
  68. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/how-to/embed-views-in-nodes.md +0 -0
  69. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/how-to/style-nodes-edges.md +0 -0
  70. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/quickstart.md +0 -0
  71. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/docs/reference/panel_reactflow.md +0 -0
  72. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/advanced.py +0 -0
  73. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/context_menu.py +0 -0
  74. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/custom_editor.py +0 -0
  75. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/edge_editors.py +0 -0
  76. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/edge_types_comparison.py +0 -0
  77. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/node_edge_instances.py +0 -0
  78. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/schema_types.py +0 -0
  79. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/simple.py +0 -0
  80. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/smart_edges_example.py +0 -0
  81. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/threejs_viewer.py +0 -0
  82. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/examples/threejs_viewer_instances.py +0 -0
  83. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/hatch_build.py +0 -0
  84. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/pixi.toml +0 -0
  85. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/pyproject.toml +0 -0
  86. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/src/panel_reactflow/__init__.py +0 -0
  87. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/src/panel_reactflow/__version.py +0 -0
  88. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/src/panel_reactflow/dist/icons/gear.svg +0 -0
  89. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/src/panel_reactflow/dist/panel-reactflow.bundle.css +0 -0
  90. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/src/panel_reactflow/py.typed +0 -0
  91. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/src/panel_reactflow/schema.py +0 -0
  92. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/__init__.py +0 -0
  93. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/conftest.py +0 -0
  94. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/test_connectable_handles.py +0 -0
  95. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/test_connectable_integration.py +0 -0
  96. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/ui/__init__.py +0 -0
  97. {panel_reactflow-0.4.1 → panel_reactflow-0.5.0b0}/tests/ui/test_context_menu.py +0 -0
@@ -11,11 +11,11 @@ jobs:
11
11
  build:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
14
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
15
15
  with:
16
16
  fetch-depth: 0
17
17
  - name: Set up pixi
18
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
18
+ uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e # v0.10.2
19
19
  with:
20
20
  environments: build
21
21
  - name: Build project
@@ -23,7 +23,7 @@ jobs:
23
23
  - name: Check package
24
24
  run: pixi run -e build check-wheel
25
25
  - name: Upload package
26
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
26
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
27
27
  with:
28
28
  name: artifact
29
29
  path: dist/*
@@ -37,9 +37,9 @@ jobs:
37
37
  id-token: write
38
38
  environment: pypi
39
39
  steps:
40
- - uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
40
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
41
41
  with:
42
42
  name: artifact
43
43
  path: dist
44
44
  - name: Publish package on PyPi
45
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
45
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
@@ -43,23 +43,23 @@ jobs:
43
43
  runs-on: ubuntu-latest
44
44
 
45
45
  steps:
46
- - uses: actions/checkout@v6
46
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
47
47
  with:
48
48
  fetch-depth: 0
49
49
  - name: Set up Pixi
50
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
50
+ uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e # v0.10.2
51
51
  with:
52
52
  environments: docs
53
53
  - name: Build documentation
54
54
  run: pixi run -e docs docs-build
55
- - uses: actions/upload-artifact@v7
55
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
56
56
  if: always()
57
57
  with:
58
58
  name: docs
59
59
  if-no-files-found: error
60
60
  path: builtdocs
61
61
  - name: Upload artifact
62
- uses: actions/upload-pages-artifact@v4
62
+ uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
63
63
  with:
64
64
  path: ./builtdocs
65
65
 
@@ -71,7 +71,7 @@ jobs:
71
71
  needs: build
72
72
  steps:
73
73
  - name: Deploy dev
74
- uses: peaceiris/actions-gh-pages@v4
74
+ uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
75
75
  # Dev site built on PRs
76
76
  if: |
77
77
  (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
@@ -88,4 +88,4 @@ jobs:
88
88
  ((github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'main') ||
89
89
  (github.event_name == 'push' && !(contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc'))))
90
90
  id: deployment
91
- uses: actions/deploy-pages@v4
91
+ uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
@@ -20,10 +20,10 @@ jobs:
20
20
  code_change: ${{ steps.filter.outputs.code }}
21
21
  matrix: ${{ env.MATRIX }}
22
22
  steps:
23
- - uses: actions/checkout@v6
23
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
24
24
  if: github.event_name != 'pull_request'
25
25
  - name: Check for code changes
26
- uses: dorny/paths-filter@v3
26
+ uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
27
27
  id: filter
28
28
  with:
29
29
  filters: |
@@ -72,7 +72,7 @@ jobs:
72
72
  name: Pixi lock
73
73
  runs-on: ubuntu-latest
74
74
  steps:
75
- - uses: holoviz-dev/holoviz_tasks/pixi_lock@v0
75
+ - uses: holoviz-dev/holoviz_tasks/pixi-lock@8fb2d0a3e4c70e218d487e0eed3b9c2488997212 # v1.0.6
76
76
  with:
77
77
  cache: ${{ github.event.inputs.cache == 'true' || github.event.inputs.cache == '' }}
78
78
 
@@ -80,15 +80,15 @@ jobs:
80
80
  needs: [setup, pixi_lock]
81
81
  runs-on: "ubuntu-latest"
82
82
  steps:
83
- - uses: actions/checkout@v6
83
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
84
84
  - name: Set up pixi
85
- uses: prefix-dev/setup-pixi@v0.9.4
86
- - uses: holoviz-dev/holoviz_tasks/pre-commit@v0
87
- - uses: pre-commit/action@v3.0.1
85
+ uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e # v0.10.2
86
+ - uses: holoviz-dev/holoviz_tasks/pre-commit@8fb2d0a3e4c70e218d487e0eed3b9c2488997212 # v1.0.6
87
+ - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
88
88
  if: needs.setup.outputs.img_change == 'true'
89
89
  with:
90
90
  extra_args: -a --hook-stage manual oxipng || true --
91
- - uses: stefanzweifel/git-auto-commit-action@v7
91
+ - uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
92
92
  if: needs.setup.outputs.img_change == 'true'
93
93
  with:
94
94
  commit_message: "Optimize PNG images (lossless)"
@@ -111,11 +111,11 @@ jobs:
111
111
  - windows-latest
112
112
  steps:
113
113
  - name: Checkout branch
114
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
114
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
115
115
  with:
116
116
  fetch-depth: 0
117
117
  - name: Set up pixi
118
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
118
+ uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e # v0.10.2
119
119
  with:
120
120
  environments: ${{ matrix.environment }}
121
121
  - name: Install repository
@@ -139,7 +139,7 @@ jobs:
139
139
  PANEL_LOG_LEVEL: info
140
140
  FAIL: "--screenshot only-on-failure --full-page-screenshot --output ui_screenshots --tracing retain-on-failure"
141
141
  steps:
142
- - uses: holoviz-dev/holoviz_tasks/pixi_install@v0
142
+ - uses: holoviz-dev/holoviz_tasks/pixi-install@8fb2d0a3e4c70e218d487e0eed3b9c2488997212 # v1.0.6
143
143
  with:
144
144
  environments: ${{ matrix.environment }}
145
145
  install: false
@@ -151,14 +151,14 @@ jobs:
151
151
  echo "[run]\nconcurrency = greenlet" > .uicoveragerc
152
152
  pixi run -e ${{ matrix.environment }} test-ui $COV --cov-config=.uicoveragerc $FAIL
153
153
  - name: Upload UI Screenshots
154
- uses: actions/upload-artifact@v7
154
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
155
155
  if: always()
156
156
  with:
157
157
  name: ui_screenshots_${{ runner.os }}
158
158
  path: ./ui_screenshots
159
159
  if-no-files-found: ignore
160
160
  - name: Upload coverage reports to Codecov
161
- uses: codecov/codecov-action@v5
161
+ uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
162
162
  with:
163
163
  token: ${{ secrets.CODECOV_TOKEN }}
164
164
  slug: panel-extensions/panel-splitjs
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: panel-reactflow
3
- Version: 0.4.1
3
+ Version: 0.5.0b0
4
4
  Summary: A Panel wrapper for the Reactflow JS library.
5
5
  Project-URL: Homepage, https://github.com/panel-extensions/panel-reactflow
6
6
  Project-URL: Source, https://github.com/panel-extensions/panel-reactflow
@@ -114,6 +114,34 @@ flow
114
114
 
115
115
  For property schemas and richer editors, provide `node_types`/`edge_types` with `PropertySpec` and handle changes via `ReactFlow.on(...)`. `.on` callbacks receive the event payload as the first argument and can optionally accept the `ReactFlow` instance as a second argument.
116
116
 
117
+ ## Connection validation
118
+
119
+ Connection checks are opt-in. For frontend-only validation, set `connection_validation` with any of `direction`, `types`, `capacity`, `duplicates`, or `cycles` set to `True`. `types` compares declared handle types case-insensitively and permits unknown types; `capacity` uses `maxConnections` on input handle dictionaries, with no limit when omitted. Existing handle connectability flags still apply.
120
+
121
+ ```python
122
+ from panel_reactflow import NodeType, ReactFlow
123
+
124
+ flow = ReactFlow(
125
+ node_types={
126
+ "source": NodeType(type="source", outputs=[{"id": "value", "type": "str"}]),
127
+ "sink": NodeType(type="sink", inputs=[{"id": "value", "type": "str", "maxConnections": 1}]),
128
+ },
129
+ connection_validation={"direction": True, "types": True, "capacity": True, "cycles": True},
130
+ )
131
+ ```
132
+
133
+ For application rules, register a Python validator. On each drag start, ReactFlow requests results for every candidate port and shows the returned reasons while dragging. The callback receives an edge-shaped payload with `source`, `target`, `sourceHandle`, and `targetHandle`; return `None` to allow or a string to reject. Hooks and frontend checks can be used together. Validate again in your `edge_added` handler before accepting the connection, since the graph may have changed after drag start.
134
+
135
+ ```python
136
+ def validate_connection(edge, flow):
137
+ if edge["source"] == edge["target"]:
138
+ return "A node cannot connect to itself."
139
+
140
+ flow.add_connection_validator(validate_connection)
141
+ ```
142
+
143
+ Run the [connection validation demo](examples/connection_validation.py) with `PYTHONPATH=src pixi run panel serve examples/connection_validation.py --show` from the repository root.
144
+
117
145
  ## Development
118
146
 
119
147
  ```bash
@@ -71,6 +71,34 @@ flow
71
71
 
72
72
  For property schemas and richer editors, provide `node_types`/`edge_types` with `PropertySpec` and handle changes via `ReactFlow.on(...)`. `.on` callbacks receive the event payload as the first argument and can optionally accept the `ReactFlow` instance as a second argument.
73
73
 
74
+ ## Connection validation
75
+
76
+ Connection checks are opt-in. For frontend-only validation, set `connection_validation` with any of `direction`, `types`, `capacity`, `duplicates`, or `cycles` set to `True`. `types` compares declared handle types case-insensitively and permits unknown types; `capacity` uses `maxConnections` on input handle dictionaries, with no limit when omitted. Existing handle connectability flags still apply.
77
+
78
+ ```python
79
+ from panel_reactflow import NodeType, ReactFlow
80
+
81
+ flow = ReactFlow(
82
+ node_types={
83
+ "source": NodeType(type="source", outputs=[{"id": "value", "type": "str"}]),
84
+ "sink": NodeType(type="sink", inputs=[{"id": "value", "type": "str", "maxConnections": 1}]),
85
+ },
86
+ connection_validation={"direction": True, "types": True, "capacity": True, "cycles": True},
87
+ )
88
+ ```
89
+
90
+ For application rules, register a Python validator. On each drag start, ReactFlow requests results for every candidate port and shows the returned reasons while dragging. The callback receives an edge-shaped payload with `source`, `target`, `sourceHandle`, and `targetHandle`; return `None` to allow or a string to reject. Hooks and frontend checks can be used together. Validate again in your `edge_added` handler before accepting the connection, since the graph may have changed after drag start.
91
+
92
+ ```python
93
+ def validate_connection(edge, flow):
94
+ if edge["source"] == edge["target"]:
95
+ return "A node cannot connect to itself."
96
+
97
+ flow.add_connection_validator(validate_connection)
98
+ ```
99
+
100
+ Run the [connection validation demo](examples/connection_validation.py) with `PYTHONPATH=src pixi run panel serve examples/connection_validation.py --show` from the repository root.
101
+
74
102
  ## Development
75
103
 
76
104
  ```bash
@@ -244,7 +244,8 @@ validation or auto-generated forms.
244
244
  ## Handle tooltips
245
245
 
246
246
  By default, handles are plain connection points. You can add a tooltip (shown
247
- on hover) by passing a dict with `"id"` and `"label"` instead of a plain string:
247
+ on hover) by passing a dict with `"id"` and `"label"` and/or `"type"` instead
248
+ of a plain string:
248
249
 
249
250
  ```python
250
251
  from panel_reactflow import NodeType
@@ -253,19 +254,68 @@ node_types = {
253
254
  "transform": NodeType(
254
255
  type="transform",
255
256
  label="Transform",
256
- inputs=[{"id": "in", "label": "Data Input"}],
257
+ inputs=[{"id": "in", "label": "Data Input", "type": "DataFrame"}],
257
258
  outputs=[
258
- {"id": "success", "label": "Successful results"},
259
- {"id": "error", "label": "Failed records"},
259
+ {"id": "success", "label": "Successful results", "type": "DataFrame"},
260
+ {"id": "error", "label": "Failed records", "type": "list"},
260
261
  ],
261
262
  ),
262
263
  }
263
264
  ```
264
265
 
265
- Plain strings and dicts can be mixed freely in the same list:
266
+ The tooltip combines both when present (`"Data Input (DataFrame)"`), or falls
267
+ back to whichever one is given. Plain strings and dicts can be mixed freely in
268
+ the same list:
266
269
 
267
270
  ```python
268
- inputs=["simple_port", {"id": "documented_port", "label": "Hover to see this"}]
271
+ inputs=["simple_port", {"id": "documented_port", "label": "Hover to see this", "type": "int"}]
272
+ ```
273
+
274
+ ---
275
+
276
+ ## Show a port's current value on click
277
+
278
+ Clicking a handle emits a `"handle_clicked"` event with the node id, handle
279
+ id, direction (`"input"`/`"output"`) and a screen position. Clicking an edge
280
+ emits `"edge_clicked"` with the edge id and position. Use
281
+ `ReactFlow.show_popup(content, position)` in the handler to display whatever
282
+ you consider the "current value" for that port or connection:
283
+
284
+ ```python
285
+ def on_handle_clicked(payload, flow):
286
+ node_id, handle_id = payload["node_id"], payload["handle_id"]
287
+ value = live_values.get(node_id, {}).get(handle_id)
288
+ flow.show_popup(pn.pane.Markdown(f"**{handle_id}**: {value!r}"), payload["position"])
289
+
290
+ def on_edge_clicked(payload, flow):
291
+ source_id, source_port = edge_sources[payload["edge_id"]]
292
+ value = live_values.get(source_id, {}).get(source_port)
293
+ flow.show_popup(pn.pane.Markdown(f"**Value:** {value!r}"), payload["position"])
294
+
295
+ flow.on("handle_clicked", on_handle_clicked)
296
+ flow.on("edge_clicked", on_edge_clicked)
297
+ ```
298
+
299
+ For `popup_trigger="hover"`, register `handle_hovered` and `edge_hovered` to
300
+ show the popup and their corresponding `handle_unhovered` and `edge_unhovered`
301
+ events to call `flow.close_popup()`. Match the unhovered target against the
302
+ currently displayed one so a delayed leave event does not dismiss a newer
303
+ popup. See the runnable example below for both pairs of callbacks.
304
+
305
+ The default `popup_hover_delay` is 500 ms. After opening, an unhover event is
306
+ emitted when the pointer moves more than 10% of the shorter canvas dimension
307
+ from the anchor (at least 48 pixels) and is not over the popup. Click-opened
308
+ popups dismiss on outside click; either mode can dismiss programmatically via
309
+ `flow.close_popup()`. Use
310
+ `popup_trigger="none"` to disable the built-in inspection events.
311
+ `panel-reactflow` only provides the interaction events and overlay; looking up
312
+ "the current value" for a port is application-specific.
313
+
314
+ For a complete runnable graph with typed port hover tooltips and popups for
315
+ both handles and edges, run:
316
+
317
+ ```bash
318
+ panel serve examples/port_value_inspection.py --show
269
319
  ```
270
320
 
271
321
  ---
@@ -358,26 +358,45 @@ Without `sourceHandle` and `targetHandle`, edges connect to the default (first)
358
358
 
359
359
  ---
360
360
 
361
- ## Update data vs. label
361
+ ## Update data vs. presentation
362
362
 
363
- `data` and `label` live in different places and are updated differently:
364
-
365
- - **Data** — use `patch_node_data()` or `patch_edge_data()`. This sends
366
- an incremental patch to the frontend without replacing the full list.
367
- - **Label** — replace the node/edge in `flow.nodes` or `flow.edges`.
363
+ A node or edge has an arbitrary `data` dictionary plus a set of top-level React
364
+ Flow fields (`label`, `style`, `type`, `className`, `position`, ...). Each has
365
+ its own patch method, and both send an incremental update to the frontend
366
+ instead of replacing the full list:
368
367
 
369
368
  ```python
370
369
  # Patch a data field
371
370
  flow.patch_node_data("n1", {"status": "running"})
372
371
  flow.patch_edge_data("e1", {"weight": 0.75})
373
372
 
374
- # Update a label
375
- flow.nodes = [
376
- {**node, "label": "Start (running)"} if node["id"] == "n1" else node
377
- for node in flow.nodes
378
- ]
373
+ # Patch a top-level field
374
+ flow.patch_node_props("n1", {"label": "Start (running)", "className": "busy"})
375
+ flow.patch_edge_props("e1", {"style": {"stroke": "#ef4444", "strokeWidth": 4}, "type": "step"})
376
+ ```
377
+
378
+ Passing `None` to `patch_node_props()`/`patch_edge_props()` clears the field so
379
+ the element falls back to the CSS/theme default:
380
+
381
+ ```python
382
+ flow.patch_edge_props("e1", {"style": None})
379
383
  ```
380
384
 
385
+ If you use `Node`/`Edge` subclasses, you rarely need either method: assigning to
386
+ a parameter patches the browser in place. Parameters you declare on the
387
+ subclass are synced into `data`, the presentational base parameters are synced
388
+ as top-level fields.
389
+
390
+ ```python
391
+ node.label = "Start (running)" # top-level label
392
+ edge.style = {"stroke": "#ef4444"} # top-level style
393
+ edge.weight = 0.75 # subclass param, goes into data
394
+ ```
395
+
396
+ `position` and `selected` are the exception: the browser owns them while the
397
+ user drags or selects, so assignment does not push them. Use
398
+ `patch_node_props()` to move or select a node from Python.
399
+
381
400
  ---
382
401
 
383
402
  ## Add and remove at runtime
@@ -399,3 +418,26 @@ flow.add_edge(EdgeSpec(id="e2", source="n3", target="n4"))
399
418
  flow.remove_node("n3") # also removes connected edges
400
419
  flow.remove_edge("e1")
401
420
  ```
421
+
422
+ `remove_node()` and `remove_edge()` also take several ids at once, either as
423
+ separate arguments or as a single sequence. Pass them together rather than
424
+ calling the methods in a loop: a batch assigns `nodes` and `edges` once, so the
425
+ browser renders a single update instead of one per element.
426
+
427
+ ```python
428
+ flow.remove_node("n1", "n2", "n3") # also removes connected edges
429
+ flow.remove_edge(["e1", "e2"])
430
+ ```
431
+
432
+ More generally, every parameter assignment is synced to the browser on its own
433
+ and the canvas re-renders per sync, so a sequence of updates renders each
434
+ intermediate graph. Wrap any batch of changes in `pn.io.hold()` to combine them
435
+ into a single render:
436
+
437
+ ```python
438
+ import panel as pn
439
+
440
+ with pn.io.hold():
441
+ flow.nodes = new_nodes
442
+ flow.edges = new_edges
443
+ ```
@@ -30,6 +30,7 @@ the `ReactFlow` instance as a second argument. You can also listen for
30
30
  | `edge_data_changed` | Edge data is patched (via API, editor patch, or parameter-driven sync). | `edge_id`, `patch` |
31
31
  | `selection_changed` | The active selection changes. | `nodes`, `edges` |
32
32
  | `sync` | A batch sync from the frontend. | *(varies)* |
33
+ | `client_error` | The graph view hit a rendering error in the browser. See [Recover from Rendering Errors](recover-from-errors.md). | `source`, `message`, `stack`, `component_stack`, `attempt`, `mode` |
33
34
 
34
35
  ---
35
36
 
@@ -0,0 +1,121 @@
1
+ # Recover from Rendering Errors
2
+
3
+ A React rendering error is unforgiving: when a component throws during
4
+ render, React unmounts the whole subtree. In a graph editor that means a
5
+ single malformed node can blank the canvas, and because the exception dies
6
+ in the browser console the server never learns about it. The user is left
7
+ staring at an empty viewport with no way back other than reloading the page,
8
+ even though their graph is still safely held in Python.
9
+
10
+ Panel-ReactFlow wraps the canvas in an error boundary that catches those
11
+ errors, tries to bring the view back, and reports what happened to the
12
+ server. This is on by default, controlled by the `error_recovery`
13
+ parameter.
14
+
15
+ ```python
16
+ from panel_reactflow import ReactFlow
17
+
18
+ flow = ReactFlow(nodes=nodes, edges=edges, error_recovery="auto")
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Recovery modes
24
+
25
+ | Mode | Behavior |
26
+ |------------|----------|
27
+ | `"auto"` | *(default)* Remount the canvas once, then remount again in safe mode. If it still fails, show the recovery panel. |
28
+ | `"manual"` | Report the error and show the recovery panel immediately, without retrying. |
29
+ | `"off"` | Disable the error boundary entirely so exceptions propagate to the browser. Useful when debugging a custom node component. |
30
+
31
+ Each retry budget refills once a remounted canvas has survived for five
32
+ seconds, so a graph that breaks again much later still gets a fresh set of
33
+ attempts rather than going straight to the failure panel.
34
+
35
+ ---
36
+
37
+ ## What safe mode does
38
+
39
+ On the second attempt the frontend validates the graph before handing it to
40
+ React Flow and either repairs or hides anything it cannot render:
41
+
42
+ | Issue | Action |
43
+ |-------|--------|
44
+ | `invalid_position` | Position is missing or not finite, so the node is placed at the origin. |
45
+ | `unknown_node_type` | Node type is not registered, so the node falls back to the default renderer. |
46
+ | `unknown_edge_type` | Edge type is not registered, so the type is stripped. |
47
+ | `dangling_edge` | Edge references a node that does not exist, so it is hidden. |
48
+ | `duplicate_node_id` / `duplicate_edge_id` | Later duplicates are hidden. |
49
+ | `missing_node_id` / `missing_edge_id` / `invalid_node` / `invalid_edge` | The element is hidden. |
50
+
51
+ Safe mode is **view-only**. It filters what the browser renders and never
52
+ sends a graph mutation back to Python, so `flow.nodes` and `flow.edges` keep
53
+ every element they had before the error. Once the underlying state is
54
+ repaired on the server, the affected elements reappear.
55
+
56
+ A banner tells the user what was changed and offers a details list of the
57
+ individual issues:
58
+
59
+ ```text
60
+ Safe mode: repaired 1 element and hid 1 element that could not be rendered.
61
+ Nothing was deleted on the server.
62
+ ```
63
+
64
+ ---
65
+
66
+ ## The recovery panel
67
+
68
+ When retries are exhausted, or in `"manual"` mode, the canvas is replaced by
69
+ a panel that names the error and offers three actions: *Try again*, which
70
+ remounts the canvas, *Reload page*, which rebuilds the session from the
71
+ server-side state, and *Copy details*, which puts a JSON diagnostic blob on
72
+ the clipboard for a bug report.
73
+
74
+ Because Python holds the canonical graph, reloading is genuinely safe: no
75
+ work is lost. The panel says so explicitly, which matters when the
76
+ alternative is a user assuming their graph is gone.
77
+
78
+ ---
79
+
80
+ ## Log and handle errors in Python
81
+
82
+ Every error the frontend catches is reported to the server, logged to the
83
+ `panel.reactflow` logger, and emitted as a `client_error` event.
84
+
85
+ ```python
86
+ import logging
87
+
88
+ logging.getLogger("panel.reactflow").setLevel(logging.INFO)
89
+
90
+ def on_client_error(payload, flow):
91
+ if payload["source"] == "safe_mode":
92
+ print("hidden or repaired:", payload["issues"])
93
+ else:
94
+ print(f"render error on attempt {payload['attempt']}: {payload['message']}")
95
+
96
+ flow.on("client_error", on_client_error)
97
+ ```
98
+
99
+ Render errors carry `name`, `message`, `stack`, `component_stack`, `attempt`,
100
+ `mode` and `auto_retry`. Errors raised inside interaction handlers are
101
+ reported with `source="handler"` and the `handler` name, which catches the
102
+ case where a drag or connect silently fails and leaves the canvas showing a
103
+ change that never reached Python. Safe mode reports arrive with
104
+ `source="safe_mode"` and the list of `issues`.
105
+
106
+ Use this hook to forward errors to your own telemetry, to snapshot the graph
107
+ for later inspection, or to attempt a server-side repair before the user
108
+ clicks *Try again*.
109
+
110
+ ---
111
+
112
+ ## Tips
113
+
114
+ - Keep `error_recovery="auto"` in production; switch to `"off"` while
115
+ developing a custom node component so you see the real stack trace.
116
+ - A `client_error` with `source="safe_mode"` is a strong signal that
117
+ something upstream produced invalid state. Treat it as a bug report
118
+ rather than a warning to be ignored.
119
+ - The error boundary only covers the graph canvas. Content you pass to
120
+ `top_panel`, `bottom_panel`, `left_panel` and `right_panel` stays mounted
121
+ when the canvas fails, so side panels remain usable during recovery.
@@ -0,0 +1,82 @@
1
+ # Validate Connections
2
+
3
+ Use `connection_validation` to reject invalid connections as users drag between handles. The policies run in the browser; a Python validator can add application-specific rules. Both are opt-in and can be used together.
4
+
5
+ ## Configure browser policies
6
+
7
+ Set only the checks your graph needs:
8
+
9
+ | Policy | Rejects |
10
+ |--------|---------|
11
+ | `direction` | Connections that do not run from a declared output to a declared input. Users can still start a drag at either end. |
12
+ | `types` | Connections between handles with different declared `type` values (case-insensitive). If either type is missing, the connection is allowed. |
13
+ | `capacity` | Connections to an input handle that has reached its positive integer `maxConnections` limit. Inputs without a limit are unrestricted. |
14
+ | `duplicates` | A second edge with the same source, target, source handle, and target handle. Different handle pairs can still connect the same nodes. |
15
+ | `cycles` | Connections that would create a cycle, including a self-connection. |
16
+
17
+ Policies default to off. Existing `NodeType` connectable flags still control whether a handle can start or receive a drag; see [Control Handle Connectivity](control-handle-connectivity.md).
18
+
19
+ The following app uses handle types and capacity limits alongside a Python rule. Save it as `validation_app.py` and run `panel serve validation_app.py --show`:
20
+
21
+ ```python
22
+ import panel as pn
23
+
24
+ from panel_reactflow import NodeSpec, NodeType, ReactFlow
25
+
26
+ pn.extension("jsoneditor")
27
+
28
+ flow = ReactFlow(
29
+ nodes=[
30
+ NodeSpec(id="source", type="source", label="Source", position={"x": 0, "y": 0}),
31
+ NodeSpec(id="transform", type="transform", label="Transform", position={"x": 260, "y": 0}),
32
+ NodeSpec(id="publish", type="publish", label="Publish", position={"x": 520, "y": 0}),
33
+ ],
34
+ node_types={
35
+ "source": NodeType(type="source", outputs=[{"id": "text", "type": "Text"}]),
36
+ "transform": NodeType(
37
+ type="transform",
38
+ inputs=[{"id": "text", "type": "text", "maxConnections": 1}],
39
+ outputs=[{"id": "cleaned", "type": "Text"}],
40
+ ),
41
+ "publish": NodeType(type="publish", inputs=[{"id": "text", "type": "Text", "maxConnections": 1}]),
42
+ },
43
+ connection_validation={
44
+ "direction": True,
45
+ "types": True,
46
+ "capacity": True,
47
+ "duplicates": True,
48
+ "cycles": True,
49
+ },
50
+ height=350,
51
+ width=800,
52
+ )
53
+
54
+
55
+ def validate_connection(edge, flow):
56
+ if edge["source"] == "source" and edge["target"] == "publish":
57
+ return "Publish requires the Transform output."
58
+ return None
59
+
60
+
61
+ flow.add_connection_validator(validate_connection)
62
+
63
+
64
+ def on_edge_added(event, flow):
65
+ edge = event["edge"]
66
+ if validate_connection(edge, flow):
67
+ flow.remove_edge(edge["id"])
68
+
69
+
70
+ flow.on("edge_added", on_edge_added)
71
+ flow.servable()
72
+ ```
73
+
74
+ Drag from **Source.text** to **Transform.text**, then from **Transform.cleaned** to **Publish.text**. A direct connection from Source to Publish is rejected by Python. Try connecting Source.text to Transform.cleaned (two outputs) to see the direction check, or connect an output to an already occupied input to see the capacity check.
75
+
76
+ ## Add application rules
77
+
78
+ Register callbacks with `flow.add_connection_validator(callback)` and unregister them with `flow.remove_connection_validator(callback)`. Each callback accepts either `edge` or `(edge, flow)` and returns `None` to allow the connection or a reason string to reject it. The payload has `source`, `target`, `sourceHandle`, and `targetHandle` keys; handles without an explicit ID use `None`.
79
+
80
+ When a user starts dragging from an output or input, Python checks every candidate handle on the opposite side. Validators run in registration order until one rejects a candidate. Browser policies and Python reasons are shown on handles while dragging; the browser prevents a rejected connection. Python results must arrive before the connection is dropped: pending requests and requests taking longer than three seconds block the connection. Exceptions also reject the candidate and are logged on the server. Keep validators fast.
81
+
82
+ Validation is for interactive drags, not a constraint on `flow.edges` or `flow.add_edge()`. Python validators run at drag start, not when the edge is added. If the rule depends on graph state that may change during the drag, check it again in an `edge_added` handler before keeping or persisting the edge. The example above removes an edge if its application rule no longer holds.
@@ -62,6 +62,7 @@ flow.servable()
62
62
  - [Define Nodes & Edges](how-to/define-nodes-edges.md)
63
63
  - [Declare Node & Edge Types](how-to/declare-types.md)
64
64
  - [Control Handle Connectivity](how-to/control-handle-connectivity.md) — restrict connections
65
+ - [Validate Connections](how-to/validate-connections.md) — check types, capacity, cycles, and application rules
65
66
  - [Define Editors](how-to/define-editors.md) — node *and* edge editors
66
67
  - [Embed Views in Nodes](how-to/embed-views-in-nodes.md)
67
68
  - [Style Nodes & Edges](how-to/style-nodes-edges.md)