reflex 0.5.3a2__py3-none-any.whl → 0.5.4__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 (69) hide show
  1. reflex/.templates/apps/demo/code/webui/state.py +3 -2
  2. reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +19 -20
  3. reflex/.templates/web/utils/state.js +6 -0
  4. reflex/__init__.py +7 -1
  5. reflex/__init__.pyi +2 -0
  6. reflex/app.py +2 -5
  7. reflex/compiler/compiler.py +2 -2
  8. reflex/components/chakra/base.py +3 -1
  9. reflex/components/chakra/forms/checkbox.py +1 -1
  10. reflex/components/chakra/forms/pininput.py +1 -1
  11. reflex/components/chakra/forms/rangeslider.py +1 -1
  12. reflex/components/chakra/navigation/link.py +3 -1
  13. reflex/components/component.py +43 -15
  14. reflex/components/core/banner.py +2 -1
  15. reflex/components/core/client_side_routing.py +3 -3
  16. reflex/components/core/client_side_routing.pyi +1 -0
  17. reflex/components/core/debounce.py +3 -1
  18. reflex/components/core/foreach.py +1 -1
  19. reflex/components/core/upload.py +2 -1
  20. reflex/components/datadisplay/code.py +4 -1
  21. reflex/components/datadisplay/dataeditor.py +11 -8
  22. reflex/components/datadisplay/dataeditor.pyi +1 -0
  23. reflex/components/el/elements/forms.py +25 -14
  24. reflex/components/el/elements/forms.pyi +2 -1
  25. reflex/components/markdown/markdown.py +17 -11
  26. reflex/components/markdown/markdown.pyi +12 -8
  27. reflex/components/plotly/plotly.py +82 -14
  28. reflex/components/plotly/plotly.pyi +15 -82
  29. reflex/components/radix/primitives/accordion.py +1 -1
  30. reflex/components/radix/themes/base.py +10 -2
  31. reflex/components/radix/themes/base.pyi +1 -0
  32. reflex/components/radix/themes/color_mode.py +1 -1
  33. reflex/components/radix/themes/components/checkbox.py +3 -1
  34. reflex/components/radix/themes/components/radio_group.py +6 -4
  35. reflex/components/radix/themes/components/separator.py +1 -1
  36. reflex/components/radix/themes/layout/container.py +1 -1
  37. reflex/components/radix/themes/layout/section.py +1 -1
  38. reflex/components/recharts/cartesian.py +42 -14
  39. reflex/components/recharts/cartesian.pyi +81 -17
  40. reflex/components/recharts/charts.py +12 -21
  41. reflex/components/recharts/charts.pyi +53 -14
  42. reflex/components/sonner/toast.py +37 -17
  43. reflex/components/sonner/toast.pyi +9 -5
  44. reflex/components/tags/tag.py +2 -1
  45. reflex/config.py +22 -14
  46. reflex/constants/__init__.py +2 -0
  47. reflex/constants/config.py +7 -0
  48. reflex/event.py +24 -15
  49. reflex/experimental/__init__.py +22 -2
  50. reflex/experimental/client_state.py +81 -23
  51. reflex/experimental/hooks.py +35 -35
  52. reflex/experimental/layout.py +17 -5
  53. reflex/experimental/layout.pyi +536 -0
  54. reflex/reflex.py +9 -5
  55. reflex/style.py +3 -2
  56. reflex/testing.py +44 -13
  57. reflex/utils/compat.py +5 -0
  58. reflex/utils/format.py +12 -2
  59. reflex/utils/processes.py +27 -0
  60. reflex/utils/pyi_generator.py +11 -4
  61. reflex/utils/serializers.py +114 -15
  62. reflex/utils/types.py +6 -2
  63. reflex/vars.py +57 -20
  64. reflex/vars.pyi +2 -2
  65. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/METADATA +1 -1
  66. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/RECORD +69 -68
  67. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/LICENSE +0 -0
  68. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/WHEEL +0 -0
  69. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/entry_points.txt +0 -0
