reflex 0.4.9a2__py3-none-any.whl → 0.5.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

Files changed (131) hide show
  1. reflex/.templates/apps/blank/code/blank.py +19 -16
  2. reflex/.templates/apps/demo/code/pages/datatable.py +4 -4
  3. reflex/.templates/apps/demo/code/pages/forms.py +2 -2
  4. reflex/.templates/web/utils/helpers/debounce.js +17 -0
  5. reflex/.templates/web/utils/helpers/throttle.js +22 -0
  6. reflex/.templates/web/utils/state.js +21 -3
  7. reflex/__init__.py +6 -1
  8. reflex/__init__.pyi +4 -1
  9. reflex/app.py +157 -140
  10. reflex/app_module_for_backend.py +1 -1
  11. reflex/base.py +13 -15
  12. reflex/compiler/compiler.py +10 -1
  13. reflex/compiler/utils.py +3 -30
  14. reflex/components/__init__.py +1 -0
  15. reflex/components/chakra/datadisplay/list.py +1 -3
  16. reflex/components/chakra/datadisplay/list.pyi +3 -3
  17. reflex/components/chakra/disclosure/accordion.py +1 -1
  18. reflex/components/chakra/forms/pininput.pyi +1 -1
  19. reflex/components/chakra/media/icon.py +2 -2
  20. reflex/components/component.py +279 -32
  21. reflex/components/core/__init__.py +2 -2
  22. reflex/components/core/cond.py +1 -10
  23. reflex/components/core/debounce.py +5 -2
  24. reflex/components/core/debounce.pyi +4 -2
  25. reflex/components/core/foreach.py +1 -16
  26. reflex/components/core/html.py +6 -0
  27. reflex/components/core/match.py +2 -17
  28. reflex/components/core/upload.py +42 -1
  29. reflex/components/core/upload.pyi +199 -1
  30. reflex/components/datadisplay/code.py +7 -3
  31. reflex/components/datadisplay/code.pyi +3 -1
  32. reflex/components/el/elements/forms.py +1 -1
  33. reflex/components/el/elements/forms.pyi +1 -1
  34. reflex/components/lucide/icon.py +5 -13
  35. reflex/components/lucide/icon.pyi +0 -1
  36. reflex/components/markdown/markdown.py +5 -23
  37. reflex/components/markdown/markdown.pyi +1 -4
  38. reflex/components/radix/primitives/accordion.py +227 -406
  39. reflex/components/radix/primitives/accordion.pyi +369 -28
  40. reflex/components/radix/primitives/form.py +33 -29
  41. reflex/components/radix/primitives/form.pyi +7 -2
  42. reflex/components/radix/primitives/progress.py +17 -9
  43. reflex/components/radix/primitives/progress.pyi +2 -0
  44. reflex/components/radix/primitives/slider.py +30 -18
  45. reflex/components/radix/primitives/slider.pyi +4 -0
  46. reflex/components/radix/themes/base.py +8 -1
  47. reflex/components/radix/themes/base.pyi +79 -1
  48. reflex/components/radix/themes/color_mode.py +74 -30
  49. reflex/components/radix/themes/color_mode.pyi +26 -185
  50. reflex/components/radix/themes/components/__init__.py +17 -0
  51. reflex/components/radix/themes/components/badge.py +2 -1
  52. reflex/components/radix/themes/components/badge.pyi +3 -1
  53. reflex/components/radix/themes/components/button.py +3 -1
  54. reflex/components/radix/themes/components/button.pyi +4 -1
  55. reflex/components/radix/themes/components/checkbox_cards.py +48 -0
  56. reflex/components/radix/themes/components/checkbox_cards.pyi +264 -0
  57. reflex/components/radix/themes/components/checkbox_group.py +42 -0
  58. reflex/components/radix/themes/components/checkbox_group.pyi +253 -0
  59. reflex/components/radix/themes/components/data_list.py +63 -0
  60. reflex/components/radix/themes/components/data_list.pyi +426 -0
  61. reflex/components/radix/themes/components/icon_button.py +20 -17
  62. reflex/components/radix/themes/components/icon_button.pyi +5 -1
  63. reflex/components/radix/themes/components/progress.py +55 -0
  64. reflex/components/radix/themes/components/progress.pyi +180 -0
  65. reflex/components/radix/themes/components/radio.py +31 -0
  66. reflex/components/radix/themes/components/radio.pyi +169 -0
  67. reflex/components/radix/themes/components/radio_cards.py +48 -0
  68. reflex/components/radix/themes/components/radio_cards.pyi +264 -0
  69. reflex/components/radix/themes/components/radio_group.py +2 -4
  70. reflex/components/radix/themes/components/segmented_control.py +48 -0
  71. reflex/components/radix/themes/components/segmented_control.pyi +262 -0
  72. reflex/components/radix/themes/components/skeleton.py +32 -0
  73. reflex/components/radix/themes/components/skeleton.pyi +106 -0
  74. reflex/components/radix/themes/components/spinner.py +26 -0
  75. reflex/components/radix/themes/components/spinner.pyi +101 -0
  76. reflex/components/radix/themes/components/tabs.py +26 -1
  77. reflex/components/radix/themes/components/tabs.pyi +69 -9
  78. reflex/components/radix/themes/components/text_field.py +101 -71
  79. reflex/components/radix/themes/components/text_field.pyi +81 -499
  80. reflex/components/radix/themes/layout/base.py +2 -2
  81. reflex/components/radix/themes/layout/base.pyi +4 -4
  82. reflex/components/radix/themes/layout/center.py +8 -3
  83. reflex/components/radix/themes/layout/center.pyi +2 -1
  84. reflex/components/radix/themes/layout/container.py +30 -2
  85. reflex/components/radix/themes/layout/container.pyi +9 -30
  86. reflex/components/radix/themes/layout/list.py +10 -5
  87. reflex/components/radix/themes/layout/list.pyi +5 -21
  88. reflex/components/radix/themes/layout/spacer.py +8 -3
  89. reflex/components/radix/themes/layout/spacer.pyi +2 -1
  90. reflex/components/radix/themes/layout/stack.py +7 -1
  91. reflex/components/radix/themes/layout/stack.pyi +3 -3
  92. reflex/components/radix/themes/typography/link.py +10 -2
  93. reflex/components/radix/themes/typography/link.pyi +5 -4
  94. reflex/components/sonner/__init__.py +3 -0
  95. reflex/components/sonner/toast.py +267 -0
  96. reflex/components/sonner/toast.pyi +205 -0
  97. reflex/components/tags/iter_tag.py +9 -6
  98. reflex/config.py +30 -54
  99. reflex/constants/__init__.py +0 -2
  100. reflex/constants/base.py +0 -5
  101. reflex/constants/colors.py +2 -0
  102. reflex/constants/installer.py +5 -1
  103. reflex/constants/route.py +4 -0
  104. reflex/custom_components/custom_components.py +22 -1
  105. reflex/event.py +75 -30
  106. reflex/experimental/__init__.py +5 -0
  107. reflex/experimental/layout.py +24 -6
  108. reflex/model.py +2 -1
  109. reflex/page.py +7 -4
  110. reflex/reflex.py +8 -3
  111. reflex/route.py +39 -0
  112. reflex/state.py +128 -131
  113. reflex/style.py +20 -1
  114. reflex/testing.py +10 -6
  115. reflex/utils/console.py +3 -1
  116. reflex/utils/exec.py +20 -7
  117. reflex/utils/format.py +1 -1
  118. reflex/utils/imports.py +3 -1
  119. reflex/utils/prerequisites.py +141 -20
  120. reflex/utils/processes.py +21 -1
  121. reflex/utils/pyi_generator.py +95 -5
  122. reflex/utils/serializers.py +1 -1
  123. reflex/utils/telemetry.py +26 -4
  124. reflex/utils/types.py +62 -18
  125. reflex/vars.py +11 -5
  126. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/METADATA +16 -4
  127. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/RECORD +130 -108
  128. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/WHEEL +1 -1
  129. reflex/app.pyi +0 -149
  130. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/LICENSE +0 -0
  131. {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/entry_points.txt +0 -0
@@ -8,10 +8,10 @@ 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, Literal
11
- from reflex.components.component import ComponentNamespace
11
+ from reflex.components.component import Component, ComponentNamespace
12
12
  from reflex.constants import EventTriggers
13
13
  from reflex.vars import Var
14
- from ..base import RadixThemesComponent
14
+ from ..base import LiteralAccentColor, RadixThemesComponent
15
15
 
16
16
  class TabsRoot(RadixThemesComponent):
17
17
  def get_event_triggers(self) -> Dict[str, Any]: ...
@@ -196,6 +196,68 @@ class TabsTrigger(RadixThemesComponent):
196
196
  *children,
197
197
  value: Optional[Union[Var[str], str]] = None,
198
198
  disabled: Optional[Union[Var[bool], bool]] = None,
199
+ color_scheme: Optional[
200
+ Union[
201
+ Var[
202
+ Literal[
203
+ "tomato",
204
+ "red",
205
+ "ruby",
206
+ "crimson",
207
+ "pink",
208
+ "plum",
209
+ "purple",
210
+ "violet",
211
+ "iris",
212
+ "indigo",
213
+ "blue",
214
+ "cyan",
215
+ "teal",
216
+ "jade",
217
+ "green",
218
+ "grass",
219
+ "brown",
220
+ "orange",
221
+ "sky",
222
+ "mint",
223
+ "lime",
224
+ "yellow",
225
+ "amber",
226
+ "gold",
227
+ "bronze",
228
+ "gray",
229
+ ]
230
+ ],
231
+ Literal[
232
+ "tomato",
233
+ "red",
234
+ "ruby",
235
+ "crimson",
236
+ "pink",
237
+ "plum",
238
+ "purple",
239
+ "violet",
240
+ "iris",
241
+ "indigo",
242
+ "blue",
243
+ "cyan",
244
+ "teal",
245
+ "jade",
246
+ "green",
247
+ "grass",
248
+ "brown",
249
+ "orange",
250
+ "sky",
251
+ "mint",
252
+ "lime",
253
+ "yellow",
254
+ "amber",
255
+ "gold",
256
+ "bronze",
257
+ "gray",
258
+ ],
259
+ ]
260
+ ] = None,
199
261
  style: Optional[Style] = None,
200
262
  key: Optional[Any] = None,
201
263
  id: Optional[Any] = None,
@@ -249,25 +311,23 @@ class TabsTrigger(RadixThemesComponent):
249
311
  ] = None,
