reflex 0.4.9a2__py3-none-any.whl → 0.5.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 (131) hide show
  1. reflex/.templates/apps/blank/code/blank.py +19 -16
  2. reflex/.templates/apps/demo/code/pages/datatable.py +4 -4
  3. reflex/.templates/apps/demo/code/pages/forms.py +2 -2
  4. reflex/.templates/web/utils/helpers/debounce.js +17 -0
  5. reflex/.templates/web/utils/helpers/throttle.js +22 -0
  6. reflex/.templates/web/utils/state.js +21 -3
  7. reflex/__init__.py +6 -1
  8. reflex/__init__.pyi +4 -1
  9. reflex/app.py +157 -140
  10. reflex/app_module_for_backend.py +1 -1
  11. reflex/base.py +13 -15
  12. reflex/compiler/compiler.py +10 -1
  13. reflex/compiler/utils.py +3 -30
  14. reflex/components/__init__.py +1 -0
  15. reflex/components/chakra/datadisplay/list.py +1 -3
  16. reflex/components/chakra/datadisplay/list.pyi +3 -3
  17. reflex/components/chakra/disclosure/accordion.py +1 -1
  18. reflex/components/chakra/forms/pininput.pyi +1 -1
  19. reflex/components/chakra/media/icon.py +2 -2
  20. reflex/components/component.py +279 -32
  21. reflex/components/core/__init__.py +2 -2
  22. reflex/components/core/cond.py +1 -10
  23. reflex/components/core/debounce.py +5 -2
  24. reflex/components/core/debounce.pyi +4 -2
  25. reflex/components/core/foreach.py +1 -16
  26. reflex/components/core/html.py +6 -0
  27. reflex/components/core/match.py +2 -17
  28. reflex/components/core/upload.py +42 -1
  29. reflex/components/core/upload.pyi +199 -1
  30. reflex/components/datadisplay/code.py +7 -3
  31. reflex/components/datadisplay/code.pyi +3 -1
  32. reflex/components/el/elements/forms.py +1 -1
  33. reflex/components/el/elements/forms.pyi +1 -1
  34. reflex/components/lucide/icon.py +5 -13
  35. reflex/components/lucide/icon.pyi +0 -1
  36. reflex/components/markdown/markdown.py +5 -23
  37. reflex/components/markdown/markdown.pyi +1 -4
  38. reflex/components/radix/primitives/accordion.py +227 -406
  39. reflex/components/radix/primitives/accordion.pyi +369 -28
  40. reflex/components/radix/primitives/form.py +33 -29
  41. reflex/components/radix/primitives/form.pyi +7 -2
  42. reflex/components/radix/primitives/progress.py +17 -9
  43. reflex/components/radix/primitives/progress.pyi +2 -0
  44. reflex/components/radix/primitives/slider.py +30 -18
  45. reflex/components/radix/primitives/slider.pyi +4 -0
  46. reflex/components/radix/themes/base.py +8 -1
  47. reflex/components/radix/themes/base.pyi +79 -1
  48. reflex/components/radix/themes/color_mode.py +74 -30
  49. reflex/components/radix/themes/color_mode.pyi +26 -185
  50. reflex/components/radix/themes/components/__init__.py +17 -0
  51. reflex/components/radix/themes/components/badge.py +2 -1
  52. reflex/components/radix/themes/components/badge.pyi +3 -1
  53. reflex/components/radix/themes/components/button.py +3 -1
  54. reflex/components/radix/themes/components/button.pyi +4 -1
  55. reflex/components/radix/themes/components/checkbox_cards.py +48 -0
  56. reflex/components/radix/themes/components/checkbox_cards.pyi +264 -0
  57. reflex/components/radix/themes/components/checkbox_group.py +42 -0
  58. reflex/components/radix/themes/components/checkbox_group.pyi +253 -0
  59. reflex/components/radix/themes/components/data_list.py +63 -0
  60. reflex/components/radix/themes/components/data_list.pyi +426 -0
  61. reflex/components/radix/themes/components/icon_button.py +20 -17
  62. reflex/components/radix/themes/components/icon_button.pyi +5 -1
  63. reflex/components/radix/themes/components/progress.py +55 -0
  64. reflex/components/radix/themes/components/progress.pyi +180 -0
  65. reflex/components/radix/themes/components/radio.py +31 -0
  66. reflex/components/radix/themes/components/radio.pyi +169 -0
  67. reflex/components/radix/themes/components/radio_cards.py +48 -0
  68. reflex/components/radix/themes/components/radio_cards.pyi +264 -0
  69. reflex/components/radix/themes/components/radio_group.py +2 -4
  70. reflex/components/radix/themes/components/segmented_control.py +48 -0
  71. reflex/components/radix/themes/components/segmented_control.pyi +262 -0
  72. reflex/components/radix/themes/components/skeleton.py +32 -0
  73. reflex/components/radix/themes/components/skeleton.pyi +106 -0
  74. reflex/components/radix/themes/components/spinner.py +26 -0
  75. reflex/components/radix/themes/components/spinner.pyi +101 -0
  76. reflex/components/radix/themes/components/tabs.py +26 -1
  77. reflex/components/radix/themes/components/tabs.pyi +69 -9
  78. reflex/components/radix/themes/components/text_field.py +101 -71
  79. reflex/components/radix/themes/components/text_field.pyi +81 -499
  80. reflex/components/radix/themes/layout/base.py +2 -2
  81. reflex/components/radix/themes/layout/base.pyi +4 -4
  82. reflex/components/radix/themes/layout/center.py +8 -3
  83. reflex/components/radix/themes/layout/center.pyi +2 -1
  84. reflex/components/radix/themes/layout/container.py +30 -2
  85. reflex/components/radix/themes/layout/container.pyi +9 -30
  86. reflex/components/radix/themes/layout/list.py +10 -5
  87. reflex/components/radix/themes/layout/list.pyi +5 -21
  88. reflex/components/radix/themes/layout/spacer.py +8 -3
  89. reflex/components/radix/themes/layout/spacer.pyi +2 -1
  90. reflex/components/radix/themes/layout/stack.py +7 -1
  91. reflex/components/radix/themes/layout/stack.pyi +3 -3
  92. reflex/components/radix/themes/typography/link.py +10 -2
  93. reflex/components/radix/themes/typography/link.pyi +5 -4
  94. reflex/components/sonner/__init__.py +3 -0
  95. reflex/components/sonner/toast.py +267 -0
  96. reflex/components/sonner/toast.pyi +205 -0
  97. reflex/components/tags/iter_tag.py +9 -6
  98. reflex/config.py +30 -54
  99. reflex/constants/__init__.py +0 -2
  100. reflex/constants/base.py +0 -5
  101. reflex/constants/colors.py +2 -0
  102. reflex/constants/installer.py +5 -1
  103. reflex/constants/route.py +4 -0
  104. reflex/custom_components/custom_components.py +22 -1
  105. reflex/event.py +75 -30
  106. reflex/experimental/__init__.py +5 -0
  107. reflex/experimental/layout.py +24 -6
  108. reflex/model.py +2 -1
  109. reflex/page.py +7 -4
  110. reflex/reflex.py +8 -3
  111. reflex/route.py +39 -0
  112. reflex/state.py +128 -131
  113. reflex/style.py +20 -1
  114. reflex/testing.py +10 -6
  115. reflex/utils/console.py +3 -1
  116. reflex/utils/exec.py +20 -7
  117. reflex/utils/format.py +1 -1
  118. reflex/utils/imports.py +3 -1
  119. reflex/utils/prerequisites.py +141 -20
  120. reflex/utils/processes.py +21 -1
  121. reflex/utils/pyi_generator.py +95 -5
  122. reflex/utils/serializers.py +1 -1
  123. reflex/utils/telemetry.py +26 -4
  124. reflex/utils/types.py +62 -18
  125. reflex/vars.py +11 -5
  126. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/METADATA +16 -4
  127. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/RECORD +130 -108
  128. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/WHEEL +1 -1
  129. reflex/app.pyi +0 -149
  130. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/LICENSE +0 -0
  131. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/entry_points.txt +0 -0
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
 