@@ -23,19 +23,23 @@ from reflex.utils.imports import ImportVar
23
23
  from reflex.vars import Var
24
24
 
25
25
  # Special vars used in the component map.
26
- _CHILDREN = Var.create_safe("children", _var_is_local=False)
27
- _PROPS = Var.create_safe("...props", _var_is_local=False)
28
- _MOCK_ARG = Var.create_safe("")
26
+ _CHILDREN = Var.create_safe("children", _var_is_local=False, _var_is_string=False)
27
+ _PROPS = Var.create_safe("...props", _var_is_local=False, _var_is_string=False)
28
+ _MOCK_ARG = Var.create_safe("", _var_is_string=False)
29
29
 
30
30
  # Special remark plugins.
31
- _REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False)
32
- _REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False)
33
- _REMARK_UNWRAP_IMAGES = Var.create_safe("remarkUnwrapImages", _var_is_local=False)
31
+ _REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False, _var_is_string=False)
32
+ _REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False, _var_is_string=False)
33
+ _REMARK_UNWRAP_IMAGES = Var.create_safe(
34
+ "remarkUnwrapImages", _var_is_local=False, _var_is_string=False
35
+ )
34
36
  _REMARK_PLUGINS = Var.create_safe([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES])
35
37
 
36
38
  # Special rehype plugins.
37
- _REHYPE_KATEX = Var.create_safe("rehypeKatex", _var_is_local=False)
38
- _REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False)
39
+ _REHYPE_KATEX = Var.create_safe(
40
+ "rehypeKatex", _var_is_local=False, _var_is_string=False
41
+ )
42
+ _REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False, _var_is_string=False)
39
43
  _REHYPE_PLUGINS = Var.create_safe([_REHYPE_KATEX, _REHYPE_RAW])
40
44
 
41
45
  # These tags do NOT get props passed to them
@@ -210,7 +214,9 @@ class Markdown(Component):
210
214
  # If the children are set as a prop, don't pass them as children.
211
215
  children_prop = props.pop("children", None)
212
216
  if children_prop is not None:
213
- special_props.add(Var.create_safe(f"children={str(children_prop)}"))
217
+ special_props.add(
218
+ Var.create_safe(f"children={str(children_prop)}", _var_is_string=False)
219
+ )
214
220
  children = []
215
221
 
216
222
  # Get the component.
@@ -229,7 +235,7 @@ class Markdown(Component):
229
235
  Returns:
230
236
  The formatted component.
231
237
  """
232
- return str(self.get_component(tag, **props)).replace("\n", " ")
238
+ return str(self.get_component(tag, **props)).replace("\n", "")
233
239
 
234
240
  def format_component_map(self) -> dict[str, str]:
235
241
  """Format the component map for rendering.
@@ -259,7 +265,7 @@ class Markdown(Component):
259
265
  return inline ? (
260
266
  {self.format_component("code")}
261
267
  ) : (
262
- {self.format_component("codeblock", language=Var.create_safe("language", _var_is_local=False))}
268
+ {self.format_component("codeblock", language=Var.create_safe("language", _var_is_local=False, _var_is_string=False))}
263
269
  );
