reflex 0.5.7a1__py3-none-any.whl → 0.5.8a1__py3-none-any.whl

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.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

Files changed (44) hide show
  1. reflex/.templates/web/utils/state.js +1 -1
  2. reflex/app.py +20 -2
  3. reflex/components/core/banner.py +14 -0
  4. reflex/components/core/banner.pyi +3 -3
  5. reflex/components/core/debounce.py +3 -0
  6. reflex/components/el/__init__.py +1 -0
  7. reflex/components/el/__init__.pyi +8 -5
  8. reflex/components/el/elements/__init__.py +3 -1
  9. reflex/components/el/elements/__init__.pyi +8 -6
  10. reflex/components/el/elements/media.py +98 -18
  11. reflex/components/el/elements/media.pyi +523 -18
  12. reflex/components/el/elements/metadata.py +5 -1
  13. reflex/components/radix/primitives/base.py +1 -1
  14. reflex/components/radix/themes/layout/list.py +0 -2
  15. reflex/components/recharts/cartesian.py +46 -20
  16. reflex/components/recharts/cartesian.pyi +26 -14
  17. reflex/components/recharts/charts.py +4 -0
  18. reflex/components/recharts/charts.pyi +3 -0
  19. reflex/components/recharts/general.py +23 -9
  20. reflex/components/recharts/general.pyi +6 -4
  21. reflex/components/recharts/polar.py +35 -11
  22. reflex/components/recharts/polar.pyi +35 -7
  23. reflex/components/sonner/toast.py +28 -2
  24. reflex/components/sonner/toast.pyi +14 -7
  25. reflex/constants/base.py +21 -0
  26. reflex/constants/event.py +2 -0
  27. reflex/experimental/vars/__init__.py +17 -0
  28. reflex/experimental/vars/base.py +282 -15
  29. reflex/experimental/vars/function.py +214 -0
  30. reflex/experimental/vars/number.py +1295 -0
  31. reflex/experimental/vars/sequence.py +1039 -0
  32. reflex/reflex.py +29 -2
  33. reflex/state.py +59 -10
  34. reflex/utils/imports.py +71 -8
  35. reflex/utils/prerequisites.py +115 -35
  36. reflex/utils/pyi_generator.py +2 -0
  37. reflex/utils/redir.py +52 -0
  38. reflex/vars.py +220 -11
  39. reflex/vars.pyi +20 -2
  40. {reflex-0.5.7a1.dist-info → reflex-0.5.8a1.dist-info}/METADATA +2 -2
  41. {reflex-0.5.7a1.dist-info → reflex-0.5.8a1.dist-info}/RECORD +44 -40
  42. {reflex-0.5.7a1.dist-info → reflex-0.5.8a1.dist-info}/LICENSE +0 -0
  43. {reflex-0.5.7a1.dist-info → reflex-0.5.8a1.dist-info}/WHEEL +0 -0
  44. {reflex-0.5.7a1.dist-info → reflex-0.5.8a1.dist-info}/entry_points.txt +0 -0
@@ -4,7 +4,7 @@ import io from "socket.io-client";
4
4
  import JSON5 from "json5";
5
5
  import env from "/env.json";
6
6
  import Cookies from "universal-cookie";
7
- import { useEffect, useReducer, useRef, useState } from "react";
7
+ import { useEffect, useRef, useState } from "react";
8
8
  import Router, { useRouter } from "next/router";
