reflex 0.5.10a3__py3-none-any.whl → 0.6.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 (303) hide show
  1. reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +2 -2
  2. reflex/.templates/jinja/web/pages/_app.js.jinja2 +1 -1
  3. reflex/.templates/jinja/web/pages/utils.js.jinja2 +4 -4
  4. reflex/.templates/jinja/web/utils/context.js.jinja2 +1 -1
  5. reflex/.templates/jinja/web/utils/theme.js.jinja2 +1 -1
  6. reflex/.templates/web/utils/state.js +3 -1
  7. reflex/__init__.py +10 -3
  8. reflex/__init__.pyi +3 -2
  9. reflex/app.py +47 -11
  10. reflex/app_module_for_backend.py +1 -1
  11. reflex/base.py +3 -2
  12. reflex/compiler/compiler.py +5 -5
  13. reflex/compiler/utils.py +5 -3
  14. reflex/components/base/app_wrap.py +2 -4
  15. reflex/components/base/app_wrap.pyi +16 -26
  16. reflex/components/base/bare.py +6 -4
  17. reflex/components/base/body.pyi +16 -26
  18. reflex/components/base/document.pyi +76 -126
  19. reflex/components/base/error_boundary.py +9 -8
  20. reflex/components/base/error_boundary.pyi +18 -30
  21. reflex/components/base/fragment.pyi +16 -26
  22. reflex/components/base/head.pyi +31 -51
  23. reflex/components/base/link.py +1 -1
  24. reflex/components/base/link.pyi +31 -51
  25. reflex/components/base/meta.pyi +61 -101
  26. reflex/components/base/script.py +2 -2
  27. reflex/components/base/script.pyi +20 -36
  28. reflex/components/component.py +107 -130
  29. reflex/components/core/banner.py +61 -66
  30. reflex/components/core/banner.pyi +129 -230
  31. reflex/components/core/client_side_routing.py +2 -2
  32. reflex/components/core/client_side_routing.pyi +31 -51
  33. reflex/components/core/clipboard.py +4 -3
  34. reflex/components/core/clipboard.pyi +19 -31
  35. reflex/components/core/cond.py +21 -44
  36. reflex/components/core/debounce.py +7 -9
  37. reflex/components/core/debounce.pyi +19 -31
  38. reflex/components/core/foreach.py +4 -14
  39. reflex/components/core/html.py +1 -1
  40. reflex/components/core/html.pyi +34 -44
  41. reflex/components/core/match.py +36 -43
  42. reflex/components/core/upload.py +27 -26
  43. reflex/components/core/upload.pyi +81 -116
  44. reflex/components/datadisplay/code.py +55 -29
  45. reflex/components/datadisplay/code.pyi +303 -410
  46. reflex/components/datadisplay/dataeditor.py +13 -9
  47. reflex/components/datadisplay/dataeditor.pyi +39 -51
  48. reflex/components/el/__init__.py +0 -1
  49. reflex/components/el/__init__.pyi +0 -11
  50. reflex/components/el/element.pyi +16 -26
  51. reflex/components/el/elements/__init__.py +1 -7
  52. reflex/components/el/elements/__init__.pyi +1 -15
  53. reflex/components/el/elements/base.py +1 -1
  54. reflex/components/el/elements/base.pyi +33 -43
  55. reflex/components/el/elements/forms.py +26 -33
  56. reflex/components/el/elements/forms.pyi +542 -694
  57. reflex/components/el/elements/inline.py +1 -1
  58. reflex/components/el/elements/inline.pyi +909 -1189
  59. reflex/components/el/elements/media.py +1 -22
  60. reflex/components/el/elements/media.pyi +765 -975
  61. reflex/components/el/elements/metadata.py +3 -5
  62. reflex/components/el/elements/metadata.pyi +175 -235
  63. reflex/components/el/elements/other.py +1 -1
  64. reflex/components/el/elements/other.pyi +228 -298
  65. reflex/components/el/elements/scripts.py +1 -1
  66. reflex/components/el/elements/scripts.pyi +106 -136
  67. reflex/components/el/elements/sectioning.py +0 -2
  68. reflex/components/el/elements/sectioning.pyi +481 -631
  69. reflex/components/el/elements/tables.py +1 -1
  70. reflex/components/el/elements/tables.pyi +341 -441
  71. reflex/components/el/elements/typography.py +1 -1
  72. reflex/components/el/elements/typography.pyi +491 -641
  73. reflex/components/gridjs/datatable.py +9 -13
  74. reflex/components/gridjs/datatable.pyi +33 -53
  75. reflex/components/lucide/icon.py +3 -127
  76. reflex/components/lucide/icon.pyi +31 -160
  77. reflex/components/markdown/markdown.py +32 -42
  78. reflex/components/markdown/markdown.pyi +28 -41
  79. reflex/components/moment/moment.py +13 -12
  80. reflex/components/moment/moment.pyi +22 -33
  81. reflex/components/next/base.pyi +16 -26
  82. reflex/components/next/image.py +1 -5
  83. reflex/components/next/image.pyi +21 -35
  84. reflex/components/next/link.py +1 -1
  85. reflex/components/next/link.pyi +16 -26
  86. reflex/components/next/video.py +1 -1
  87. reflex/components/next/video.pyi +16 -26
  88. reflex/components/plotly/plotly.py +17 -30
  89. reflex/components/plotly/plotly.pyi +38 -52
  90. reflex/components/props.py +21 -10
  91. reflex/components/radix/__init__.pyi +2 -1
  92. reflex/components/radix/primitives/accordion.py +6 -7
  93. reflex/components/radix/primitives/accordion.pyi +415 -485
  94. reflex/components/radix/primitives/base.py +1 -1
  95. reflex/components/radix/primitives/base.pyi +31 -51
  96. reflex/components/radix/primitives/drawer.py +1 -1
  97. reflex/components/radix/primitives/drawer.pyi +162 -262
  98. reflex/components/radix/primitives/form.py +1 -1
  99. reflex/components/radix/primitives/form.pyi +247 -353
  100. reflex/components/radix/primitives/progress.py +1 -1
  101. reflex/components/radix/primitives/progress.pyi +226 -276
  102. reflex/components/radix/primitives/slider.py +1 -1
  103. reflex/components/radix/primitives/slider.pyi +82 -132
  104. reflex/components/radix/themes/base.py +8 -25
  105. reflex/components/radix/themes/base.pyi +171 -242
  106. reflex/components/radix/themes/color_mode.py +11 -20
  107. reflex/components/radix/themes/color_mode.pyi +198 -231
  108. reflex/components/radix/themes/components/__init__.pyi +1 -0
  109. reflex/components/radix/themes/components/alert_dialog.py +1 -1
  110. reflex/components/radix/themes/components/alert_dialog.pyi +129 -199
  111. reflex/components/radix/themes/components/aspect_ratio.py +1 -1
  112. reflex/components/radix/themes/components/aspect_ratio.pyi +16 -26
  113. reflex/components/radix/themes/components/avatar.py +1 -1
  114. reflex/components/radix/themes/components/avatar.pyi +69 -79
  115. reflex/components/radix/themes/components/badge.py +1 -1
  116. reflex/components/radix/themes/components/badge.pyi +87 -97
  117. reflex/components/radix/themes/components/button.py +1 -1
  118. reflex/components/radix/themes/components/button.pyi +97 -107
  119. reflex/components/radix/themes/components/callout.py +1 -1
  120. reflex/components/radix/themes/components/callout.pyi +317 -367
  121. reflex/components/radix/themes/components/card.py +1 -1
  122. reflex/components/radix/themes/components/card.pyi +37 -47
  123. reflex/components/radix/themes/components/checkbox.py +2 -4
  124. reflex/components/radix/themes/components/checkbox.pyi +205 -241
  125. reflex/components/radix/themes/components/checkbox_cards.py +1 -1
  126. reflex/components/radix/themes/components/checkbox_cards.pyi +92 -112
  127. reflex/components/radix/themes/components/checkbox_group.py +1 -1
  128. reflex/components/radix/themes/components/checkbox_group.pyi +84 -104
  129. reflex/components/radix/themes/components/context_menu.py +1 -1
  130. reflex/components/radix/themes/components/context_menu.pyi +230 -310
  131. reflex/components/radix/themes/components/data_list.py +6 -1
  132. reflex/components/radix/themes/components/data_list.pyi +131 -166
  133. reflex/components/radix/themes/components/dialog.py +1 -1
  134. reflex/components/radix/themes/components/dialog.pyi +132 -202
  135. reflex/components/radix/themes/components/dropdown_menu.py +1 -1
  136. reflex/components/radix/themes/components/dropdown_menu.pyi +241 -323
  137. reflex/components/radix/themes/components/hover_card.py +1 -1
  138. reflex/components/radix/themes/components/hover_card.pyi +86 -126
  139. reflex/components/radix/themes/components/icon_button.py +1 -1
  140. reflex/components/radix/themes/components/icon_button.pyi +97 -107
  141. reflex/components/radix/themes/components/inset.py +1 -1
  142. reflex/components/radix/themes/components/inset.pyi +46 -56
  143. reflex/components/radix/themes/components/popover.py +1 -1
  144. reflex/components/radix/themes/components/popover.pyi +91 -131
  145. reflex/components/radix/themes/components/progress.py +1 -1
  146. reflex/components/radix/themes/components/progress.pyi +70 -80
  147. reflex/components/radix/themes/components/radio.py +1 -1
  148. reflex/components/radix/themes/components/radio.pyi +68 -78
  149. reflex/components/radix/themes/components/radio_cards.py +1 -1
  150. reflex/components/radix/themes/components/radio_cards.pyi +96 -116
  151. reflex/components/radix/themes/components/radio_group.py +32 -31
  152. reflex/components/radix/themes/components/radio_group.pyi +230 -266
  153. reflex/components/radix/themes/components/scroll_area.py +1 -1
  154. reflex/components/radix/themes/components/scroll_area.pyi +20 -30
  155. reflex/components/radix/themes/components/segmented_control.py +1 -1
  156. reflex/components/radix/themes/components/segmented_control.pyi +88 -110
  157. reflex/components/radix/themes/components/select.py +1 -1
  158. reflex/components/radix/themes/components/select.pyi +365 -461
  159. reflex/components/radix/themes/components/separator.py +2 -4
  160. reflex/components/radix/themes/components/separator.pyi +68 -78
  161. reflex/components/radix/themes/components/skeleton.py +1 -1
  162. reflex/components/radix/themes/components/skeleton.pyi +22 -32
  163. reflex/components/radix/themes/components/slider.py +1 -1
  164. reflex/components/radix/themes/components/slider.pyi +74 -86
  165. reflex/components/radix/themes/components/spinner.py +1 -1
  166. reflex/components/radix/themes/components/spinner.pyi +18 -28
  167. reflex/components/radix/themes/components/switch.py +1 -1
  168. reflex/components/radix/themes/components/switch.pyi +70 -82
  169. reflex/components/radix/themes/components/table.py +1 -1
  170. reflex/components/radix/themes/components/table.pyi +254 -324
  171. reflex/components/radix/themes/components/tabs.py +1 -1
  172. reflex/components/radix/themes/components/tabs.pyi +134 -188
  173. reflex/components/radix/themes/components/text_area.py +1 -1
  174. reflex/components/radix/themes/components/text_area.pyi +95 -109
  175. reflex/components/radix/themes/components/text_field.py +1 -80
  176. reflex/components/radix/themes/components/text_field.pyi +245 -290
  177. reflex/components/radix/themes/components/tooltip.py +1 -1
  178. reflex/components/radix/themes/components/tooltip.pyi +25 -35
  179. reflex/components/radix/themes/layout/__init__.pyi +1 -0
  180. reflex/components/radix/themes/layout/base.py +1 -1
  181. reflex/components/radix/themes/layout/base.pyi +55 -65
  182. reflex/components/radix/themes/layout/box.pyi +33 -43
  183. reflex/components/radix/themes/layout/center.pyi +55 -65
  184. reflex/components/radix/themes/layout/container.py +2 -4
  185. reflex/components/radix/themes/layout/container.pyi +35 -45
  186. reflex/components/radix/themes/layout/flex.py +1 -1
  187. reflex/components/radix/themes/layout/flex.pyi +55 -65
  188. reflex/components/radix/themes/layout/grid.py +1 -1
  189. reflex/components/radix/themes/layout/grid.pyi +63 -73
  190. reflex/components/radix/themes/layout/list.py +1 -1
  191. reflex/components/radix/themes/layout/list.pyi +188 -238
  192. reflex/components/radix/themes/layout/section.py +2 -4
  193. reflex/components/radix/themes/layout/section.pyi +35 -45
  194. reflex/components/radix/themes/layout/spacer.pyi +55 -65
  195. reflex/components/radix/themes/layout/stack.py +1 -1
  196. reflex/components/radix/themes/layout/stack.pyi +125 -155
  197. reflex/components/radix/themes/typography/blockquote.py +1 -1
  198. reflex/components/radix/themes/typography/blockquote.pyi +88 -98
  199. reflex/components/radix/themes/typography/code.py +1 -1
  200. reflex/components/radix/themes/typography/code.pyi +89 -99
  201. reflex/components/radix/themes/typography/heading.py +1 -1
  202. reflex/components/radix/themes/typography/heading.pyi +95 -105
  203. reflex/components/radix/themes/typography/link.py +1 -1
  204. reflex/components/radix/themes/typography/link.pyi +101 -111
  205. reflex/components/radix/themes/typography/text.py +1 -1
  206. reflex/components/radix/themes/typography/text.pyi +494 -564
  207. reflex/components/react_player/audio.pyi +32 -58
  208. reflex/components/react_player/react_player.py +1 -1
  209. reflex/components/react_player/react_player.pyi +32 -58
  210. reflex/components/react_player/video.pyi +32 -58
  211. reflex/components/recharts/cartesian.py +22 -19
  212. reflex/components/recharts/cartesian.pyi +658 -840
  213. reflex/components/recharts/charts.py +3 -3
  214. reflex/components/recharts/charts.pyi +238 -342
  215. reflex/components/recharts/general.py +8 -8
  216. reflex/components/recharts/general.pyi +175 -225
  217. reflex/components/recharts/polar.py +11 -11
  218. reflex/components/recharts/polar.pyi +135 -171
  219. reflex/components/recharts/recharts.pyi +31 -51
  220. reflex/components/sonner/toast.py +27 -31
  221. reflex/components/sonner/toast.pyi +36 -45
  222. reflex/components/suneditor/editor.py +1 -1
  223. reflex/components/suneditor/editor.pyi +54 -76
  224. reflex/components/tags/cond_tag.py +6 -4
  225. reflex/components/tags/iter_tag.py +37 -25
  226. reflex/components/tags/match_tag.py +6 -4
  227. reflex/components/tags/tag.py +43 -28
  228. reflex/constants/base.py +3 -1
  229. reflex/constants/event.py +1 -0
  230. reflex/custom_components/custom_components.py +3 -1
  231. reflex/event.py +166 -108
  232. reflex/experimental/__init__.py +25 -6
  233. reflex/experimental/client_state.py +34 -57
  234. reflex/experimental/hooks.py +12 -17
  235. reflex/experimental/layout.py +4 -4
  236. reflex/experimental/layout.pyi +130 -180
  237. reflex/middleware/hydrate_middleware.py +2 -0
  238. reflex/middleware/middleware.py +3 -3
  239. reflex/model.py +22 -0
  240. reflex/reflex.py +4 -0
  241. reflex/state.py +491 -110
  242. reflex/style.py +56 -39
  243. reflex/testing.py +8 -3
  244. reflex/utils/exceptions.py +32 -0
  245. reflex/utils/exec.py +0 -14
  246. reflex/utils/format.py +80 -209
  247. reflex/utils/imports.py +16 -73
  248. reflex/utils/net.py +43 -0
  249. reflex/utils/path_ops.py +13 -1
  250. reflex/utils/prerequisites.py +81 -41
  251. reflex/utils/pyi_generator.py +12 -6
  252. reflex/utils/serializers.py +13 -41
  253. reflex/utils/telemetry.py +3 -2
  254. reflex/utils/types.py +47 -7
  255. reflex/{experimental/vars → vars}/__init__.py +6 -3
  256. reflex/vars/base.py +2563 -0
  257. reflex/vars/function.py +196 -0
  258. reflex/vars/number.py +1158 -0
  259. reflex/vars/object.py +562 -0
  260. reflex/vars/sequence.py +1604 -0
  261. {reflex-0.5.10a3.dist-info → reflex-0.6.0.dist-info}/METADATA +6 -9
  262. reflex-0.6.0.dist-info/RECORD +382 -0
  263. reflex/.templates/apps/demo/.gitignore +0 -4
  264. reflex/.templates/apps/demo/assets/favicon.ico +0 -0
  265. reflex/.templates/apps/demo/assets/github.svg +0 -10
  266. reflex/.templates/apps/demo/assets/icon.svg +0 -37
  267. reflex/.templates/apps/demo/assets/logo.svg +0 -68
  268. reflex/.templates/apps/demo/assets/paneleft.svg +0 -13
  269. reflex/.templates/apps/demo/code/__init__.py +0 -1
  270. reflex/.templates/apps/demo/code/demo.py +0 -127
  271. reflex/.templates/apps/demo/code/pages/__init__.py +0 -7
  272. reflex/.templates/apps/demo/code/pages/chatapp.py +0 -31
  273. reflex/.templates/apps/demo/code/pages/datatable.py +0 -360
  274. reflex/.templates/apps/demo/code/pages/forms.py +0 -257
  275. reflex/.templates/apps/demo/code/pages/graphing.py +0 -253
  276. reflex/.templates/apps/demo/code/pages/home.py +0 -56
  277. reflex/.templates/apps/demo/code/sidebar.py +0 -178
  278. reflex/.templates/apps/demo/code/state.py +0 -22
  279. reflex/.templates/apps/demo/code/states/form_state.py +0 -40
  280. reflex/.templates/apps/demo/code/states/pie_state.py +0 -47
  281. reflex/.templates/apps/demo/code/styles.py +0 -68
  282. reflex/.templates/apps/demo/code/webui/__init__.py +0 -0
  283. reflex/.templates/apps/demo/code/webui/components/__init__.py +0 -4
  284. reflex/.templates/apps/demo/code/webui/components/chat.py +0 -118
  285. reflex/.templates/apps/demo/code/webui/components/loading_icon.py +0 -19
  286. reflex/.templates/apps/demo/code/webui/components/modal.py +0 -56
  287. reflex/.templates/apps/demo/code/webui/components/navbar.py +0 -70
  288. reflex/.templates/apps/demo/code/webui/components/sidebar.py +0 -66
  289. reflex/.templates/apps/demo/code/webui/state.py +0 -146
  290. reflex/.templates/apps/demo/code/webui/styles.py +0 -88
  291. reflex/.templates/web/components/reflex/chakra_color_mode_provider.js +0 -36
  292. reflex/experimental/vars/base.py +0 -583
  293. reflex/experimental/vars/function.py +0 -290
  294. reflex/experimental/vars/number.py +0 -1458
  295. reflex/experimental/vars/object.py +0 -804
  296. reflex/experimental/vars/sequence.py +0 -1764
  297. reflex/utils/watch.py +0 -96
  298. reflex/vars.py +0 -2604
  299. reflex/vars.pyi +0 -218
  300. reflex-0.5.10a3.dist-info/RECORD +0 -413
  301. {reflex-0.5.10a3.dist-info → reflex-0.6.0.dist-info}/LICENSE +0 -0
  302. {reflex-0.5.10a3.dist-info → reflex-0.6.0.dist-info}/WHEEL +0 -0
  303. {reflex-0.5.10a3.dist-info → reflex-0.6.0.dist-info}/entry_points.txt +0 -0