264
270
  }}}}""".replace("\n", " ")
265
271
 
@@ -26,15 +26,19 @@ from reflex.utils import imports, types
26
26
  from reflex.utils.imports import ImportVar
27
27
  from reflex.vars import Var
28
28
 
29
- _CHILDREN = Var.create_safe("children", _var_is_local=False)
30
- _PROPS = Var.create_safe("...props", _var_is_local=False)
31
- _MOCK_ARG = Var.create_safe("")
32
- _REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False)
33
- _REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False)
34
- _REMARK_UNWRAP_IMAGES = Var.create_safe("remarkUnwrapImages", _var_is_local=False)
29
+ _CHILDREN = Var.create_safe("children", _var_is_local=False, _var_is_string=False)
30
+ _PROPS = Var.create_safe("...props", _var_is_local=False, _var_is_string=False)
31
+ _MOCK_ARG = Var.create_safe("", _var_is_string=False)
32
+ _REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False, _var_is_string=False)
33
+ _REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False, _var_is_string=False)
34
+ _REMARK_UNWRAP_IMAGES = Var.create_safe(
35
+ "remarkUnwrapImages", _var_is_local=False, _var_is_string=False
36
+ )
35
37
  _REMARK_PLUGINS = Var.create_safe([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES])
36
- _REHYPE_KATEX = Var.create_safe("rehypeKatex", _var_is_local=False)
37
- _REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False)
38
+ _REHYPE_KATEX = Var.create_safe(
39
+ "rehypeKatex", _var_is_local=False, _var_is_string=False
40
+ )
41
+ _REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False, _var_is_string=False)
38
42
  _REHYPE_PLUGINS = Var.create_safe([_REHYPE_KATEX, _REHYPE_RAW])
39
43
  NO_PROPS_TAGS = ("ul", "ol", "li")
40
44
 
@@ -4,14 +4,20 @@ from __future__ import annotations
4
4
  from typing import Any, Dict, List
5
5
 
6
6
  from reflex.base import Base
7
- from reflex.components.component import NoSSRComponent
7
+ from reflex.components.component import Component, NoSSRComponent
8
+ from reflex.components.core.cond import color_mode_cond
8
9
  from reflex.event import EventHandler
10
+ from reflex.utils import console
9
11
  from reflex.vars import Var
10
12
 
11
13
  try:
12
- from plotly.graph_objects import Figure
14
+ from plotly.graph_objects import Figure, layout
15
+
16
+ Template = layout.Template
13
17
  except ImportError:
18
+ console.warn("Plotly is not installed. Please run `pip install plotly`.")
14
19
  Figure = Any # type: ignore
20
+ Template = Any # type: ignore
15
21
 
16
22
 
17
23
  def _event_data_signature(e0: Var) -> List[Any]:
@@ -23,7 +29,7 @@ def _event_data_signature(e0: Var) -> List[Any]:
23
29
  Returns:
24
30
  The event key extracted from the event data (if defined).
25
31
  """
26
- return [Var.create_safe(f"{e0}?.event")]
32
+ return [Var.create_safe(f"{e0}?.event", _var_is_string=False)]
27
33
 
28
34
 
29
35
  def _event_points_data_signature(e0: Var) -> List[Any]:
@@ -36,9 +42,10 @@ def _event_points_data_signature(e0: Var) -> List[Any]:
36
42
  The event data and the extracted points.
37
43
  """
38
44
  return [
39
- Var.create_safe(f"{e0}?.event"),
45
+ Var.create_safe(f"{e0}?.event", _var_is_string=False),
40
46
  Var.create_safe(
41
47
  f"extractPoints({e0}?.points)",
48
+ _var_is_string=False,
42
49
  ),
43
50
  ]
44
51
 
@@ -84,17 +91,13 @@ def _null_signature() -> List[Any]:
84
91
  return []
85
92
 
86
93
 
87
- class PlotlyLib(NoSSRComponent):
88
- """A component that wraps a plotly lib."""
94
+ class Plotly(NoSSRComponent):
95
+ """Display a plotly graph."""
89
96
 
90
97
  library = "react-plotly.js@2.6.0"
91
98
 
92
99
  lib_dependencies: List[str] = ["plotly.js@2.22.0"]
93
100
 
94
-
95
- class Plotly(PlotlyLib):
96
- """Display a plotly graph."""
97
-
98
101
  tag = "Plot"
99
102
 
100
103
  is_default = True
@@ -105,6 +108,9 @@ class Plotly(PlotlyLib):
105
108
  # The layout of the graph.
106
109
  layout: Var[Dict]
107
110
 
111
+ # The template for visual appearance of the graph.
112
+ template: Var[Template]
113
+
108
114
  # The config of the graph.
109
115
  config: Var[Dict]
110
116
 
@@ -171,6 +177,17 @@ class Plotly(PlotlyLib):
171
177
  # Fired when a hovered element is no longer hovered.
172
178
  on_unhover: EventHandler[_event_points_data_signature]
173
179
 
180
+ def add_imports(self) -> dict[str, str]:
181
+ """Add imports for the plotly component.
182
+
183
+ Returns:
184
+ The imports for the plotly component.
185
+ """
186
+ return {
187
+ # For merging plotly data/layout/templates.
188
+ "mergician@v2.0.2": "mergician"
189
+ }
190
+
174
191
  def add_custom_code(self) -> list[str]:
175
192
  """Add custom codes for processing the plotly points data.