9
9
  import {
10
10
  initialEvents,
reflex/app.py CHANGED
@@ -112,11 +112,29 @@ def default_backend_exception_handler(exception: Exception) -> EventSpec:
112
112
  EventSpec: The window alert event.
113
113
 
114
114
  """
115
+ from reflex.components.sonner.toast import Toaster, toast
116
+
115
117
  error = traceback.format_exc()
116
118
 
117
119
  console.error(f"[Reflex Backend Exception]\n {error}\n")
118
120
 
119
- return window_alert("An error occurred. See logs for details.")
121
+ error_message = (
122
+ ["Contact the website administrator."]
123
+ if is_prod_mode()
124
+ else [f"{type(exception).__name__}: {exception}.", "See logs for details."]
125
+ )
126
+ if Toaster.is_used:
127
+ return toast(
128
+ level="error",
129
+ title="An error occurred.",
130
+ description="<br/>".join(error_message),
131
+ position="top-center",
132
+ id="backend_error",
133
+ style={"width": "500px"},
134
+ ) # type: ignore
135
+ else:
136
+ error_message.insert(0, "An error occurred.")
137
+ return window_alert("\n".join(error_message))
120
138
 
121
139
 
122
140
  def default_overlay_component() -> Component:
@@ -183,7 +201,7 @@ class App(MiddlewareMixin, LifespanMixin, Base):
183
201
 
184
202
  # A component that is present on every page (defaults to the Connection Error banner).
185
203
  overlay_component: Optional[Union[Component, ComponentCallable]] = (
186
- default_overlay_component
204
+ default_overlay_component()
187
205
  )
188
206
 
189
207
  # Error boundary component to wrap the app with.
@@ -153,6 +153,20 @@ useEffect(() => {{
153
153
  hook,
154
154
  ]
155
155
 
156
+ @classmethod
157
+ def create(cls, *children, **props) -> Component:
158
+ """Create a connection toaster component.
159
+
160
+ Args:
161
+ *children: The children of the component.
162
+ **props: The properties of the component.
163
+
164
+ Returns:
165
+ The connection toaster component.
166
+ """
167
+ Toaster.is_used = True
168
+ return super().create(*children, **props)
169
+
156
170
 
157
171
  class ConnectionBanner(Component):
158
172
  """A connection banner component."""
@@ -187,7 +187,7 @@ class ConnectionToaster(Toaster):
187
187
  ] = None,
188
188
  **props,
189
189
  ) -> "ConnectionToaster":
190
- """Create the component.
190
+ """Create a connection toaster component.
191
191
 
192
192
  Args:
193
193
  *children: The children of the component.
@@ -211,10 +211,10 @@ class ConnectionToaster(Toaster):
211
211
  class_name: The class name for the component.
212
212
  autofocus: Whether the component should take the focus once the page is loaded
213
213
  custom_attrs: custom attribute
214
- **props: The props of the component.
214
+ **props: The properties of the component.
215
215
 
216
216
  Returns:
217
- The component.
217
+ The connection toaster component.
218
218
  """
219
219
  ...
220
220
 
@@ -101,6 +101,9 @@ class DebounceInput(Component):
101
101
  props.setdefault("style", {}).update(child.style)
102
102
  if child.class_name is not None:
103
103
  props["class_name"] = f"{props.get('class_name', '')} {child.class_name}"
104
+ for field in ("key", "special_props"):
105
+ if getattr(child, field) is not None:
106
+ props[field] = getattr(child, field)
104
107
  child_ref = child.get_ref()
105
108
  if props.get("input_ref") is None and child_ref:
106
109
  props["input_ref"] = Var.create_safe(
@@ -10,6 +10,7 @@ _SUBMODULES: set[str] = {"elements"}
10
10
  _SUBMOD_ATTRS: dict[str, list[str]] = {
11
11
  f"elements.{k}": v for k, v in elements._MAPPING.items()
12
12
  }
13
+ _PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS
13
14
 
14
15
  __getattr__, __dir__, __all__ = lazy_loader.attach(
15
16
  __name__,
@@ -3,6 +3,7 @@
3
3
  # This file was generated by `reflex/utils/pyi_generator.py`!
4
4
  # ------------------------------------------------------
5
5
 
6
+ from . import elements
6
7
  from .elements.forms import Button as Button
7
8
  from .elements.forms import Fieldset as Fieldset
8
9
  from .elements.forms import Form as Form
@@ -91,7 +92,7 @@ from .elements.media import Defs as Defs
91
92
  from .elements.media import Embed as Embed
92
93
  from .elements.media import Iframe as Iframe
93
94
  from .elements.media import Img as Img
94
- from .elements.media import Lineargradient as Lineargradient
95
+ from .elements.media import LinearGradient as LinearGradient
95
96
  from .elements.media import Map as Map
96
97
  from .elements.media import Object as Object
97
98
  from .elements.media import Path as Path
@@ -104,19 +105,19 @@ from .elements.media import Track as Track
104
105
  from .elements.media import Video as Video
105
106
  from .elements.media import area as area
106
107
  from .elements.media import audio as audio
107
- from .elements.media import defs as defs
108
+ from .elements.media import defs as defs # type: ignore
108
109
  from .elements.media import embed as embed
109
110
  from .elements.media import iframe as iframe
110
111
  from .elements.media import image as image
111
112
  from .elements.media import img as img
112
- from .elements.media import lineargradient as lineargradient
113
+ from .elements.media import lineargradient as lineargradient # type: ignore
113
114
  from .elements.media import map as map
114
115
  from .elements.media import object as object
115
- from .elements.media import path as path
116
+ from .elements.media import path as path # type: ignore
116
117
  from .elements.media import picture as picture
117
118
  from .elements.media import portal as portal
118
119
  from .elements.media import source as source
119
- from .elements.media import stop as stop
120
+ from .elements.media import stop as stop # type: ignore
120
121
  from .elements.media import svg as svg
121
122
  from .elements.media import track as track
122
123
  from .elements.media import video as video
@@ -230,3 +231,5 @@ from .elements.typography import ol as ol
230
231
  from .elements.typography import p as p
231
232
  from .elements.typography import pre as pre
232
233
  from .elements.typography import ul as ul
234
+
235
+ _PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS
@@ -67,6 +67,7 @@ _MAPPING = {
67
67
  "svg",
68
68
  "defs",
69
69
  "lineargradient",
70
+ "LinearGradient",
70
71
  "stop",
71
72
  "path",
72
73
  ],
@@ -129,12 +130,13 @@ _MAPPING = {
129
130
  }
130
131
 
131
132
 
132
- EXCLUDE = ["del_", "Del", "image"]
133
+ EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"]
133
134
  for _, v in _MAPPING.items():
134
135
  v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE])
135
136
 
136
137
  _SUBMOD_ATTRS: dict[str, list[str]] = _MAPPING
137
138
 
139
+ _PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"]
138
140
  __getattr__, __dir__, __all__ = lazy_loader.attach(
139
141
  __name__,
140
142
  submod_attrs=_SUBMOD_ATTRS,
@@ -91,7 +91,7 @@ from .media import Defs as Defs
91
91
  from .media import Embed as Embed
92
92
  from .media import Iframe as Iframe
93
93
  from .media import Img as Img
94
- from .media import Lineargradient as Lineargradient
94
+ from .media import LinearGradient as LinearGradient
95
95
  from .media import Map as Map
96
96
  from .media import Object as Object
97
97
  from .media import Path as Path
@@ -104,19 +104,19 @@ from .media import Track as Track
104
104
  from .media import Video as Video
105
105
  from .media import area as area
106
106
  from .media import audio as audio
107
- from .media import defs as defs
107
+ from .media import defs as defs # type: ignore
108
108
  from .media import embed as embed
109
109
  from .media import iframe as iframe
110
110
  from .media import image as image
111
111
  from .media import img as img
112
- from .media import lineargradient as lineargradient
112
+ from .media import lineargradient as lineargradient # type: ignore
113
113
  from .media import map as map
114
114
  from .media import object as object
115
- from .media import path as path
115
+ from .media import path as path # type: ignore
116
116
  from .media import picture as picture
117
117
  from .media import portal as portal
118
118
  from .media import source as source
119
- from .media import stop as stop
119
+ from .media import stop as stop # type: ignore
120
120
  from .media import svg as svg
121
121
  from .media import track as track
122
122
  from .media import video as video
@@ -294,6 +294,7 @@ _MAPPING = {
294
294
  "svg",
295
295
  "defs",
296
296
  "lineargradient",
297
+ "LinearGradient",
297
298
  "stop",
298
299
  "path",
299
300
  ],
@@ -347,6 +348,7 @@ _MAPPING = {
347
348
  "Del",
348
349
  ],
349
350
  }
350
- EXCLUDE = ["del_", "Del", "image"]
351
+ EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"]
351
352
  for _, v in _MAPPING.items():
352
353
  v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE])