@@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Optional, Union, overload
8
8
  from reflex.components.el.elements.typography import Div
9
9
  from reflex.event import EventHandler, EventSpec
10
10
  from reflex.style import Style
11
- from reflex.vars import BaseVar, Var
11
+ from reflex.vars.base import Var
12
12
 
13
13
  class Html(Div):
14
14
  @overload
@@ -17,82 +17,72 @@ class Html(Div):
17
17
  cls,
18
18
  *children,
19
19
  dangerouslySetInnerHTML: Optional[
20
- Union[Var[Dict[str, str]], Dict[str, str]]
20
+ Union[Dict[str, str], Var[Dict[str, str]]]
21
21
  ] = None,
22
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
22
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
23
23
  auto_capitalize: Optional[
24
- Union[Var[Union[bool, int, str]], str, int, bool]
24
+ Union[Var[Union[bool, int, str]], bool, int, str]
25
25
  ] = None,
26
26
  content_editable: Optional[
27
- Union[Var[Union[bool, int, str]], str, int, bool]
27
+ Union[Var[Union[bool, int, str]], bool, int, str]
28
28
  ] = None,
29
29
  context_menu: Optional[
30
- Union[Var[Union[bool, int, str]], str, int, bool]
30
+ Union[Var[Union[bool, int, str]], bool, int, str]
31
31
  ] = None,
