reflex 0.4.9a1__py3-none-any.whl → 0.5.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.
- reflex/.templates/apps/blank/code/blank.py +19 -16
- reflex/.templates/apps/demo/code/demo.py +1 -1
- reflex/.templates/apps/demo/code/pages/datatable.py +4 -4
- reflex/.templates/apps/demo/code/pages/forms.py +2 -2
- reflex/.templates/jinja/web/tailwind.config.js.jinja2 +12 -0
- 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 +160 -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 +275 -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 +60 -49
- 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 +265 -410
- reflex/components/radix/primitives/accordion.pyi +390 -36
- 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 +88 -20
- reflex/components/radix/themes/color_mode.pyi +157 -139
- 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 +6 -1
- reflex/constants/route.py +4 -0
- reflex/custom_components/custom_components.py +24 -2
- 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 +25 -3
- 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 +100 -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.9a1.dist-info → reflex-0.5.0.dist-info}/METADATA +16 -4
- {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/RECORD +132 -110
- {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/WHEEL +1 -1
- reflex/app.pyi +0 -149
- {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/LICENSE +0 -0
- {reflex-0.4.9a1.dist-info → reflex-0.5.0.dist-info}/entry_points.txt +0 -0
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
import inspect
|
|
5
|
-
from
|
|
6
|
-
from typing import Any, Callable, Iterable, Optional
|
|
5
|
+
from typing import Any, Callable, Iterable
|
|
7
6
|
|
|
8
7
|
from reflex.components.base.fragment import Fragment
|
|
9
8
|
from reflex.components.component import Component
|
|
10
9
|
from reflex.components.tags import IterTag
|
|
11
10
|
from reflex.constants import MemoizationMode
|
|
11
|
+
from reflex.utils import console
|
|
12
12
|
from reflex.vars import Var
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
class ForeachVarError(TypeError):
|
|
16
|
+
"""Raised when the iterable type is Any."""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ForeachRenderError(TypeError):
|
|
20
|
+
"""Raised when there is an error with the foreach render function."""
|
|
21
|
+
|
|
22
|
+
|
|
15
23
|
class Foreach(Component):
|
|
16
24
|
"""A component that takes in an iterable and a render function and renders a list of components."""
|
|
17
25
|
|
|
@@ -23,68 +31,85 @@ class Foreach(Component):
|
|
|
23
31
|
# A function from the render args to the component.
|
|
24
32
|
render_fn: Callable = Fragment.create
|
|
25
33
|
|
|
26
|
-
# The theme if set.
|
|
27
|
-
theme: Optional[Component] = None
|
|
28
|
-
|
|
29
|
-
def _apply_theme(self, theme: Component):
|
|
30
|
-
"""Apply the theme to this component.
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
theme: The theme to apply.
|
|
34
|
-
"""
|
|
35
|
-
self.theme = theme
|
|
36
|
-
|
|
37
34
|
@classmethod
|
|
38
|
-
def create(
|
|
35
|
+
def create(
|
|
36
|
+
cls,
|
|
37
|
+
iterable: Var[Iterable] | Iterable,
|
|
38
|
+
render_fn: Callable,
|
|
39
|
+
**props,
|
|
40
|
+
) -> Foreach:
|
|
39
41
|
"""Create a foreach component.
|
|
40
42
|
|
|
41
43
|
Args:
|
|
42
44
|
iterable: The iterable to create components from.
|
|
43
45
|
render_fn: A function from the render args to the component.
|
|
44
|
-
**props: The attributes to pass to each child component.
|
|
46
|
+
**props: The attributes to pass to each child component (deprecated).
|
|
45
47
|
|
|
46
48
|
Returns:
|
|
47
49
|
The foreach component.
|
|
48
50
|
|
|
49
51
|
Raises:
|
|
50
|
-
|
|
52
|
+
ForeachVarError: If the iterable is of type Any.
|
|
51
53
|
"""
|
|
52
|
-
|
|
54
|
+
if props:
|
|
55
|
+
console.deprecate(
|
|
56
|
+
feature_name="Passing props to rx.foreach",
|
|
57
|
+
reason="it does not have the intended effect and may be confusing",
|
|
58
|
+
deprecation_version="0.5.0",
|
|
59
|
+
removal_version="0.6.0",
|
|
60
|
+
)
|
|
61
|
+
iterable = Var.create_safe(iterable)
|
|
53
62
|
if iterable._var_type == Any:
|
|
54
|
-
raise
|
|
55
|
-
f"Could not foreach over var of type Any.
|
|
63
|
+
raise ForeachVarError(
|
|
64
|
+
f"Could not foreach over var `{iterable._var_full_name}` of type Any. "
|
|
65
|
+
"(If you are trying to foreach over a state var, add a type annotation to the var). "
|
|
66
|
+
"See https://reflex.dev/docs/library/layout/foreach/"
|
|
56
67
|
)
|
|
57
68
|
component = cls(
|
|
58
69
|
iterable=iterable,
|
|
59
70
|
render_fn=render_fn,
|
|
60
|
-
**props,
|
|
61
71
|
)
|
|
62
|
-
# Keep a ref to a rendered component to determine correct imports.
|
|
63
|
-
component.children = [
|
|
64
|
-
component._render(props=dict(index_var_name="i")).render_component()
|
|
65
|
-
]
|
|
72
|
+
# Keep a ref to a rendered component to determine correct imports/hooks/styles.
|
|
73
|
+
component.children = [component._render().render_component()]
|
|
66
74
|
return component
|
|
67
75
|
|
|
68
|
-
def _render(self
|
|
69
|
-
props = {}
|
|
76
|
+
def _render(self) -> IterTag:
|
|
77
|
+
props = {}
|
|
70
78
|
|
|
71
|
-
# Determine the arg var name based on the params accepted by render_fn.
|
|
72
79
|
render_sig = inspect.signature(self.render_fn)
|
|
73
80
|
params = list(render_sig.parameters.values())
|
|
81
|
+
|
|
82
|
+
# Validate the render function signature.
|
|
83
|
+
if len(params) == 0 or len(params) > 2:
|
|
84
|
+
raise ForeachRenderError(
|
|
85
|
+
"Expected 1 or 2 parameters in foreach render function, got "
|
|
86
|
+
f"{[p.name for p in params]}. See https://reflex.dev/docs/library/layout/foreach/"
|
|
87
|
+
)
|
|
88
|
+
|
|
74
89
|
if len(params) >= 1:
|
|
75
|
-
|
|
90
|
+
# Determine the arg var name based on the params accepted by render_fn.
|
|
91
|
+
props["arg_var_name"] = params[0].name
|
|
76
92
|
|
|
77
|
-
if len(params)
|
|
93
|
+
if len(params) == 2:
|
|
78
94
|
# Determine the index var name based on the params accepted by render_fn.
|
|
79
|
-
props
|
|
80
|
-
|
|
81
|
-
# Otherwise, use a deterministic index, based on the
|
|
82
|
-
code_hash =
|
|
83
|
-
|
|
95
|
+
props["index_var_name"] = params[1].name
|
|
96
|
+
else:
|
|
97
|
+
# Otherwise, use a deterministic index, based on the render function bytecode.
|
|
98
|
+
code_hash = (
|
|
99
|
+
hash(self.render_fn.__code__)
|
|
100
|
+
.to_bytes(
|
|
101
|
+
length=8,
|
|
102
|
+
byteorder="big",
|
|
103
|
+
signed=True,
|
|
104
|
+
)
|
|
105
|
+
.hex()
|
|
106
|
+
)
|
|
107
|
+
props["index_var_name"] = f"index_{code_hash}"
|
|
84
108
|
|
|
85
109
|
return IterTag(
|
|
86
110
|
iterable=self.iterable,
|
|
87
111
|
render_fn=self.render_fn,
|
|
112
|
+
children=self.children,
|
|
88
113
|
**props,
|
|
89
114
|
)
|
|
90
115
|
|
|
@@ -95,23 +120,9 @@ class Foreach(Component):
|
|
|
95
120
|
The dictionary for template of component.
|
|
96
121
|
"""
|
|
97
122
|
tag = self._render()
|
|
98
|
-
component = tag.render_component()
|
|
99
|
-
|
|
100
|
-
# Apply the theme to the children.
|
|
101
|
-
if self.theme is not None:
|
|
102
|
-
component.apply_theme(self.theme)
|
|
103
123
|
|
|
104
124
|
return dict(
|
|
105
|
-
tag
|
|
106
|
-
**self.event_triggers,
|
|
107
|
-
key=self.key,
|
|
108
|
-
sx=self.style,
|
|
109
|
-
id=self.id,
|
|
110
|
-
class_name=self.class_name,
|
|
111
|
-
).set(
|
|
112
|
-
children=[component.render()],
|
|
113
|
-
props=tag.format_props(),
|
|
114
|
-
),
|
|
125
|
+
tag,
|
|
115
126
|
iterable_state=tag.iterable._var_full_name,
|
|
116
127
|
arg_name=tag.arg_var_name,
|
|
117
128
|
arg_index=tag.get_index_var_arg(),
|
reflex/components/core/html.py
CHANGED
|
@@ -35,5 +35,11 @@ class Html(Div):
|
|
|
35
35
|
else:
|
|
36
36
|
props["dangerouslySetInnerHTML"] = {"__html": children[0]}
|
|
37
37
|
|
|
38
|
+
# Apply the default classname
|
|
39
|
+
given_class_name = props.pop("class_name", [])
|
|
40
|
+
if isinstance(given_class_name, str):
|
|
41
|
+
given_class_name = [given_class_name]
|
|
42
|
+
props["class_name"] = ["rx-Html", *given_class_name]
|
|
43
|
+
|
|
38
44
|
# Create the component.
|
|
39
45
|
return super().create(**props)
|
reflex/components/core/match.py
CHANGED
|
@@ -67,7 +67,7 @@ class Match(MemoizationLeaf):
|
|
|
67
67
|
Raises:
|
|
68
68
|
ValueError: If the condition is not provided.
|
|
69
69
|
"""
|
|
70
|
-
match_cond_var = Var.create(cond, _var_is_string=
|
|
70
|
+
match_cond_var = Var.create(cond, _var_is_string=isinstance(cond, str))
|
|
71
71
|
|
|
72
72
|
if match_cond_var is None:
|
|
73
73
|
raise ValueError("The condition must be set")
|
|
@@ -119,7 +119,7 @@ class Match(MemoizationLeaf):
|
|
|
119
119
|
_var_data = case_element._var_data if isinstance(case_element, Style) else None # type: ignore
|
|
120
120
|
case_element = Var.create(
|
|
121
121
|
case_element,
|
|
122
|
-
_var_is_string=
|
|
122
|
+
_var_is_string=isinstance(case_element, (str, Color)),
|
|
123
123
|
)
|
|
124
124
|
if _var_data is not None:
|
|
125
125
|
case_element._var_data = VarData.merge(case_element._var_data, _var_data) # type: ignore
|
|
@@ -273,18 +273,3 @@ class Match(MemoizationLeaf):
|
|
|
273
273
|
super()._get_imports(),
|
|
274
274
|
getattr(self.cond._var_data, "imports", {}),
|
|
275
275
|
)
|
|
276
|
-
|
|
277
|
-
def _apply_theme(self, theme: Component):
|
|
278
|
-
"""Apply the theme to this component.
|
|
279
|
-
|
|
280
|
-
Args:
|
|
281
|
-
theme: The theme to apply.
|
|
282
|
-
"""
|
|
283
|
-
# apply theme to return components.
|
|
284
|
-
for match_case in self.match_cases:
|
|
285
|
-
if isinstance(match_case[-1], Component):
|
|
286
|
-
match_case[-1].apply_theme(theme)
|
|
287
|
-
|
|
288
|
-
# apply theme to default component
|
|
289
|
-
if isinstance(self.default, Component):
|
|
290
|
-
self.default.apply_theme(theme)
|
reflex/components/core/upload.py
CHANGED
|
@@ -9,7 +9,7 @@ from typing import Any, Callable, ClassVar, Dict, List, Optional, Union
|
|
|
9
9
|
from reflex import constants
|
|
10
10
|
from reflex.components.chakra.forms.input import Input
|
|
11
11
|
from reflex.components.chakra.layout.box import Box
|
|
12
|
-
from reflex.components.component import Component, MemoizationLeaf
|
|
12
|
+
from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
|
|
13
13
|
from reflex.constants import Dirs
|
|
14
14
|
from reflex.event import (
|
|
15
15
|
CallableEventSpec,
|
|
@@ -219,6 +219,12 @@ class Upload(MemoizationLeaf):
|
|
|
219
219
|
# Mark the Upload component as used in the app.
|
|
220
220
|
cls.is_used = True
|
|
221
221
|
|
|
222
|
+
# Apply the default classname
|
|
223
|
+
given_class_name = props.pop("class_name", [])
|
|
224
|
+
if isinstance(given_class_name, str):
|
|
225
|
+
given_class_name = [given_class_name]
|
|
226
|
+
props["class_name"] = ["rx-Upload", *given_class_name]
|
|
227
|
+
|
|
222
228
|
# get only upload component props
|
|
223
229
|
supported_props = cls.get_props().union({"on_drop"})
|
|
224
230
|
upload_props = {
|
|
@@ -299,3 +305,38 @@ class Upload(MemoizationLeaf):
|
|
|
299
305
|
return {
|
|
300
306
|
(5, "UploadFilesProvider"): UploadFilesProvider.create(),
|
|
301
307
|
}
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
class StyledUpload(Upload):
|
|
311
|
+
"""The styled Upload Component."""
|
|
312
|
+
|
|
313
|
+
@classmethod
|
|
314
|
+
def create(cls, *children, **props) -> Component:
|
|
315
|
+
"""Create the styled upload component.
|
|
316
|
+
|
|
317
|
+
Args:
|
|
318
|
+
*children: The children of the component.
|
|
319
|
+
**props: The properties of the component.
|
|
320
|
+
|
|
321
|
+
Returns:
|
|
322
|
+
The styled upload component.
|
|
323
|
+
"""
|
|
324
|
+
# Set default props.
|
|
325
|
+
props.setdefault("border", "1px dashed var(--accent-12)")
|
|
326
|
+
props.setdefault("padding", "5em")
|
|
327
|
+
props.setdefault("textAlign", "center")
|
|
328
|
+
|
|
329
|
+
# Mark the Upload component as used in the app.
|
|
330
|
+
Upload.is_used = True
|
|
331
|
+
|
|
332
|
+
return super().create(
|
|
333
|
+
*children,
|
|
334
|
+
**props,
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
class UploadNamespace(ComponentNamespace):
|
|
339
|
+
"""Upload component namespace."""
|
|
340
|
+
|
|
341
|
+
root = Upload.create
|
|
342
|
+
__call__ = StyledUpload.create
|
|
@@ -13,7 +13,7 @@ from typing import Any, Callable, ClassVar, Dict, List, Optional, Union
|
|
|
13
13
|
from reflex import constants
|
|
14
14
|
from reflex.components.chakra.forms.input import Input
|
|
15
15
|
from reflex.components.chakra.layout.box import Box
|
|
16
|
-
from reflex.components.component import Component, MemoizationLeaf
|
|
16
|
+
from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
|
|
17
17
|
from reflex.constants import Dirs
|
|
18
18
|
from reflex.event import (
|
|
19
19
|
CallableEventSpec,
|
|
@@ -219,3 +219,201 @@ class Upload(MemoizationLeaf):
|
|
|
219
219
|
"""
|
|
220
220
|
...
|
|
221
221
|
def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ...
|
|
222
|
+
|
|
223
|
+
class StyledUpload(Upload):
|
|
224
|
+
@overload
|
|
225
|
+
@classmethod
|
|
226
|
+
def create( # type: ignore
|
|
227
|
+
cls,
|
|
228
|
+
*children,
|
|
229
|
+
accept: Optional[
|
|
230
|
+
Union[Var[Optional[Dict[str, List]]], Optional[Dict[str, List]]]
|
|
231
|
+
] = None,
|
|
232
|
+
disabled: Optional[Union[Var[bool], bool]] = None,
|
|
233
|
+
max_files: Optional[Union[Var[int], int]] = None,
|
|
234
|
+
max_size: Optional[Union[Var[int], int]] = None,
|
|
235
|
+
min_size: Optional[Union[Var[int], int]] = None,
|
|
236
|
+
multiple: Optional[Union[Var[bool], bool]] = None,
|
|
237
|
+
no_click: Optional[Union[Var[bool], bool]] = None,
|
|
238
|
+
no_drag: Optional[Union[Var[bool], bool]] = None,
|
|
239
|
+
no_keyboard: Optional[Union[Var[bool], bool]] = None,
|
|
240
|
+
style: Optional[Style] = None,
|
|
241
|
+
key: Optional[Any] = None,
|
|
242
|
+
id: Optional[Any] = None,
|
|
243
|
+
class_name: Optional[Any] = None,
|
|
244
|
+
autofocus: Optional[bool] = None,
|
|
245
|
+
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
|
|
246
|
+
on_blur: Optional[
|
|
247
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
248
|
+
] = None,
|
|
249
|
+
on_click: Optional[
|
|
250
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
251
|
+
] = None,
|
|
252
|
+
on_context_menu: Optional[
|
|
253
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
254
|
+
] = None,
|
|
255
|
+
on_double_click: Optional[
|
|
256
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
257
|
+
] = None,
|
|
258
|
+
on_drop: Optional[
|
|
259
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
260
|
+
] = None,
|
|
261
|
+
on_focus: Optional[
|
|
262
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
263
|
+
] = None,
|
|
264
|
+
on_mount: Optional[
|
|
265
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
266
|
+
] = None,
|
|
267
|
+
on_mouse_down: Optional[
|
|
268
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
269
|
+
] = None,
|
|
270
|
+
on_mouse_enter: Optional[
|
|
271
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
272
|
+
] = None,
|
|
273
|
+
on_mouse_leave: Optional[
|
|
274
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
275
|
+
] = None,
|
|
276
|
+
on_mouse_move: Optional[
|
|
277
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
278
|
+
] = None,
|
|
279
|
+
on_mouse_out: Optional[
|
|
280
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
281
|
+
] = None,
|
|
282
|
+
on_mouse_over: Optional[
|
|
283
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
284
|
+
] = None,
|
|
285
|
+
on_mouse_up: Optional[
|
|
286
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
287
|
+
] = None,
|
|
288
|
+
on_scroll: Optional[
|
|
289
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
290
|
+
] = None,
|
|
291
|
+
on_unmount: Optional[
|
|
292
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
293
|
+
] = None,
|
|
294
|
+
**props
|
|
295
|
+
) -> "StyledUpload":
|
|
296
|
+
"""Create the styled upload component.
|
|
297
|
+
|
|
298
|
+
Args:
|
|
299
|
+
*children: The children of the component.
|
|
300
|
+
accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
|
301
|
+
disabled: Whether the dropzone is disabled.
|
|
302
|
+
max_files: The maximum number of files that can be uploaded.
|
|
303
|
+
max_size: The maximum file size (bytes) that can be uploaded.
|
|
304
|
+
min_size: The minimum file size (bytes) that can be uploaded.
|
|
305
|
+
multiple: Whether to allow multiple files to be uploaded.
|
|
306
|
+
no_click: Whether to disable click to upload.
|
|
307
|
+
no_drag: Whether to disable drag and drop.
|
|
308
|
+
no_keyboard: Whether to disable using the space/enter keys to upload.
|
|
309
|
+
style: The style of the component.
|
|
310
|
+
key: A unique key for the component.
|
|
311
|
+
id: The id for the component.
|
|
312
|
+
class_name: The class name for the component.
|
|
313
|
+
autofocus: Whether the component should take the focus once the page is loaded
|
|
314
|
+
custom_attrs: custom attribute
|
|
315
|
+
**props: The properties of the component.
|
|
316
|
+
|
|
317
|
+
Returns:
|
|
318
|
+
The styled upload component.
|
|
319
|
+
"""
|
|
320
|
+
...
|
|
321
|
+
|
|
322
|
+
class UploadNamespace(ComponentNamespace):
|
|
323
|
+
root = Upload.create
|
|
324
|
+
|
|
325
|
+
@staticmethod
|
|
326
|
+
def __call__(
|
|
327
|
+
*children,
|
|
328
|
+
accept: Optional[
|
|
329
|
+
Union[Var[Optional[Dict[str, List]]], Optional[Dict[str, List]]]
|
|
330
|
+
] = None,
|
|
331
|
+
disabled: Optional[Union[Var[bool], bool]] = None,
|
|
332
|
+
max_files: Optional[Union[Var[int], int]] = None,
|
|
333
|
+
max_size: Optional[Union[Var[int], int]] = None,
|
|
334
|
+
min_size: Optional[Union[Var[int], int]] = None,
|
|
335
|
+
multiple: Optional[Union[Var[bool], bool]] = None,
|
|
336
|
+
no_click: Optional[Union[Var[bool], bool]] = None,
|
|
337
|
+
no_drag: Optional[Union[Var[bool], bool]] = None,
|
|
338
|
+
no_keyboard: Optional[Union[Var[bool], bool]] = None,
|
|
339
|
+
style: Optional[Style] = None,
|
|
340
|
+
key: Optional[Any] = None,
|
|
341
|
+
id: Optional[Any] = None,
|
|
342
|
+
class_name: Optional[Any] = None,
|
|
343
|
+
autofocus: Optional[bool] = None,
|
|
344
|
+
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
|
|
345
|
+
on_blur: Optional[
|
|
346
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
347
|
+
] = None,
|
|
348
|
+
on_click: Optional[
|
|
349
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
350
|
+
] = None,
|
|
351
|
+
on_context_menu: Optional[
|
|
352
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
353
|
+
] = None,
|
|
354
|
+
on_double_click: Optional[
|
|
355
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
356
|
+
] = None,
|
|
357
|
+
on_drop: Optional[
|
|
358
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
359
|
+
] = None,
|
|
360
|
+
on_focus: Optional[
|
|
361
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
362
|
+
] = None,
|
|
363
|
+
on_mount: Optional[
|
|
364
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
365
|
+
] = None,
|
|
366
|
+
on_mouse_down: Optional[
|
|
367
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
368
|
+
] = None,
|
|
369
|
+
on_mouse_enter: Optional[
|
|
370
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
371
|
+
] = None,
|
|
372
|
+
on_mouse_leave: Optional[
|
|
373
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
374
|
+
] = None,
|
|
375
|
+
on_mouse_move: Optional[
|
|
376
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
377
|
+
] = None,
|
|
378
|
+
on_mouse_out: Optional[
|
|
379
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
380
|
+
] = None,
|
|
381
|
+
on_mouse_over: Optional[
|
|
382
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
383
|
+
] = None,
|
|
384
|
+
on_mouse_up: Optional[
|
|
385
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
386
|
+
] = None,
|
|
387
|
+
on_scroll: Optional[
|
|
388
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
389
|
+
] = None,
|
|
390
|
+
on_unmount: Optional[
|
|
391
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
392
|
+
] = None,
|
|
393
|
+
**props
|
|
394
|
+
) -> "StyledUpload":
|
|
395
|
+
"""Create the styled upload component.
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
*children: The children of the component.
|
|
399
|
+
accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
|
400
|
+
disabled: Whether the dropzone is disabled.
|
|
401
|
+
max_files: The maximum number of files that can be uploaded.
|
|
402
|
+
max_size: The maximum file size (bytes) that can be uploaded.
|
|
403
|
+
min_size: The minimum file size (bytes) that can be uploaded.
|
|
404
|
+
multiple: Whether to allow multiple files to be uploaded.
|
|
405
|
+
no_click: Whether to disable click to upload.
|
|
406
|
+
no_drag: Whether to disable drag and drop.
|
|
407
|
+
no_keyboard: Whether to disable using the space/enter keys to upload.
|
|
408
|
+
style: The style of the component.
|
|
409
|
+
key: A unique key for the component.
|
|
410
|
+
id: The id for the component.
|
|
411
|
+
class_name: The class name for the component.
|
|
412
|
+
autofocus: Whether the component should take the focus once the page is loaded
|
|
413
|
+
custom_attrs: custom attribute
|
|
414
|
+
**props: The properties of the component.
|
|
415
|
+
|
|
416
|
+
Returns:
|
|
417
|
+
The styled upload component.
|
|
418
|
+
"""
|
|
419
|
+
...
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"""A code component."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
2
4
|
import re
|
|
3
5
|
from typing import Dict, Literal, Optional, Union
|
|
4
6
|
|
|
@@ -7,6 +9,7 @@ from reflex.components.chakra.layout import Box
|
|
|
7
9
|
from reflex.components.chakra.media import Icon
|
|
8
10
|
from reflex.components.component import Component
|
|
9
11
|
from reflex.components.core.cond import color_mode_cond
|
|
12
|
+
from reflex.constants.colors import Color
|
|
10
13
|
from reflex.event import set_clipboard
|
|
11
14
|
from reflex.style import Style
|
|
12
15
|
from reflex.utils import format, imports
|
|
@@ -373,7 +376,7 @@ class CodeBlock(Component):
|
|
|
373
376
|
wrap_long_lines: Var[bool]
|
|
374
377
|
|
|
375
378
|
# A custom style for the code block.
|
|
376
|
-
custom_style: Dict[str, str] = {}
|
|
379
|
+
custom_style: Dict[str, Union[str, Var, Color]] = {}
|
|
377
380
|
|
|
378
381
|
# Props passed down to the code tag.
|
|
379
382
|
code_tag_props: Var[Dict[str, str]]
|
|
@@ -490,8 +493,9 @@ class CodeBlock(Component):
|
|
|
490
493
|
else:
|
|
491
494
|
return code_block
|
|
492
495
|
|
|
493
|
-
def
|
|
494
|
-
|
|
496
|
+
def add_style(self) -> Style | None:
|
|
497
|
+
"""Add style to the component."""
|
|
498
|
+
self.custom_style.update(self.style)
|
|
495
499
|
|
|
496
500
|
def _render(self):
|
|
497
501
|
out = super()._render()
|
|
@@ -14,6 +14,7 @@ from reflex.components.chakra.layout import Box
|
|
|
14
14
|
from reflex.components.chakra.media import Icon
|
|
15
15
|
from reflex.components.component import Component
|
|
16
16
|
from reflex.components.core.cond import color_mode_cond
|
|
17
|
+
from reflex.constants.colors import Color
|
|
17
18
|
from reflex.event import set_clipboard
|
|
18
19
|
from reflex.style import Style
|
|
19
20
|
from reflex.utils import format, imports
|
|
@@ -1029,7 +1030,7 @@ class CodeBlock(Component):
|
|
|
1029
1030
|
show_line_numbers: Optional[Union[Var[bool], bool]] = None,
|
|
1030
1031
|
starting_line_number: Optional[Union[Var[int], int]] = None,
|
|
1031
1032
|
wrap_long_lines: Optional[Union[Var[bool], bool]] = None,
|
|
1032
|
-
custom_style: Optional[Dict[str, str]] = None,
|
|
1033
|
+
custom_style: Optional[Dict[str, Union[str, Var, Color]]] = None,
|
|
1033
1034
|
code_tag_props: Optional[Union[Var[Dict[str, str]], Dict[str, str]]] = None,
|
|
1034
1035
|
style: Optional[Style] = None,
|
|
1035
1036
|
key: Optional[Any] = None,
|
|
@@ -1110,5 +1111,6 @@ class CodeBlock(Component):
|
|
|
1110
1111
|
The text component.
|
|
1111
1112
|
"""
|
|
1112
1113
|
...
|
|
1114
|
+
def add_style(self) -> Style | None: ...
|
|
1113
1115
|
@staticmethod
|
|
1114
1116
|
def convert_theme_name(theme) -> str: ...
|
|
@@ -338,7 +338,7 @@ class Input(BaseHTML):
|
|
|
338
338
|
use_map: Var[Union[str, int, bool]]
|
|
339
339
|
|
|
340
340
|
# Value of the input
|
|
341
|
-
value: Var[Union[str, int,
|
|
341
|
+
value: Var[Union[str, int, float]]
|
|
342
342
|
|
|
343
343
|
def get_event_triggers(self) -> Dict[str, Any]:
|
|
344
344
|
"""Get the event triggers that pass the component's value to the handler.
|
|
@@ -662,7 +662,7 @@ class Input(BaseHTML):
|
|
|
662
662
|
Union[Var[Union[str, int, bool]], Union[str, int, bool]]
|
|
663
663
|
] = None,
|
|
664
664
|
value: Optional[
|
|
665
|
-
Union[Var[Union[str, int,
|
|
665
|
+
Union[Var[Union[str, int, float]], Union[str, int, float]]
|
|
666
666
|
] = None,
|
|
667
667
|
access_key: Optional[
|
|
668
668
|
Union[Var[Union[str, int, bool]], Union[str, int, bool]]
|
reflex/components/lucide/icon.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Lucide Icon component."""
|
|
2
2
|
|
|
3
3
|
from reflex.components.component import Component
|
|
4
|
-
from reflex.style import Style
|
|
5
4
|
from reflex.utils import console, format
|
|
6
5
|
from reflex.vars import Var
|
|
7
6
|
|
|
@@ -45,24 +44,24 @@ class Icon(LucideIconComponent):
|
|
|
45
44
|
feature_name=f"icon {tag}",
|
|
46
45
|
reason=f"it was renamed upstream. Use {new_tag} instead.",
|
|
47
46
|
deprecation_version="0.4.6",
|
|
48
|
-
removal_version="0.
|
|
47
|
+
removal_version="0.6.0",
|
|
49
48
|
)
|
|
50
49
|
return new_tag
|
|
51
50
|
return tag
|
|
52
51
|
|
|
53
52
|
if children:
|
|
54
|
-
if len(children) == 1 and
|
|
53
|
+
if len(children) == 1 and isinstance(children[0], str):
|
|
55
54
|
props["tag"] = children[0]
|
|
56
55
|
children = []
|
|
57
56
|
else:
|
|
58
57
|
raise AttributeError(
|
|
59
58
|
f"Passing multiple children to Icon component is not allowed: remove positional arguments {children[1:]} to fix"
|
|
60
59
|
)
|
|
61
|
-
if "tag" not in props
|
|
60
|
+
if "tag" not in props:
|
|
62
61
|
raise AttributeError("Missing 'tag' keyword-argument for Icon")
|
|
63
62
|
|
|
64
63
|
if (
|
|
65
|
-
|
|
64
|
+
not isinstance(props["tag"], str)
|
|
66
65
|
or map_deprecated_icon_names_05(format.to_snake_case(props["tag"]))
|
|
67
66
|
not in LUCIDE_ICON_LIST
|
|
68
67
|
):
|
|
@@ -73,16 +72,9 @@ class Icon(LucideIconComponent):
|
|
|
73
72
|
|
|
74
73
|
props["tag"] = format.to_title_case(format.to_snake_case(props["tag"])) + "Icon"
|
|
75
74
|
props["alias"] = f"Lucide{props['tag']}"
|
|
75
|
+
props.setdefault("color", f"var(--current-color)")
|
|
76
76
|
return super().create(*children, **props)
|
|
77
77
|
|
|
78
|
-
def _apply_theme(self, theme: Component):
|
|
79
|
-
self.style = Style(
|
|
80
|
-
{
|
|
81
|
-
"color": f"var(--current-color)",
|
|
82
|
-
**self.style,
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
|
|
86
78
|
|
|
87
79
|
RENAMED_ICONS_05 = {
|
|
88
80
|
"activity_square": "square_activity",
|
|
@@ -8,7 +8,6 @@ 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 reflex.components.component import Component
|
|
11
|
-
from reflex.style import Style
|
|
12
11
|
from reflex.utils import console, format
|
|
13
12
|
from reflex.vars import Var
|
|
14
13
|
|