354
+ _PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"]
@@ -2,8 +2,9 @@
2
2
 
3
3
  from typing import Any, Union
4
4
 
5
- from reflex import Component
5
+ from reflex import Component, ComponentNamespace
6
6
  from reflex.constants.colors import Color
7
+ from reflex.utils import console
7
8
  from reflex.vars import Var as Var
8
9
 
9
10
  from .base import BaseHTML
@@ -309,6 +310,56 @@ class Svg(BaseHTML):
309
310
  """Display the svg element."""
310
311
 
311
312
  tag = "svg"
313
+ # The width of the svg.
314
+ width: Var[Union[str, int]]
315
+ # The height of the svg.
316
+ height: Var[Union[str, int]]
317
+ # The XML namespace declaration.
318
+ xmlns: Var[str]
319
+
320
+
321
+ class Circle(BaseHTML):
322
+ """The SVG circle component."""
323
+
324
+ tag = "circle"
325
+ # The x-axis coordinate of the center of the circle.
326
+ cx: Var[Union[str, int]]
327
+ # The y-axis coordinate of the center of the circle.
328
+ cy: Var[Union[str, int]]
329
+ # The radius of the circle.
330
+ r: Var[Union[str, int]]
331
+ # The total length for the circle's circumference, in user units.
332
+ path_length: Var[int]
333
+
334
+
335
+ class Rect(BaseHTML):
336
+ """The SVG rect component."""
337
+
338
+ tag = "rect"
339
+ # The x coordinate of the rect.
340
+ x: Var[Union[str, int]]
341
+ # The y coordinate of the rect.
342
+ y: Var[Union[str, int]]
343
+ # The width of the rect
344
+ width: Var[Union[str, int]]
345
+ # The height of the rect.
346
+ height: Var[Union[str, int]]
347
+ # The horizontal corner radius of the rect. Defaults to ry if it is specified.
348
+ rx: Var[Union[str, int]]
349
+ # The vertical corner radius of the rect. Defaults to rx if it is specified.
350
+ ry: Var[Union[str, int]]
351
+ # The total length of the rectangle's perimeter, in user units.
352
+ path_length: Var[int]
353
+
354
+
355
+ class Polygon(BaseHTML):
356
+ """The SVG polygon component."""
357
+
358
+ tag = "polygon"
359
+ # defines the list of points (pairs of x,y absolute coordinates) required to draw the polygon.
360
+ points: Var[str]
361
+ # This prop lets specify the total length for the path, in user units.
362
+ path_length: Var[int]
312
363
 