32
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
33
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
32
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
33
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
34
34
  enter_key_hint: Optional[
35
- Union[Var[Union[bool, int, str]], str, int, bool]
36
- ] = None,
37
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
38
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
39
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
40
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
41
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
42
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
43
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
44
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
45
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
35
+ Union[Var[Union[bool, int, str]], bool, int, str]
36
+ ] = None,
37
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
38
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
39
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
40
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
41
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
42
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
43
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
44
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
45
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
46
46
  style: Optional[Style] = None,
47
47
  key: Optional[Any] = None,
48
48
  id: Optional[Any] = None,
49
49
  class_name: Optional[Any] = None,
50
50
  autofocus: Optional[bool] = None,
51
51
  custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
52
- on_blur: Optional[
53
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
54
- ] = None,
55
- on_click: Optional[
56
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
57
- ] = None,
52
+ on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
53
+ on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
58
54
  on_context_menu: Optional[
59
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
55
+ Union[EventHandler, EventSpec, list, Callable, Var]
60
56
  ] = None,
61
57
  on_double_click: Optional[
62
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
63
- ] = None,
64
- on_focus: Optional[
65
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
66
- ] = None,
67
- on_mount: Optional[
68
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
58
+ Union[EventHandler, EventSpec, list, Callable, Var]
69
59
  ] = None,
