reflex 0.6.8a1__py3-none-any.whl → 0.7.0a1__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 (155) hide show
  1. reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +1 -1
  2. reflex/.templates/jinja/web/pages/_app.js.jinja2 +7 -7
  3. reflex/.templates/jinja/web/pages/utils.js.jinja2 +2 -2
  4. reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +1 -4
  5. reflex/.templates/web/utils/state.js +65 -36
  6. reflex/__init__.py +4 -17
  7. reflex/__init__.pyi +1 -2
  8. reflex/app.py +244 -115
  9. reflex/app_mixins/lifespan.py +9 -9
  10. reflex/app_mixins/middleware.py +6 -6
  11. reflex/app_module_for_backend.py +3 -7
  12. reflex/base.py +7 -7
  13. reflex/compiler/compiler.py +8 -0
  14. reflex/compiler/utils.py +35 -6
  15. reflex/components/base/bare.py +1 -1
  16. reflex/components/base/error_boundary.py +2 -1
  17. reflex/components/base/error_boundary.pyi +2 -1
  18. reflex/components/base/meta.py +2 -2
  19. reflex/components/base/strict_mode.py +10 -0
  20. reflex/components/base/strict_mode.pyi +57 -0
  21. reflex/components/component.py +38 -77
  22. reflex/components/core/banner.py +83 -4
  23. reflex/components/core/banner.pyi +86 -0
  24. reflex/components/core/breakpoints.py +3 -1
  25. reflex/components/core/client_side_routing.py +1 -1
  26. reflex/components/core/client_side_routing.pyi +1 -1
  27. reflex/components/core/cond.py +9 -10
  28. reflex/components/core/debounce.py +1 -1
  29. reflex/components/core/foreach.py +23 -3
  30. reflex/components/core/html.py +1 -1
  31. reflex/components/core/match.py +5 -5
  32. reflex/components/core/sticky.py +160 -0
  33. reflex/components/core/sticky.pyi +449 -0
  34. reflex/components/core/upload.py +2 -2
  35. reflex/components/datadisplay/code.py +5 -14
  36. reflex/components/datadisplay/dataeditor.py +7 -4
  37. reflex/components/datadisplay/logo.py +13 -8
  38. reflex/components/datadisplay/shiki_code_block.py +14 -9
  39. reflex/components/dynamic.py +22 -3
  40. reflex/components/el/constants/reflex.py +1 -1
  41. reflex/components/el/element.py +1 -1
  42. reflex/components/el/elements/forms.py +4 -4
  43. reflex/components/el/elements/forms.pyi +4 -4
  44. reflex/components/lucide/icon.py +46 -8
  45. reflex/components/lucide/icon.pyi +54 -0
  46. reflex/components/markdown/markdown.py +10 -8
  47. reflex/components/moment/moment.py +2 -2
  48. reflex/components/next/image.py +16 -4
  49. reflex/components/next/image.pyi +4 -2
  50. reflex/components/next/link.py +1 -1
  51. reflex/components/plotly/plotly.py +5 -5
  52. reflex/components/props.py +3 -3
  53. reflex/components/radix/__init__.pyi +1 -1
  54. reflex/components/radix/primitives/accordion.py +9 -5
  55. reflex/components/radix/primitives/accordion.pyi +3 -1
  56. reflex/components/radix/primitives/drawer.py +5 -2
  57. reflex/components/radix/primitives/drawer.pyi +4 -4
  58. reflex/components/radix/primitives/form.pyi +6 -6
  59. reflex/components/radix/primitives/progress.py +1 -1
  60. reflex/components/radix/primitives/slider.py +1 -1
  61. reflex/components/radix/themes/color_mode.py +11 -9
  62. reflex/components/radix/themes/components/alert_dialog.py +3 -0
  63. reflex/components/radix/themes/components/card.py +1 -1
  64. reflex/components/radix/themes/components/card.pyi +1 -1
  65. reflex/components/radix/themes/components/context_menu.py +5 -0
  66. reflex/components/radix/themes/components/dialog.py +3 -0
  67. reflex/components/radix/themes/components/dropdown_menu.py +5 -0
  68. reflex/components/radix/themes/components/hover_card.py +3 -0
  69. reflex/components/radix/themes/components/icon_button.py +2 -2
  70. reflex/components/radix/themes/components/icon_button.pyi +1 -0
  71. reflex/components/radix/themes/components/popover.py +3 -0
  72. reflex/components/radix/themes/components/radio_cards.py +2 -0
  73. reflex/components/radix/themes/components/radio_group.py +1 -1
  74. reflex/components/radix/themes/components/select.py +3 -0
  75. reflex/components/radix/themes/components/tabs.py +3 -0
  76. reflex/components/radix/themes/components/text_area.py +12 -0
  77. reflex/components/radix/themes/components/text_area.pyi +2 -0
  78. reflex/components/radix/themes/components/text_field.py +1 -1
  79. reflex/components/radix/themes/components/tooltip.py +3 -1
  80. reflex/components/radix/themes/components/tooltip.pyi +1 -0
  81. reflex/components/radix/themes/layout/__init__.pyi +1 -1
  82. reflex/components/radix/themes/layout/list.py +2 -2
  83. reflex/components/radix/themes/layout/stack.py +2 -2
  84. reflex/components/radix/themes/typography/link.py +1 -1
  85. reflex/components/radix/themes/typography/text.py +2 -2
  86. reflex/components/react_player/react_player.py +1 -1
  87. reflex/components/recharts/__init__.py +2 -0
  88. reflex/components/recharts/__init__.pyi +2 -0
  89. reflex/components/recharts/charts.py +15 -15
  90. reflex/components/recharts/general.py +19 -4
  91. reflex/components/recharts/general.pyi +55 -4
  92. reflex/components/recharts/polar.py +2 -2
  93. reflex/components/recharts/recharts.py +4 -4
  94. reflex/components/sonner/toast.py +15 -13
  95. reflex/components/sonner/toast.pyi +6 -6
  96. reflex/components/suneditor/editor.py +6 -4
  97. reflex/components/suneditor/editor.pyi +2 -2
  98. reflex/components/tags/iter_tag.py +3 -3
  99. reflex/components/tags/tag.py +25 -3
  100. reflex/config.py +48 -20
  101. reflex/constants/__init__.py +1 -0
  102. reflex/constants/base.py +4 -1
  103. reflex/constants/compiler.py +5 -2
  104. reflex/constants/config.py +8 -1
  105. reflex/constants/installer.py +9 -9
  106. reflex/constants/style.py +1 -1
  107. reflex/custom_components/custom_components.py +9 -7
  108. reflex/event.py +137 -163
  109. reflex/experimental/__init__.py +19 -11
  110. reflex/experimental/client_state.py +53 -28
  111. reflex/experimental/hooks.py +5 -5
  112. reflex/experimental/layout.py +8 -5
  113. reflex/experimental/layout.pyi +1 -1
  114. reflex/experimental/misc.py +3 -3
  115. reflex/istate/wrappers.py +1 -1
  116. reflex/middleware/hydrate_middleware.py +2 -2
  117. reflex/model.py +11 -6
  118. reflex/page.py +3 -3
  119. reflex/reflex.py +90 -19
  120. reflex/route.py +1 -1
  121. reflex/state.py +358 -401
  122. reflex/style.py +27 -3
  123. reflex/testing.py +34 -39
  124. reflex/utils/build.py +6 -2
  125. reflex/utils/codespaces.py +1 -4
  126. reflex/utils/compat.py +6 -5
  127. reflex/utils/console.py +52 -21
  128. reflex/utils/exceptions.py +76 -26
  129. reflex/utils/exec.py +69 -74
  130. reflex/utils/export.py +6 -1
  131. reflex/utils/format.py +7 -39
  132. reflex/utils/imports.py +2 -2
  133. reflex/utils/lazy_loader.py +7 -1
  134. reflex/utils/path_ops.py +28 -14
  135. reflex/utils/prerequisites.py +324 -65
  136. reflex/utils/processes.py +45 -32
  137. reflex/utils/pyi_generator.py +30 -25
  138. reflex/utils/registry.py +4 -4
  139. reflex/utils/serializers.py +1 -1
  140. reflex/utils/telemetry.py +5 -4
  141. reflex/utils/types.py +42 -18
  142. reflex/vars/base.py +650 -333
  143. reflex/vars/datetime.py +6 -7
  144. reflex/vars/dep_tracking.py +344 -0
  145. reflex/vars/function.py +11 -5
  146. reflex/vars/number.py +31 -43
  147. reflex/vars/object.py +63 -62
  148. reflex/vars/sequence.py +79 -67
  149. {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/METADATA +7 -10
  150. {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/RECORD +153 -150
  151. {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/WHEEL +1 -1
  152. reflex/experimental/assets.py +0 -37
  153. reflex/proxy.py +0 -119
  154. {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/LICENSE +0 -0
  155. {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/entry_points.txt +0 -0
@@ -14,6 +14,7 @@ from ..base import RadixThemesComponent
14
14
  LiteralSideType = Literal["top", "right", "bottom", "left"]
15
15
  LiteralAlignType = Literal["start", "center", "end"]
16
16
  LiteralStickyType = Literal["partial", "always"]
17
+ ARIA_LABEL_KEY = "aria_label"
17
18
 
18
19
  class Tooltip(RadixThemesComponent):
19
20
  @overload
@@ -9,7 +9,7 @@ from .container import container as container
9
9
  from .flex import flex as flex
10
10
  from .grid import grid as grid
11
11
  from .list import list_item as list_item
12
- from .list import list_ns as list # noqa
12
+ from .list import list_ns as list # noqa: F401
13
13
  from .list import ordered_list as ordered_list
14
14
  from .list import unordered_list as unordered_list
15
15
  from .section import section as section
@@ -72,7 +72,7 @@ class BaseList(Component, MarkdownComponentMap):
72
72
  if isinstance(items, Var):
73
73
  children = [Foreach.create(items, ListItem.create)]
74
74
  else:
75
- children = [ListItem.create(item) for item in items] # type: ignore
75
+ children = [ListItem.create(item) for item in items]
76
76
  props["direction"] = "column"
77
77
  style = props.setdefault("style", {})
78
78
  style["list_style_type"] = list_style_type
@@ -189,7 +189,7 @@ ordered_list = list_ns.ordered
189
189
  unordered_list = list_ns.unordered
190
190
 
191
191
 
192
- def __getattr__(name):
192
+ def __getattr__(name: Any):
193
193
  # special case for when accessing list to avoid shadowing
194
194
  # python's built in list object.
195
195
  if name == "list":
@@ -49,14 +49,14 @@ class VStack(Stack):
49
49
  """A vertical stack component."""
50
50
 
51
51
  # The direction of the stack.
52
- direction: Var[LiteralFlexDirection] = "column" # type: ignore
52
+ direction: Var[LiteralFlexDirection] = Var.create("column")
53
53
 
54
54
 
55
55
  class HStack(Stack):
56
56
  """A horizontal stack component."""
57
57
 
58
58
  # The direction of the stack.
59
- direction: Var[LiteralFlexDirection] = "row" # type: ignore
59
+ direction: Var[LiteralFlexDirection] = Var.create("row")
60
60
 
61
61
 
62
62
  stack = Stack.create
@@ -60,7 +60,7 @@ class Link(RadixThemesComponent, A, MemoizationLeaf, MarkdownComponentMap):
60
60
  Returns:
61
61
  The import dict.
62
62
  """
63
- return next_link._get_imports() # type: ignore
63
+ return next_link._get_imports() # pyright: ignore [reportReturnType]
64
64
 
65
65
  @classmethod
66
66
  def create(cls, *children, **props) -> Component:
@@ -47,7 +47,7 @@ class Text(elements.Span, RadixThemesComponent, MarkdownComponentMap):
47
47
  as_child: Var[bool]
48
48
 
49
49
  # Change the default rendered element into a semantically appropriate alternative (cannot be used with asChild)
50
- as_: Var[LiteralType] = "p" # type: ignore
50
+ as_: Var[LiteralType] = Var.create("p")
51
51
 
52
52
  # Text size: "1" - "9"
53
53
  size: Var[Responsive[LiteralTextSize]]
@@ -71,7 +71,7 @@ class Text(elements.Span, RadixThemesComponent, MarkdownComponentMap):
71
71
  class Span(Text):
72
72
  """A variant of text rendering as <span> element."""
73
73
 
74
- as_: Var[LiteralType] = "span" # type: ignore
74
+ as_: Var[LiteralType] = Var.create("span")
75
75
 
76
76
 
77
77
  class Em(elements.Em, RadixThemesComponent):
@@ -39,7 +39,7 @@ class ReactPlayer(NoSSRComponent):
39
39
  loop: Var[bool]
40
40
 
41
41
  # Set to true or false to display native player controls.
42
- controls: Var[bool] = True # type: ignore
42
+ controls: Var[bool] = Var.create(True)
43
43
 
44
44
  # Set to true to show just the video thumbnail, which loads the full player on click
45
45
  light: Var[bool]
@@ -70,6 +70,8 @@ _SUBMOD_ATTRS: dict = {
70
70
  "Label",
71
71
  "label_list",
72
72
  "LabelList",
73
+ "cell",
74
+ "Cell",
73
75
  ],
74
76
  "polar": [
75
77
  "pie",
@@ -53,11 +53,13 @@ from .charts import radar_chart as radar_chart
53
53
  from .charts import radial_bar_chart as radial_bar_chart
54
54
  from .charts import scatter_chart as scatter_chart
55
55
  from .charts import treemap as treemap
56
+ from .general import Cell as Cell
56
57
  from .general import GraphingTooltip as GraphingTooltip
57
58
  from .general import Label as Label
58
59
  from .general import LabelList as LabelList
59
60
  from .general import Legend as Legend
60
61
  from .general import ResponsiveContainer as ResponsiveContainer
62
+ from .general import cell as cell
61
63
  from .general import graphing_tooltip as graphing_tooltip
62
64
  from .general import label as label
63
65
  from .general import label_list as label_list
@@ -25,10 +25,10 @@ class ChartBase(RechartsCharts):
25
25
  """A component that wraps a Recharts charts."""
26
26
 
27
27
  # The width of chart container. String or Integer
28
- width: Var[Union[str, int]] = "100%" # type: ignore
28
+ width: Var[Union[str, int]] = Var.create("100%")
29
29
 
30
30
  # The height of chart container.
31
- height: Var[Union[str, int]] = "100%" # type: ignore
31
+ height: Var[Union[str, int]] = Var.create("100%")
32
32
 
33
33
  # The customized event handler of click on the component in this chart
34
34
  on_click: EventHandler[no_args_event_spec]
@@ -69,7 +69,7 @@ class ChartBase(RechartsCharts):
69
69
  )
70
70
 
71
71
  @classmethod
72
- def create(cls, *children, **props) -> Component:
72
+ def create(cls, *children: Any, **props: Any) -> Component:
73
73
  """Create a chart component.
74
74
 
75
75
  Args:
@@ -84,19 +84,19 @@ class ChartBase(RechartsCharts):
84
84
  cls._ensure_valid_dimension("width", width)
85
85
  cls._ensure_valid_dimension("height", height)
86
86
 
87
- dim_props = {
88
- "width": width if width is not None else "100%",
89
- "height": height if height is not None else "100%",
90
- }
91
- # Provide min dimensions so the graph always appears, even if the outer container is zero-size.
92
- if width is None:
93
- dim_props["min_width"] = 200
94
- if height is None:
95
- dim_props["min_height"] = 100
87
+ # Ensure that the min_height and min_width are set to prevent the chart from collapsing.
88
+ # We are using small values so that height and width can still be used over min_height and min_width.
89
+ # Without this, sometimes the chart will not be visible. Causing confusion to the user.
90
+ # With this, the user will see a small chart and can adjust the height and width and can figure out that the issue is with the size.
91
+ min_height = props.pop("min_height", 10)
92
+ min_width = props.pop("min_width", 10)
96
93
 
97
94
  return ResponsiveContainer.create(
98
95
  super().create(*children, **props),
99
- **dim_props, # type: ignore
96
+ width=width if width is not None else "100%",
97
+ height=height if height is not None else "100%",
98
+ min_width=min_width,
99
+ min_height=min_height,
100
100
  )
101
101
 
102
102
 
@@ -458,10 +458,10 @@ class Treemap(RechartsCharts):
458
458
  alias = "RechartsTreemap"
459
459
 
460
460
  # The width of chart container. String or Integer. Default: "100%"
461
- width: Var[Union[str, int]] = "100%" # type: ignore
461
+ width: Var[Union[str, int]] = Var.create("100%")
462
462
 
463
463
  # The height of chart container. String or Integer. Default: "100%"
464
- height: Var[Union[str, int]] = "100%" # type: ignore
464
+ height: Var[Union[str, int]] = Var.create("100%")
465
465
 
466
466
  # data of treemap. Array
467
467
  data: Var[List[Dict[str, Any]]]
@@ -36,11 +36,11 @@ class ResponsiveContainer(Recharts, MemoizationLeaf):
36
36
  # The height of chart container. Can be a number or string. Default: "100%"
37
37
  height: Var[Union[int, str]]
38
38
 
39
- # The minimum width of chart container. Number
40
- min_width: Var[int]
39
+ # The minimum width of chart container. Number or string.
40
+ min_width: Var[Union[int, str]]
41
41
 
42
- # The minimum height of chart container. Number
43
- min_height: Var[int]
42
+ # The minimum height of chart container. Number or string.
43
+ min_height: Var[Union[int, str]]
44
44
 
45
45
  # If specified a positive number, debounced function will be used to handle the resize event. Default: 0
46
46
  debounce: Var[int]
@@ -242,8 +242,23 @@ class LabelList(Recharts):
242
242
  stroke: Var[Union[str, Color]] = LiteralVar.create("none")
243
243
 
244
244
 
245
+ class Cell(Recharts):
246
+ """A Cell component in Recharts."""
247
+
248
+ tag = "Cell"
249
+
250
+ alias = "RechartsCell"
251
+
252
+ # The presentation attribute of a rectangle in bar or a sector in pie.
253
+ fill: Var[str | Color]
254
+
255
+ # The presentation attribute of a rectangle in bar or a sector in pie.
256
+ stroke: Var[str | Color]
257
+
258
+
245
259
  responsive_container = ResponsiveContainer.create
246
260
  legend = Legend.create
247
261
  graphing_tooltip = GraphingTooltip.create
248
262
  label = Label.create
249
263
  label_list = LabelList.create
264
+ cell = Cell.create
@@ -22,8 +22,8 @@ class ResponsiveContainer(Recharts, MemoizationLeaf):
22
22
  aspect: Optional[Union[Var[int], int]] = None,
23
23
  width: Optional[Union[Var[Union[int, str]], int, str]] = None,
24
24
  height: Optional[Union[Var[Union[int, str]], int, str]] = None,
25
- min_width: Optional[Union[Var[int], int]] = None,
26
- min_height: Optional[Union[Var[int], int]] = None,
25
+ min_width: Optional[Union[Var[Union[int, str]], int, str]] = None,
26
+ min_height: Optional[Union[Var[Union[int, str]], int, str]] = None,
27
27
  debounce: Optional[Union[Var[int], int]] = None,
28
28
  style: Optional[Style] = None,
29
29
  key: Optional[Any] = None,
@@ -56,8 +56,8 @@ class ResponsiveContainer(Recharts, MemoizationLeaf):
56
56
  aspect: The aspect ratio of the container. The final aspect ratio of the SVG element will be (width / height) * aspect. Number
57
57
  width: The width of chart container. Can be a number or string. Default: "100%"
58
58
  height: The height of chart container. Can be a number or string. Default: "100%"
59
- min_width: The minimum width of chart container. Number
60
- min_height: The minimum height of chart container. Number
59
+ min_width: The minimum width of chart container. Number or string.
60
+ min_height: The minimum height of chart container. Number or string.
61
61
  debounce: If specified a positive number, debounced function will be used to handle the resize event. Default: 0
62
62
  on_resize: If specified provides a callback providing the updated chart width and height values.
63
63
  style: The style of the component.
@@ -482,8 +482,59 @@ class LabelList(Recharts):
482
482
  """
483
483
  ...
484
484
 
485
+ class Cell(Recharts):
486
+ @overload
487
+ @classmethod
488
+ def create( # type: ignore
489
+ cls,
490
+ *children,
491
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
492
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
493
+ style: Optional[Style] = None,
494
+ key: Optional[Any] = None,
495
+ id: Optional[Any] = None,
496
+ class_name: Optional[Any] = None,
497
+ autofocus: Optional[bool] = None,
498
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
499
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
500
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
501
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
502
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
503
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
504
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
505
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
506
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
507
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
508
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
509
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
510
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
511
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
512
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
513
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
514
+ **props,
515
+ ) -> "Cell":
516
+ """Create the component.
517
+
518
+ Args:
519
+ *children: The children of the component.
520
+ fill: The presentation attribute of a rectangle in bar or a sector in pie.
521
+ stroke: The presentation attribute of a rectangle in bar or a sector in pie.
522
+ style: The style of the component.
523
+ key: A unique key for the component.
524
+ id: The id for the component.
525
+ class_name: The class name for the component.
526
+ autofocus: Whether the component should take the focus once the page is loaded
527
+ custom_attrs: custom attribute
528
+ **props: The props of the component.
529
+
530
+ Returns:
531
+ The component.
532
+ """
533
+ ...
534
+
485
535
  responsive_container = ResponsiveContainer.create
486
536
  legend = Legend.create
487
537
  graphing_tooltip = GraphingTooltip.create
488
538
  label = Label.create
489
539
  label_list = LabelList.create
540
+ cell = Cell.create
@@ -64,7 +64,7 @@ class Pie(Recharts):
64
64
  legend_type: Var[LiteralLegendType]
65
65
 
66
66
  # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
67
- label: Var[bool] = False # type: ignore
67
+ label: Var[bool] = Var.create(False)
68
68
 
69
69
  # If false set, label lines will not be drawn. If true set, label lines will be drawn which have the props calculated internally. Default: False
70
70
  label_line: Var[bool]
@@ -73,7 +73,7 @@ class Pie(Recharts):
73
73
  data: Var[List[Dict[str, Any]]]
74
74
 
75
75
  # Valid children components
76
- _valid_children: List[str] = ["Cell", "LabelList"]
76
+ _valid_children: List[str] = ["Cell", "LabelList", "Bare"]
77
77
 
78
78
  # Stoke color. Default: rx.color("accent", 9)
79
79
  stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
@@ -1,6 +1,6 @@
1
1
  """A component that wraps a recharts lib."""
2
2
 
3
- from typing import Dict, Literal
3
+ from typing import Literal
4
4
 
5
5
  from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent
6
6
 
@@ -8,16 +8,16 @@ from reflex.components.component import Component, MemoizationLeaf, NoSSRCompone
8
8
  class Recharts(Component):
9
9
  """A component that wraps a recharts lib."""
10
10
 
11
- library = "recharts@2.13.0"
11
+ library = "recharts@2.15.0"
12
12
 
13
- def _get_style(self) -> Dict:
13
+ def _get_style(self) -> dict:
14
14
  return {"wrapperStyle": self.style}
15
15
 
16
16
 
17
17
  class RechartsCharts(NoSSRComponent, MemoizationLeaf):
18
18
  """A component that wraps a recharts lib."""
19
19
 
20
- library = "recharts@2.13.0"
20
+ library = "recharts@2.15.0"
21
21
 
22
22
 
23
23
  LiteralAnimationEasing = Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]
@@ -132,7 +132,7 @@ class ToastProps(PropsBase, NoExtrasAllowedProps):
132
132
  # Function that gets called when the toast disappears automatically after it's timeout (duration` prop).
133
133
  on_auto_close: Optional[Any]
134
134
 
135
- def dict(self, *args, **kwargs) -> dict[str, Any]:
135
+ def dict(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
136
136
  """Convert the object to a dictionary.
137
137
 
138
138
  Args:
@@ -142,7 +142,7 @@ class ToastProps(PropsBase, NoExtrasAllowedProps):
142
142
  Returns:
143
143
  The object as a dictionary with ToastAction fields intact.
144
144
  """
145
- kwargs.setdefault("exclude_none", True) # type: ignore
145
+ kwargs.setdefault("exclude_none", True)
146
146
  d = super().dict(*args, **kwargs)
147
147
  # Keep these fields as ToastAction so they can be serialized specially
148
148
  if "action" in d:
@@ -167,7 +167,7 @@ class ToastProps(PropsBase, NoExtrasAllowedProps):
167
167
  class Toaster(Component):
168
168
  """A Toaster Component for displaying toast notifications."""
169
169
 
170
- library: str = "sonner@1.7.1"
170
+ library: str | None = "sonner@1.7.2"
171
171
 
172
172
  tag = "Toaster"
173
173
 
@@ -222,6 +222,8 @@ class Toaster(Component):
222
222
  Returns:
223
223
  The hooks for the toaster component.
224
224
  """
225
+ if self.library is None:
226
+ return []
225
227
  hook = Var(
226
228
  _js_expr=f"{toast_ref} = toast",
227
229
  _var_data=VarData(
@@ -266,7 +268,7 @@ class Toaster(Component):
266
268
  raise ValueError("Toast message or title or description must be provided.")
267
269
 
268
270
  if props:
269
- args = LiteralVar.create(ToastProps(component_name="rx.toast", **props)) # pyright: ignore [reportCallIssue, reportGeneralTypeIssues]
271
+ args = LiteralVar.create(ToastProps(component_name="rx.toast", **props)) # pyright: ignore [reportCallIssue]
270
272
  toast = toast_command.call(message, args)
271
273
  else:
272
274
  toast = toast_command.call(message)
@@ -274,12 +276,12 @@ class Toaster(Component):
274
276
  return run_script(toast)
275
277
 
276
278
  @staticmethod
277
- def toast_info(message: str | Var = "", **kwargs):
279
+ def toast_info(message: str | Var = "", **kwargs: Any):
278
280
  """Display an info toast message.
279
281
 
280
282
  Args:
281
283
  message: The message to display.
282
- kwargs: Additional toast props.
284
+ **kwargs: Additional toast props.
283
285
 
284
286
  Returns:
285
287
  The toast event.
@@ -287,12 +289,12 @@ class Toaster(Component):
287
289
  return Toaster.send_toast(message, level="info", **kwargs)
288
290
 
289
291
  @staticmethod
290
- def toast_warning(message: str | Var = "", **kwargs):
292
+ def toast_warning(message: str | Var = "", **kwargs: Any):
291
293
  """Display a warning toast message.
292
294
 
293
295
  Args:
294
296
  message: The message to display.
295
- kwargs: Additional toast props.
297
+ **kwargs: Additional toast props.
296
298
 
297
299
  Returns:
298
300
  The toast event.
@@ -300,12 +302,12 @@ class Toaster(Component):
300
302
  return Toaster.send_toast(message, level="warning", **kwargs)
301
303
 
302
304
  @staticmethod
303
- def toast_error(message: str | Var = "", **kwargs):
305
+ def toast_error(message: str | Var = "", **kwargs: Any):
304
306
  """Display an error toast message.
305
307
 
306
308
  Args:
307
309
  message: The message to display.
308
- kwargs: Additional toast props.
310
+ **kwargs: Additional toast props.
309
311
 
310
312
  Returns:
311
313
  The toast event.
@@ -313,12 +315,12 @@ class Toaster(Component):
313
315
  return Toaster.send_toast(message, level="error", **kwargs)
314
316
 
315
317
  @staticmethod
316
- def toast_success(message: str | Var = "", **kwargs):
318
+ def toast_success(message: str | Var = "", **kwargs: Any):
317
319
  """Display a success toast message.
318
320
 
319
321
  Args:
320
322
  message: The message to display.
321
- kwargs: Additional toast props.
323
+ **kwargs: Additional toast props.
322
324
 
323
325
  Returns:
324
326
  The toast event.
@@ -350,7 +352,7 @@ class Toaster(Component):
350
352
  return run_script(dismiss_action)
351
353
 
352
354
  @classmethod
353
- def create(cls, *children, **props) -> Component:
355
+ def create(cls, *children: Any, **props: Any) -> Component:
354
356
  """Create a toaster component.
355
357
 
356
358
  Args:
@@ -51,7 +51,7 @@ class ToastProps(PropsBase, NoExtrasAllowedProps):
51
51
  on_dismiss: Optional[Any]
52
52
  on_auto_close: Optional[Any]
53
53
 
54
- def dict(self, *args, **kwargs) -> dict[str, Any]: ...
54
+ def dict(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
55
55
 
56
56
  class Toaster(Component):
57
57
  is_used: ClassVar[bool] = False
@@ -62,13 +62,13 @@ class Toaster(Component):
62
62
  message: str | Var = "", level: str | None = None, **props
63
63
  ) -> EventSpec: ...
64
64
  @staticmethod
65
- def toast_info(message: str | Var = "", **kwargs): ...
65
+ def toast_info(message: str | Var = "", **kwargs: Any): ...
66
66
  @staticmethod
67
- def toast_warning(message: str | Var = "", **kwargs): ...
67
+ def toast_warning(message: str | Var = "", **kwargs: Any): ...
68
68
  @staticmethod
69
- def toast_error(message: str | Var = "", **kwargs): ...
69
+ def toast_error(message: str | Var = "", **kwargs: Any): ...
70
70
  @staticmethod
71
- def toast_success(message: str | Var = "", **kwargs): ...
71
+ def toast_success(message: str | Var = "", **kwargs: Any): ...
72
72
  @staticmethod
73
73
  def toast_dismiss(id: Var | str | None = None): ...
74
74
  @overload
@@ -177,7 +177,7 @@ class ToastNamespace(ComponentNamespace):
177
177
  @staticmethod
178
178
  def __call__(
179
179
  message: Union[str, Var] = "", level: Optional[str] = None, **props
180
- ) -> "Optional[EventSpec]":
180
+ ) -> "EventSpec":
181
181
  """Send a toast message.
182
182
 
183
183
  Args:
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import enum
6
- from typing import Dict, List, Literal, Optional, Tuple, Union
6
+ from typing import Any, Dict, List, Literal, Optional, Tuple, Union
7
7
 
8
8
  from reflex.base import Base
9
9
  from reflex.components.component import Component, NoSSRComponent
@@ -115,7 +115,7 @@ class Editor(NoSSRComponent):
115
115
  # Alternatively to a string, a dict of your language can be passed to this prop.
116
116
  # Please refer to the library docs for this.
117
117
  # options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" |
118
- # "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it"
118
+ # "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it"
119
119
  # default: "en".
120
120
  lang: Var[
121
121
  Union[
@@ -244,11 +244,13 @@ class Editor(NoSSRComponent):
244
244
  }
245
245
 
246
246
  @classmethod
247
- def create(cls, set_options: Optional[EditorOptions] = None, **props) -> Component:
247
+ def create(
248
+ cls, set_options: Optional[EditorOptions] = None, **props: Any
249
+ ) -> Component:
248
250
  """Create an instance of Editor. No children allowed.
249
251
 
250
252
  Args:
251
- set_options(Optional[EditorOptions]): Configuration object to further configure the instance.
253
+ set_options: Configuration object to further configure the instance.
252
254
  **props: Any properties to be passed to the Editor
253
255
 
254
256
  Returns:
@@ -171,8 +171,8 @@ class Editor(NoSSRComponent):
171
171
  """Create an instance of Editor. No children allowed.
172
172
 
173
173
  Args:
174
- set_options(Optional[EditorOptions]): Configuration object to further configure the instance.
175
- lang: Language of the editor. Alternatively to a string, a dict of your language can be passed to this prop. Please refer to the library docs for this. options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" | "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it" default: "en".
174
+ set_options: Configuration object to further configure the instance.
175
+ lang: Language of the editor. Alternatively to a string, a dict of your language can be passed to this prop. Please refer to the library docs for this. options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" | "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it" default: "en".
176
176
  name: This is used to set the HTML form name of the editor. This means on HTML form submission, it will be submitted together with contents of the editor by the name provided.
177
177
  default_value: Sets the default value of the editor. This is useful if you don't want the on_change method to be called on render. If you want the on_change method to be called on render please use the set_contents prop
178
178
  width: Sets the width of the editor. px and percentage values are accepted, eg width="100%" or width="500px" default: 100%
@@ -41,14 +41,14 @@ class IterTag(Tag):
41
41
  try:
42
42
  if iterable._var_type.mro()[0] is dict:
43
43
  # Arg is a tuple of (key, value).
44
- return Tuple[get_args(iterable._var_type)] # type: ignore
44
+ return Tuple[get_args(iterable._var_type)] # pyright: ignore [reportReturnType]
45
45
  elif iterable._var_type.mro()[0] is tuple:
46
46
  # Arg is a union of any possible values in the tuple.
47
- return Union[get_args(iterable._var_type)] # type: ignore
47
+ return Union[get_args(iterable._var_type)] # pyright: ignore [reportReturnType]
48
48
  else:
49
49
  return get_args(iterable._var_type)[0]
50
50
  except Exception:
51
- return Any
51
+ return Any # pyright: ignore [reportReturnType]
52
52
 
53
53
  def get_index_var(self) -> Var:
54
54
  """Get the index var for the tag (with curly braces).
@@ -3,13 +3,33 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import dataclasses
6
- from typing import Any, Dict, List, Optional, Union
6
+ from typing import Any, Dict, List, Optional, Sequence, Union
7
7
 
8
8
  from reflex.event import EventChain
9
9
  from reflex.utils import format, types
10
10
  from reflex.vars.base import LiteralVar, Var
11
11
 
12
12
 
13
+ def render_prop(value: Any) -> Any:
14
+ """Render the prop.
15
+
16
+ Args:
17
+ value: The value to render.
18
+
19
+ Returns:
20
+ The rendered value.
21
+ """
22
+ from reflex.components.component import BaseComponent
23
+
24
+ if isinstance(value, BaseComponent):
25
+ return value.render()
26
+ if isinstance(value, Sequence) and not isinstance(value, str):
27
+ return [render_prop(v) for v in value]
28
+ if callable(value) and not isinstance(value, Var):
29
+ return None
30
+ return value
31
+
32
+
13
33
  @dataclasses.dataclass()
14
34
  class Tag:
15
35
  """A React tag."""
@@ -49,7 +69,7 @@ class Tag:
49
69
  """Set the tag's fields.
50
70
 
51
71
  Args:
52
- kwargs: The fields to set.
72
+ **kwargs: The fields to set.
53
73
 
54
74
  Returns:
55
75
  The tag with the fields
@@ -66,7 +86,9 @@ class Tag:
66
86
  Tuple[str, Any]: The field name and value.
67
87
  """
68
88
  for field in dataclasses.fields(self):
69
- yield field.name, getattr(self, field.name)
89
+ rendered_value = render_prop(getattr(self, field.name))
90
+ if rendered_value is not None:
91
+ yield field.name, rendered_value
70
92
 
71
93
  def add_props(self, **kwargs: Optional[Any]) -> Tag:
72
94
  """Add props to the tag.