313
364
 
314
365
  class Defs(BaseHTML):
@@ -317,30 +368,30 @@ class Defs(BaseHTML):
317
368
  tag = "defs"
318
369
 
319
370
 
320
- class Lineargradient(BaseHTML):
371
+ class LinearGradient(BaseHTML):
321
372
  """Display the linearGradient element."""
322
373
 
323
374
  tag = "linearGradient"
324
375
 
325
- # Units for the gradient
376
+ # Units for the gradient.
326
377
  gradient_units: Var[Union[str, bool]]
327
378
 
328
- # Transform applied to the gradient
379
+ # Transform applied to the gradient.
329
380
  gradient_transform: Var[Union[str, bool]]
330
381
 
331
- # Method used to spread the gradient
382
+ # Method used to spread the gradient.
332
383
  spread_method: Var[Union[str, bool]]
333
384
 
334
- # X coordinate of the starting point of the gradient
385
+ # X coordinate of the starting point of the gradient.
335
386
  x1: Var[Union[str, int, bool]]
336
387
 
337
- # X coordinate of the ending point of the gradient
388
+ # X coordinate of the ending point of the gradient.
338
389
  x2: Var[Union[str, int, bool]]
339
390
 
340
- # Y coordinate of the starting point of the gradient
391
+ # Y coordinate of the starting point of the gradient.
341
392
  y1: Var[Union[str, int, bool]]
342
393
 
343
- # Y coordinate of the ending point of the gradient
394
+ # Y coordinate of the ending point of the gradient.
344
395
  y2: Var[Union[str, int, bool]]
345
396
 
346
397
 
@@ -349,13 +400,13 @@ class Stop(BaseHTML):
349
400
 
350
401
  tag = "stop"
351
402
 
352
- # Offset of the gradient stop
403
+ # Offset of the gradient stop.
353
404
  offset: Var[Union[str, float, int]]
354
405
 
355
- # Color of the gradient stop
406
+ # Color of the gradient stop.
356
407
  stop_color: Var[Union[str, Color, bool]]
357
408
 
358
- # Opacity of the gradient stop
409
+ # Opacity of the gradient stop.
359
410
  stop_opacity: Var[Union[str, float, int, bool]]
360
411
 
361
412
 
@@ -364,10 +415,23 @@ class Path(BaseHTML):
364
415
 
365
416
  tag = "path"
366
417
 
367
- # Defines the shape of the path
418
+ # Defines the shape of the path.
368
419
  d: Var[Union[str, int, bool]]
369
420
 
370
421
 
422
+ class SVG(ComponentNamespace):
423
+ """SVG component namespace."""
424
+
425
+ circle = staticmethod(Circle.create)
426
+ rect = staticmethod(Rect.create)
427
+ polygon = staticmethod(Polygon.create)
428
+ path = staticmethod(Path.create)
429
+ stop = staticmethod(Stop.create)
430
+ linear_gradient = staticmethod(LinearGradient.create)
431
+ defs = staticmethod(Defs.create)
432
+ __call__ = staticmethod(Svg.create)
433
+
434
+
371
435
  area = Area.create
372
436
  audio = Audio.create
373
437
  image = img = Img.create
@@ -380,8 +444,24 @@ object = Object.create
380
444
  picture = Picture.create
381
445
  portal = Portal.create
382
446
  source = Source.create
383
- svg = Svg.create
384
- defs = Defs.create
385
- lineargradient = Lineargradient.create
386
- stop = Stop.create
387
- path = Path.create
447
+ svg = SVG()
448
+
449
+
450
+ def __getattr__(name: str):
451
+ if name in ("defs", "lineargradient", "stop", "path"):
452
+ console.deprecate(
453
+ f"`rx.el.{name}`",
454
+ reason=f"use `rx.el.svg.{'linear_gradient' if name =='lineargradient' else name}`",
455
+ deprecation_version="0.5.8",
456
+ removal_version="0.6.0",
457
+ )
458
+ return (
459
+ LinearGradient.create
460
+ if name == "lineargradient"
461
+ else globals()[name.capitalize()].create
462
+ )
463
+
464
+ try:
465
+ return globals()[name]
466
+ except KeyError:
467
+ raise AttributeError(f"module '{__name__} has no attribute '{name}'") from None