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.
- reflex/.templates/apps/blank/code/blank.py +19 -16
- reflex/.templates/apps/demo/code/pages/datatable.py +4 -4
- reflex/.templates/apps/demo/code/pages/forms.py +2 -2
- reflex/.templates/web/utils/helpers/debounce.js +17 -0
- reflex/.templates/web/utils/helpers/throttle.js +22 -0
- reflex/.templates/web/utils/state.js +21 -3
- reflex/__init__.py +6 -1
- reflex/__init__.pyi +4 -1
- reflex/app.py +157 -140
- reflex/app_module_for_backend.py +1 -1
- reflex/base.py +13 -15
- reflex/compiler/compiler.py +10 -1
- reflex/compiler/utils.py +3 -30
- reflex/components/__init__.py +1 -0
- reflex/components/chakra/datadisplay/list.py +1 -3
- reflex/components/chakra/datadisplay/list.pyi +3 -3
- reflex/components/chakra/disclosure/accordion.py +1 -1
- reflex/components/chakra/forms/pininput.pyi +1 -1
- reflex/components/chakra/media/icon.py +2 -2
- reflex/components/component.py +279 -32
- reflex/components/core/__init__.py +2 -2
- reflex/components/core/cond.py +1 -10
- reflex/components/core/debounce.py +5 -2
- reflex/components/core/debounce.pyi +4 -2
- reflex/components/core/foreach.py +1 -16
- reflex/components/core/html.py +6 -0
- reflex/components/core/match.py +2 -17
- reflex/components/core/upload.py +42 -1
- reflex/components/core/upload.pyi +199 -1
- reflex/components/datadisplay/code.py +7 -3
- reflex/components/datadisplay/code.pyi +3 -1
- reflex/components/el/elements/forms.py +1 -1
- reflex/components/el/elements/forms.pyi +1 -1
- reflex/components/lucide/icon.py +5 -13
- reflex/components/lucide/icon.pyi +0 -1
- reflex/components/markdown/markdown.py +5 -23
- reflex/components/markdown/markdown.pyi +1 -4
- reflex/components/radix/primitives/accordion.py +227 -406
- reflex/components/radix/primitives/accordion.pyi +369 -28
- reflex/components/radix/primitives/form.py +33 -29
- reflex/components/radix/primitives/form.pyi +7 -2
- reflex/components/radix/primitives/progress.py +17 -9
- reflex/components/radix/primitives/progress.pyi +2 -0
- reflex/components/radix/primitives/slider.py +30 -18
- reflex/components/radix/primitives/slider.pyi +4 -0
- reflex/components/radix/themes/base.py +8 -1
- reflex/components/radix/themes/base.pyi +79 -1
- reflex/components/radix/themes/color_mode.py +74 -30
- reflex/components/radix/themes/color_mode.pyi +26 -185
- reflex/components/radix/themes/components/__init__.py +17 -0
- reflex/components/radix/themes/components/badge.py +2 -1
- reflex/components/radix/themes/components/badge.pyi +3 -1
- reflex/components/radix/themes/components/button.py +3 -1
- reflex/components/radix/themes/components/button.pyi +4 -1
- reflex/components/radix/themes/components/checkbox_cards.py +48 -0
- reflex/components/radix/themes/components/checkbox_cards.pyi +264 -0
- reflex/components/radix/themes/components/checkbox_group.py +42 -0
- reflex/components/radix/themes/components/checkbox_group.pyi +253 -0
- reflex/components/radix/themes/components/data_list.py +63 -0
- reflex/components/radix/themes/components/data_list.pyi +426 -0
- reflex/components/radix/themes/components/icon_button.py +20 -17
- reflex/components/radix/themes/components/icon_button.pyi +5 -1
- reflex/components/radix/themes/components/progress.py +55 -0
- reflex/components/radix/themes/components/progress.pyi +180 -0
- reflex/components/radix/themes/components/radio.py +31 -0
- reflex/components/radix/themes/components/radio.pyi +169 -0
- reflex/components/radix/themes/components/radio_cards.py +48 -0
- reflex/components/radix/themes/components/radio_cards.pyi +264 -0
- reflex/components/radix/themes/components/radio_group.py +2 -4
- reflex/components/radix/themes/components/segmented_control.py +48 -0
- reflex/components/radix/themes/components/segmented_control.pyi +262 -0
- reflex/components/radix/themes/components/skeleton.py +32 -0
- reflex/components/radix/themes/components/skeleton.pyi +106 -0
- reflex/components/radix/themes/components/spinner.py +26 -0
- reflex/components/radix/themes/components/spinner.pyi +101 -0
- reflex/components/radix/themes/components/tabs.py +26 -1
- reflex/components/radix/themes/components/tabs.pyi +69 -9
- reflex/components/radix/themes/components/text_field.py +101 -71
- reflex/components/radix/themes/components/text_field.pyi +81 -499
- reflex/components/radix/themes/layout/base.py +2 -2
- reflex/components/radix/themes/layout/base.pyi +4 -4
- reflex/components/radix/themes/layout/center.py +8 -3
- reflex/components/radix/themes/layout/center.pyi +2 -1
- reflex/components/radix/themes/layout/container.py +30 -2
- reflex/components/radix/themes/layout/container.pyi +9 -30
- reflex/components/radix/themes/layout/list.py +10 -5
- reflex/components/radix/themes/layout/list.pyi +5 -21
- reflex/components/radix/themes/layout/spacer.py +8 -3
- reflex/components/radix/themes/layout/spacer.pyi +2 -1
- reflex/components/radix/themes/layout/stack.py +7 -1
- reflex/components/radix/themes/layout/stack.pyi +3 -3
- reflex/components/radix/themes/typography/link.py +10 -2
- reflex/components/radix/themes/typography/link.pyi +5 -4
- reflex/components/sonner/__init__.py +3 -0
- reflex/components/sonner/toast.py +267 -0
- reflex/components/sonner/toast.pyi +205 -0
- reflex/components/tags/iter_tag.py +9 -6
- reflex/config.py +30 -54
- reflex/constants/__init__.py +0 -2
- reflex/constants/base.py +0 -5
- reflex/constants/colors.py +2 -0
- reflex/constants/installer.py +5 -1
- reflex/constants/route.py +4 -0
- reflex/custom_components/custom_components.py +22 -1
- reflex/event.py +75 -30
- reflex/experimental/__init__.py +5 -0
- reflex/experimental/layout.py +24 -6
- reflex/model.py +2 -1
- reflex/page.py +7 -4
- reflex/reflex.py +8 -3
- reflex/route.py +39 -0
- reflex/state.py +128 -131
- reflex/style.py +20 -1
- reflex/testing.py +10 -6
- reflex/utils/console.py +3 -1
- reflex/utils/exec.py +20 -7
- reflex/utils/format.py +1 -1
- reflex/utils/imports.py +3 -1
- reflex/utils/prerequisites.py +141 -20
- reflex/utils/processes.py +21 -1
- reflex/utils/pyi_generator.py +95 -5
- reflex/utils/serializers.py +1 -1
- reflex/utils/telemetry.py +26 -4
- reflex/utils/types.py +62 -18
- reflex/vars.py +11 -5
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/METADATA +16 -4
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/RECORD +130 -108
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/WHEEL +1 -1
- reflex/app.pyi +0 -149
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/LICENSE +0 -0
- {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
|
|
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:
|
|
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:
|
|
327
|
+
**props: The properties of the component.
|
|
268
328
|
|
|
269
329
|
Returns:
|
|
270
|
-
|
|
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[
|
|
52
|
+
max_length: Var[int]
|
|
111
53
|
|
|
112
54
|
# Specifies the minimum number of characters required in the input
|
|
113
|
-
min_length: Var[
|
|
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
|
-
|
|
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.
|
|
165
|
-
input = staticmethod(
|
|
194
|
+
root = staticmethod(TextFieldRoot.create_root_deprecated)
|
|
195
|
+
input = staticmethod(TextFieldRoot.create_input_deprecated)
|
|
166
196
|
slot = staticmethod(TextFieldSlot.create)
|
|
167
|
-
__call__ = staticmethod(
|
|
197
|
+
__call__ = staticmethod(TextFieldRoot.create)
|
|
168
198
|
|
|
169
199
|
|
|
170
200
|
text_field = TextField()
|