Skip to content

Commit fa48bbc

Browse files
authored
Rework VDOM construction and type hints (#1281)
- Removed ``reactpy.vdom``. Use ``reactpy.Vdom`` instead. - Removed ``reactpy.core.make_vdom_constructor``. Use ``reactpy.Vdom`` instead. - Removed ``reactpy.core.custom_vdom_constructor``. Use ``reactpy.Vdom`` instead. - ``reactpy.html`` will now automatically flatten lists recursively (ex. ``reactpy.html(["child1", ["child2"]])``) - Added type hints to ``reactpy.html`` attributes.
1 parent 3c6abe6 commit fa48bbc

16 files changed

+1218
-469
lines changed

docs/source/about/changelog.rst

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ Unreleased
1919
- :pull:`1113` - Added ``reactpy.executors.asgi.ReactPy`` that can be used to run ReactPy in standalone mode via ASGI.
2020
- :pull:`1269` - Added ``reactpy.executors.asgi.ReactPyPyodide`` that can be used to run ReactPy in standalone mode via ASGI, but rendered entirely client-sided.
2121
- :pull:`1113` - Added ``reactpy.executors.asgi.ReactPyMiddleware`` that can be used to utilize ReactPy within any ASGI compatible framework.
22-
- :pull:`1113` :pull:`1269` - Added ``reactpy.templatetags.Jinja`` that can be used alongside ``ReactPyMiddleware`` to embed several ReactPy components into your existing application. This includes the following template tags: ``{% component %}``, ``{% pyscript_component %}``, and ``{% pyscript_setup %}``.
22+
- :pull:`1269` - Added ``reactpy.templatetags.Jinja`` that can be used alongside ``ReactPyMiddleware`` to embed several ReactPy components into your existing application. This includes the following template tags: ``{% component %}``, ``{% pyscript_component %}``, and ``{% pyscript_setup %}``.
2323
- :pull:`1269` - Added ``reactpy.pyscript_component`` that can be used to embed ReactPy components into your existing application.
2424
- :pull:`1113` - Added ``uvicorn`` and ``jinja`` installation extras (for example ``pip install reactpy[jinja]``).
2525
- :pull:`1113` - Added support for Python 3.12 and 3.13.
2626
- :pull:`1264` - Added ``reactpy.use_async_effect`` hook.
2727
- :pull:`1267` - Added ``shutdown_timeout`` parameter to the ``reactpy.use_async_effect`` hook.
28+
- :pull:`1281` - ``reactpy.html`` will now automatically flatten lists recursively (ex. ``reactpy.html(["child1", ["child2"]])``)
29+
- :pull:`1281` - Added ``reactpy.Vdom`` primitive interface for creating VDOM dictionaries.
30+
- :pull:`1281` - Added type hints to ``reactpy.html`` attributes.
2831

2932
**Changed**
3033

@@ -40,6 +43,9 @@ Unreleased
4043
- :pull:`1263` - ReactPy no longer auto-converts ``snake_case`` props to ``camelCase``. It is now the responsibility of the user to ensure that props are in the correct format.
4144
- :pull:`1278` - ``reactpy.utils.reactpy_to_string`` will now retain the user's original casing for ``data-*`` and ``aria-*`` attributes.
4245
- :pull:`1278` - ``reactpy.utils.string_to_reactpy`` has been upgraded to handle more complex scenarios without causing ReactJS rendering errors.
46+
- :pull:`1281` - ``reactpy.core.vdom._CustomVdomDictConstructor`` has been moved to ``reactpy.types.CustomVdomConstructor``.
47+
- :pull:`1281` - ``reactpy.core.vdom._EllipsisRepr`` has been moved to ``reactpy.types.EllipsisRepr``.
48+
- :pull:`1281` - ``reactpy.types.VdomDictConstructor`` has been renamed to ``reactpy.types.VdomConstructor``.
4349

4450
**Removed**
4551

@@ -56,6 +62,9 @@ Unreleased
5662
- :pull:`1113` - Removed deprecated function ``module_from_template``.
5763
- :pull:`1113` - Removed support for Python 3.9.
5864
- :pull:`1264` - Removed support for async functions within ``reactpy.use_effect`` hook. Use ``reactpy.use_async_effect`` instead.
65+
- :pull:`1281` - Removed ``reactpy.vdom``. Use ``reactpy.Vdom`` instead.
66+
- :pull:`1281` - Removed ``reactpy.core.make_vdom_constructor``. Use ``reactpy.Vdom`` instead.
67+
- :pull:`1281` - Removed ``reactpy.core.custom_vdom_constructor``. Use ``reactpy.Vdom`` instead.
5968

6069
**Fixed**
6170

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ filterwarnings = """
107107
ignore::DeprecationWarning:uvicorn.*
108108
ignore::DeprecationWarning:websockets.*
109109
ignore::UserWarning:tests.test_core.test_vdom
110+
ignore::UserWarning:tests.test_pyscript.test_components
111+
ignore::UserWarning:tests.test_utils
110112
"""
111113
testpaths = "tests"
112114
xfail_strict = true

src/reactpy/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use_state,
2020
)
2121
from reactpy.core.layout import Layout
22-
from reactpy.core.vdom import vdom
22+
from reactpy.core.vdom import Vdom
2323
from reactpy.pyscript.components import pyscript_component
2424
from reactpy.utils import Ref, reactpy_to_string, string_to_reactpy
2525

@@ -29,6 +29,7 @@
2929
__all__ = [
3030
"Layout",
3131
"Ref",
32+
"Vdom",
3233
"component",
3334
"config",
3435
"create_context",
@@ -52,7 +53,6 @@
5253
"use_ref",
5354
"use_scope",
5455
"use_state",
55-
"vdom",
5656
"web",
5757
"widgets",
5858
]

0 commit comments

Comments
 (0)