reflex 0.6.8a2__py3-none-any.whl → 0.7.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 (247) hide show
  1. reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +1 -1
  2. reflex/.templates/jinja/web/pages/_app.js.jinja2 +7 -7
  3. reflex/.templates/jinja/web/pages/utils.js.jinja2 +3 -3
  4. reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +1 -4
  5. reflex/.templates/web/utils/state.js +65 -36
  6. reflex/__init__.py +4 -17
  7. reflex/__init__.pyi +1 -2
  8. reflex/app.py +286 -129
  9. reflex/app_mixins/lifespan.py +9 -9
  10. reflex/app_mixins/middleware.py +6 -6
  11. reflex/app_module_for_backend.py +3 -7
  12. reflex/base.py +7 -7
  13. reflex/compiler/compiler.py +8 -0
  14. reflex/compiler/utils.py +57 -18
  15. reflex/components/base/app_wrap.pyi +16 -16
  16. reflex/components/base/bare.py +1 -1
  17. reflex/components/base/body.pyi +16 -16
  18. reflex/components/base/document.pyi +76 -76
  19. reflex/components/base/error_boundary.py +2 -1
  20. reflex/components/base/error_boundary.pyi +19 -22
  21. reflex/components/base/fragment.pyi +16 -16
  22. reflex/components/base/head.pyi +31 -31
  23. reflex/components/base/link.pyi +31 -31
  24. reflex/components/base/meta.py +2 -2
  25. reflex/components/base/meta.pyi +61 -61
  26. reflex/components/base/script.pyi +19 -19
  27. reflex/components/base/strict_mode.py +10 -0
  28. reflex/components/base/strict_mode.pyi +57 -0
  29. reflex/components/component.py +38 -77
  30. reflex/components/core/banner.py +159 -4
  31. reflex/components/core/banner.pyi +162 -76
  32. reflex/components/core/breakpoints.py +3 -1
  33. reflex/components/core/client_side_routing.py +1 -1
  34. reflex/components/core/client_side_routing.pyi +32 -32
  35. reflex/components/core/clipboard.pyi +17 -20
  36. reflex/components/core/cond.py +9 -10
  37. reflex/components/core/debounce.py +1 -1
  38. reflex/components/core/debounce.pyi +17 -17
  39. reflex/components/core/foreach.py +28 -3
  40. reflex/components/core/html.py +1 -1
  41. reflex/components/core/html.pyi +16 -16
  42. reflex/components/core/match.py +5 -5
  43. reflex/components/core/sticky.py +134 -0
  44. reflex/components/core/sticky.pyi +449 -0
  45. reflex/components/core/upload.py +2 -2
  46. reflex/components/core/upload.pyi +80 -88
  47. reflex/components/datadisplay/code.py +5 -14
  48. reflex/components/datadisplay/code.pyi +31 -31
  49. reflex/components/datadisplay/dataeditor.py +7 -4
  50. reflex/components/datadisplay/dataeditor.pyi +40 -54
  51. reflex/components/datadisplay/logo.py +13 -8
  52. reflex/components/datadisplay/shiki_code_block.py +14 -9
  53. reflex/components/datadisplay/shiki_code_block.pyi +46 -46
  54. reflex/components/dynamic.py +22 -3
  55. reflex/components/el/constants/reflex.py +1 -1
  56. reflex/components/el/element.py +1 -1
  57. reflex/components/el/element.pyi +16 -16
  58. reflex/components/el/elements/base.pyi +16 -16
  59. reflex/components/el/elements/forms.py +4 -4
  60. reflex/components/el/elements/forms.pyi +224 -258
  61. reflex/components/el/elements/inline.pyi +421 -421
  62. reflex/components/el/elements/media.pyi +376 -376
  63. reflex/components/el/elements/metadata.pyi +91 -91
  64. reflex/components/el/elements/other.pyi +106 -106
  65. reflex/components/el/elements/scripts.pyi +46 -46
  66. reflex/components/el/elements/sectioning.pyi +226 -226
  67. reflex/components/el/elements/tables.pyi +151 -151
  68. reflex/components/el/elements/typography.pyi +226 -226
  69. reflex/components/gridjs/datatable.pyi +31 -31
  70. reflex/components/lucide/icon.py +46 -8
  71. reflex/components/lucide/icon.pyi +85 -31
  72. reflex/components/markdown/markdown.py +10 -8
  73. reflex/components/markdown/markdown.pyi +16 -16
  74. reflex/components/moment/moment.py +2 -2
  75. reflex/components/moment/moment.pyi +17 -19
  76. reflex/components/next/base.pyi +16 -16
  77. reflex/components/next/image.py +16 -4
  78. reflex/components/next/image.pyi +22 -20
  79. reflex/components/next/link.py +1 -1
  80. reflex/components/next/link.pyi +16 -16
  81. reflex/components/next/video.pyi +16 -16
  82. reflex/components/plotly/__init__.py +29 -2
  83. reflex/components/plotly/plotly.py +240 -5
  84. reflex/components/plotly/plotly.pyi +799 -44
  85. reflex/components/props.py +3 -3
  86. reflex/components/radix/__init__.pyi +1 -1
  87. reflex/components/radix/primitives/accordion.py +9 -5
  88. reflex/components/radix/primitives/accordion.pyi +110 -108
  89. reflex/components/radix/primitives/base.pyi +31 -31
  90. reflex/components/radix/primitives/drawer.py +5 -2
  91. reflex/components/radix/primitives/drawer.pyi +179 -187
  92. reflex/components/radix/primitives/form.pyi +160 -172
  93. reflex/components/radix/primitives/progress.py +1 -1
  94. reflex/components/radix/primitives/progress.pyi +76 -76
  95. reflex/components/radix/primitives/slider.py +1 -1
  96. reflex/components/radix/primitives/slider.pyi +78 -82
  97. reflex/components/radix/themes/base.pyi +121 -121
  98. reflex/components/radix/themes/color_mode.py +11 -9
  99. reflex/components/radix/themes/color_mode.pyi +47 -49
  100. reflex/components/radix/themes/components/alert_dialog.py +3 -0
  101. reflex/components/radix/themes/components/alert_dialog.pyi +110 -112
  102. reflex/components/radix/themes/components/aspect_ratio.pyi +16 -16
  103. reflex/components/radix/themes/components/avatar.pyi +16 -16
  104. reflex/components/radix/themes/components/badge.pyi +16 -16
  105. reflex/components/radix/themes/components/button.pyi +16 -16
  106. reflex/components/radix/themes/components/callout.pyi +76 -76
  107. reflex/components/radix/themes/components/card.py +1 -1
  108. reflex/components/radix/themes/components/card.pyi +17 -17
  109. reflex/components/radix/themes/components/checkbox.pyi +49 -55
  110. reflex/components/radix/themes/components/checkbox_cards.pyi +31 -31
  111. reflex/components/radix/themes/components/checkbox_group.pyi +31 -31
  112. reflex/components/radix/themes/components/context_menu.py +5 -0
  113. reflex/components/radix/themes/components/context_menu.pyi +149 -155
  114. reflex/components/radix/themes/components/data_list.pyi +61 -61
  115. reflex/components/radix/themes/components/dialog.py +3 -0
  116. reflex/components/radix/themes/components/dialog.pyi +113 -117
  117. reflex/components/radix/themes/components/dropdown_menu.py +5 -0
  118. reflex/components/radix/themes/components/dropdown_menu.pyi +133 -137
  119. reflex/components/radix/themes/components/hover_card.py +3 -0
  120. reflex/components/radix/themes/components/hover_card.pyi +63 -67
  121. reflex/components/radix/themes/components/icon_button.py +2 -2
  122. reflex/components/radix/themes/components/icon_button.pyi +17 -16
  123. reflex/components/radix/themes/components/inset.pyi +16 -16
  124. reflex/components/radix/themes/components/popover.py +3 -0
  125. reflex/components/radix/themes/components/popover.pyi +68 -70
  126. reflex/components/radix/themes/components/progress.pyi +16 -16
  127. reflex/components/radix/themes/components/radio.pyi +16 -16
  128. reflex/components/radix/themes/components/radio_cards.py +2 -0
  129. reflex/components/radix/themes/components/radio_cards.pyi +32 -34
  130. reflex/components/radix/themes/components/radio_group.py +1 -1
  131. reflex/components/radix/themes/components/radio_group.pyi +62 -64
  132. reflex/components/radix/themes/components/scroll_area.pyi +16 -16
  133. reflex/components/radix/themes/components/segmented_control.pyi +32 -35
  134. reflex/components/radix/themes/components/select.py +4 -0
  135. reflex/components/radix/themes/components/select.pyi +145 -157
  136. reflex/components/radix/themes/components/separator.pyi +16 -16
  137. reflex/components/radix/themes/components/skeleton.py +3 -0
  138. reflex/components/radix/themes/components/skeleton.pyi +16 -16
  139. reflex/components/radix/themes/components/slider.pyi +22 -28
  140. reflex/components/radix/themes/components/spinner.pyi +16 -16
  141. reflex/components/radix/themes/components/switch.pyi +17 -19
  142. reflex/components/radix/themes/components/table.pyi +106 -106
  143. reflex/components/radix/themes/components/tabs.py +3 -0
  144. reflex/components/radix/themes/components/tabs.pyi +78 -82
  145. reflex/components/radix/themes/components/text_area.py +12 -0
  146. reflex/components/radix/themes/components/text_area.pyi +21 -33
  147. reflex/components/radix/themes/components/text_field.py +1 -1
  148. reflex/components/radix/themes/components/text_field.pyi +52 -80
  149. reflex/components/radix/themes/components/tooltip.py +6 -1
  150. reflex/components/radix/themes/components/tooltip.pyi +20 -21
  151. reflex/components/radix/themes/layout/__init__.pyi +1 -1
  152. reflex/components/radix/themes/layout/base.pyi +16 -16
  153. reflex/components/radix/themes/layout/box.pyi +16 -16
  154. reflex/components/radix/themes/layout/center.pyi +16 -16
  155. reflex/components/radix/themes/layout/container.pyi +16 -16
  156. reflex/components/radix/themes/layout/flex.pyi +16 -16
  157. reflex/components/radix/themes/layout/grid.pyi +16 -16
  158. reflex/components/radix/themes/layout/list.py +2 -2
  159. reflex/components/radix/themes/layout/list.pyi +76 -76
  160. reflex/components/radix/themes/layout/section.pyi +16 -16
  161. reflex/components/radix/themes/layout/spacer.pyi +16 -16
  162. reflex/components/radix/themes/layout/stack.py +2 -2
  163. reflex/components/radix/themes/layout/stack.pyi +46 -46
  164. reflex/components/radix/themes/typography/blockquote.pyi +16 -16
  165. reflex/components/radix/themes/typography/code.pyi +16 -16
  166. reflex/components/radix/themes/typography/heading.pyi +16 -16
  167. reflex/components/radix/themes/typography/link.py +1 -1
  168. reflex/components/radix/themes/typography/link.pyi +16 -16
  169. reflex/components/radix/themes/typography/text.py +2 -2
  170. reflex/components/radix/themes/typography/text.pyi +106 -106
  171. reflex/components/react_player/audio.pyi +33 -39
  172. reflex/components/react_player/react_player.py +1 -1
  173. reflex/components/react_player/react_player.pyi +32 -38
  174. reflex/components/react_player/video.pyi +33 -39
  175. reflex/components/recharts/__init__.py +2 -0
  176. reflex/components/recharts/__init__.pyi +2 -0
  177. reflex/components/recharts/cartesian.pyi +282 -282
  178. reflex/components/recharts/charts.py +15 -15
  179. reflex/components/recharts/charts.pyi +164 -164
  180. reflex/components/recharts/general.py +19 -4
  181. reflex/components/recharts/general.pyi +132 -81
  182. reflex/components/recharts/polar.py +2 -2
  183. reflex/components/recharts/polar.pyi +55 -55
  184. reflex/components/recharts/recharts.py +4 -4
  185. reflex/components/recharts/recharts.pyi +31 -31
  186. reflex/components/sonner/toast.py +15 -13
  187. reflex/components/sonner/toast.pyi +22 -22
  188. reflex/components/suneditor/editor.py +6 -4
  189. reflex/components/suneditor/editor.pyi +26 -40
  190. reflex/components/tags/iter_tag.py +3 -3
  191. reflex/components/tags/tag.py +25 -3
  192. reflex/config.py +48 -15
  193. reflex/constants/__init__.py +1 -0
  194. reflex/constants/base.py +4 -1
  195. reflex/constants/compiler.py +5 -2
  196. reflex/constants/config.py +8 -1
  197. reflex/constants/installer.py +9 -9
  198. reflex/constants/style.py +1 -1
  199. reflex/custom_components/custom_components.py +18 -10
  200. reflex/event.py +221 -231
  201. reflex/experimental/__init__.py +19 -11
  202. reflex/experimental/client_state.py +53 -28
  203. reflex/experimental/hooks.py +5 -5
  204. reflex/experimental/layout.py +8 -5
  205. reflex/experimental/layout.pyi +79 -83
  206. reflex/experimental/misc.py +3 -3
  207. reflex/istate/wrappers.py +1 -1
  208. reflex/middleware/hydrate_middleware.py +2 -2
  209. reflex/model.py +11 -6
  210. reflex/page.py +5 -5
  211. reflex/reflex.py +104 -26
  212. reflex/route.py +1 -1
  213. reflex/state.py +358 -401
  214. reflex/style.py +27 -3
  215. reflex/testing.py +29 -23
  216. reflex/utils/build.py +6 -2
  217. reflex/utils/codespaces.py +1 -4
  218. reflex/utils/compat.py +6 -5
  219. reflex/utils/console.py +71 -16
  220. reflex/utils/exceptions.py +89 -26
  221. reflex/utils/exec.py +69 -74
  222. reflex/utils/export.py +6 -1
  223. reflex/utils/format.py +8 -40
  224. reflex/utils/imports.py +5 -2
  225. reflex/utils/lazy_loader.py +7 -1
  226. reflex/utils/path_ops.py +74 -14
  227. reflex/utils/prerequisites.py +345 -68
  228. reflex/utils/processes.py +45 -32
  229. reflex/utils/pyi_generator.py +39 -33
  230. reflex/utils/registry.py +4 -4
  231. reflex/utils/serializers.py +1 -1
  232. reflex/utils/telemetry.py +5 -4
  233. reflex/utils/types.py +42 -18
  234. reflex/vars/base.py +695 -330
  235. reflex/vars/datetime.py +6 -7
  236. reflex/vars/dep_tracking.py +344 -0
  237. reflex/vars/function.py +11 -5
  238. reflex/vars/number.py +31 -43
  239. reflex/vars/object.py +74 -64
  240. reflex/vars/sequence.py +79 -67
  241. {reflex-0.6.8a2.dist-info → reflex-0.7.0.dist-info}/METADATA +7 -8
  242. reflex-0.7.0.dist-info/RECORD +401 -0
  243. {reflex-0.6.8a2.dist-info → reflex-0.7.0.dist-info}/WHEEL +1 -1
  244. reflex/experimental/assets.py +0 -37
  245. reflex-0.6.8a2.dist-info/RECORD +0 -397
  246. {reflex-0.6.8a2.dist-info → reflex-0.7.0.dist-info}/LICENSE +0 -0
  247. {reflex-0.6.8a2.dist-info → reflex-0.7.0.dist-info}/entry_points.txt +0 -0
