reflex 0.7.0a5__py3-none-any.whl → 0.7.1a1__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/web/components/reflex/radix_themes_color_mode_provider.js +3 -1
- reflex/__init__.py +1 -0
- reflex/__init__.pyi +1 -0
- reflex/app.py +250 -67
- reflex/base.py +4 -10
- reflex/compiler/compiler.py +46 -12
- reflex/compiler/templates.py +1 -2
- reflex/compiler/utils.py +23 -14
- reflex/components/base/bare.py +109 -16
- reflex/components/component.py +179 -124
- reflex/components/core/__init__.py +1 -0
- reflex/components/core/__init__.pyi +1 -0
- reflex/components/core/auto_scroll.py +111 -0
- reflex/components/core/auto_scroll.pyi +284 -0
- reflex/components/core/banner.py +35 -5
- reflex/components/core/banner.pyi +398 -36
- reflex/components/core/breakpoints.py +1 -1
- reflex/components/core/cond.py +0 -8
- reflex/components/core/foreach.py +12 -2
- reflex/components/core/html.pyi +200 -19
- reflex/components/core/match.py +4 -4
- reflex/components/core/sticky.pyi +874 -90
- reflex/components/core/upload.py +3 -5
- reflex/components/core/upload.pyi +2 -4
- reflex/components/datadisplay/code.py +36 -10
- reflex/components/datadisplay/code.pyi +1 -1
- reflex/components/datadisplay/dataeditor.py +1 -3
- reflex/components/datadisplay/dataeditor.pyi +1 -3
- reflex/components/el/elements/base.py +95 -17
- reflex/components/el/elements/base.pyi +278 -19
- reflex/components/el/elements/forms.py +124 -102
- reflex/components/el/elements/forms.pyi +2787 -365
- reflex/components/el/elements/inline.py +24 -15
- reflex/components/el/elements/inline.pyi +5655 -546
- reflex/components/el/elements/media.py +79 -95
- reflex/components/el/elements/media.pyi +5167 -565
- reflex/components/el/elements/metadata.py +19 -17
- reflex/components/el/elements/metadata.pyi +841 -89
- reflex/components/el/elements/other.py +3 -5
- reflex/components/el/elements/other.pyi +1404 -137
- reflex/components/el/elements/scripts.py +10 -13
- reflex/components/el/elements/scripts.pyi +634 -65
- reflex/components/el/elements/sectioning.pyi +3001 -286
- reflex/components/el/elements/tables.py +14 -35
- reflex/components/el/elements/tables.pyi +2029 -218
- reflex/components/el/elements/typography.py +10 -13
- reflex/components/el/elements/typography.pyi +3014 -297
- reflex/components/lucide/icon.py +22 -6
- reflex/components/markdown/markdown.py +30 -10
- reflex/components/markdown/markdown.pyi +3 -2
- reflex/components/plotly/plotly.py +1 -3
- reflex/components/plotly/plotly.pyi +1 -3
- reflex/components/radix/primitives/form.pyi +624 -93
- reflex/components/radix/themes/color_mode.py +1 -1
- reflex/components/radix/themes/color_mode.pyi +213 -31
- reflex/components/radix/themes/components/alert_dialog.pyi +199 -18
- reflex/components/radix/themes/components/badge.pyi +199 -18
- reflex/components/radix/themes/components/button.pyi +213 -31
- reflex/components/radix/themes/components/callout.pyi +1000 -95
- reflex/components/radix/themes/components/card.pyi +199 -18
- reflex/components/radix/themes/components/context_menu.py +79 -1
- reflex/components/radix/themes/components/context_menu.pyi +320 -1
- reflex/components/radix/themes/components/dialog.pyi +199 -18
- reflex/components/radix/themes/components/hover_card.pyi +199 -18
- reflex/components/radix/themes/components/icon_button.pyi +213 -31
- reflex/components/radix/themes/components/inset.pyi +199 -18
- reflex/components/radix/themes/components/popover.pyi +199 -18
- reflex/components/radix/themes/components/table.pyi +1437 -154
- reflex/components/radix/themes/components/text_area.py +2 -2
- reflex/components/radix/themes/components/text_area.pyi +201 -20
- reflex/components/radix/themes/components/text_field.py +1 -1
- reflex/components/radix/themes/components/text_field.pyi +444 -88
- reflex/components/radix/themes/layout/box.pyi +200 -19
- reflex/components/radix/themes/layout/center.pyi +199 -18
- reflex/components/radix/themes/layout/container.pyi +199 -18
- reflex/components/radix/themes/layout/flex.pyi +199 -18
- reflex/components/radix/themes/layout/grid.pyi +199 -18
- reflex/components/radix/themes/layout/list.pyi +604 -57
- reflex/components/radix/themes/layout/section.pyi +199 -18
- reflex/components/radix/themes/layout/spacer.pyi +199 -18
- reflex/components/radix/themes/layout/stack.pyi +597 -54
- reflex/components/radix/themes/typography/blockquote.pyi +200 -19
- reflex/components/radix/themes/typography/code.pyi +199 -18
- reflex/components/radix/themes/typography/heading.pyi +199 -18
- reflex/components/radix/themes/typography/link.pyi +238 -28
- reflex/components/radix/themes/typography/text.pyi +1394 -127
- reflex/components/react_player/react_player.py +1 -1
- reflex/components/react_player/react_player.pyi +1 -3
- reflex/components/sonner/toast.py +19 -1
- reflex/components/sonner/toast.pyi +10 -1
- reflex/components/tags/iter_tag.py +4 -0
- reflex/components/tags/tag.py +3 -3
- reflex/config.py +187 -28
- reflex/constants/__init__.py +2 -0
- reflex/constants/base.py +6 -0
- reflex/constants/compiler.py +9 -0
- reflex/constants/event.py +1 -0
- reflex/constants/installer.py +4 -5
- reflex/constants/utils.py +1 -3
- reflex/event.py +7 -16
- reflex/experimental/layout.pyi +597 -54
- reflex/py.typed +0 -0
- reflex/reflex.py +30 -41
- reflex/state.py +49 -44
- reflex/style.py +6 -4
- reflex/testing.py +2 -0
- reflex/utils/build.py +12 -0
- reflex/utils/console.py +4 -0
- reflex/utils/decorator.py +25 -0
- reflex/utils/exec.py +92 -34
- reflex/utils/format.py +35 -6
- reflex/utils/path_ops.py +16 -1
- reflex/utils/prerequisites.py +34 -8
- reflex/utils/processes.py +12 -13
- reflex/utils/serializers.py +20 -43
- reflex/utils/telemetry.py +4 -15
- reflex/utils/types.py +36 -66
- reflex/vars/base.py +53 -76
- reflex/vars/function.py +17 -5
- reflex/vars/number.py +1 -1
- reflex/vars/sequence.py +80 -4
- {reflex-0.7.0a5.dist-info → reflex-0.7.1a1.dist-info}/METADATA +4 -5
- {reflex-0.7.0a5.dist-info → reflex-0.7.1a1.dist-info}/RECORD +126 -122
- {reflex-0.7.0a5.dist-info → reflex-0.7.1a1.dist-info}/LICENSE +0 -0
- {reflex-0.7.0a5.dist-info → reflex-0.7.1a1.dist-info}/WHEEL +0 -0
- {reflex-0.7.0a5.dist-info → reflex-0.7.1a1.dist-info}/entry_points.txt +0 -0
reflex/components/lucide/icon.py
CHANGED
|
@@ -4,7 +4,7 @@ from reflex.components.component import Component
|
|
|
4
4
|
from reflex.utils import format
|
|
5
5
|
from reflex.utils.imports import ImportVar
|
|
6
6
|
from reflex.vars.base import LiteralVar, Var
|
|
7
|
-
from reflex.vars.sequence import LiteralStringVar
|
|
7
|
+
from reflex.vars.sequence import LiteralStringVar, StringVar
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class LucideIconComponent(Component):
|
|
@@ -40,7 +40,12 @@ class Icon(LucideIconComponent):
|
|
|
40
40
|
The created component.
|
|
41
41
|
"""
|
|
42
42
|
if children:
|
|
43
|
-
if len(children) == 1
|
|
43
|
+
if len(children) == 1:
|
|
44
|
+
child = Var.create(children[0]).guess_type()
|
|
45
|
+
if not isinstance(child, StringVar):
|
|
46
|
+
raise AttributeError(
|
|
47
|
+
f"Icon name must be a string, got {children[0]._var_type if isinstance(children[0], Var) else children[0]}"
|
|
48
|
+
)
|
|
44
49
|
props["tag"] = children[0]
|
|
45
50
|
else:
|
|
46
51
|
raise AttributeError(
|
|
@@ -49,22 +54,33 @@ class Icon(LucideIconComponent):
|
|
|
49
54
|
if "tag" not in props:
|
|
50
55
|
raise AttributeError("Missing 'tag' keyword-argument for Icon")
|
|
51
56
|
|
|
52
|
-
tag: str | Var | LiteralVar = props.pop("tag")
|
|
57
|
+
tag: str | Var | LiteralVar = Var.create(props.pop("tag"))
|
|
53
58
|
if isinstance(tag, LiteralVar):
|
|
54
59
|
if isinstance(tag, LiteralStringVar):
|
|
55
60
|
tag = tag._var_value
|
|
56
61
|
else:
|
|
57
62
|
raise TypeError(f"Icon name must be a string, got {type(tag)}")
|
|
58
63
|
elif isinstance(tag, Var):
|
|
59
|
-
|
|
64
|
+
tag_stringified = tag.guess_type()
|
|
65
|
+
if not isinstance(tag_stringified, StringVar):
|
|
66
|
+
raise TypeError(f"Icon name must be a string, got {tag._var_type}")
|
|
67
|
+
return DynamicIcon.create(name=tag_stringified.replace("_", "-"), **props)
|
|
60
68
|
|
|
61
69
|
if (
|
|
62
70
|
not isinstance(tag, str)
|
|
63
71
|
or format.to_snake_case(tag) not in LUCIDE_ICON_LIST
|
|
64
72
|
):
|
|
73
|
+
if isinstance(tag, str):
|
|
74
|
+
icons_sorted = sorted(
|
|
75
|
+
LUCIDE_ICON_LIST,
|
|
76
|
+
key=lambda s: format.length_of_largest_common_substring(tag, s),
|
|
77
|
+
reverse=True,
|
|
78
|
+
)
|
|
79
|
+
else:
|
|
80
|
+
icons_sorted = LUCIDE_ICON_LIST
|
|
65
81
|
raise ValueError(
|
|
66
|
-
f"Invalid icon tag: {tag}. Please use one of the following: {', '.join(
|
|
67
|
-
"\nSee full list at https://
|
|
82
|
+
f"Invalid icon tag: {tag}. Please use one of the following: {', '.join(icons_sorted[0:25])}, ..."
|
|
83
|
+
"\nSee full list at https://reflex.dev/docs/library/data-display/icon/#icons-list."
|
|
68
84
|
)
|
|
69
85
|
|
|
70
86
|
if tag in LUCIDE_ICON_MAPPING_OVERRIDE:
|
|
@@ -6,13 +6,12 @@ import dataclasses
|
|
|
6
6
|
import textwrap
|
|
7
7
|
from functools import lru_cache
|
|
8
8
|
from hashlib import md5
|
|
9
|
-
from typing import Any, Callable, Dict, Sequence
|
|
9
|
+
from typing import Any, Callable, Dict, Sequence
|
|
10
10
|
|
|
11
11
|
from reflex.components.component import BaseComponent, Component, CustomComponent
|
|
12
12
|
from reflex.components.tags.tag import Tag
|
|
13
|
-
from reflex.utils import types
|
|
14
13
|
from reflex.utils.imports import ImportDict, ImportVar
|
|
15
|
-
from reflex.vars.base import LiteralVar, Var
|
|
14
|
+
from reflex.vars.base import LiteralVar, Var, VarData
|
|
16
15
|
from reflex.vars.function import ARRAY_ISARRAY, ArgsFunctionOperation, DestructuredArg
|
|
17
16
|
from reflex.vars.number import ternary_operation
|
|
18
17
|
|
|
@@ -83,13 +82,13 @@ class MarkdownComponentMap:
|
|
|
83
82
|
_explicit_return: bool = dataclasses.field(default=False)
|
|
84
83
|
|
|
85
84
|
@classmethod
|
|
86
|
-
def get_component_map_custom_code(cls) ->
|
|
85
|
+
def get_component_map_custom_code(cls) -> Var:
|
|
87
86
|
"""Get the custom code for the component map.
|
|
88
87
|
|
|
89
88
|
Returns:
|
|
90
89
|
The custom code for the component map.
|
|
91
90
|
"""
|
|
92
|
-
return ""
|
|
91
|
+
return Var("")
|
|
93
92
|
|
|
94
93
|
@classmethod
|
|
95
94
|
def create_map_fn_var(
|
|
@@ -97,6 +96,7 @@ class MarkdownComponentMap:
|
|
|
97
96
|
fn_body: Var | None = None,
|
|
98
97
|
fn_args: Sequence[str] | None = None,
|
|
99
98
|
explicit_return: bool | None = None,
|
|
99
|
+
var_data: VarData | None = None,
|
|
100
100
|
) -> Var:
|
|
101
101
|
"""Create a function Var for the component map.
|
|
102
102
|
|
|
@@ -104,6 +104,7 @@ class MarkdownComponentMap:
|
|
|
104
104
|
fn_body: The formatted component as a string.
|
|
105
105
|
fn_args: The function arguments.
|
|
106
106
|
explicit_return: Whether to use explicit return syntax.
|
|
107
|
+
var_data: The var data for the function.
|
|
107
108
|
|
|
108
109
|
Returns:
|
|
109
110
|
The function Var for the component map.
|
|
@@ -116,6 +117,7 @@ class MarkdownComponentMap:
|
|
|
116
117
|
args_names=(DestructuredArg(fields=tuple(fn_args)),),
|
|
117
118
|
return_expr=fn_body,
|
|
118
119
|
explicit_return=explicit_return,
|
|
120
|
+
_var_data=var_data,
|
|
119
121
|
)
|
|
120
122
|
|
|
121
123
|
@classmethod
|
|
@@ -166,7 +168,7 @@ class Markdown(Component):
|
|
|
166
168
|
Returns:
|
|
167
169
|
The markdown component.
|
|
168
170
|
"""
|
|
169
|
-
if len(children) != 1 or not
|
|
171
|
+
if len(children) != 1 or not isinstance(children[0], (str, Var)):
|
|
170
172
|
raise ValueError(
|
|
171
173
|
"Markdown component must have exactly one child containing the markdown source."
|
|
172
174
|
)
|
|
@@ -239,6 +241,15 @@ class Markdown(Component):
|
|
|
239
241
|
component(_MOCK_ARG)._get_all_imports()
|
|
240
242
|
for component in self.component_map.values()
|
|
241
243
|
],
|
|
244
|
+
*(
|
|
245
|
+
[inline_code_var_data.old_school_imports()]
|
|
246
|
+
if (
|
|
247
|
+
inline_code_var_data
|
|
248
|
+
:= self._get_inline_code_fn_var()._get_all_var_data()
|
|
249
|
+
)
|
|
250
|
+
is not None
|
|
251
|
+
else []
|
|
252
|
+
),
|
|
242
253
|
]
|
|
243
254
|
|
|
244
255
|
def _get_tag_map_fn_var(self, tag: str) -> Var:
|
|
@@ -278,12 +289,20 @@ class Markdown(Component):
|
|
|
278
289
|
self._get_map_fn_custom_code_from_children(self.get_component("code"))
|
|
279
290
|
)
|
|
280
291
|
|
|
281
|
-
|
|
292
|
+
var_data = VarData.merge(
|
|
293
|
+
*[
|
|
294
|
+
code._get_all_var_data()
|
|
295
|
+
for code in custom_code_list
|
|
296
|
+
if isinstance(code, Var)
|
|
297
|
+
]
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
codeblock_custom_code = "\n".join(map(str, custom_code_list))
|
|
282
301
|
|
|
283
302
|
# Format the code to handle inline and block code.
|
|
284
303
|
formatted_code = f"""
|
|
285
304
|
const match = (className || '').match(/language-(?<lang>.*)/);
|
|
286
|
-
|
|
305
|
+
let {_LANGUAGE!s} = match ? match[1] : '';
|
|
287
306
|
{codeblock_custom_code};
|
|
288
307
|
return inline ? (
|
|
289
308
|
{self.format_component("code")}
|
|
@@ -302,6 +321,7 @@ const {_LANGUAGE!s} = match ? match[1] : '';
|
|
|
302
321
|
),
|
|
303
322
|
fn_body=Var(_js_expr=formatted_code),
|
|
304
323
|
explicit_return=True,
|
|
324
|
+
var_data=var_data,
|
|
305
325
|
)
|
|
306
326
|
|
|
307
327
|
def get_component(self, tag: str, **props) -> Component:
|
|
@@ -381,7 +401,7 @@ const {_LANGUAGE!s} = match ? match[1] : '';
|
|
|
381
401
|
|
|
382
402
|
def _get_map_fn_custom_code_from_children(
|
|
383
403
|
self, component: BaseComponent
|
|
384
|
-
) -> list[str]:
|
|
404
|
+
) -> list[str | Var]:
|
|
385
405
|
"""Recursively get markdown custom code from children components.
|
|
386
406
|
|
|
387
407
|
Args:
|
|
@@ -390,7 +410,7 @@ const {_LANGUAGE!s} = match ? match[1] : '';
|
|
|
390
410
|
Returns:
|
|
391
411
|
A list of markdown custom code strings.
|
|
392
412
|
"""
|
|
393
|
-
custom_code_list = []
|
|
413
|
+
custom_code_list: list[str | Var] = []
|
|
394
414
|
if isinstance(component, MarkdownComponentMap):
|
|
395
415
|
custom_code_list.append(component.get_component_map_custom_code())
|
|
396
416
|
|
|
@@ -11,7 +11,7 @@ from reflex.components.component import Component
|
|
|
11
11
|
from reflex.event import EventType
|
|
12
12
|
from reflex.style import Style
|
|
13
13
|
from reflex.utils.imports import ImportDict
|
|
14
|
-
from reflex.vars.base import LiteralVar, Var
|
|
14
|
+
from reflex.vars.base import LiteralVar, Var, VarData
|
|
15
15
|
|
|
16
16
|
_CHILDREN = Var(_js_expr="children", _var_type=str)
|
|
17
17
|
_PROPS = Var(_js_expr="...props")
|
|
@@ -32,13 +32,14 @@ def get_base_component_map() -> dict[str, Callable]: ...
|
|
|
32
32
|
@dataclasses.dataclass()
|
|
33
33
|
class MarkdownComponentMap:
|
|
34
34
|
@classmethod
|
|
35
|
-
def get_component_map_custom_code(cls) ->
|
|
35
|
+
def get_component_map_custom_code(cls) -> Var: ...
|
|
36
36
|
@classmethod
|
|
37
37
|
def create_map_fn_var(
|
|
38
38
|
cls,
|
|
39
39
|
fn_body: Var | None = None,
|
|
40
40
|
fn_args: Sequence[str] | None = None,
|
|
41
41
|
explicit_return: bool | None = None,
|
|
42
|
+
var_data: VarData | None = None,
|
|
42
43
|
) -> Var: ...
|
|
43
44
|
@classmethod
|
|
44
45
|
def get_fn_args(cls) -> Sequence[str]: ...
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict, List, Tuple, Union
|
|
6
|
-
|
|
7
|
-
from typing_extensions import TypedDict, TypeVar
|
|
5
|
+
from typing import Any, Dict, List, Tuple, TypedDict, TypeVar, Union
|
|
8
6
|
|
|
9
7
|
from reflex.components.component import Component, NoSSRComponent
|
|
10
8
|
from reflex.components.core.cond import color_mode_cond
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
# ------------------- DO NOT EDIT ----------------------
|
|
4
4
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
|
5
5
|
# ------------------------------------------------------
|
|
6
|
-
from typing import Any, Dict, List, Optional, Union, overload
|
|
7
|
-
|
|
8
|
-
from typing_extensions import TypedDict, TypeVar
|
|
6
|
+
from typing import Any, Dict, List, Optional, TypedDict, TypeVar, Union, overload
|
|
9
7
|
|
|
10
8
|
from reflex.components.component import NoSSRComponent
|
|
11
9
|
from reflex.event import EventType
|