60
+ on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
61
+ on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
70
62
  on_mouse_down: Optional[
71
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
63
+ Union[EventHandler, EventSpec, list, Callable, Var]
72
64
  ] = None,
73
65
  on_mouse_enter: Optional[
74
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
66
+ Union[EventHandler, EventSpec, list, Callable, Var]
75
67
  ] = None,
76
68
  on_mouse_leave: Optional[
77
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
69
+ Union[EventHandler, EventSpec, list, Callable, Var]
78
70
  ] = None,
79
71
  on_mouse_move: Optional[
80
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
72
+ Union[EventHandler, EventSpec, list, Callable, Var]
81
73
  ] = None,
82
74
  on_mouse_out: Optional[
83
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
75
+ Union[EventHandler, EventSpec, list, Callable, Var]
84
76
  ] = None,
85
77
  on_mouse_over: Optional[
86
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
78
+ Union[EventHandler, EventSpec, list, Callable, Var]
87
79
  ] = None,
88
80
  on_mouse_up: Optional[
89
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
90
- ] = None,
91
- on_scroll: Optional[
92
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
81
+ Union[EventHandler, EventSpec, list, Callable, Var]
93
82
  ] = None,
83
+ on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
94
84
  on_unmount: Optional[
95
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
85
+ Union[EventHandler, EventSpec, list, Callable, Var]
96
86
  ] = None,