4
4
  import inspect
5
5
  from hashlib import md5
6
- from typing import Any, Callable, Iterable, Optional
6
+ from typing import Any, Callable, Iterable
7
7
 
8
8
  from reflex.components.base.fragment import Fragment
9
9
  from reflex.components.component import Component
@@ -23,17 +23,6 @@ class Foreach(Component):
23
23
  # A function from the render args to the component.
24
24
  render_fn: Callable = Fragment.create
25
25
 
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
26
  @classmethod
38
27
  def create(cls, iterable: Var[Iterable], render_fn: Callable, **props) -> Foreach:
39
28
  """Create a foreach component.
@@ -97,10 +86,6 @@ class Foreach(Component):
97
86
  tag = self._render()
98
87
  component = tag.render_component()
99
88
 
100
- # Apply the theme to the children.
101
- if self.theme is not None:
102
- component.apply_theme(self.theme)
103
-
104
89
  return dict(
105
90
  tag.add_props(
106
91
  **self.event_triggers,
@@ -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
 
@@ -18,8 +18,7 @@ from reflex.components.radix.themes.typography.heading import Heading
18
18
  from reflex.components.radix.themes.typography.link import Link
19
19
  from reflex.components.radix.themes.typography.text import Text
20
20
  from reflex.components.tags.tag import Tag
21
- from reflex.style import Style
22
- from reflex.utils import console, imports, types
21
+ from reflex.utils import imports, types
23
22
  from reflex.utils.imports import ImportVar
24
23
  from reflex.vars import Var
25
24
 
@@ -85,9 +84,6 @@ class Markdown(Component):
85
84
  # The component map from a tag to a lambda that creates a component.
86
85
  component_map: Dict[str, Any] = {}
87
86
 
88
- # Custom styles for the markdown (deprecated in v0.2.9).
89
- custom_styles: Dict[str, Any] = {}
90
-
91
87
  # The hash of the component map, generated at create() time.
92
88
  component_map_hash: str = ""
93
89
 
@@ -102,19 +98,10 @@ class Markdown(Component):
102
98
  Returns:
103
99
  The markdown component.
104
100
  """