@@ -5,12 +5,14 @@
5
5
  # ------------------------------------------------------
6
6
  from typing import Any, Dict, Literal, Optional, Union, overload
7
7
 
8
- from reflex.event import BASE_STATE, EventType
8
+ from reflex.event import EventType
9
9
  from reflex.style import Style
10
10
  from reflex.vars.base import Var
11
11
 
12
12
  from .base import NextComponent
13
13
 
14
+ DEFAULT_W_H = "100%"
15
+
14
16
  class Image(NextComponent):
15
17
  @overload
16
18
  @classmethod
@@ -30,30 +32,30 @@ class Image(NextComponent):
30
32
  loading: Optional[
31
33
  Union[Literal["eager", "lazy"], Var[Literal["eager", "lazy"]]]
32
34
  ] = None,
33
- blurDataURL: Optional[Union[Var[str], str]] = None,
35
+ blur_data_url: Optional[Union[Var[str], str]] = None,
34
36
  style: Optional[Style] = None,
35
37
  key: Optional[Any] = None,
36
38
  id: Optional[Any] = None,
37
39
  class_name: Optional[Any] = None,
38
40
  autofocus: Optional[bool] = None,
39
41
  custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
40
- on_blur: Optional[EventType[[], BASE_STATE]] = None,
41
- on_click: Optional[EventType[[], BASE_STATE]] = None,
42
- on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
43
- on_double_click: Optional[EventType[[], BASE_STATE]] = None,
44
- on_error: Optional[EventType[[], BASE_STATE]] = None,
45
- on_focus: Optional[EventType[[], BASE_STATE]] = None,
46
- on_load: Optional[EventType[[], BASE_STATE]] = None,
47
- on_mount: Optional[EventType[[], BASE_STATE]] = None,
48
- on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
49
- on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
50
- on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
51
- on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
52
- on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
53
- on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
54
- on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
55
- on_scroll: Optional[EventType[[], BASE_STATE]] = None,
56
- on_unmount: Optional[EventType[[], BASE_STATE]] = None,
42
+ on_blur: Optional[EventType[()]] = None,
43
+ on_click: Optional[EventType[()]] = None,
44
+ on_context_menu: Optional[EventType[()]] = None,
45
+ on_double_click: Optional[EventType[()]] = None,
46
+ on_error: Optional[EventType[()]] = None,
47
+ on_focus: Optional[EventType[()]] = None,
48
+ on_load: Optional[EventType[()]] = None,
49
+ on_mount: Optional[EventType[()]] = None,
50
+ on_mouse_down: Optional[EventType[()]] = None,
51
+ on_mouse_enter: Optional[EventType[()]] = None,
52
+ on_mouse_leave: Optional[EventType[()]] = None,
53
+ on_mouse_move: Optional[EventType[()]] = None,
54
+ on_mouse_out: Optional[EventType[()]] = None,
55
+ on_mouse_over: Optional[EventType[()]] = None,
56
+ on_mouse_up: Optional[EventType[()]] = None,
57
+ on_scroll: Optional[EventType[()]] = None,
58
+ on_unmount: Optional[EventType[()]] = None,
57
59
  **props,