97
87
  **props,
98
88
  ) -> "Html":
@@ -5,13 +5,13 @@ from typing import Any, Dict, List, Optional, Tuple, Union
5
5
 
6
6
  from reflex.components.base import Fragment
7
7
  from reflex.components.component import BaseComponent, Component, MemoizationLeaf
8
- from reflex.components.core.colors import Color
9
8
  from reflex.components.tags import MatchTag, Tag
10
9
  from reflex.style import Style
11
10
  from reflex.utils import format, types
12
11
  from reflex.utils.exceptions import MatchTypeError
13
12
  from reflex.utils.imports import ImportDict
14
- from reflex.vars import BaseVar, Var, VarData
13
+ from reflex.vars import VarData
14
+ from reflex.vars.base import LiteralVar, Var
15
15
 
16
16
 
17
17
  class Match(MemoizationLeaf):
@@ -27,7 +27,7 @@ class Match(MemoizationLeaf):
27
27
  default: Any
28
28
 
29
29
  @classmethod
30
- def create(cls, cond: Any, *cases) -> Union[Component, BaseVar]:
30
+ def create(cls, cond: Any, *cases) -> Union[Component, Var]:
31
31
  """Create a Match Component.
32
32
 
33
33
  Args:
@@ -46,7 +46,7 @@ class Match(MemoizationLeaf):
46
46
 
47
47
  cls._validate_return_types(match_cases)
48
48
 
49
- if default is None and types._issubclass(type(match_cases[0][-1]), BaseVar):
49
+ if default is None and types._issubclass(type(match_cases[0][-1]), Var):
50
50
  raise ValueError(
51
51
  "For cases with return types as Vars, a default case must be provided"
52
52
  )
@@ -56,7 +56,7 @@ class Match(MemoizationLeaf):
56
56
  )
57
57
 
58
58
  @classmethod
59
- def _create_condition_var(cls, cond: Any) -> BaseVar:
59
+ def _create_condition_var(cls, cond: Any) -> Var:
60
60
  """Convert the condition to a Var.
