reflex 0.4.9a1__py3-none-any.whl → 0.5.0__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 (133) hide show
  1. reflex/.templates/apps/blank/code/blank.py +19 -16
  2. reflex/.templates/apps/demo/code/demo.py +1 -1
  3. reflex/.templates/apps/demo/code/pages/datatable.py +4 -4
  4. reflex/.templates/apps/demo/code/pages/forms.py +2 -2
  5. reflex/.templates/jinja/web/tailwind.config.js.jinja2 +12 -0
  6. reflex/.templates/web/utils/helpers/debounce.js +17 -0
  7. reflex/.templates/web/utils/helpers/throttle.js +22 -0
  8. reflex/.templates/web/utils/state.js +21 -3
  9. reflex/__init__.py +6 -1
  10. reflex/__init__.pyi +4 -1
  11. reflex/app.py +160 -140
  12. reflex/app_module_for_backend.py +1 -1
  13. reflex/base.py +13 -15
  14. reflex/compiler/compiler.py +10 -1
  15. reflex/compiler/utils.py +3 -30
  16. reflex/components/__init__.py +1 -0
  17. reflex/components/chakra/datadisplay/list.py +1 -3
  18. reflex/components/chakra/datadisplay/list.pyi +3 -3
  19. reflex/components/chakra/disclosure/accordion.py +1 -1
  20. reflex/components/chakra/forms/pininput.pyi +1 -1
  21. reflex/components/chakra/media/icon.py +2 -2
  22. reflex/components/component.py +275 -32
  23. reflex/components/core/__init__.py +2 -2
  24. reflex/components/core/cond.py +1 -10
  25. reflex/components/core/debounce.py +5 -2
  26. reflex/components/core/debounce.pyi +4 -2
  27. reflex/components/core/foreach.py +60 -49
  28. reflex/components/core/html.py +6 -0
  29. reflex/components/core/match.py +2 -17
  30. reflex/components/core/upload.py +42 -1
  31. reflex/components/core/upload.pyi +199 -1
  32. reflex/components/datadisplay/code.py +7 -3
  33. reflex/components/datadisplay/code.pyi +3 -1
  34. reflex/components/el/elements/forms.py +1 -1
  35. reflex/components/el/elements/forms.pyi +1 -1
  36. reflex/components/lucide/icon.py +5 -13
  37. reflex/components/lucide/icon.pyi +0 -1
  38. reflex/components/markdown/markdown.py +5 -23
  39. reflex/components/markdown/markdown.pyi +1 -4
  40. reflex/components/radix/primitives/accordion.py +265 -410
  41. reflex/components/radix/primitives/accordion.pyi +390 -36
  42. reflex/components/radix/primitives/form.py +33 -29
  43. reflex/components/radix/primitives/form.pyi +7 -2
  44. reflex/components/radix/primitives/progress.py +17 -9
  45. reflex/components/radix/primitives/progress.pyi +2 -0
  46. reflex/components/radix/primitives/slider.py +30 -18
  47. reflex/components/radix/primitives/slider.pyi +4 -0
  48. reflex/components/radix/themes/base.py +8 -1
  49. reflex/components/radix/themes/base.pyi +79 -1
  50. reflex/components/radix/themes/color_mode.py +88 -20
  51. reflex/components/radix/themes/color_mode.pyi +157 -139
  52. reflex/components/radix/themes/components/__init__.py +17 -0
  53. reflex/components/radix/themes/components/badge.py +2 -1
  54. reflex/components/radix/themes/components/badge.pyi +3 -1
  55. reflex/components/radix/themes/components/button.py +3 -1
  56. reflex/components/radix/themes/components/button.pyi +4 -1
  57. reflex/components/radix/themes/components/checkbox_cards.py +48 -0
  58. reflex/components/radix/themes/components/checkbox_cards.pyi +264 -0
  59. reflex/components/radix/themes/components/checkbox_group.py +42 -0
  60. reflex/components/radix/themes/components/checkbox_group.pyi +253 -0
  61. reflex/components/radix/themes/components/data_list.py +63 -0
  62. reflex/components/radix/themes/components/data_list.pyi +426 -0
  63. reflex/components/radix/themes/components/icon_button.py +20 -17
  64. reflex/components/radix/themes/components/icon_button.pyi +5 -1
  65. reflex/components/radix/themes/components/progress.py +55 -0
  66. reflex/components/radix/themes/components/progress.pyi +180 -0
  67. reflex/components/radix/themes/components/radio.py +31 -0
  68. reflex/components/radix/themes/components/radio.pyi +169 -0
  69. reflex/components/radix/themes/components/radio_cards.py +48 -0
  70. reflex/components/radix/themes/components/radio_cards.pyi +264 -0
  71. reflex/components/radix/themes/components/radio_group.py +2 -4
  72. reflex/components/radix/themes/components/segmented_control.py +48 -0
  73. reflex/components/radix/themes/components/segmented_control.pyi +262 -0
  74. reflex/components/radix/themes/components/skeleton.py +32 -0
  75. reflex/components/radix/themes/components/skeleton.pyi +106 -0
  76. reflex/components/radix/themes/components/spinner.py +26 -0
  77. reflex/components/radix/themes/components/spinner.pyi +101 -0
  78. reflex/components/radix/themes/components/tabs.py +26 -1
  79. reflex/components/radix/themes/components/tabs.pyi +69 -9
  80. reflex/components/radix/themes/components/text_field.py +101 -71
  81. reflex/components/radix/themes/components/text_field.pyi +81 -499
  82. reflex/components/radix/themes/layout/base.py +2 -2
  83. reflex/components/radix/themes/layout/base.pyi +4 -4
  84. reflex/components/radix/themes/layout/center.py +8 -3
  85. reflex/components/radix/themes/layout/center.pyi +2 -1
  86. reflex/components/radix/themes/layout/container.py +30 -2
  87. reflex/components/radix/themes/layout/container.pyi +9 -30
  88. reflex/components/radix/themes/layout/list.py +10 -5
  89. reflex/components/radix/themes/layout/list.pyi +5 -21
  90. reflex/components/radix/themes/layout/spacer.py +8 -3
  91. reflex/components/radix/themes/layout/spacer.pyi +2 -1
  92. reflex/components/radix/themes/layout/stack.py +7 -1
  93. reflex/components/radix/themes/layout/stack.pyi +3 -3
  94. reflex/components/radix/themes/typography/link.py +10 -2
  95. reflex/components/radix/themes/typography/link.pyi +5 -4
  96. reflex/components/sonner/__init__.py +3 -0
  97. reflex/components/sonner/toast.py +267 -0
  98. reflex/components/sonner/toast.pyi +205 -0
  99. reflex/components/tags/iter_tag.py +9 -6
  100. reflex/config.py +30 -54
  101. reflex/constants/__init__.py +0 -2
  102. reflex/constants/base.py +0 -5
  103. reflex/constants/colors.py +2 -0
  104. reflex/constants/installer.py +6 -1
  105. reflex/constants/route.py +4 -0
  106. reflex/custom_components/custom_components.py +24 -2
  107. reflex/event.py +75 -30
  108. reflex/experimental/__init__.py +5 -0
  109. reflex/experimental/layout.py +24 -6
  110. reflex/model.py +2 -1
  111. reflex/page.py +7 -4
  112. reflex/reflex.py +8 -3
  113. reflex/route.py +39 -0
  114. reflex/state.py +128 -131
  115. reflex/style.py +25 -3
  116. reflex/testing.py +10 -6
  117. reflex/utils/console.py +3 -1
  118. reflex/utils/exec.py +20 -7
  119. reflex/utils/format.py +1 -1
  120. reflex/utils/imports.py +3 -1
  121. reflex/utils/prerequisites.py +141 -20
  122. reflex/utils/processes.py +21 -1
  123. reflex/utils/pyi_generator.py +100 -5
  124. reflex/utils/serializers.py +1 -1
  125. reflex/utils/telemetry.py +26 -4
  126. reflex/utils/types.py +62 -18
  127. reflex/vars.py +11 -5
  128. {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/METADATA +16 -4
  129. {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/RECORD +132 -110
  130. {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/WHEEL +1 -1
  131. reflex/app.pyi +0 -149
  132. {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/LICENSE +0 -0
  133. {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/entry_points.txt +0 -0
@@ -2,16 +2,24 @@
2
2
  from __future__ import annotations
3
3
 
4
4
  import inspect
5
- from hashlib import md5
6
- from typing import Any, Callable, Iterable, Optional
5
+ from typing import Any, Callable, Iterable
7
6
 
8
7
  from reflex.components.base.fragment import Fragment
9
8
  from reflex.components.component import Component
10
9
  from reflex.components.tags import IterTag
11
10
  from reflex.constants import MemoizationMode
11
+ from reflex.utils import console
12
12
  from reflex.vars import Var
13
13
 
14
14
 
15
+ class ForeachVarError(TypeError):
16
+ """Raised when the iterable type is Any."""
17
+
18
+
19
+ class ForeachRenderError(TypeError):
20
+ """Raised when there is an error with the foreach render function."""
21
+
22
+
15
23
  class Foreach(Component):
16
24
  """A component that takes in an iterable and a render function and renders a list of components."""
17
25
 
@@ -23,68 +31,85 @@ class Foreach(Component):
23
31
  # A function from the render args to the component.
24
32
  render_fn: Callable = Fragment.create
25
33
 
26
- # The theme if set.
27
- theme: Optional[Component] = None
28
-
29
- def _apply_theme(self, theme: Component):
30
- """Apply the theme to this component.
31
-
32
- Args:
33
- theme: The theme to apply.
34
- """
35
- self.theme = theme
36
-
37
34
  @classmethod
38
- def create(cls, iterable: Var[Iterable], render_fn: Callable, **props) -> Foreach:
35
+ def create(
36
+ cls,
37
+ iterable: Var[Iterable] | Iterable,
38
+ render_fn: Callable,
39
+ **props,
40
+ ) -> Foreach:
39
41
  """Create a foreach component.
40
42
 
41
43
  Args:
42
44
  iterable: The iterable to create components from.
43
45
  render_fn: A function from the render args to the component.
44
- **props: The attributes to pass to each child component.
46
+ **props: The attributes to pass to each child component (deprecated).
45
47
 
46
48
  Returns:
47
49
  The foreach component.
48
50
 
49
51
  Raises:
50
- TypeError: If the iterable is of type Any.
52
+ ForeachVarError: If the iterable is of type Any.
51
53
  """
52
- iterable = Var.create(iterable) # type: ignore
54
+ if props:
55
+ console.deprecate(
56
+ feature_name="Passing props to rx.foreach",
57
+ reason="it does not have the intended effect and may be confusing",
58
+ deprecation_version="0.5.0",
59
+ removal_version="0.6.0",
60
+ )
61
+ iterable = Var.create_safe(iterable)
53
62
  if iterable._var_type == Any:
54
- raise TypeError(
55
- f"Could not foreach over var of type Any. (If you are trying to foreach over a state var, add a type annotation to the var.)"
63
+ raise ForeachVarError(
64
+ f"Could not foreach over var `{iterable._var_full_name}` of type Any. "
65
+ "(If you are trying to foreach over a state var, add a type annotation to the var). "
66
+ "See https://reflex.dev/docs/library/layout/foreach/"
56
67
  )
57
68
  component = cls(
58
69
  iterable=iterable,
59
70
  render_fn=render_fn,
60
- **props,
61
71
  )
62
- # Keep a ref to a rendered component to determine correct imports.
63
- component.children = [
64
- component._render(props=dict(index_var_name="i")).render_component()
65
- ]
72
+ # Keep a ref to a rendered component to determine correct imports/hooks/styles.
73
+ component.children = [component._render().render_component()]
66
74
  return component
67
75
 
68
- def _render(self, props: dict[str, Any] | None = None) -> IterTag:
69
- props = {} if props is None else props.copy()
76
+ def _render(self) -> IterTag:
77
+ props = {}
70
78
 
71
- # Determine the arg var name based on the params accepted by render_fn.
72
79
  render_sig = inspect.signature(self.render_fn)
73
80
  params = list(render_sig.parameters.values())
81
+
82
+ # Validate the render function signature.
83
+ if len(params) == 0 or len(params) > 2:
84
+ raise ForeachRenderError(
85
+ "Expected 1 or 2 parameters in foreach render function, got "
86
+ f"{[p.name for p in params]}. See https://reflex.dev/docs/library/layout/foreach/"
87
+ )
88
+
74
89
  if len(params) >= 1:
75
- props.setdefault("arg_var_name", params[0].name)
90
+ # Determine the arg var name based on the params accepted by render_fn.
91
+ props["arg_var_name"] = params[0].name
76
92
 
77
- if len(params) >= 2:
93
+ if len(params) == 2:
78
94
  # Determine the index var name based on the params accepted by render_fn.
79
- props.setdefault("index_var_name", params[1].name)
80
- elif "index_var_name" not in props:
81
- # Otherwise, use a deterministic index, based on the rendered code.
82
- code_hash = md5(str(self.children[0].render()).encode("utf-8")).hexdigest()
83
- props.setdefault("index_var_name", f"index_{code_hash}")
95
+ props["index_var_name"] = params[1].name
96
+ else:
97
+ # Otherwise, use a deterministic index, based on the render function bytecode.
98
+ code_hash = (
99
+ hash(self.render_fn.__code__)
100
+ .to_bytes(
101
+ length=8,
102
+ byteorder="big",
103
+ signed=True,
104
+ )
105
+ .hex()
106
+ )
107
+ props["index_var_name"] = f"index_{code_hash}"
84
108
 
85
109
  return IterTag(
86
110
  iterable=self.iterable,
87
111
  render_fn=self.render_fn,
112
+ children=self.children,
88
113
  **props,
89
114
  )
90
115
 
@@ -95,23 +120,9 @@ class Foreach(Component):
95
120
  The dictionary for template of component.
96
121
  """
97
122
  tag = self._render()
98
- component = tag.render_component()
99
-
100
- # Apply the theme to the children.
101
- if self.theme is not None:
102
- component.apply_theme(self.theme)
103
123
 
104
124
  return dict(
105
- tag.add_props(
106
- **self.event_triggers,
107
- key=self.key,
108
- sx=self.style,
109
- id=self.id,
110
- class_name=self.class_name,
111
- ).set(
112
- children=[component.render()],
113
- props=tag.format_props(),
114
- ),
125
+ tag,
115
126
  iterable_state=tag.iterable._var_full_name,
116
127
  arg_name=tag.arg_var_name,
117
128
  arg_index=tag.get_index_var_arg(),
@@ -35,5 +35,11 @@ class Html(Div):
35
35
  else:
36
36
  props["dangerouslySetInnerHTML"] = {"__html": children[0]}
37
37
 
38
+ # Apply the default classname
39
+ given_class_name = props.pop("class_name", [])
40
+ if isinstance(given_class_name, str):
41
+ given_class_name = [given_class_name]
42
+ props["class_name"] = ["rx-Html", *given_class_name]
43
+
38
44
  # Create the component.
39
45
  return super().create(**props)
@@ -67,7 +67,7 @@ class Match(MemoizationLeaf):
67
67
  Raises:
68
68
  ValueError: If the condition is not provided.
69
69
  """
70
- match_cond_var = Var.create(cond, _var_is_string=type(cond) is str)
70
+ match_cond_var = Var.create(cond, _var_is_string=isinstance(cond, str))
71
71
 
72
72
  if match_cond_var is None:
73
73
  raise ValueError("The condition must be set")
@@ -119,7 +119,7 @@ class Match(MemoizationLeaf):
119
119
  _var_data = case_element._var_data if isinstance(case_element, Style) else None # type: ignore
120
120
  case_element = Var.create(
121
121
  case_element,
122
- _var_is_string=type(case_element) is str or isinstance(case_element, Color),
122
+ _var_is_string=isinstance(case_element, (str, Color)),
123
123
  )
124
124
  if _var_data is not None:
125
125
  case_element._var_data = VarData.merge(case_element._var_data, _var_data) # type: ignore
@@ -273,18 +273,3 @@ class Match(MemoizationLeaf):
273
273
  super()._get_imports(),
274
274
  getattr(self.cond._var_data, "imports", {}),
275
275
  )
276
-
277
- def _apply_theme(self, theme: Component):
278
- """Apply the theme to this component.
279
-
280
- Args:
281
- theme: The theme to apply.
282
- """
283
- # apply theme to return components.
284
- for match_case in self.match_cases:
285
- if isinstance(match_case[-1], Component):
286
- match_case[-1].apply_theme(theme)
287
-
288
- # apply theme to default component
289
- if isinstance(self.default, Component):
290
- self.default.apply_theme(theme)
@@ -9,7 +9,7 @@ from typing import Any, Callable, ClassVar, Dict, List, Optional, Union
9
9
  from reflex import constants
10
10
  from reflex.components.chakra.forms.input import Input
11
11
  from reflex.components.chakra.layout.box import Box
12
- from reflex.components.component import Component, MemoizationLeaf
12
+ from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
13
13
  from reflex.constants import Dirs
14
14
  from reflex.event import (
15
15
  CallableEventSpec,
@@ -219,6 +219,12 @@ class Upload(MemoizationLeaf):
219
219
  # Mark the Upload component as used in the app.
220
220
  cls.is_used = True
221
221
 
222
+ # Apply the default classname
223
+ given_class_name = props.pop("class_name", [])
224
+ if isinstance(given_class_name, str):
225
+ given_class_name = [given_class_name]
226
+ props["class_name"] = ["rx-Upload", *given_class_name]
227
+
222
228
  # get only upload component props
223
229
  supported_props = cls.get_props().union({"on_drop"})
224
230
  upload_props = {
@@ -299,3 +305,38 @@ class Upload(MemoizationLeaf):
299
305
  return {
300
306
  (5, "UploadFilesProvider"): UploadFilesProvider.create(),
301
307
  }
308
+
309
+
310
+ class StyledUpload(Upload):
311
+ """The styled Upload Component."""
312
+
313
+ @classmethod
314
+ def create(cls, *children, **props) -> Component:
315
+ """Create the styled upload component.
316
+
317
+ Args:
318
+ *children: The children of the component.
319
+ **props: The properties of the component.
320
+
321
+ Returns:
322
+ The styled upload component.
323
+ """
324
+ # Set default props.
325
+ props.setdefault("border", "1px dashed var(--accent-12)")
326
+ props.setdefault("padding", "5em")
327
+ props.setdefault("textAlign", "center")
328
+
329
+ # Mark the Upload component as used in the app.
330
+ Upload.is_used = True
331
+
332
+ return super().create(
333
+ *children,
334
+ **props,
335
+ )
336
+
337
+
338
+ class UploadNamespace(ComponentNamespace):
339
+ """Upload component namespace."""
340
+
341
+ root = Upload.create
342
+ __call__ = StyledUpload.create
@@ -13,7 +13,7 @@ from typing import Any, Callable, ClassVar, Dict, List, Optional, Union
13
13
  from reflex import constants
14
14
  from reflex.components.chakra.forms.input import Input
15
15
  from reflex.components.chakra.layout.box import Box
16
- from reflex.components.component import Component, MemoizationLeaf
16
+ from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
17
17
  from reflex.constants import Dirs
18
18
  from reflex.event import (
19
19
  CallableEventSpec,
@@ -219,3 +219,201 @@ class Upload(MemoizationLeaf):
219
219
  """
220
220
  ...
221
221
  def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ...
222
+
223
+ class StyledUpload(Upload):
224
+ @overload
225
+ @classmethod
226
+ def create( # type: ignore
227
+ cls,
228
+ *children,
229
+ accept: Optional[
230
+ Union[Var[Optional[Dict[str, List]]], Optional[Dict[str, List]]]
231
+ ] = None,
232
+ disabled: Optional[Union[Var[bool], bool]] = None,
233
+ max_files: Optional[Union[Var[int], int]] = None,
234
+ max_size: Optional[Union[Var[int], int]] = None,
235
+ min_size: Optional[Union[Var[int], int]] = None,
236
+ multiple: Optional[Union[Var[bool], bool]] = None,
237
+ no_click: Optional[Union[Var[bool], bool]] = None,
238
+ no_drag: Optional[Union[Var[bool], bool]] = None,
239
+ no_keyboard: Optional[Union[Var[bool], bool]] = None,
240
+ style: Optional[Style] = None,
241
+ key: Optional[Any] = None,
242
+ id: Optional[Any] = None,
243
+ class_name: Optional[Any] = None,
244
+ autofocus: Optional[bool] = None,
245
+ custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
246
+ on_blur: Optional[
247
+ Union[EventHandler, EventSpec, list, function, BaseVar]
248
+ ] = None,
249
+ on_click: Optional[
250
+ Union[EventHandler, EventSpec, list, function, BaseVar]
251
+ ] = None,
252
+ on_context_menu: Optional[
253
+ Union[EventHandler, EventSpec, list, function, BaseVar]
254
+ ] = None,
255
+ on_double_click: Optional[
256
+ Union[EventHandler, EventSpec, list, function, BaseVar]
257
+ ] = None,
258
+ on_drop: Optional[
259
+ Union[EventHandler, EventSpec, list, function, BaseVar]
260
+ ] = None,
261
+ on_focus: Optional[
262
+ Union[EventHandler, EventSpec, list, function, BaseVar]
263
+ ] = None,
264
+ on_mount: Optional[
265
+ Union[EventHandler, EventSpec, list, function, BaseVar]
266
+ ] = None,
267
+ on_mouse_down: Optional[
268
+ Union[EventHandler, EventSpec, list, function, BaseVar]
269
+ ] = None,
270
+ on_mouse_enter: Optional[
271
+ Union[EventHandler, EventSpec, list, function, BaseVar]
272
+ ] = None,
273
+ on_mouse_leave: Optional[
274
+ Union[EventHandler, EventSpec, list, function, BaseVar]
275
+ ] = None,
276
+ on_mouse_move: Optional[
277
+ Union[EventHandler, EventSpec, list, function, BaseVar]
278
+ ] = None,
279
+ on_mouse_out: Optional[
280
+ Union[EventHandler, EventSpec, list, function, BaseVar]
281
+ ] = None,
282
+ on_mouse_over: Optional[
283
+ Union[EventHandler, EventSpec, list, function, BaseVar]
284
+ ] = None,
285
+ on_mouse_up: Optional[
286
+ Union[EventHandler, EventSpec, list, function, BaseVar]
287
+ ] = None,
288
+ on_scroll: Optional[
289
+ Union[EventHandler, EventSpec, list, function, BaseVar]
290
+ ] = None,
291
+ on_unmount: Optional[
292
+ Union[EventHandler, EventSpec, list, function, BaseVar]
293
+ ] = None,
294
+ **props
295
+ ) -> "StyledUpload":
296
+ """Create the styled upload component.
297
+
298
+ Args:
299
+ *children: The children of the component.
300
+ accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
301
+ disabled: Whether the dropzone is disabled.
302
+ max_files: The maximum number of files that can be uploaded.
303
+ max_size: The maximum file size (bytes) that can be uploaded.
304
+ min_size: The minimum file size (bytes) that can be uploaded.
305
+ multiple: Whether to allow multiple files to be uploaded.
306
+ no_click: Whether to disable click to upload.
307
+ no_drag: Whether to disable drag and drop.
308
+ no_keyboard: Whether to disable using the space/enter keys to upload.
309
+ style: The style of the component.
310
+ key: A unique key for the component.
311
+ id: The id for the component.
312
+ class_name: The class name for the component.
313
+ autofocus: Whether the component should take the focus once the page is loaded
314
+ custom_attrs: custom attribute
315
+ **props: The properties of the component.
316
+
317
+ Returns:
318
+ The styled upload component.
319
+ """
320
+ ...
321
+
322
+ class UploadNamespace(ComponentNamespace):
323
+ root = Upload.create
324
+
325
+ @staticmethod
326
+ def __call__(
327
+ *children,
328
+ accept: Optional[
329
+ Union[Var[Optional[Dict[str, List]]], Optional[Dict[str, List]]]
330
+ ] = None,
331
+ disabled: Optional[Union[Var[bool], bool]] = None,
332
+ max_files: Optional[Union[Var[int], int]] = None,
333
+ max_size: Optional[Union[Var[int], int]] = None,
334
+ min_size: Optional[Union[Var[int], int]] = None,
335
+ multiple: Optional[Union[Var[bool], bool]] = None,
336
+ no_click: Optional[Union[Var[bool], bool]] = None,
337
+ no_drag: Optional[Union[Var[bool], bool]] = None,
338
+ no_keyboard: Optional[Union[Var[bool], bool]] = None,
339
+ style: Optional[Style] = None,
340
+ key: Optional[Any] = None,
341
+ id: Optional[Any] = None,
342
+ class_name: Optional[Any] = None,
343
+ autofocus: Optional[bool] = None,
344
+ custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
345
+ on_blur: Optional[
346
+ Union[EventHandler, EventSpec, list, function, BaseVar]
347
+ ] = None,
348
+ on_click: Optional[
349
+ Union[EventHandler, EventSpec, list, function, BaseVar]
350
+ ] = None,
351
+ on_context_menu: Optional[
352
+ Union[EventHandler, EventSpec, list, function, BaseVar]
353
+ ] = None,
354
+ on_double_click: Optional[
355
+ Union[EventHandler, EventSpec, list, function, BaseVar]
356
+ ] = None,
357
+ on_drop: Optional[
358
+ Union[EventHandler, EventSpec, list, function, BaseVar]
359
+ ] = None,
360
+ on_focus: Optional[
361
+ Union[EventHandler, EventSpec, list, function, BaseVar]
362
+ ] = None,
363
+ on_mount: Optional[
364
+ Union[EventHandler, EventSpec, list, function, BaseVar]
365
+ ] = None,
366
+ on_mouse_down: Optional[
367
+ Union[EventHandler, EventSpec, list, function, BaseVar]
368
+ ] = None,
369
+ on_mouse_enter: Optional[
370
+ Union[EventHandler, EventSpec, list, function, BaseVar]
371
+ ] = None,
372
+ on_mouse_leave: Optional[
373
+ Union[EventHandler, EventSpec, list, function, BaseVar]
374
+ ] = None,
375
+ on_mouse_move: Optional[
376
+ Union[EventHandler, EventSpec, list, function, BaseVar]
377
+ ] = None,
378
+ on_mouse_out: Optional[
379
+ Union[EventHandler, EventSpec, list, function, BaseVar]
380
+ ] = None,
381
+ on_mouse_over: Optional[
382
+ Union[EventHandler, EventSpec, list, function, BaseVar]
383
+ ] = None,
384
+ on_mouse_up: Optional[
385
+ Union[EventHandler, EventSpec, list, function, BaseVar]
386
+ ] = None,
387
+ on_scroll: Optional[
388
+ Union[EventHandler, EventSpec, list, function, BaseVar]
389
+ ] = None,
390
+ on_unmount: Optional[
391
+ Union[EventHandler, EventSpec, list, function, BaseVar]
392
+ ] = None,
393
+ **props
394
+ ) -> "StyledUpload":
395
+ """Create the styled upload component.
396
+
397
+ Args:
398
+ *children: The children of the component.
399
+ accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
400
+ disabled: Whether the dropzone is disabled.
401
+ max_files: The maximum number of files that can be uploaded.
402
+ max_size: The maximum file size (bytes) that can be uploaded.
403
+ min_size: The minimum file size (bytes) that can be uploaded.
404
+ multiple: Whether to allow multiple files to be uploaded.
405
+ no_click: Whether to disable click to upload.
406
+ no_drag: Whether to disable drag and drop.
407
+ no_keyboard: Whether to disable using the space/enter keys to upload.
408
+ style: The style of the component.
409
+ key: A unique key for the component.
410
+ id: The id for the component.
411
+ class_name: The class name for the component.
412
+ autofocus: Whether the component should take the focus once the page is loaded
413
+ custom_attrs: custom attribute
414
+ **props: The properties of the component.
415
+
416
+ Returns:
417
+ The styled upload component.
418
+ """
419
+ ...
@@ -1,4 +1,6 @@
1
1
  """A code component."""
2
+ from __future__ import annotations
3
+
2
4
  import re
3
5
  from typing import Dict, Literal, Optional, Union
4
6
 
@@ -7,6 +9,7 @@ from reflex.components.chakra.layout import Box
7
9
  from reflex.components.chakra.media import Icon
8
10
  from reflex.components.component import Component
9
11
  from reflex.components.core.cond import color_mode_cond
12
+ from reflex.constants.colors import Color
10
13
  from reflex.event import set_clipboard
11
14
  from reflex.style import Style
12
15
  from reflex.utils import format, imports
@@ -373,7 +376,7 @@ class CodeBlock(Component):
373
376
  wrap_long_lines: Var[bool]
374
377
 
375
378
  # A custom style for the code block.
376
- custom_style: Dict[str, str] = {}
379
+ custom_style: Dict[str, Union[str, Var, Color]] = {}
377
380
 
378
381
  # Props passed down to the code tag.
379
382
  code_tag_props: Var[Dict[str, str]]
@@ -490,8 +493,9 @@ class CodeBlock(Component):
490
493
  else:
491
494
  return code_block
492
495
 
493
- def _add_style(self, style):
494
- self.custom_style.update(style) # type: ignore
496
+ def add_style(self) -> Style | None:
497
+ """Add style to the component."""
498
+ self.custom_style.update(self.style)
495
499
 
496
500
  def _render(self):
497
501
  out = super()._render()
@@ -14,6 +14,7 @@ from reflex.components.chakra.layout import Box
14
14
  from reflex.components.chakra.media import Icon
15
15
  from reflex.components.component import Component
16
16
  from reflex.components.core.cond import color_mode_cond
17
+ from reflex.constants.colors import Color
17
18
  from reflex.event import set_clipboard
18
19
  from reflex.style import Style
19
20
  from reflex.utils import format, imports
@@ -1029,7 +1030,7 @@ class CodeBlock(Component):
1029
1030
  show_line_numbers: Optional[Union[Var[bool], bool]] = None,
1030
1031
  starting_line_number: Optional[Union[Var[int], int]] = None,
1031
1032
  wrap_long_lines: Optional[Union[Var[bool], bool]] = None,
1032
- custom_style: Optional[Dict[str, str]] = None,
1033
+ custom_style: Optional[Dict[str, Union[str, Var, Color]]] = None,
1033
1034
  code_tag_props: Optional[Union[Var[Dict[str, str]], Dict[str, str]]] = None,
1034
1035
  style: Optional[Style] = None,
1035
1036
  key: Optional[Any] = None,
@@ -1110,5 +1111,6 @@ class CodeBlock(Component):
1110
1111
  The text component.
1111
1112
  """
1112
1113
  ...
1114
+ def add_style(self) -> Style | None: ...
1113
1115
  @staticmethod
1114
1116
  def convert_theme_name(theme) -> str: ...
@@ -338,7 +338,7 @@ class Input(BaseHTML):
338
338
  use_map: Var[Union[str, int, bool]]
339
339
 
340
340
  # Value of the input
341
- value: Var[Union[str, int, bool]]
341
+ value: Var[Union[str, int, float]]
342
342
 
343
343
  def get_event_triggers(self) -> Dict[str, Any]:
344
344
  """Get the event triggers that pass the component's value to the handler.
@@ -662,7 +662,7 @@ class Input(BaseHTML):
662
662
  Union[Var[Union[str, int, bool]], Union[str, int, bool]]
663
663
  ] = None,
664
664
  value: Optional[
665
- Union[Var[Union[str, int, bool]], Union[str, int, bool]]
665
+ Union[Var[Union[str, int, float]], Union[str, int, float]]
666
666
  ] = None,
667
667
  access_key: Optional[
668
668
  Union[Var[Union[str, int, bool]], Union[str, int, bool]]
@@ -1,7 +1,6 @@
1
1
  """Lucide Icon component."""
2
2
 
3
3
  from reflex.components.component import Component
4
- from reflex.style import Style
5
4
  from reflex.utils import console, format
6
5
  from reflex.vars import Var
7
6
 
@@ -45,24 +44,24 @@ class Icon(LucideIconComponent):
45
44
  feature_name=f"icon {tag}",
46
45
  reason=f"it was renamed upstream. Use {new_tag} instead.",
47
46
  deprecation_version="0.4.6",
48
- removal_version="0.5.0",
47
+ removal_version="0.6.0",
49
48
  )
50
49
  return new_tag
51
50
  return tag
52
51
 
53
52
  if children:
54
- if len(children) == 1 and type(children[0]) == str:
53
+ if len(children) == 1 and isinstance(children[0], str):
55
54
  props["tag"] = children[0]
56
55
  children = []
57
56
  else:
58
57
  raise AttributeError(
59
58
  f"Passing multiple children to Icon component is not allowed: remove positional arguments {children[1:]} to fix"
60
59
  )
61
- if "tag" not in props.keys():
60
+ if "tag" not in props:
62
61
  raise AttributeError("Missing 'tag' keyword-argument for Icon")
63
62
 
64
63
  if (
65
- type(props["tag"]) != str
64
+ not isinstance(props["tag"], str)
66
65
  or map_deprecated_icon_names_05(format.to_snake_case(props["tag"]))
67
66
  not in LUCIDE_ICON_LIST
68
67
  ):
@@ -73,16 +72,9 @@ class Icon(LucideIconComponent):
73
72
 
74
73
  props["tag"] = format.to_title_case(format.to_snake_case(props["tag"])) + "Icon"
75
74
  props["alias"] = f"Lucide{props['tag']}"
75
+ props.setdefault("color", f"var(--current-color)")
76
76
  return super().create(*children, **props)
77
77
 
78
- def _apply_theme(self, theme: Component):
79
- self.style = Style(
80
- {
81
- "color": f"var(--current-color)",
82
- **self.style,
83
- }
84
- )
85
-
86
78
 
87
79
  RENAMED_ICONS_05 = {
88
80
  "activity_square": "square_activity",
@@ -8,7 +8,6 @@ from reflex.vars import Var, BaseVar, ComputedVar
8
8
  from reflex.event import EventChain, EventHandler, EventSpec
9
9
  from reflex.style import Style
10
10
  from reflex.components.component import Component
11
- from reflex.style import Style
12
11
  from reflex.utils import console, format
13
12
  from reflex.vars import Var
14
13