58
60
  ) -> "Image":
59
61
  """Create an Image component from next/image.
@@ -71,7 +73,7 @@ class Image(NextComponent):
71
73
  priority: When true, the image will be considered high priority and preload. Lazy loading is automatically disabled for images using priority.
72
74
  placeholder: A placeholder to use while the image is loading. Possible values are blur, empty, or data:image/.... Defaults to empty.
73
75
  loading: The loading behavior of the image. Defaults to lazy. Can hurt performance, recommended to use `priority` instead.
74
- blurDataURL: A Data URL to be used as a placeholder image before the src image successfully loads. Only takes effect when combined with placeholder="blur".
76
+ blur_data_url: A Data URL to be used as a placeholder image before the src image successfully loads. Only takes effect when combined with placeholder="blur".
75
77
  on_load: Fires when the image has loaded.
76
78
  on_error: Fires when the image has an error.
77
79
  style: The style of the component.
@@ -17,4 +17,4 @@ class NextLink(Component):
17
17
  href: Var[str]
18
18
 
19
19
  # Whether to pass the href prop to the child.
20
- pass_href: Var[bool] = True # type: ignore
20
+ pass_href: Var[bool] = Var.create(True)
@@ -6,7 +6,7 @@
6
6
  from typing import Any, Dict, Optional, Union, overload
7
7
 
8
8
  from reflex.components.component import Component
9
- from reflex.event import BASE_STATE, EventType
9
+ from reflex.event import EventType
10
10
  from reflex.style import Style
11
11
  from reflex.vars.base import Var
12
12
 
@@ -24,21 +24,21 @@ class NextLink(Component):
24
24
  class_name: Optional[Any] = None,
25
25
  autofocus: Optional[bool] = None,
26
26
  custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
27
- on_blur: Optional[EventType[[], BASE_STATE]] = None,
28
- on_click: Optional[EventType[[], BASE_STATE]] = None,
29
- on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
30
- on_double_click: Optional[EventType[[], BASE_STATE]] = None,
31
- on_focus: Optional[EventType[[], BASE_STATE]] = None,
32
- on_mount: Optional[EventType[[], BASE_STATE]] = None,
33
- on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
34
- on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
35
- on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
36
- on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
37
- on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
38
- on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
39
- on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
40
- on_scroll: Optional[EventType[[], BASE_STATE]] = None,
41
- on_unmount: Optional[EventType[[], BASE_STATE]] = None,
27
+ on_blur: Optional[EventType[()]] = None,
28
+ on_click: Optional[EventType[()]] = None,
29
+ on_context_menu: Optional[EventType[()]] = None,
30
+ on_double_click: Optional[EventType[()]] = None,
31
+ on_focus: Optional[EventType[()]] = None,
32
+ on_mount: Optional[EventType[()]] = None,
33
+ on_mouse_down: Optional[EventType[()]] = None,
34
+ on_mouse_enter: Optional[EventType[()]] = None,
35
+ on_mouse_leave: Optional[EventType[()]] = None,
36
+ on_mouse_move: Optional[EventType[()]] = None,
37
+ on_mouse_out: Optional[EventType[()]] = None,
38
+ on_mouse_over: Optional[EventType[()]] = None,
39
+ on_mouse_up: Optional[EventType[()]] = None,
40
+ on_scroll: Optional[EventType[()]] = None,
41
+ on_unmount: Optional[EventType[()]] = None,
42
42
  **props,
43
43
  ) -> "NextLink":
44
44
  """Create the component.