105
- assert len(children) == 1 and types._isinstance(
106
- children[0], Union[str, Var]
101
+ assert (
102
+ len(children) == 1 and types._isinstance(children[0], Union[str, Var])
107
103
  ), "Markdown component must have exactly one child containing the markdown source."
108
104
 
109
- # Custom styles are deprecated.
110
- if "custom_styles" in props:
111
- console.deprecate(
112
- feature_name="rx.markdown custom_styles",
113
- reason="Use the component_map prop instead.",
114
- deprecation_version="0.2.9",
115
- removal_version="0.5.0",
116
- )
117
-
118
105
  # Update the base component map with the custom component map.
119
106
  component_map = {**get_base_component_map(), **props.pop("component_map", {})}
120
107
 
@@ -230,7 +217,6 @@ class Markdown(Component):
230
217
  component = self.component_map[tag](*children, **props).set(
231
218
  special_props=special_props
232
219
  )
233
- component._add_style(Style(self.custom_styles.get(tag, {})))
234
220
  return component
235
221
 
236
222
  def format_component(self, tag: str, **props) -> str:
@@ -257,9 +243,7 @@ class Markdown(Component):
257
243
  }
258
244
 
259
245
  # Separate out inline code and code blocks.
260
- components[
261
- "code"
262
- ] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
246
+ components["code"] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
263
247
  const match = (className || '').match(/language-(?<lang>.*)/);
264
248
  const language = match ? match[1] : '';
265
249
  if (language) {{
@@ -277,9 +261,7 @@ class Markdown(Component):
277
261
  ) : (
278
262
  {self.format_component("codeblock", language=Var.create_safe("language", _var_is_local=False))}
279
263
  );
280
- }}}}""".replace(
281
- "\n", " "
282
- )
264
+ }}}}""".replace("\n", " ")
283
265
 
284
266
  return components
285
267
 
@@ -22,8 +22,7 @@ from reflex.components.radix.themes.typography.heading import Heading
22
22
  from reflex.components.radix.themes.typography.link import Link
23
23
  from reflex.components.radix.themes.typography.text import Text
24
24
  from reflex.components.tags.tag import Tag
25
- from reflex.style import Style
26
- from reflex.utils import console, imports, types
25
+ from reflex.utils import imports, types
27
26
  from reflex.utils.imports import ImportVar
28
27
  from reflex.vars import Var
29
28
 
@@ -49,7 +48,6 @@ class Markdown(Component):
49
48
  cls,
50
49
  *children,
51
50
  component_map: Optional[Dict[str, Any]] = None,
52
- custom_styles: Optional[Dict[str, Any]] = None,
53
51
  component_map_hash: Optional[str] = None,
54
52
  style: Optional[Style] = None,
55
53
  key: Optional[Any] = None,
@@ -109,7 +107,6 @@ class Markdown(Component):
109
107
  Args:
110
108
  *children: The children of the component.
111
109
  component_map: The component map from a tag to a lambda that creates a component.
112
- custom_styles: Custom styles for the markdown (deprecated in v0.2.9).
113
110
  component_map_hash: The hash of the component map, generated at create() time.
114
111
  style: The style of the component.
115
112
  key: A unique key for the component.