61
61
 
62
62
  Args:
@@ -68,16 +68,16 @@ class Match(MemoizationLeaf):
68
68
  Raises:
69
69
  ValueError: If the condition is not provided.
70
70
  """
71
- match_cond_var = Var.create(cond, _var_is_string=isinstance(cond, str))
71
+ match_cond_var = LiteralVar.create(cond)
72
72
 
73
73
  if match_cond_var is None:
74
74
  raise ValueError("The condition must be set")
75
- return match_cond_var # type: ignore
75
+ return match_cond_var
76
76
 
77
77
  @classmethod
78
78
  def _process_cases(
79
79
  cls, cases: List
80
- ) -> Tuple[List, Optional[Union[BaseVar, BaseComponent]]]:
80
+ ) -> Tuple[List, Optional[Union[Var, BaseComponent]]]:
81
81
  """Process the list of match cases and the catchall default case.
82
82
 
83
83
  Args:
@@ -94,6 +94,9 @@ class Match(MemoizationLeaf):
94
94
  if len([case for case in cases if not isinstance(case, tuple)]) > 1:
95
95
  raise ValueError("rx.match can only have one default case.")
96
96
 
97
+ if not cases:
98
+ raise ValueError("rx.match should have at least one case.")
99
+
97
100
  # Get the default case which should be the last non-tuple arg
98
101
  if not isinstance(cases[-1], tuple):
99
102
  default = cases.pop()
@@ -103,7 +106,7 @@ class Match(MemoizationLeaf):
103
106
  else default
104
107
  )
105
108
 
106
- return cases, default # type: ignore
109
+ return cases, default
107
110
 
108
111
  @classmethod
109
112
  def _create_case_var_with_var_data(cls, case_element):
@@ -117,17 +120,12 @@ class Match(MemoizationLeaf):
117
120
  Returns:
118
121
  The case element Var.
119
122
  """
120
- _var_data = case_element._var_data if isinstance(case_element, Style) else None # type: ignore
121
- case_element = Var.create(
122
- case_element,
123
- _var_is_string=isinstance(case_element, (str, Color)),
124
- )
125
- if _var_data is not None:
126
- case_element._var_data = VarData.merge(case_element._var_data, _var_data) # type: ignore
123
+ _var_data = case_element._var_data if isinstance(case_element, Style) else None
124
+ case_element = LiteralVar.create(case_element, _var_data=_var_data)
127
125
  return case_element
128
126
 
129
127
  @classmethod
130
- def _process_match_cases(cls, cases: List) -> List[List[BaseVar]]:
128
+ def _process_match_cases(cls, cases: List) -> List[List[Var]]:
131
129
  """Process the individual match cases.
132
130
 
133
131
  Args:
@@ -159,7 +157,7 @@ class Match(MemoizationLeaf):
159
157
  if not isinstance(element, BaseComponent)
160
158
  else element
161
159
  )
162
- if not isinstance(el, (BaseVar, BaseComponent)):
160
+ if not isinstance(el, (Var, BaseComponent)):
163
161
  raise ValueError("Case element must be a var or component")
164
162
  case_list.append(el)
165
163
 
@@ -168,7 +166,7 @@ class Match(MemoizationLeaf):
168
166
  return match_cases
169
167
 
170
168
  @classmethod