@@ -6,7 +6,7 @@
6
6
  from typing import Any, Dict, Optional, Union, overload
7
7
 
8
8
  from reflex.components.component import Component
9
- from reflex.event import BASE_STATE, EventType
9
+ from reflex.event import EventType
10
10
  from reflex.style import Style
11
11
  from reflex.vars.base import Var
12
12
 
@@ -26,21 +26,21 @@ class Video(NextComponent):
26
26
  class_name: Optional[Any] = None,
27
27
  autofocus: Optional[bool] = None,
28
28
  custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
29
- on_blur: Optional[EventType[[], BASE_STATE]] = None,
30
- on_click: Optional[EventType[[], BASE_STATE]] = None,
31
- on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
32
- on_double_click: Optional[EventType[[], BASE_STATE]] = None,
33
- on_focus: Optional[EventType[[], BASE_STATE]] = None,
34
- on_mount: Optional[EventType[[], BASE_STATE]] = None,
35
- on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
36
- on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
37
- on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
38
- on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
39
- on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
40
- on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
41
- on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
42
- on_scroll: Optional[EventType[[], BASE_STATE]] = None,
43
- on_unmount: Optional[EventType[[], BASE_STATE]] = None,
29
+ on_blur: Optional[EventType[()]] = None,
30
+ on_click: Optional[EventType[()]] = None,
31
+ on_context_menu: Optional[EventType[()]] = None,
32
+ on_double_click: Optional[EventType[()]] = None,
33
+ on_focus: Optional[EventType[()]] = None,
34
+ on_mount: Optional[EventType[()]] = None,
35
+ on_mouse_down: Optional[EventType[()]] = None,
36
+ on_mouse_enter: Optional[EventType[()]] = None,
37
+ on_mouse_leave: Optional[EventType[()]] = None,
38
+ on_mouse_move: Optional[EventType[()]] = None,
39
+ on_mouse_out: Optional[EventType[()]] = None,
40
+ on_mouse_over: Optional[EventType[()]] = None,
41
+ on_mouse_up: Optional[EventType[()]] = None,
42
+ on_scroll: Optional[EventType[()]] = None,
43
+ on_unmount: Optional[EventType[()]] = None,
44
44
  **props,