176
193
 
@@ -210,14 +227,65 @@ const extractPoints = (points) => {
210
227
  """,
211
228
  ]
212
229
 
230
+ @classmethod
231
+ def create(cls, *children, **props) -> Component:
232
+ """Create the Plotly component.
233
+
234
+ Args:
235
+ *children: The children of the component.
236
+ **props: The properties of the component.
237
+
238
+ Returns:
239
+ The Plotly component.
240
+ """
241
+ from plotly.io import templates
242
+
243
+ responsive_template = color_mode_cond(
244
+ light=Var.create_safe(templates["plotly"]).to(dict),
245
+ dark=Var.create_safe(templates["plotly_dark"]).to(dict),
246
+ )
247
+ if isinstance(responsive_template, Var):
248
+ # Mark the conditional Var as a Template to avoid type mismatch
249
+ responsive_template = responsive_template.to(Template)
250
+ props.setdefault("template", responsive_template)
251
+ return super().create(*children, **props)
252
+
253
+ def _exclude_props(self) -> set[str]:
254
+ # These props are handled specially in the _render function
255
+ return {"data", "layout", "template"}
256
+
213
257
  def _render(self):
214
258
  tag = super()._render()
215
259
  figure = self.data.to(dict)
216
- if self.layout is None:
217
- tag.remove_props("data", "layout")
260
+ merge_dicts = [] # Data will be merged and spread from these dict Vars
261
+ if self.layout is not None:
262
+ # Why is this not a literal dict? Great question... it didn't work
263
+ # reliably because of how _var_name_unwrapped strips the outer curly
264
+ # brackets if any of the contained Vars depend on state.
265
+ layout_dict = Var.create_safe(
266
+ f"{{'layout': {self.layout.to(dict)._var_name_unwrapped}}}"
267
+ ).to(dict)
268
+ merge_dicts.append(layout_dict)
269
+ if self.template is not None:
270
+ template_dict = Var.create_safe(
271
+ {"layout": {"template": self.template.to(dict)}}
272
+ )
273
+ template_dict._var_data = None # To avoid stripping outer curly brackets
274
+ merge_dicts.append(template_dict)
275
+ if merge_dicts:
218
276
  tag.special_props.add(
219
- Var.create_safe(f"{{...{figure._var_name_unwrapped}}}")
277
+ # Merge all dictionaries and spread the result over props.
278
+ Var.create_safe(
279
+ f"{{...mergician({figure._var_name_unwrapped},"
280
+ f"{','.join(md._var_name_unwrapped for md in merge_dicts)})}}",
281
+ _var_is_string=False,
282
+ ),
220
283
  )
221
284
  else:
222
- tag.add_props(data=figure["data"])
285
+ # Spread the figure dict over props, nothing to merge.
286
+ tag.special_props.add(
287
+ Var.create_safe(
288
+ f"{{...{figure._var_name_unwrapped}}}", _var_is_string=False
289
+ )
290
+ )
223
291
  return tag
@@ -9,97 +9,28 @@ from reflex.event import EventChain, EventHandler, EventSpec
9
9
  from reflex.style import Style
10
10
  from typing import Any, Dict, List
11
11
  from reflex.base import Base
12
- from reflex.components.component import NoSSRComponent
12
+ from reflex.components.component import Component, NoSSRComponent
13
+ from reflex.components.core.cond import color_mode_cond
13
14
  from reflex.event import EventHandler
15
+ from reflex.utils import console
14
16
  from reflex.vars import Var
15
17
 
16
18
  try:
17
- from plotly.graph_objects import Figure # type: ignore
19
+ from plotly.graph_objects import Figure, layout # type: ignore
20
+
21
+ Template = layout.Template
18
22
  except ImportError:
23
+ console.warn("Plotly is not installed. Please run `pip install plotly`.")
19
24
  Figure = Any # type: ignore
25
+ Template = Any
20
26
 
21
27
  class _ButtonClickData(Base):
22
28
  menu: Any
23
29
  button: Any
24
30
  active: Any
25
31
 
26
- class PlotlyLib(NoSSRComponent):
27
- @overload
28
- @classmethod
29
- def create( # type: ignore
30
- cls,
31
- *children,
32
- style: Optional[Style] = None,
33
- key: Optional[Any] = None,
34
- id: Optional[Any] = None,
35
- class_name: Optional[Any] = None,
36
- autofocus: Optional[bool] = None,
37
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
38
- on_blur: Optional[
39
- Union[EventHandler, EventSpec, list, function, BaseVar]
40
- ] = None,
41
- on_click: Optional[
42
- Union[EventHandler, EventSpec, list, function, BaseVar]
43
- ] = None,
44
- on_context_menu: Optional[
45
- Union[EventHandler, EventSpec, list, function, BaseVar]
46
- ] = None,
47
- on_double_click: Optional[
48
- Union[EventHandler, EventSpec, list, function, BaseVar]
49
- ] = None,
50
- on_focus: Optional[
51
- Union[EventHandler, EventSpec, list, function, BaseVar]
52
- ] = None,
53
- on_mount: Optional[
54
- Union[EventHandler, EventSpec, list, function, BaseVar]
55
- ] = None,
56
- on_mouse_down: Optional[
57
- Union[EventHandler, EventSpec, list, function, BaseVar]
58
- ] = None,
59
- on_mouse_enter: Optional[
60
- Union[EventHandler, EventSpec, list, function, BaseVar]
61
- ] = None,
62
- on_mouse_leave: Optional[
63
- Union[EventHandler, EventSpec, list, function, BaseVar]
64
- ] = None,
65
- on_mouse_move: Optional[
66
- Union[EventHandler, EventSpec, list, function, BaseVar]
67
- ] = None,
68
- on_mouse_out: Optional[
69
- Union[EventHandler, EventSpec, list, function, BaseVar]
70
- ] = None,
71
- on_mouse_over: Optional[
72
- Union[EventHandler, EventSpec, list, function, BaseVar]
73
- ] = None,
74
- on_mouse_up: Optional[
75
- Union[EventHandler, EventSpec, list, function, BaseVar]
76
- ] = None,
77
- on_scroll: Optional[
78
- Union[EventHandler, EventSpec, list, function, BaseVar]
79
- ] = None,
80
- on_unmount: Optional[
81
- Union[EventHandler, EventSpec, list, function, BaseVar]
82
- ] = None,
83
- **props
84
- ) -> "PlotlyLib":
85
- """Create the component.
86
-
87
- Args:
88
- *children: The children of the component.
89
- style: The style of the component.
90
- key: A unique key for the component.
91
- id: The id for the component.
92
- class_name: The class name for the component.
93
- autofocus: Whether the component should take the focus once the page is loaded
94
- custom_attrs: custom attribute
95
- **props: The props of the component.
96
-
97
- Returns:
98
- The component.
99
- """
100
- ...
101
-
102
- class Plotly(PlotlyLib):
32
+ class Plotly(NoSSRComponent):
33
+ def add_imports(self) -> dict[str, str]: ...
103
34
  def add_custom_code(self) -> list[str]: ...
104
35
  @overload
105
36
  @classmethod
@@ -108,6 +39,7 @@ class Plotly(PlotlyLib):
108
39
  *children,
109
40
  data: Optional[Union[Var[Figure], Figure]] = None, # type: ignore
110
41
  layout: Optional[Union[Var[Dict], Dict]] = None,
42
+ template: Optional[Union[Var[Template], Template]] = None, # type: ignore
111
43
  config: Optional[Union[Var[Dict], Dict]] = None,
112
44
  use_resize_handler: Optional[Union[Var[bool], bool]] = None,
113
45
  style: Optional[Style] = None,
@@ -217,12 +149,13 @@ class Plotly(PlotlyLib):
217
149
  ] = None,
218
150
  **props
219
151
  ) -> "Plotly":
220
- """Create the component.
152
+ """Create the Plotly component.
221
153
 
222
154
  Args:
223
155
  *children: The children of the component.
224
156
  data: The figure to display. This can be a plotly figure or a plotly data json.
225
157
  layout: The layout of the graph.
158
+ template: The template for visual appearance of the graph.
226
159
  config: The config of the graph.
227
160
  use_resize_handler: If true, the graph will resize when the window is resized.
228
161
  style: The style of the component.
@@ -231,9 +164,9 @@ class Plotly(PlotlyLib):
231
164
  class_name: The class name for the component.
232
165
  autofocus: Whether the component should take the focus once the page is loaded
233
166
  custom_attrs: custom attribute
234
- **props: The props of the component.
167
+ **props: The properties of the component.
235
168
 
236
169
  Returns:
237
- The component.
170
+ The Plotly component.
238
171
  """
239
172
  ...
@@ -105,7 +105,7 @@ class AccordionRoot(AccordionComponent):
105
105
  duration: Var[int] = Var.create_safe(DEFAULT_ANIMATION_DURATION)
106
106
 
107
107
  # The easing function to use for the animation.
108
- easing: Var[str] = Var.create_safe(DEFAULT_ANIMATION_EASING)
108
+ easing: Var[str] = Var.create_safe(DEFAULT_ANIMATION_EASING, _var_is_string=True)
109
109
 
110
110
  # Whether to show divider lines between items.
111
111
  show_dividers: Var[bool]
@@ -233,6 +233,7 @@ class Theme(RadixThemesComponent):
233
233
  css=Var.create(
234
234
  "{{...theme.styles.global[':root'], ...theme.styles.global.body}}",
235
235
  _var_is_local=False,
236
+ _var_is_string=False,
236
237
  ),
237
238
  )