171
- def _validate_return_types(cls, match_cases: List[List[BaseVar]]) -> None:
169
+ def _validate_return_types(cls, match_cases: List[List[Var]]) -> None:
172
170
  """Validate that match cases have the same return types.
173
171
 
174
172
  Args:
@@ -182,14 +180,14 @@ class Match(MemoizationLeaf):
182
180
 
183
181
  if types._isinstance(first_case_return, BaseComponent):
184
182
  return_type = BaseComponent
185
- elif types._isinstance(first_case_return, BaseVar):
186
- return_type = BaseVar
183
+ elif types._isinstance(first_case_return, Var):
184
+ return_type = Var
187
185
 
188
186
  for index, case in enumerate(match_cases):
189
187
  if not types._issubclass(type(case[-1]), return_type):
190
188
  raise MatchTypeError(
191
189
  f"Match cases should have the same return types. Case {index} with return "
192
- f"value `{case[-1]._var_name if isinstance(case[-1], BaseVar) else textwrap.shorten(str(case[-1]), width=250)}`"
190
+ f"value `{case[-1]._js_expr if isinstance(case[-1], Var) else textwrap.shorten(str(case[-1]), width=250)}`"
193
191
  f" of type {type(case[-1])!r} is not {return_type}"
194
192
  )
195
193
 
@@ -197,9 +195,9 @@ class Match(MemoizationLeaf):
197
195
  def _create_match_cond_var_or_component(
198
196
  cls,
199
197
  match_cond_var: Var,
200
- match_cases: List[List[BaseVar]],
201
- default: Optional[Union[BaseVar, BaseComponent]],
202
- ) -> Union[Component, BaseVar]:
198
+ match_cases: List[List[Var]],
199
+ default: Optional[Union[Var, BaseComponent]],
200
+ ) -> Union[Component, Var]:
203
201
  """Create and return the match condition var or component.
204
202
 
205
203
  Args:
@@ -230,28 +228,22 @@ class Match(MemoizationLeaf):
230
228
 
231
229
  # Validate the match cases (as well as the default case) to have Var return types.
232
230
  if any(
233
- case for case in match_cases if not types._isinstance(case[-1], BaseVar)
234
- ) or not types._isinstance(default, BaseVar):
231
+ case for case in match_cases if not types._isinstance(case[-1], Var)
232
+ ) or not types._isinstance(default, Var):
235
233
  raise ValueError("Return types of match cases should be Vars.")
236
234
 