45
45
  ) -> "Video":
46
46
  """Create a Video component.
@@ -1,5 +1,32 @@
1
1
  """Plotly components."""
2
2
 
3
- from .plotly import Plotly
3
+ from reflex.components.component import ComponentNamespace
4
4
 
5
- plotly = Plotly.create
5
+ from .plotly import (
6
+ Plotly,
7
+ PlotlyBasic,
8
+ PlotlyCartesian,
9
+ PlotlyFinance,
10
+ PlotlyGeo,
11
+ PlotlyGl2d,
12
+ PlotlyGl3d,
13
+ PlotlyMapbox,
14
+ PlotlyStrict,
15
+ )
16
+
17
+
18
+ class PlotlyNamespace(ComponentNamespace):
19
+ """Plotly namespace."""
20
+
21
+ __call__ = Plotly.create
22
+ basic = PlotlyBasic.create
23
+ cartesian = PlotlyCartesian.create
24
+ geo = PlotlyGeo.create
25
+ gl2d = PlotlyGl2d.create
26
+ gl3d = PlotlyGl3d.create
27
+ finance = PlotlyFinance.create
28
+ mapbox = PlotlyMapbox.create
29
+ strict = PlotlyStrict.create
30
+
31
+
32
+ plotly = PlotlyNamespace()
@@ -10,6 +10,7 @@ from reflex.components.component import Component, NoSSRComponent
10
10
  from reflex.components.core.cond import color_mode_cond
11
11
  from reflex.event import EventHandler, no_args_event_spec
12
12
  from reflex.utils import console
13
+ from reflex.utils.imports import ImportDict, ImportVar
13
14
  from reflex.vars.base import LiteralVar, Var
14
15
 
15
16
  try:
@@ -18,8 +19,8 @@ try:
18
19
  Template = layout.Template
19
20
  except ImportError:
20
21
  console.warn("Plotly is not installed. Please run `pip install plotly`.")
21
- Figure = Any # type: ignore
22
- Template = Any # type: ignore
22
+ Figure = Any
23
+ Template = Any
23
24
 
24
25
 
25
26
  def _event_points_data_signature(e0: Var) -> Tuple[Var[List[Point]]]:
@@ -95,20 +96,20 @@ class Plotly(NoSSRComponent):
95
96
 
96
97
  library = "react-plotly.js@2.6.0"
97
98
 
98
- lib_dependencies: List[str] = ["plotly.js@2.35.2"]
99
+ lib_dependencies: List[str] = ["plotly.js@2.35.3"]
99
100
 
100
101
  tag = "Plot"
101
102
 
102
103
  is_default = True
103
104
 
104
105
  # The figure to display. This can be a plotly figure or a plotly data json.
105
- data: Var[Figure] # type: ignore
106
+ data: Var[Figure] # pyright: ignore [reportInvalidTypeForm]
106
107
 
107
108
  # The layout of the graph.
108
109
  layout: Var[Dict]
109
110
 
110
111
  # The template for visual appearance of the graph.
111
- template: Var[Template] # type: ignore
112
+ template: Var[Template] # pyright: ignore [reportInvalidTypeForm]
112
113
 
113
114
  # The config of the graph.
114
115
  config: Var[Dict]
@@ -278,3 +279,237 @@ const extractPoints = (points) => {
278
279
  # Spread the figure dict over props, nothing to merge.
279
280
  tag.special_props.append(Var(_js_expr=f"{{...{figure!s}}}"))
280
281
  return tag
282
+
283
+
284
+ CREATE_PLOTLY_COMPONENT: ImportDict = {
285
+ "react-plotly.js": [
286
+ ImportVar(
287
+ tag="createPlotlyComponent",
288
+ is_default=True,
289
+ package_path="/factory",
290
+ ),
291
+ ]
292
+ }
293
+
294
+
295
+ def dynamic_plotly_import(name: str, package: str) -> str:
296
+ """Create a dynamic import for a plotly component.
297
+
298
+ Args:
299
+ name: The name of the component.
300
+ package: The package path of the component.
301
+
302
+ Returns:
303
+ The dynamic import for the plotly component.
304
+ """
305
+ return f"""
306
+ const {name} = dynamic(() => import('{package}').then(mod => createPlotlyComponent(mod)), {{ssr: false}})
307
+ """
308
+
309
+
310
+ class PlotlyBasic(Plotly):
311
+ """Display a basic plotly graph."""
312
+
313
+ tag: str = "BasicPlotlyPlot"
314
+
315
+ library = "react-plotly.js@2.6.0"
316
+
317
+ lib_dependencies: list[str] = ["plotly.js-basic-dist-min@3.0.0"]
318
+
319
+ def add_imports(self) -> ImportDict | list[ImportDict]:
320
+ """Add imports for the plotly basic component.
321
+
322
+ Returns:
323
+ The imports for the plotly basic component.
324
+ """
325
+ return CREATE_PLOTLY_COMPONENT
326
+
327
+ def _get_dynamic_imports(self) -> str:
328
+ """Get the dynamic imports for the plotly basic component.
329
+
330
+ Returns:
331
+ The dynamic imports for the plotly basic component.
332
+ """
333
+ return dynamic_plotly_import(self.tag, "plotly.js-basic-dist-min")
334
+
335
+
336
+ class PlotlyCartesian(Plotly):
337
+ """Display a plotly cartesian graph."""
338
+
339
+ tag: str = "CartesianPlotlyPlot"
340
+
341
+ library = "react-plotly.js@2.6.0"
342
+
343
+ lib_dependencies: list[str] = ["plotly.js-cartesian-dist-min@3.0.0"]
344
+
345
+ def add_imports(self) -> ImportDict | list[ImportDict]:
346
+ """Add imports for the plotly cartesian component.
347
+
348
+ Returns:
349
+ The imports for the plotly cartesian component.
350
+ """
351
+ return CREATE_PLOTLY_COMPONENT
352
+
353
+ def _get_dynamic_imports(self) -> str:
354
+ """Get the dynamic imports for the plotly cartesian component.
355
+
356
+ Returns:
357
+ The dynamic imports for the plotly cartesian component.
358
+ """
359
+ return dynamic_plotly_import(self.tag, "plotly.js-cartesian-dist-min")
360
+
361
+
362
+ class PlotlyGeo(Plotly):
363
+ """Display a plotly geo graph."""
364
+
365
+ tag: str = "GeoPlotlyPlot"
366
+
367
+ library = "react-plotly.js@2.6.0"
368
+
369
+ lib_dependencies: list[str] = ["plotly.js-geo-dist-min@3.0.0"]
370
+
371
+ def add_imports(self) -> ImportDict | list[ImportDict]:
372
+ """Add imports for the plotly geo component.
373
+
374
+ Returns:
375
+ The imports for the plotly geo component.
376
+ """
377
+ return CREATE_PLOTLY_COMPONENT
378
+
379
+ def _get_dynamic_imports(self) -> str:
380
+ """Get the dynamic imports for the plotly geo component.
381
+
382
+ Returns:
383
+ The dynamic imports for the plotly geo component.
384
+ """
385
+ return dynamic_plotly_import(self.tag, "plotly.js-geo-dist-min")
386
+
387
+
388
+ class PlotlyGl3d(Plotly):
389
+ """Display a plotly 3d graph."""
390
+
391
+ tag: str = "Gl3dPlotlyPlot"
392
+
393
+ library = "react-plotly.js@2.6.0"
394
+
395
+ lib_dependencies: list[str] = ["plotly.js-gl3d-dist-min@3.0.0"]
396
+
397
+ def add_imports(self) -> ImportDict | list[ImportDict]:
398
+ """Add imports for the plotly 3d component.
399
+
400
+ Returns:
401
+ The imports for the plotly 3d component.
402
+ """
403
+ return CREATE_PLOTLY_COMPONENT
404
+
405
+ def _get_dynamic_imports(self) -> str:
406
+ """Get the dynamic imports for the plotly 3d component.
407
+
408
+ Returns:
409
+ The dynamic imports for the plotly 3d component.
410
+ """
411
+ return dynamic_plotly_import(self.tag, "plotly.js-gl3d-dist-min")
412
+
413
+
414
+ class PlotlyGl2d(Plotly):
415
+ """Display a plotly 2d graph."""
416
+
417
+ tag: str = "Gl2dPlotlyPlot"
418
+
419
+ library = "react-plotly.js@2.6.0"
420
+
421
+ lib_dependencies: list[str] = ["plotly.js-gl2d-dist-min@3.0.0"]
422
+
423
+ def add_imports(self) -> ImportDict | list[ImportDict]:
424
+ """Add imports for the plotly 2d component.
425
+
426
+ Returns:
427
+ The imports for the plotly 2d component.
428
+ """
429
+ return CREATE_PLOTLY_COMPONENT
430
+
431
+ def _get_dynamic_imports(self) -> str:
432
+ """Get the dynamic imports for the plotly 2d component.
433
+
434
+ Returns:
435
+ The dynamic imports for the plotly 2d component.
436
+ """
437
+ return dynamic_plotly_import(self.tag, "plotly.js-gl2d-dist-min")
438
+
439
+
440
+ class PlotlyMapbox(Plotly):
441
+ """Display a plotly mapbox graph."""
442
+
443
+ tag: str = "MapboxPlotlyPlot"
444
+
445
+ library = "react-plotly.js@2.6.0"
446
+
447
+ lib_dependencies: list[str] = ["plotly.js-mapbox-dist-min@3.0.0"]
448
+
449
+ def add_imports(self) -> ImportDict | list[ImportDict]:
450
+ """Add imports for the plotly mapbox component.
451
+
452
+ Returns:
453
+ The imports for the plotly mapbox component.
454
+ """
455
+ return CREATE_PLOTLY_COMPONENT
456
+
457
+ def _get_dynamic_imports(self) -> str:
458
+ """Get the dynamic imports for the plotly mapbox component.
459
+
460
+ Returns:
461
+ The dynamic imports for the plotly mapbox component.
462
+ """
463
+ return dynamic_plotly_import(self.tag, "plotly.js-mapbox-dist-min")
464
+
465
+
466
+ class PlotlyFinance(Plotly):
467
+ """Display a plotly finance graph."""
468
+
469
+ tag: str = "FinancePlotlyPlot"
470
+
471
+ library = "react-plotly.js@2.6.0"
472
+
473
+ lib_dependencies: list[str] = ["plotly.js-finance-dist-min@3.0.0"]
474
+
475
+ def add_imports(self) -> ImportDict | list[ImportDict]:
476
+ """Add imports for the plotly finance component.
477
+
478
+ Returns:
479
+ The imports for the plotly finance component.
480
+ """
481
+ return CREATE_PLOTLY_COMPONENT
482
+
483
+ def _get_dynamic_imports(self) -> str:
484
+ """Get the dynamic imports for the plotly finance component.
485
+
486
+ Returns:
487
+ The dynamic imports for the plotly finance component.
488
+ """
489
+ return dynamic_plotly_import(self.tag, "plotly.js-finance-dist-min")
490
+
491
+
492
+ class PlotlyStrict(Plotly):
493
+ """Display a plotly strict graph."""
494
+
495
+ tag: str = "StrictPlotlyPlot"
496
+
497
+ library = "react-plotly.js@2.6.0"
498
+
499
+ lib_dependencies: list[str] = ["plotly.js-strict-dist-min@3.0.0"]
500
+
501
+ def add_imports(self) -> ImportDict | list[ImportDict]:
502
+ """Add imports for the plotly strict component.
503
+
504
+ Returns:
505
+ The imports for the plotly strict component.
506
+ """
507
+ return CREATE_PLOTLY_COMPONENT
508
+
509
+ def _get_dynamic_imports(self) -> str:
510
+ """Get the dynamic imports for the plotly strict component.
511
+
512
+ Returns:
513
+ The dynamic imports for the plotly strict component.
514
+ """
515
+ return dynamic_plotly_import(self.tag, "plotly.js-strict-dist-min")