238
239
  return tag
@@ -257,10 +258,16 @@ class ThemePanel(RadixThemesComponent):
257
258
  """
258
259
  return {"react": "useEffect"}
259
260
 
260
- def _get_hooks(self) -> str | None:
261
+ def add_hooks(self) -> list[str]:
262
+ """Add a hook on the ThemePanel to clear chakra-ui-color-mode.
263
+
264
+ Returns:
265
+ The hooks to render.
266
+ """
261
267
  # The panel freezes the tab if the user color preference differs from the
262
268
  # theme "appearance", so clear it out when theme panel is used.
263
- return """
269
+ return [
270
+ """
264
271
  useEffect(() => {
265
272
  if (typeof window !== 'undefined') {
266
273
  window.onbeforeunload = () => {
@@ -269,6 +276,7 @@ class ThemePanel(RadixThemesComponent):
269
276
  window.onbeforeunload();
270
277
  }
271
278
  }, [])"""
279
+ ]
272
280
 
273
281
 
274
282
  class RadixThemesColorModeProvider(Component):
@@ -584,6 +584,7 @@ class Theme(RadixThemesComponent):
584
584
 
585
585
  class ThemePanel(RadixThemesComponent):
586
586
  def add_imports(self) -> dict[str, str]: ...
587
+ def add_hooks(self) -> list[str]: ...
587
588
  @overload