237
- # match cases and default should all be Vars at this point.
238
- # Retrieve var data of every var in the match cases and default.
239
- var_data = [
240
- *[el._var_data for case in match_cases for el in case],
241
- default._var_data, # type: ignore
242
- ]
243
-
244
- return match_cond_var._replace(
245
- _var_name=format.format_match(
246
- cond=match_cond_var._var_name_unwrapped,
247
- match_cases=match_cases, # type: ignore
235
+ return Var(
236
+ _js_expr=format.format_match(
237
+ cond=str(match_cond_var),
238
+ match_cases=match_cases,
248
239
  default=default, # type: ignore
249
240
  ),
250
241
  _var_type=default._var_type, # type: ignore
251
- _var_is_local=False,
252
- _var_full_name_needs_state_prefix=False,
253
- _var_is_string=False,
254
- merge_var_data=VarData.merge(*var_data),
242
+ _var_data=VarData.merge(
243
+ match_cond_var._get_all_var_data(),
244
+ *[el._get_all_var_data() for case in match_cases for el in case],
245
+ default._get_all_var_data(), # type: ignore
246
+ ),
255
247
  )
256
248
 
257
249
  def _render(self) -> Tag:
@@ -275,7 +267,8 @@ class Match(MemoizationLeaf):
275
267
  Returns:
276
268
  The import dict.
277
269
  """
278
- return getattr(self.cond._var_data, "imports", {})
270
+ var_data = VarData.merge(self.cond._get_all_var_data())
271
+ return var_data.old_school_imports() if var_data else {}
279
272
 
280
273
 
281
274
  match = Match.create
@@ -20,7 +20,9 @@ from reflex.event import (
20
20
  parse_args_spec,
21
21
  )
22
22
  from reflex.utils.imports import ImportVar
23
- from reflex.vars import BaseVar, CallableVar, Var, VarData
23
+ from reflex.vars import VarData
24
+ from reflex.vars.base import CallableVar, LiteralVar, Var
25
+ from reflex.vars.sequence import LiteralStringVar
24
26
 
25
27
  DEFAULT_UPLOAD_ID: str = "default"
26
28
 
@@ -36,7 +38,7 @@ upload_files_context_var_data: VarData = VarData(
36
38
 
37
39
 
38
40
  @CallableVar
39
- def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar:
41
+ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
40
42
  """Get the file upload drop trigger.
41
43
 
42
44
  This var is passed to the dropzone component to update the file list when a
@@ -48,23 +50,25 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar:
48
50
  Returns:
49
51
  A var referencing the file upload drop trigger.
50
52
  """
51
- id_var = Var.create_safe(id_, _var_is_string=True)
53
+ id_var = LiteralStringVar.create(id_)
52
54
  var_name = f"""e => setFilesById(filesById => {{
53
55
  const updatedFilesById = Object.assign({{}}, filesById);
54
- updatedFilesById[{id_var._var_name_unwrapped}] = e;
56
+ updatedFilesById[{str(id_var)}] = e;
55
57
  return updatedFilesById;
56
58
  }})
57
59
  """
58
60
 
59
- return BaseVar(
60
- _var_name=var_name,
61
+ return Var(
62
+ _js_expr=var_name,
61
63
  _var_type=EventChain,
62
- _var_data=VarData.merge(upload_files_context_var_data, id_var._var_data),
64
+ _var_data=VarData.merge(
65
+ upload_files_context_var_data, id_var._get_all_var_data()
66
+ ),
63
67
  )
64
68
 
65
69
 
66
70
  @CallableVar
67
- def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar:
71
+ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var:
68
72
  """Get the list of selected files.
69
73
 
70
74
  Args:
@@ -73,12 +77,14 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar:
73
77
  Returns:
74
78
  A var referencing the list of selected file paths.
75
79
  """
76
- id_var = Var.create_safe(id_, _var_is_string=True)
77
- return BaseVar(
78
- _var_name=f"(filesById[{id_var._var_name_unwrapped}] ? filesById[{id_var._var_name_unwrapped}].map((f) => (f.path || f.name)) : [])",
80
+ id_var = LiteralStringVar.create(id_)
81
+ return Var(
82
+ _js_expr=f"(filesById[{str(id_var)}] ? filesById[{str(id_var)}].map((f) => (f.path || f.name)) : [])",
79
83
  _var_type=List[str],
80
- _var_data=VarData.merge(upload_files_context_var_data, id_var._var_data),
81
- )
84
+ _var_data=VarData.merge(
85
+ upload_files_context_var_data, id_var._get_all_var_data()
86
+ ),
87
+ ).guess_type()
82
88
 
83
89
 
84
90
  @CallableEventSpec
@@ -107,7 +113,7 @@ def cancel_upload(upload_id: str) -> EventSpec:
107
113
  An event spec that cancels the upload when triggered.
108
114
  """
109
115
  return call_script(
110
- f"upload_controllers[{Var.create_safe(upload_id, _var_is_string=True)._var_name_unwrapped}]?.abort()"
116
+ f"upload_controllers[{str(LiteralVar.create(upload_id))}]?.abort()"
111
117
  )
112
118
 
113
119
 
@@ -126,16 +132,15 @@ def get_upload_dir() -> Path:
126
132
  return uploaded_files_dir
127
133
 
128
134
 
129
- uploaded_files_url_prefix: Var = Var.create_safe(
130
- "${getBackendURL(env.UPLOAD)}",
131
- _var_is_string=False,
135
+ uploaded_files_url_prefix = Var(
136
+ _js_expr="getBackendURL(env.UPLOAD)",
132
137
  _var_data=VarData(
133
138
  imports={
134
139
  f"/{Dirs.STATE_PATH}": "getBackendURL",
135
140
  "/env.json": ImportVar(tag="env", is_default=True),
136
141
  }
137
142
  ),
138
- )
143
+ ).to(str)
139
144
 
140
145
 
141
146
  def get_upload_url(file_path: str) -> Var[str]:
@@ -149,9 +154,7 @@ def get_upload_url(file_path: str) -> Var[str]:
149
154
  """
150
155
  Upload.is_used = True
151
156
 
152
- return Var.create_safe(
153
- f"{uploaded_files_url_prefix}/{file_path}", _var_is_string=True
154
- )
157
+ return uploaded_files_url_prefix + "/" + file_path
155
158
 
156
159
 
157
160
  def _on_drop_spec(files: Var):
@@ -244,9 +247,7 @@ class Upload(MemoizationLeaf):
244
247
  }
245
248
  # The file input to use.
246
249
  upload = Input.create(type="file")
247
- upload.special_props = {
248
- BaseVar(_var_name="{...getInputProps()}", _var_type=None)
249
- }
250
+ upload.special_props = [Var(_js_expr="{...getInputProps()}", _var_type=None)]
250
251
 
251
252
  # The dropzone to use.
252
253
  zone = Box.create(
@@ -254,7 +255,7 @@ class Upload(MemoizationLeaf):
254
255
  *children,
255
256
  **{k: v for k, v in props.items() if k not in supported_props},
256
257
  )
257
- zone.special_props = {BaseVar(_var_name="{...getRootProps()}", _var_type=None)}
258
+ zone.special_props = [Var(_js_expr="{...getRootProps()}", _var_type=None)]
258
259
 
259
260
  # Create the component.
260
261
  upload_props["id"] = props.get("id", DEFAULT_UPLOAD_ID)
@@ -291,7 +292,7 @@ class Upload(MemoizationLeaf):
291
292
  Returns:
292
293
  The updated arg_value tuple when arg is "files", otherwise the original arg_value.
293
294
  """
294
- if arg_value[0]._var_name == "files":
295
+ if arg_value[0]._js_expr == "files":
295
296
  placeholder = parse_args_spec(_on_drop_spec)[0]
296
297
  return (arg_value[0], placeholder)
297
298
  return arg_value