250
312
  **props
251
313
  ) -> "TabsTrigger":
252
- """Create a new component instance.
253
-
254
- Will prepend "RadixThemes" to the component tag to avoid conflicts with
255
- other UI libraries for common names, like Text and Button.
314
+ """Create a TabsTrigger component.
256
315
 
257
316
  Args:
258
- *children: Child components.
317
+ *children: The children of the component.
259
318
  value: The value of the tab. Must be unique for each tab.
260
319
  disabled: Whether the tab is disabled
320
+ color_scheme: The color of the line under the tab when active.
261
321
  style: The style of the component.
262
322
  key: A unique key for the component.
263
323
  id: The id for the component.
264
324
  class_name: The class name for the component.
265
325
  autofocus: Whether the component should take the focus once the page is loaded
266
326
  custom_attrs: custom attribute
267
- **props: Component properties.
327
+ **props: The properties of the component.
268
328
 
269
329
  Returns:
270
- A new component instance.
330
+ The TabsTrigger Component.
271
331
  """
272
332
  ...
273
333
 
@@ -1,11 +1,15 @@
1
1
  """Interactive components provided by @radix-ui/themes."""
2
+ from __future__ import annotations
2
3
 
3
- from typing import Any, Dict, Literal
4
+ from typing import Any, Dict, Literal, Union
4
5
 
5
6
  from reflex.components import el
7
+ from reflex.components.base.fragment import Fragment
6
8
  from reflex.components.component import Component, ComponentNamespace
7
9
  from reflex.components.core.debounce import DebounceInput
8
10
  from reflex.constants import EventTriggers
11
+ from reflex.style import Style, format_as_emotion
12
+ from reflex.utils import console
9
13
  from reflex.vars import Var
10
14
 
11
15
  from ..base import (
@@ -35,68 +39,6 @@ class TextFieldRoot(el.Div, RadixThemesComponent):
35
39
  # Override theme radius for text field: "none" | "small" | "medium" | "large" | "full"
36
40
  radius: Var[LiteralRadius]
37
41
 
38
-
39
- class TextFieldInput(el.Input, TextFieldRoot):
40
- """The input part of a TextField, may be used by itself."""
41
-
42
- tag = "TextField.Input"
43
-
44
- @classmethod
45
- def create(cls, *children, **props) -> Component:
46
- """Create an Input component.
47
-
48
- Args:
49
- *children: The children of the component.
50
- **props: The properties of the component.
51
-
52
- Returns:
53
- The component.
54
- """
55
- if props.get("value") is not None and props.get("on_change"):
56
- # create a debounced input if the user requests full control to avoid typing jank
57
- return DebounceInput.create(super().create(*children, **props))
58
- return super().create(*children, **props)
59
-
60
- def get_event_triggers(self) -> Dict[str, Any]:
61
- """Get the event triggers that pass the component's value to the handler.
62
-
63
- Returns:
64
- A dict mapping the event trigger to the var that is passed to the handler.
65
- """
66
- return {
67
- **super().get_event_triggers(),
68
- EventTriggers.ON_CHANGE: lambda e0: [e0.target.value],
69
- EventTriggers.ON_FOCUS: lambda e0: [e0.target.value],
70
- EventTriggers.ON_BLUR: lambda e0: [e0.target.value],
71
- EventTriggers.ON_KEY_DOWN: lambda e0: [e0.key],
72
- EventTriggers.ON_KEY_UP: lambda e0: [e0.key],
73
- }
74
-
75
-
76
- class TextFieldSlot(RadixThemesComponent):
77
- """Contains icons or buttons associated with an Input."""
78
-
79
- tag = "TextField.Slot"
80
-
81
- # Override theme color for text field slot
82
- color_scheme: Var[LiteralAccentColor]
83
-
84
-
85
- class Input(RadixThemesComponent):
86
- """High level wrapper for the Input component."""
87
-
88
- # Text field size "1" - "3"
89
- size: Var[LiteralTextFieldSize]
90
-
91
- # Variant of text field: "classic" | "surface" | "soft"
92
- variant: Var[LiteralTextFieldVariant]
93
-
94
- # Override theme color for text field
95
- color_scheme: Var[LiteralAccentColor]
96
-
97
- # Override theme radius for text field: "none" | "small" | "medium" | "large" | "full"
98
- radius: Var[LiteralRadius]
99
-
100
42
  # Whether the input should have autocomplete enabled
101
43
  auto_complete: Var[bool]
102
44
 
@@ -107,10 +49,10 @@ class Input(RadixThemesComponent):
107
49
  disabled: Var[bool]
108
50
 
109
51
  # Specifies the maximum number of characters allowed in the input
110
- max_length: Var[str]
52
+ max_length: Var[int]
111
53
 
112
54
  # Specifies the minimum number of characters required in the input
113
- min_length: Var[str]
55
+ min_length: Var[int]
114
56
 
115
57
  # Name of the input, used when sending form data
116
58
  name: Var[str]
@@ -128,19 +70,98 @@ class Input(RadixThemesComponent):
128
70
  type: Var[str]
129
71
 
130
72
  # Value of the input
131
- value: Var[str]
73
+ value: Var[Union[str, int, float]]
132
74
 
133
75
  @classmethod
134
- def create(cls, **props):
76
+ def create(cls, *children, **props) -> Component:
135
77
  """Create an Input component.