588
589
  @classmethod
589
590
  def create( # type: ignore
@@ -73,7 +73,7 @@ position_map = {
73
73
 
74
74
  # needed to inverse contains for find
75
75
  def _find(const, var):
76
- return Var.create_safe(const).contains(var)
76
+ return Var.create_safe(const, _var_is_string=False).contains(var)
77
77
 
78
78
 
79
79
  def _set_var_default(props, position, prop, default1, default2=""):
@@ -130,7 +130,9 @@ class HighLevelCheckbox(RadixThemesComponent):
130
130
  }
131
131
 
132
132
  @classmethod
133
- def create(cls, text: Var[str] = Var.create_safe(""), **props) -> Component:
133
+ def create(
134
+ cls, text: Var[str] = Var.create_safe("", _var_is_string=True), **props
135
+ ) -> Component:
134
136
  """Create a checkbox with a label.
135
137
 
136
138
  Args:
@@ -91,10 +91,10 @@ class HighLevelRadioGroup(RadixThemesComponent):
91
91
  direction: Var[LiteralFlexDirection]
92
92
 
93
93
  # The gap between the items of the radio group.
94
- spacing: Var[LiteralSpacing] = Var.create_safe("2")
94
+ spacing: Var[LiteralSpacing] = Var.create_safe("2", _var_is_string=True)
95
95
 
96
96
  # The size of the radio group.
97
- size: Var[Literal["1", "2", "3"]] = Var.create_safe("2")
97
+ size: Var[Literal["1", "2", "3"]] = Var.create_safe("2", _var_is_string=True)
98
98
 
99
99
  # The variant of the radio group
100
100
  variant: Var[Literal["classic", "surface", "soft"]]
@@ -151,11 +151,13 @@ class HighLevelRadioGroup(RadixThemesComponent):
151
151
  default_value = Var.create(default_value, _var_is_string=True) # type: ignore
152
152
  else:
153
153
  default_value = (
154
- Var.create(default_value).to_string()._replace(_var_is_local=False) # type: ignore
154
+ Var.create(default_value, _var_is_string=False)
155
+ .to_string() # type: ignore
156
+ ._replace(_var_is_local=False)
155
157
  )
156
158
 
157
159
  def radio_group_item(value: str | Var) -> Component:
158
- item_value = Var.create(value) # type: ignore
160
+ item_value = Var.create(value, _var_is_string=False) # type: ignore
159
161
  item_value = rx.cond(
160
162
  item_value._type() == str, # type: ignore
161
163
  item_value,
@@ -17,7 +17,7 @@ class Separator(RadixThemesComponent):
17
17
  tag = "Separator"
18
18
 
19
19
  # The size of the select: "1" | "2" | "3" | "4"
20
- size: Var[LiteralSeperatorSize] = Var.create_safe("4")
20
+ size: Var[LiteralSeperatorSize] = Var.create_safe("4", _var_is_string=True)
21
21
 
22
22
  # The color of the select
23
23
  color_scheme: Var[LiteralAccentColor]
@@ -21,7 +21,7 @@ class Container(elements.Div, RadixThemesComponent):
21
21
  tag = "Container"
22
22
 
23
23
  # The size of the container: "1" - "4" (default "3")
24
- size: Var[LiteralContainerSize] = Var.create_safe("3")
24
+ size: Var[LiteralContainerSize] = Var.create_safe("3", _var_is_string=True)
25
25
 
26
26
  @classmethod
27
27
  def create(
@@ -17,7 +17,7 @@ class Section(elements.Section, RadixThemesComponent):
17
17
  tag = "Section"
18
18
 
19
19
  # The size of the section: "1" - "3" (default "2")
20
- size: Var[LiteralSectionSize] = Var.create_safe("2")
20
+ size: Var[LiteralSectionSize] = Var.create_safe("2", _var_is_string=True)
21
21
 
22
22
 
23
23
  section = Section.create