reflex 0.5.2a1__py3-none-any.whl → 0.5.3a1__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 (163) hide show
  1. reflex/.templates/web/postcss.config.js +1 -0
  2. reflex/.templates/web/styles/tailwind.css +4 -1
  3. reflex/__init__.py +298 -204
  4. reflex/__init__.pyi +196 -157
  5. reflex/app.py +13 -2
  6. reflex/components/__init__.py +31 -17
  7. reflex/components/__init__.pyi +26 -0
  8. reflex/components/base/__init__.py +25 -9
  9. reflex/components/base/__init__.pyi +26 -0
  10. reflex/components/base/fragment.py +3 -0
  11. reflex/components/base/fragment.pyi +2 -0
  12. reflex/components/base/head.py +3 -0
  13. reflex/components/base/head.pyi +2 -0
  14. reflex/components/base/script.py +3 -0
  15. reflex/components/base/script.pyi +2 -0
  16. reflex/components/core/__init__.py +51 -37
  17. reflex/components/core/__init__.pyi +39 -0
  18. reflex/components/core/banner.py +7 -1
  19. reflex/components/core/banner.pyi +6 -1
  20. reflex/components/core/debounce.py +3 -0
  21. reflex/components/core/debounce.pyi +2 -0
  22. reflex/components/core/foreach.py +3 -0
  23. reflex/components/core/html.py +3 -0
  24. reflex/components/core/html.pyi +2 -0
  25. reflex/components/core/match.py +3 -0
  26. reflex/components/core/responsive.py +1 -1
  27. reflex/components/core/upload.py +5 -2
  28. reflex/components/core/upload.pyi +4 -2
  29. reflex/components/datadisplay/__init__.py +17 -8
  30. reflex/components/datadisplay/__init__.pyi +14 -0
  31. reflex/components/datadisplay/code.py +3 -0
  32. reflex/components/datadisplay/code.pyi +2 -0
  33. reflex/components/datadisplay/dataeditor.py +4 -0
  34. reflex/components/datadisplay/dataeditor.pyi +3 -0
  35. reflex/components/el/__init__.py +15 -1
  36. reflex/components/el/__init__.pyi +227 -0
  37. reflex/components/el/elements/__init__.py +129 -220
  38. reflex/components/el/elements/__init__.pyi +341 -0
  39. reflex/components/el/elements/forms.py +15 -0
  40. reflex/components/el/elements/forms.pyi +14 -0
  41. reflex/components/el/elements/inline.py +30 -0
  42. reflex/components/el/elements/inline.pyi +29 -0
  43. reflex/components/el/elements/media.py +16 -0
  44. reflex/components/el/elements/media.pyi +15 -0
  45. reflex/components/el/elements/metadata.py +7 -0
  46. reflex/components/el/elements/metadata.pyi +6 -0
  47. reflex/components/el/elements/other.py +9 -0
  48. reflex/components/el/elements/other.pyi +8 -0
  49. reflex/components/el/elements/scripts.py +5 -0
  50. reflex/components/el/elements/scripts.pyi +4 -0
  51. reflex/components/el/elements/sectioning.py +17 -0
  52. reflex/components/el/elements/sectioning.pyi +16 -0
  53. reflex/components/el/elements/tables.py +12 -0
  54. reflex/components/el/elements/tables.pyi +11 -0
  55. reflex/components/el/elements/typography.py +16 -0
  56. reflex/components/el/elements/typography.pyi +15 -0
  57. reflex/components/moment/__init__.py +1 -1
  58. reflex/components/plotly/plotly.py +184 -6
  59. reflex/components/plotly/plotly.pyi +62 -4
  60. reflex/components/radix/__init__.py +14 -2
  61. reflex/components/radix/__init__.pyi +73 -0
  62. reflex/components/radix/primitives/__init__.py +13 -5
  63. reflex/components/radix/primitives/__init__.pyi +11 -0
  64. reflex/components/radix/themes/__init__.py +20 -6
  65. reflex/components/radix/themes/__init__.pyi +13 -0
  66. reflex/components/radix/themes/base.py +26 -20
  67. reflex/components/radix/themes/base.pyi +4 -1
  68. reflex/components/radix/themes/color_mode.py +3 -1
  69. reflex/components/radix/themes/color_mode.pyi +3 -1
  70. reflex/components/radix/themes/components/__init__.py +11 -79
  71. reflex/components/radix/themes/components/__init__.pyi +44 -0
  72. reflex/components/radix/themes/components/alert_dialog.py +2 -2
  73. reflex/components/radix/themes/components/alert_dialog.pyi +2 -2
  74. reflex/components/radix/themes/components/badge.py +2 -2
  75. reflex/components/radix/themes/components/badge.pyi +2 -2
  76. reflex/components/radix/themes/components/button.py +2 -2
  77. reflex/components/radix/themes/components/button.pyi +2 -2
  78. reflex/components/radix/themes/components/callout.py +4 -4
  79. reflex/components/radix/themes/components/callout.pyi +4 -4
  80. reflex/components/radix/themes/components/card.py +2 -2
  81. reflex/components/radix/themes/components/card.pyi +2 -2
  82. reflex/components/radix/themes/components/dialog.py +2 -2
  83. reflex/components/radix/themes/components/dialog.pyi +2 -2
  84. reflex/components/radix/themes/components/hover_card.py +2 -2
  85. reflex/components/radix/themes/components/hover_card.pyi +2 -2
  86. reflex/components/radix/themes/components/icon_button.py +2 -2
  87. reflex/components/radix/themes/components/icon_button.pyi +2 -2
  88. reflex/components/radix/themes/components/inset.py +2 -2
  89. reflex/components/radix/themes/components/inset.pyi +2 -2
  90. reflex/components/radix/themes/components/popover.py +2 -2
  91. reflex/components/radix/themes/components/popover.pyi +2 -2
  92. reflex/components/radix/themes/components/table.py +8 -8
  93. reflex/components/radix/themes/components/table.pyi +8 -8
  94. reflex/components/radix/themes/components/text_area.py +11 -2
  95. reflex/components/radix/themes/components/text_area.pyi +18 -3
  96. reflex/components/radix/themes/components/text_field.py +3 -3
  97. reflex/components/radix/themes/components/text_field.pyi +3 -3
  98. reflex/components/radix/themes/layout/__init__.py +12 -38
  99. reflex/components/radix/themes/layout/__init__.pyi +21 -0
  100. reflex/components/radix/themes/layout/box.py +5 -2
  101. reflex/components/radix/themes/layout/box.pyi +4 -2
  102. reflex/components/radix/themes/layout/center.py +3 -0
  103. reflex/components/radix/themes/layout/center.pyi +2 -0
  104. reflex/components/radix/themes/layout/container.py +5 -2
  105. reflex/components/radix/themes/layout/container.pyi +4 -2
  106. reflex/components/radix/themes/layout/flex.py +5 -2
  107. reflex/components/radix/themes/layout/flex.pyi +4 -2
  108. reflex/components/radix/themes/layout/grid.py +5 -2
  109. reflex/components/radix/themes/layout/grid.pyi +4 -2
  110. reflex/components/radix/themes/layout/list.py +14 -0
  111. reflex/components/radix/themes/layout/list.pyi +3 -0
  112. reflex/components/radix/themes/layout/section.py +7 -4
  113. reflex/components/radix/themes/layout/section.pyi +5 -3
  114. reflex/components/radix/themes/layout/spacer.py +3 -0
  115. reflex/components/radix/themes/layout/spacer.pyi +2 -0
  116. reflex/components/radix/themes/layout/stack.py +5 -0
  117. reflex/components/radix/themes/layout/stack.pyi +4 -0
  118. reflex/components/radix/themes/typography/__init__.py +11 -16
  119. reflex/components/radix/themes/typography/__init__.pyi +12 -0
  120. reflex/components/radix/themes/typography/blockquote.py +5 -2
  121. reflex/components/radix/themes/typography/blockquote.pyi +4 -2
  122. reflex/components/radix/themes/typography/code.py +5 -2
  123. reflex/components/radix/themes/typography/code.pyi +4 -2
  124. reflex/components/radix/themes/typography/heading.py +5 -2
  125. reflex/components/radix/themes/typography/heading.pyi +4 -2
  126. reflex/components/radix/themes/typography/link.py +3 -0
  127. reflex/components/radix/themes/typography/link.pyi +2 -0
  128. reflex/components/radix/themes/typography/text.py +6 -6
  129. reflex/components/radix/themes/typography/text.pyi +6 -6
  130. reflex/components/recharts/__init__.py +114 -104
  131. reflex/components/recharts/__init__.pyi +106 -0
  132. reflex/components/recharts/cartesian.py +17 -0
  133. reflex/components/recharts/cartesian.pyi +16 -0
  134. reflex/components/recharts/charts.py +12 -0
  135. reflex/components/recharts/charts.pyi +11 -0
  136. reflex/components/recharts/general.py +7 -0
  137. reflex/components/recharts/general.pyi +6 -0
  138. reflex/components/recharts/polar.py +11 -0
  139. reflex/components/recharts/polar.pyi +9 -0
  140. reflex/config.py +3 -0
  141. reflex/constants/__init__.py +0 -2
  142. reflex/constants/base.py +2 -0
  143. reflex/constants/base.pyi +5 -0
  144. reflex/constants/installer.py +2 -1
  145. reflex/experimental/__init__.py +2 -0
  146. reflex/experimental/assets.py +56 -0
  147. reflex/experimental/client_state.py +4 -2
  148. reflex/experimental/hooks.py +8 -6
  149. reflex/experimental/layout.py +3 -1
  150. reflex/state.py +54 -4
  151. reflex/utils/exec.py +8 -0
  152. reflex/utils/lazy_loader.py +33 -0
  153. reflex/utils/prerequisites.py +1 -14
  154. reflex/utils/pyi_generator.py +71 -20
  155. reflex/utils/serializers.py +3 -3
  156. reflex/vars.py +79 -5
  157. reflex/vars.pyi +16 -0
  158. {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/METADATA +2 -1
  159. {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/RECORD +162 -148
  160. reflex/config.pyi +0 -112
  161. {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/LICENSE +0 -0
  162. {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/WHEEL +0 -0
  163. {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/entry_points.txt +0 -0
@@ -2180,3 +2180,17 @@ class Textarea(BaseHTML):
2180
2180
  The component.
2181
2181
  """
2182
2182
  ...
2183
+
2184
+ button = Button.create
2185
+ fieldset = Fieldset.create
2186
+ form = Form.create
2187
+ input = Input.create
2188
+ label = Label.create
2189
+ legend = Legend.create
2190
+ meter = Meter.create
2191
+ optgroup = Optgroup.create
2192
+ option = Option.create
2193
+ output = Output.create
2194
+ progress = Progress.create
2195
+ select = Select.create
2196
+ textarea = Textarea.create
@@ -208,3 +208,33 @@ class Wbr(BaseHTML):
208
208
  """Display the wbr element."""
209
209
 
210
210
  tag = "wbr"
211
+
212
+
213
+ a = A.create
214
+ abbr = Abbr.create
215
+ b = B.create
216
+ bdi = Bdi.create
217
+ bdo = Bdo.create
218
+ br = Br.create
219
+ cite = Cite.create
220
+ code = Code.create
221
+ data = Data.create
222
+ dfn = Dfn.create
223
+ em = Em.create
224
+ i = I.create
225
+ kbd = Kbd.create
226
+ mark = Mark.create
227
+ q = Q.create
228
+ rp = Rp.create
229
+ rt = Rt.create
230
+ ruby = Ruby.create
231
+ s = S.create
232
+ samp = Samp.create
233
+ small = Small.create
234
+ span = Span.create
235
+ strong = Strong.create
236
+ sub = Sub.create
237
+ sup = Sup.create
238
+ time = Time.create
239
+ u = U.create
240
+ wbr = Wbr.create
@@ -3746,3 +3746,32 @@ class Wbr(BaseHTML):
3746
3746
  The component.
3747
3747
  """
3748
3748
  ...
3749
+
3750
+ a = A.create
3751
+ abbr = Abbr.create
3752
+ b = B.create
3753
+ bdi = Bdi.create
3754
+ bdo = Bdo.create
3755
+ br = Br.create
3756
+ cite = Cite.create
3757
+ code = Code.create
3758
+ data = Data.create
3759
+ dfn = Dfn.create
3760
+ em = Em.create
3761
+ i = I.create
3762
+ kbd = Kbd.create
3763
+ mark = Mark.create
3764
+ q = Q.create
3765
+ rp = Rp.create
3766
+ rt = Rt.create
3767
+ ruby = Ruby.create
3768
+ s = S.create
3769
+ samp = Samp.create
3770
+ small = Small.create
3771
+ span = Span.create
3772
+ strong = Strong.create
3773
+ sub = Sub.create
3774
+ sup = Sup.create
3775
+ time = Time.create
3776
+ u = U.create
3777
+ wbr = Wbr.create
@@ -316,3 +316,19 @@ class Path(BaseHTML):
316
316
 
317
317
  # Defines the shape of the path
318
318
  d: Var[Union[str, int, bool]]
319
+
320
+
321
+ area = Area.create
322
+ audio = Audio.create
323
+ image = img = Img.create
324
+ map = Map.create
325
+ track = Track.create
326
+ video = Video.create
327
+ embed = Embed.create
328
+ iframe = Iframe.create
329
+ object = Object.create
330
+ picture = Picture.create
331
+ portal = Portal.create
332
+ source = Source.create
333
+ svg = Svg.create
334
+ path = Path.create
@@ -2086,3 +2086,18 @@ class Path(BaseHTML):
2086
2086
  The component.
2087
2087
  """
2088
2088
  ...
2089
+
2090
+ area = Area.create
2091
+ audio = Audio.create
2092
+ image = img = Img.create
2093
+ map = Map.create
2094
+ track = Track.create
2095
+ video = Video.create
2096
+ embed = Embed.create
2097
+ iframe = Iframe.create
2098
+ object = Object.create
2099
+ picture = Picture.create
2100
+ portal = Portal.create
2101
+ source = Source.create
2102
+ svg = Svg.create
2103
+ path = Path.create
@@ -53,3 +53,10 @@ class Title(Element): # noqa: E742
53
53
  """Display the title element."""
54
54
 
55
55
  tag = "title"
56
+
57
+
58
+ base = Base.create
59
+ head = Head.create
60
+ link = Link.create
61
+ meta = Meta.create
62
+ title = Title.create
@@ -650,3 +650,9 @@ class Title(Element):
650
650
  The component.
651
651
  """
652
652
  ...
653
+
654
+ base = Base.create
655
+ head = Head.create
656
+ link = Link.create
657
+ meta = Meta.create
658
+ title = Title.create
@@ -59,3 +59,12 @@ class Html(BaseHTML):
59
59
 
60
60
  # Specifies the URL of the document's cache manifest (obsolete in HTML5)
61
61
  manifest: Var[Union[str, int, bool]]
62
+
63
+
64
+ details = Details.create
65
+ dialog = Dialog.create
66
+ summary = Summary.create
67
+ slot = Slot.create
68
+ template = Template.create
69
+ math = Math.create
70
+ html = Html.create
@@ -942,3 +942,11 @@ class Html(BaseHTML):
942
942
  The component.
943
943
  """
944
944
  ...
945
+
946
+ details = Details.create
947
+ dialog = Dialog.create
948
+ summary = Summary.create
949
+ slot = Slot.create
950
+ template = Template.create
951
+ math = Math.create
952
+ html = Html.create
@@ -50,3 +50,8 @@ class Script(BaseHTML):
50
50
 
51
51
  # Specifies the MIME type of the script
52
52
  type: Var[Union[str, int, bool]]
53
+
54
+
55
+ canvas = Canvas.create
56
+ noscript = Noscript.create
57
+ script = Script.create
@@ -438,3 +438,7 @@ class Script(BaseHTML):
438
438
  The component.
439
439
  """
440
440
  ...
441
+
442
+ canvas = Canvas.create
443
+ noscript = Noscript.create
444
+ script = Script.create
@@ -93,3 +93,20 @@ class Section(BaseHTML): # noqa: E742
93
93
  """Display the section element."""
94
94
 
95
95
  tag = "section"
96
+
97
+
98
+ address = Address.create
99
+ article = Article.create
100
+ aside = Aside.create
101
+ body = Body.create
102
+ header = Header.create
103
+ footer = Footer.create
104
+ h1 = H1.create
105
+ h2 = H2.create
106
+ h3 = H3.create
107
+ h4 = H4.create
108
+ h5 = H5.create
109
+ h6 = H6.create
110
+ main = Main.create
111
+ nav = Nav.create
112
+ section = Section.create
@@ -1989,3 +1989,19 @@ class Section(BaseHTML):
1989
1989
  The component.
1990
1990
  """
1991
1991
  ...
1992
+
1993
+ address = Address.create
1994
+ article = Article.create
1995
+ aside = Aside.create
1996
+ body = Body.create
1997
+ header = Header.create
1998
+ footer = Footer.create
1999
+ h1 = H1.create
2000
+ h2 = H2.create
2001
+ h3 = H3.create
2002
+ h4 = H4.create
2003
+ h5 = H5.create
2004
+ h6 = H6.create
2005
+ main = Main.create
2006
+ nav = Nav.create
2007
+ section = Section.create
@@ -124,3 +124,15 @@ class Tr(BaseHTML):
124
124
 
125
125
  # Alignment of the content within the table row
126
126
  align: Var[Union[str, int, bool]]
127
+
128
+
129
+ caption = Caption.create
130
+ col = Col.create
131
+ colgroup = Colgroup.create
132
+ table = Table.create
133
+ tbody = Tbody.create
134
+ td = Td.create
135
+ tfoot = Tfoot.create
136
+ th = Th.create
137
+ thead = Thead.create
138
+ tr = Tr.create
@@ -1406,3 +1406,14 @@ class Tr(BaseHTML):
1406
1406
  The component.
1407
1407
  """
1408
1408
  ...
1409
+
1410
+ caption = Caption.create
1411
+ col = Col.create
1412
+ colgroup = Colgroup.create
1413
+ table = Table.create
1414
+ tbody = Tbody.create
1415
+ td = Td.create
1416
+ tfoot = Tfoot.create
1417
+ th = Th.create
1418
+ thead = Thead.create
1419
+ tr = Tr.create
@@ -124,3 +124,19 @@ class Del(BaseHTML):
124
124
 
125
125
  # Specifies the date and time of when the text was deleted.
126
126
  date_time: Var[Union[str, int, bool]]
127
+
128
+
129
+ blockquote = Blockquote.create
130
+ dd = Dd.create
131
+ div = Div.create
132
+ dl = Dl.create
133
+ dt = Dt.create
134
+ figcaption = Figcaption.create
135
+ hr = Hr.create
136
+ li = Li.create
137
+ ol = Ol.create
138
+ p = P.create
139
+ pre = Pre.create
140
+ ul = Ul.create
141
+ ins = Ins.create
142
+ del_ = Del.create # 'del' is a reserved keyword in Python
@@ -2020,3 +2020,18 @@ class Del(BaseHTML):
2020
2020
  The component.
2021
2021
  """
2022
2022
  ...
2023
+
2024
+ blockquote = Blockquote.create
2025
+ dd = Dd.create
2026
+ div = Div.create
2027
+ dl = Dl.create
2028
+ dt = Dt.create
2029
+ figcaption = Figcaption.create
2030
+ hr = Hr.create
2031
+ li = Li.create
2032
+ ol = Ol.create
2033
+ p = P.create
2034
+ pre = Pre.create
2035
+ ul = Ul.create
2036
+ ins = Ins.create
2037
+ del_ = Del.create
@@ -1,5 +1,5 @@
1
1
  """Moment.js component."""
2
2
 
3
- from .moment import Moment
3
+ from .moment import Moment, MomentDelta
4
4
 
5
5
  moment = Moment.create
@@ -1,8 +1,11 @@
1
1
  """Component for displaying a plotly graph."""
2
+ from __future__ import annotations
2
3
 
3
4
  from typing import Any, Dict, List
4
5
 
6
+ from reflex.base import Base
5
7
  from reflex.components.component import NoSSRComponent
8
+ from reflex.event import EventHandler
6
9
  from reflex.vars import Var
7
10
 
8
11
  try:
@@ -11,6 +14,76 @@ except ImportError:
11
14
  Figure = Any # type: ignore
12
15
 
13
16
 
17
+ def _event_data_signature(e0: Var) -> List[Any]:
18
+ """For plotly events with event data and no points.
19
+
20
+ Args:
21
+ e0: The event data.
22
+
23
+ Returns:
24
+ The event key extracted from the event data (if defined).
25
+ """
26
+ return [Var.create_safe(f"{e0}?.event")]
27
+
28
+
29
+ def _event_points_data_signature(e0: Var) -> List[Any]:
30
+ """For plotly events with event data containing a point array.
31
+
32
+ Args:
33
+ e0: The event data.
34
+
35
+ Returns:
36
+ The event data and the extracted points.
37
+ """
38
+ return [
39
+ Var.create_safe(f"{e0}?.event"),
40
+ Var.create_safe(
41
+ f"extractPoints({e0}?.points)",
42
+ ),
43
+ ]
44
+
45
+
46
+ class _ButtonClickData(Base):
47
+ """Event data structure for plotly UI buttons."""
48
+
49
+ menu: Any
50
+ button: Any
51
+ active: Any
52
+
53
+
54
+ def _button_click_signature(e0: _ButtonClickData) -> List[Any]:
55
+ """For plotly button click events.
56
+
57
+ Args:
58
+ e0: The button click data.
59
+
60
+ Returns:
61
+ The menu, button, and active state.
62
+ """
63
+ return [e0.menu, e0.button, e0.active]
64
+
65
+
66
+ def _passthrough_signature(e0: Var) -> List[Any]:
67
+ """For plotly events with arbitrary serializable data, passed through directly.
68
+
69
+ Args:
70
+ e0: The event data.
71
+
72
+ Returns:
73
+ The event data.
74
+ """
75
+ return [e0]
76
+
77
+
78
+ def _null_signature() -> List[Any]:
79
+ """For plotly events with no data or non-serializable data. Nothing passed through.
80
+
81
+ Returns:
82
+ An empty list (nothing passed through).
83
+ """
84
+ return []
85
+
86
+
14
87
  class PlotlyLib(NoSSRComponent):
15
88
  """A component that wraps a plotly lib."""
16
89
 
@@ -35,11 +108,116 @@ class Plotly(PlotlyLib):
35
108
  # The config of the graph.
36
109
  config: Var[Dict]
37
110
 
38
- # The width of the graph.
39
- width: Var[str]
40
-
41
- # The height of the graph.
42
- height: Var[str]
43
-
44
111
  # If true, the graph will resize when the window is resized.
45
112
  use_resize_handler: Var[bool]
113
+
114
+ # Fired after the plot is redrawn.
115
+ on_after_plot: EventHandler[_passthrough_signature]
116
+
117
+ # Fired after the plot was animated.
118
+ on_animated: EventHandler[_null_signature]
119
+
120
+ # Fired while animating a single frame (does not currently pass data through).
121
+ on_animating_frame: EventHandler[_null_signature]
122
+
123
+ # Fired when an animation is interrupted (to start a new animation for example).
124
+ on_animation_interrupted: EventHandler[_null_signature]
125
+
126
+ # Fired when the plot is responsively sized.
127
+ on_autosize: EventHandler[_event_data_signature]
128
+
129
+ # Fired whenever mouse moves over a plot.
130
+ on_before_hover: EventHandler[_event_data_signature]
131
+
132
+ # Fired when a plotly UI button is clicked.
133
+ on_button_clicked: EventHandler[_button_click_signature]
134
+
135
+ # Fired when the plot is clicked.
136
+ on_click: EventHandler[_event_points_data_signature]
137
+
138
+ # Fired when a selection is cleared (via double click).
139
+ on_deselect: EventHandler[_null_signature]
140
+
141
+ # Fired when the plot is double clicked.
142
+ on_double_click: EventHandler[_passthrough_signature]
143
+
144
+ # Fired when a plot element is hovered over.
145
+ on_hover: EventHandler[_event_points_data_signature]
146
+
147
+ # Fired after the plot is layed out (zoom, pan, etc).
148
+ on_relayout: EventHandler[_passthrough_signature]
149
+
150
+ # Fired while the plot is being layed out.
151
+ on_relayouting: EventHandler[_passthrough_signature]
152
+
153
+ # Fired after the plot style is changed.
154
+ on_restyle: EventHandler[_passthrough_signature]
155
+
156
+ # Fired after the plot is redrawn.
157
+ on_redraw: EventHandler[_event_data_signature]
158
+
159
+ # Fired after selecting plot elements.
160
+ on_selected: EventHandler[_event_points_data_signature]
161
+
162
+ # Fired while dragging a selection.
163
+ on_selecting: EventHandler[_event_points_data_signature]
164
+
165
+ # Fired while an animation is occuring.
166
+ on_transitioning: EventHandler[_event_data_signature]
167
+
168
+ # Fired when a transition is stopped early.
169
+ on_transition_interrupted: EventHandler[_event_data_signature]
170
+
171
+ # Fired when a hovered element is no longer hovered.
172
+ on_unhover: EventHandler[_event_points_data_signature]
173
+
174
+ def add_custom_code(self) -> list[str]:
175
+ """Add custom codes for processing the plotly points data.
176
+
177
+ Returns:
178
+ Custom code snippets for the module level.
179
+ """
180
+ return [
181
+ "const removeUndefined = (obj) => {Object.keys(obj).forEach(key => obj[key] === undefined && delete obj[key]); return obj}",
182
+ """
183
+ const extractPoints = (points) => {
184
+ if (!points) return [];
185
+ return points.map(point => {
186
+ const bbox = point.bbox ? removeUndefined({
187
+ x0: point.bbox.x0,
188
+ x1: point.bbox.x1,
189
+ y0: point.bbox.y0,
190
+ y1: point.bbox.y1,
191
+ z0: point.bbox.y0,
192
+ z1: point.bbox.y1,
193
+ }) : undefined;
194
+ return removeUndefined({
195
+ x: point.x,
196
+ y: point.y,
197
+ z: point.z,
198
+ lat: point.lat,
199
+ lon: point.lon,
200
+ curveNumber: point.curveNumber,
201
+ pointNumber: point.pointNumber,
202
+ pointNumbers: point.pointNumbers,
203
+ pointIndex: point.pointIndex,
204
+ 'marker.color': point['marker.color'],
205
+ 'marker.size': point['marker.size'],
206
+ bbox: bbox,
207
+ })
208
+ })
209
+ }
210
+ """,
211
+ ]
212
+
213
+ def _render(self):
214
+ tag = super()._render()
215
+ figure = self.data.to(dict)
216
+ if self.layout is None:
217
+ tag.remove_props("data", "layout")
218
+ tag.special_props.add(
219
+ Var.create_safe(f"{{...{figure._var_name_unwrapped}}}")
220
+ )
221
+ else:
222
+ tag.add_props(data=figure["data"])
223
+ return tag
@@ -8,7 +8,9 @@ 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 typing import Any, Dict, List
11
+ from reflex.base import Base
11
12
  from reflex.components.component import NoSSRComponent
13
+ from reflex.event import EventHandler
12
14
  from reflex.vars import Var
13
15
 
14
16
  try:
@@ -16,6 +18,11 @@ try:
16
18
  except ImportError:
17
19
  Figure = Any # type: ignore
18
20
 
21
+ class _ButtonClickData(Base):
22
+ menu: Any
23
+ button: Any
24
+ active: Any
25
+
19
26
  class PlotlyLib(NoSSRComponent):
20
27
  @overload
21
28
  @classmethod
@@ -93,6 +100,7 @@ class PlotlyLib(NoSSRComponent):
93
100
  ...
94
101
 
95
102
  class Plotly(PlotlyLib):
103
+ def add_custom_code(self) -> list[str]: ...
96
104
  @overload
97
105
  @classmethod
98
106
  def create( # type: ignore
@@ -101,8 +109,6 @@ class Plotly(PlotlyLib):
101
109
  data: Optional[Union[Var[Figure], Figure]] = None, # type: ignore
102
110
  layout: Optional[Union[Var[Dict], Dict]] = None,
103
111
  config: Optional[Union[Var[Dict], Dict]] = None,
104
- width: Optional[Union[Var[str], str]] = None,
105
- height: Optional[Union[Var[str], str]] = None,
106
112
  use_resize_handler: Optional[Union[Var[bool], bool]] = None,
107
113
  style: Optional[Style] = None,
108
114
  key: Optional[Any] = None,
@@ -110,21 +116,48 @@ class Plotly(PlotlyLib):
110
116
  class_name: Optional[Any] = None,
111
117
  autofocus: Optional[bool] = None,
112
118
  custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
119
+ on_after_plot: Optional[
120
+ Union[EventHandler, EventSpec, list, function, BaseVar]
121
+ ] = None,
122
+ on_animated: Optional[
123
+ Union[EventHandler, EventSpec, list, function, BaseVar]
124
+ ] = None,
125
+ on_animating_frame: Optional[
126
+ Union[EventHandler, EventSpec, list, function, BaseVar]
127
+ ] = None,
128
+ on_animation_interrupted: Optional[
129
+ Union[EventHandler, EventSpec, list, function, BaseVar]
130
+ ] = None,
131
+ on_autosize: Optional[
132
+ Union[EventHandler, EventSpec, list, function, BaseVar]
133
+ ] = None,
134
+ on_before_hover: Optional[
135
+ Union[EventHandler, EventSpec, list, function, BaseVar]
136
+ ] = None,
113
137
  on_blur: Optional[
114
138
  Union[EventHandler, EventSpec, list, function, BaseVar]
115
139
  ] = None,
140
+ on_button_clicked: Optional[
141
+ Union[EventHandler, EventSpec, list, function, BaseVar]
142
+ ] = None,
116
143
  on_click: Optional[
117
144
  Union[EventHandler, EventSpec, list, function, BaseVar]
118
145
  ] = None,
119
146
  on_context_menu: Optional[
120
147
  Union[EventHandler, EventSpec, list, function, BaseVar]
121
148
  ] = None,
149
+ on_deselect: Optional[
150
+ Union[EventHandler, EventSpec, list, function, BaseVar]
151
+ ] = None,
122
152
  on_double_click: Optional[
123
153
  Union[EventHandler, EventSpec, list, function, BaseVar]
124
154
  ] = None,
125
155
  on_focus: Optional[
126
156
  Union[EventHandler, EventSpec, list, function, BaseVar]
127
157
  ] = None,
158
+ on_hover: Optional[
159
+ Union[EventHandler, EventSpec, list, function, BaseVar]
160
+ ] = None,
128
161
  on_mount: Optional[
129
162
  Union[EventHandler, EventSpec, list, function, BaseVar]
130
163
  ] = None,
@@ -149,9 +182,36 @@ class Plotly(PlotlyLib):
149
182
  on_mouse_up: Optional[
150
183
  Union[EventHandler, EventSpec, list, function, BaseVar]
151
184
  ] = None,
185
+ on_redraw: Optional[
186
+ Union[EventHandler, EventSpec, list, function, BaseVar]
187
+ ] = None,
188
+ on_relayout: Optional[
189
+ Union[EventHandler, EventSpec, list, function, BaseVar]
190
+ ] = None,
191
+ on_relayouting: Optional[
192
+ Union[EventHandler, EventSpec, list, function, BaseVar]
193
+ ] = None,
194
+ on_restyle: Optional[
195
+ Union[EventHandler, EventSpec, list, function, BaseVar]
196
+ ] = None,
152
197
  on_scroll: Optional[
153
198
  Union[EventHandler, EventSpec, list, function, BaseVar]
154
199
  ] = None,
200
+ on_selected: Optional[
201
+ Union[EventHandler, EventSpec, list, function, BaseVar]
202
+ ] = None,
203
+ on_selecting: Optional[
204
+ Union[EventHandler, EventSpec, list, function, BaseVar]
205
+ ] = None,
206
+ on_transition_interrupted: Optional[
207
+ Union[EventHandler, EventSpec, list, function, BaseVar]
208
+ ] = None,
209
+ on_transitioning: Optional[
210
+ Union[EventHandler, EventSpec, list, function, BaseVar]
211
+ ] = None,
212
+ on_unhover: Optional[
213
+ Union[EventHandler, EventSpec, list, function, BaseVar]
214
+ ] = None,
155
215
  on_unmount: Optional[
156
216
  Union[EventHandler, EventSpec, list, function, BaseVar]
157
217
  ] = None,
@@ -164,8 +224,6 @@ class Plotly(PlotlyLib):
164
224
  data: The figure to display. This can be a plotly figure or a plotly data json.
165
225
  layout: The layout of the graph.
166
226
  config: The config of the graph.
167
- width: The width of the graph.
168
- height: The height of the graph.
169
227
  use_resize_handler: If true, the graph will resize when the window is resized.
170
228
  style: The style of the component.
171
229
  key: A unique key for the component.
@@ -1,4 +1,16 @@
1
1
  """Namespace for components provided by @radix-ui packages."""
2
+ from __future__ import annotations
2
3
 
3
- from .primitives import *
4
- from .themes import *
4
+ from reflex import RADIX_MAPPING
5
+ from reflex.utils import lazy_loader
6
+
7
+ _SUBMODULES: set[str] = {"themes", "primitives"}
8
+
9
+ _SUBMOD_ATTRS: dict[str, list[str]] = {
10
+ "".join(k.split("components.radix.")[-1]): v for k, v in RADIX_MAPPING.items()
11
+ }
12
+ __getattr__, __dir__, __all__ = lazy_loader.attach(
13
+ __name__,
14
+ submodules=_SUBMODULES,
15
+ submod_attrs=_SUBMOD_ATTRS,
16
+ )