136
78
 
137
79
  Args:
80
+ *children: The children of the component.
138
81
  **props: The properties of the component.
139
82
 
140
83
  Returns:
141
84
  The component.
142
85
  """
143
- return TextFieldInput.create(**props)
86
+ component = super().create(*children, **props)
87
+ if props.get("value") is not None and props.get("on_change"):
88
+ # create a debounced input if the user requests full control to avoid typing jank
89
+ return DebounceInput.create(component)
90
+ return component
91
+
92
+ @classmethod
93
+ def create_root_deprecated(cls, *children, **props) -> Component:
94
+ """Create a Fragment component (wrapper for deprecated name).
95
+
96
+ Copy the attributes that were previously defined on TextFieldRoot in 0.4.9 to
97
+ any child input elements (via custom_attrs).
98
+
99
+ Args:
100
+ *children: The children of the component.
101
+ **props: The properties of the component.
102
+
103
+ Returns:
104
+ The component.
105
+ """
106
+ console.deprecate(
107
+ feature_name="rx.input.root",
108
+ reason="use rx.input without the .root suffix",
109
+ deprecation_version="0.5.0",
110
+ removal_version="0.6.0",
111
+ )
112
+ inputs = [
113
+ child
114
+ for child in children
115
+ if isinstance(child, (TextFieldRoot, DebounceInput))
116
+ ]
117
+ if not inputs:
118
+ # Old-style where no explicit child input was provided
119
+ return cls.create(*children, **props)
120
+ slots = [child for child in children if isinstance(child, TextFieldSlot)]
121
+ carry_props = {
122
+ prop: props.pop(prop)
123
+ for prop in ["size", "variant", "color_scheme", "radius"]
124
+ if prop in props
125
+ }
126
+ template = cls.create(**props)
127
+ for child in inputs:
128
+ child.children.extend(slots)
129
+ custom_attrs = child.custom_attrs
130
+ custom_attrs.update(
131
+ {
132
+ prop: value
133
+ for prop, value in carry_props.items()
134
+ if prop not in custom_attrs and getattr(child, prop) is None
135
+ }
136
+ )
137
+ style = Style(template.style)
138
+ style.update(child.style)
139
+ child._get_style = lambda style=style: {
140
+ "css": Var.create(format_as_emotion(style))
141
+ }
142
+ for trigger in template.event_triggers:
143
+ if trigger not in child.event_triggers:
144
+ child.event_triggers[trigger] = template.event_triggers[trigger]
145
+ return Fragment.create(*inputs)
146
+
147
+ @classmethod
148
+ def create_input_deprecated(cls, *children, **props) -> Component:
149
+ """Create a TextFieldRoot component (wrapper for deprecated name).
150
+
151
+ Args:
152
+ *children: The children of the component.
153
+ **props: The properties of the component.
154
+
155
+ Returns:
156
+ The component.
157
+ """
158
+ console.deprecate(
159
+ feature_name="rx.input.input",
160
+ reason="use rx.input without the .input suffix",
161
+ deprecation_version="0.5.0",
162
+ removal_version="0.6.0",
163
+ )
164
+ return cls.create(*children, **props)
144
165
 
145
166
  def get_event_triggers(self) -> Dict[str, Any]:
146
167
  """Get the event triggers that pass the component's value to the handler.
@@ -158,13 +179,22 @@ class Input(RadixThemesComponent):
158
179
  }
159
180
 
160
181
 
182
+ class TextFieldSlot(RadixThemesComponent):
183
+ """Contains icons or buttons associated with an Input."""
184
+
185
+ tag = "TextField.Slot"
186
+
187
+ # Override theme color for text field slot
188
+ color_scheme: Var[LiteralAccentColor]
189
+
190
+
161
191
  class TextField(ComponentNamespace):
162
192
  """TextField components namespace."""
163
193
 
164
- root = staticmethod(TextFieldRoot.create)
165
- input = staticmethod(TextFieldInput.create)
194
+ root = staticmethod(TextFieldRoot.create_root_deprecated)
195
+ input = staticmethod(TextFieldRoot.create_input_deprecated)
166
196
  slot = staticmethod(TextFieldSlot.create)
167
- __call__ = staticmethod(Input.create)
197
+ __call__ = staticmethod(TextFieldRoot.create)
168
198
 
169
199
 
170
200
  text_field = TextField()