reflex 0.7.1a4__py3-none-any.whl → 0.7.2a2__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/jinja/web/utils/context.js.jinja2 +8 -8
- reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +3 -3
- reflex/.templates/web/utils/state.js +18 -18
- reflex/admin.py +1 -2
- reflex/app.py +46 -49
- reflex/app_mixins/lifespan.py +2 -2
- reflex/app_mixins/middleware.py +1 -2
- reflex/assets.py +1 -2
- reflex/base.py +2 -2
- reflex/compiler/compiler.py +51 -16
- reflex/compiler/utils.py +4 -13
- reflex/components/base/app_wrap.pyi +7 -7
- reflex/components/base/bare.py +3 -3
- reflex/components/base/body.pyi +7 -7
- reflex/components/base/document.py +1 -3
- reflex/components/base/document.pyi +32 -32
- reflex/components/base/error_boundary.py +2 -4
- reflex/components/base/error_boundary.pyi +11 -13
- reflex/components/base/fragment.pyi +7 -7
- reflex/components/base/head.pyi +13 -13
- reflex/components/base/link.pyi +22 -22
- reflex/components/base/meta.py +5 -7
- reflex/components/base/meta.pyi +40 -40
- reflex/components/base/script.pyi +11 -14
- reflex/components/base/strict_mode.pyi +7 -7
- reflex/components/component.py +188 -113
- reflex/components/core/auto_scroll.py +8 -1
- reflex/components/core/auto_scroll.pyi +183 -210
- reflex/components/core/banner.py +2 -4
- reflex/components/core/banner.pyi +390 -444
- reflex/components/core/breakpoints.py +5 -5
- reflex/components/core/client_side_routing.pyi +14 -14
- reflex/components/core/clipboard.py +4 -4
- reflex/components/core/clipboard.pyi +12 -14
- reflex/components/core/cond.py +17 -25
- reflex/components/core/debounce.py +3 -3
- reflex/components/core/debounce.pyi +14 -14
- reflex/components/core/foreach.py +7 -2
- reflex/components/core/html.py +1 -3
- reflex/components/core/html.pyi +184 -213
- reflex/components/core/match.py +15 -19
- reflex/components/core/sticky.pyi +930 -1078
- reflex/components/core/upload.py +4 -4
- reflex/components/core/upload.pyi +62 -62
- reflex/components/datadisplay/code.py +6 -6
- reflex/components/datadisplay/code.pyi +1159 -1165
- reflex/components/datadisplay/dataeditor.py +49 -49
- reflex/components/datadisplay/dataeditor.pyi +95 -123
- reflex/components/datadisplay/logo.py +1 -3
- reflex/components/datadisplay/shiki_code_block.py +8 -10
- reflex/components/datadisplay/shiki_code_block.pyi +1678 -1720
- reflex/components/el/element.pyi +7 -7
- reflex/components/el/elements/base.pyi +183 -210
- reflex/components/el/elements/forms.py +24 -24
- reflex/components/el/elements/forms.pyi +2572 -2934
- reflex/components/el/elements/inline.py +4 -4
- reflex/components/el/elements/inline.pyi +5191 -5953
- reflex/components/el/elements/media.py +47 -47
- reflex/components/el/elements/media.pyi +4802 -5500
- reflex/components/el/elements/metadata.py +1 -3
- reflex/components/el/elements/metadata.pyi +782 -896
- reflex/components/el/elements/other.pyi +1278 -1467
- reflex/components/el/elements/scripts.pyi +580 -667
- reflex/components/el/elements/sectioning.pyi +2761 -3166
- reflex/components/el/elements/tables.pyi +1840 -2119
- reflex/components/el/elements/typography.pyi +2772 -3179
- reflex/components/gridjs/datatable.py +7 -7
- reflex/components/gridjs/datatable.pyi +19 -19
- reflex/components/lucide/icon.pyi +21 -21
- reflex/components/markdown/markdown.py +2 -2
- reflex/components/markdown/markdown.pyi +9 -9
- reflex/components/moment/moment.py +11 -12
- reflex/components/moment/moment.pyi +44 -47
- reflex/components/next/base.pyi +7 -7
- reflex/components/next/image.py +3 -3
- reflex/components/next/image.pyi +19 -21
- reflex/components/next/link.pyi +9 -9
- reflex/components/next/video.py +1 -3
- reflex/components/next/video.pyi +9 -9
- reflex/components/plotly/plotly.py +22 -45
- reflex/components/plotly/plotly.pyi +164 -164
- reflex/components/radix/primitives/accordion.py +14 -14
- reflex/components/radix/primitives/accordion.pyi +439 -487
- reflex/components/radix/primitives/base.py +1 -3
- reflex/components/radix/primitives/base.pyi +15 -15
- reflex/components/radix/primitives/drawer.py +3 -3
- reflex/components/radix/primitives/drawer.pyi +110 -116
- reflex/components/radix/primitives/form.py +1 -1
- reflex/components/radix/primitives/form.pyi +668 -752
- reflex/components/radix/primitives/progress.py +6 -6
- reflex/components/radix/primitives/progress.pyi +225 -243
- reflex/components/radix/primitives/slider.py +6 -6
- reflex/components/radix/primitives/slider.pyi +52 -55
- reflex/components/radix/themes/base.py +3 -6
- reflex/components/radix/themes/base.pyi +197 -303
- reflex/components/radix/themes/color_mode.py +5 -5
- reflex/components/radix/themes/color_mode.pyi +366 -436
- reflex/components/radix/themes/components/alert_dialog.pyi +229 -262
- reflex/components/radix/themes/components/aspect_ratio.py +1 -3
- reflex/components/radix/themes/components/aspect_ratio.pyi +8 -8
- reflex/components/radix/themes/components/avatar.pyi +79 -94
- reflex/components/radix/themes/components/badge.pyi +252 -295
- reflex/components/radix/themes/components/button.pyi +269 -314
- reflex/components/radix/themes/components/callout.py +2 -2
- reflex/components/radix/themes/components/callout.pyi +1116 -1290
- reflex/components/radix/themes/components/card.pyi +194 -229
- reflex/components/radix/themes/components/checkbox.pyi +243 -278
- reflex/components/radix/themes/components/checkbox_cards.py +3 -7
- reflex/components/radix/themes/components/checkbox_cards.pyi +101 -135
- reflex/components/radix/themes/components/checkbox_group.py +2 -2
- reflex/components/radix/themes/components/checkbox_group.pyi +83 -96
- reflex/components/radix/themes/components/context_menu.py +18 -15
- reflex/components/radix/themes/components/context_menu.pyi +408 -458
- reflex/components/radix/themes/components/data_list.pyi +122 -147
- reflex/components/radix/themes/components/dialog.pyi +231 -264
- reflex/components/radix/themes/components/dropdown_menu.py +16 -13
- reflex/components/radix/themes/components/dropdown_menu.pyi +223 -246
- reflex/components/radix/themes/components/hover_card.py +2 -2
- reflex/components/radix/themes/components/hover_card.pyi +237 -282
- reflex/components/radix/themes/components/icon_button.pyi +269 -314
- reflex/components/radix/themes/components/inset.py +8 -8
- reflex/components/radix/themes/components/inset.pyi +232 -292
- reflex/components/radix/themes/components/popover.py +2 -2
- reflex/components/radix/themes/components/popover.pyi +229 -271
- reflex/components/radix/themes/components/progress.pyi +80 -96
- reflex/components/radix/themes/components/radio.pyi +73 -86
- reflex/components/radix/themes/components/radio_cards.py +4 -8
- reflex/components/radix/themes/components/radio_cards.pyi +117 -154
- reflex/components/radix/themes/components/radio_group.py +3 -3
- reflex/components/radix/themes/components/radio_group.pyi +250 -291
- reflex/components/radix/themes/components/scroll_area.pyi +14 -20
- reflex/components/radix/themes/components/segmented_control.py +6 -6
- reflex/components/radix/themes/components/segmented_control.pyi +89 -108
- reflex/components/radix/themes/components/select.py +7 -7
- reflex/components/radix/themes/components/select.pyi +376 -444
- reflex/components/radix/themes/components/separator.pyi +79 -93
- reflex/components/radix/themes/components/skeleton.pyi +32 -26
- reflex/components/radix/themes/components/slider.py +8 -8
- reflex/components/radix/themes/components/slider.pyi +99 -122
- reflex/components/radix/themes/components/spinner.pyi +12 -19
- reflex/components/radix/themes/components/switch.pyi +84 -99
- reflex/components/radix/themes/components/table.py +9 -9
- reflex/components/radix/themes/components/table.pyi +1440 -1794
- reflex/components/radix/themes/components/tabs.py +4 -4
- reflex/components/radix/themes/components/tabs.pyi +120 -132
- reflex/components/radix/themes/components/text_area.pyi +281 -331
- reflex/components/radix/themes/components/text_field.py +2 -2
- reflex/components/radix/themes/components/text_field.pyi +639 -734
- reflex/components/radix/themes/components/tooltip.py +6 -6
- reflex/components/radix/themes/components/tooltip.pyi +34 -43
- reflex/components/radix/themes/layout/base.pyi +85 -182
- reflex/components/radix/themes/layout/box.pyi +183 -210
- reflex/components/radix/themes/layout/center.pyi +225 -286
- reflex/components/radix/themes/layout/container.pyi +191 -224
- reflex/components/radix/themes/layout/flex.py +2 -2
- reflex/components/radix/themes/layout/flex.pyi +225 -286
- reflex/components/radix/themes/layout/grid.py +2 -2
- reflex/components/radix/themes/layout/grid.pyi +245 -315
- reflex/components/radix/themes/layout/list.py +2 -2
- reflex/components/radix/themes/layout/list.pyi +712 -815
- reflex/components/radix/themes/layout/section.pyi +187 -221
- reflex/components/radix/themes/layout/spacer.pyi +225 -286
- reflex/components/radix/themes/layout/stack.pyi +625 -768
- reflex/components/radix/themes/typography/blockquote.pyi +257 -299
- reflex/components/radix/themes/typography/code.pyi +259 -304
- reflex/components/radix/themes/typography/heading.pyi +272 -324
- reflex/components/radix/themes/typography/link.pyi +302 -358
- reflex/components/radix/themes/typography/text.pyi +1669 -1945
- reflex/components/react_player/audio.pyi +20 -22
- reflex/components/react_player/react_player.pyi +19 -19
- reflex/components/react_player/video.pyi +20 -22
- reflex/components/recharts/cartesian.py +100 -97
- reflex/components/recharts/cartesian.pyi +891 -1007
- reflex/components/recharts/charts.py +42 -42
- reflex/components/recharts/charts.pyi +212 -249
- reflex/components/recharts/general.py +22 -21
- reflex/components/recharts/general.pyi +198 -223
- reflex/components/recharts/polar.py +42 -45
- reflex/components/recharts/polar.pyi +254 -288
- reflex/components/recharts/recharts.pyi +13 -13
- reflex/components/sonner/toast.py +20 -20
- reflex/components/sonner/toast.pyi +58 -61
- reflex/components/suneditor/editor.py +9 -9
- reflex/components/suneditor/editor.pyi +78 -83
- reflex/components/tags/cond_tag.py +2 -2
- reflex/components/tags/iter_tag.py +10 -14
- reflex/components/tags/match_tag.py +2 -2
- reflex/components/tags/tag.py +10 -10
- reflex/config.py +36 -35
- reflex/constants/__init__.py +56 -53
- reflex/custom_components/custom_components.py +6 -7
- reflex/event.py +38 -42
- reflex/experimental/client_state.py +2 -4
- reflex/experimental/layout.py +2 -2
- reflex/experimental/layout.pyi +579 -663
- reflex/istate/data.py +4 -5
- reflex/middleware/hydrate_middleware.py +2 -2
- reflex/middleware/middleware.py +2 -2
- reflex/model.py +3 -5
- reflex/page.py +2 -2
- reflex/reflex.py +9 -10
- reflex/state.py +77 -49
- reflex/style.py +9 -3
- reflex/testing.py +21 -24
- reflex/utils/console.py +1 -1
- reflex/utils/decorator.py +26 -1
- reflex/utils/exec.py +6 -11
- reflex/utils/export.py +2 -3
- reflex/utils/format.py +4 -4
- reflex/utils/imports.py +12 -12
- reflex/utils/prerequisites.py +35 -84
- reflex/utils/processes.py +5 -5
- reflex/utils/pyi_generator.py +33 -22
- reflex/utils/serializers.py +60 -15
- reflex/utils/types.py +237 -56
- reflex/vars/base.py +122 -72
- reflex/vars/datetime.py +2 -2
- reflex/vars/function.py +52 -55
- reflex/vars/number.py +59 -5
- reflex/vars/object.py +57 -26
- reflex/vars/sequence.py +983 -958
- {reflex-0.7.1a4.dist-info → reflex-0.7.2a2.dist-info}/METADATA +3 -6
- reflex-0.7.2a2.dist-info/RECORD +405 -0
- {reflex-0.7.1a4.dist-info → reflex-0.7.2a2.dist-info}/WHEEL +1 -1
- reflex-0.7.1a4.dist-info/RECORD +0 -405
- {reflex-0.7.1a4.dist-info → reflex-0.7.2a2.dist-info}/LICENSE +0 -0
- {reflex-0.7.1a4.dist-info → reflex-0.7.2a2.dist-info}/entry_points.txt +0 -0
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import TypeVar
|
|
6
6
|
|
|
7
7
|
breakpoints_values = ["30em", "48em", "62em", "80em", "96em"]
|
|
8
8
|
breakpoint_names = ["xs", "sm", "md", "lg", "xl"]
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def set_breakpoints(values:
|
|
11
|
+
def set_breakpoints(values: tuple[str, str, str, str, str]):
|
|
12
12
|
"""Overwrite default breakpoint values.
|
|
13
13
|
|
|
14
14
|
Args:
|
|
@@ -22,7 +22,7 @@ K = TypeVar("K", bound=str)
|
|
|
22
22
|
V = TypeVar("V")
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class Breakpoints(
|
|
25
|
+
class Breakpoints(dict[K, V]):
|
|
26
26
|
"""A responsive styling helper."""
|
|
27
27
|
|
|
28
28
|
def factorize(self):
|
|
@@ -46,7 +46,7 @@ class Breakpoints(Dict[K, V]):
|
|
|
46
46
|
@classmethod
|
|
47
47
|
def create(
|
|
48
48
|
cls,
|
|
49
|
-
custom:
|
|
49
|
+
custom: dict[K, V] | None = None,
|
|
50
50
|
initial: V | None = None,
|
|
51
51
|
xs: V | None = None,
|
|
52
52
|
sm: V | None = None,
|
|
@@ -94,4 +94,4 @@ breakpoints = Breakpoints.create
|
|
|
94
94
|
|
|
95
95
|
T = TypeVar("T")
|
|
96
96
|
|
|
97
|
-
Responsive =
|
|
97
|
+
Responsive = T | Breakpoints[str, T]
|
|
@@ -3,7 +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,
|
|
6
|
+
from typing import Any, Optional, overload
|
|
7
7
|
|
|
8
8
|
from reflex.components.component import Component
|
|
9
9
|
from reflex.event import EventType
|
|
@@ -20,12 +20,12 @@ class ClientSideRouting(Component):
|
|
|
20
20
|
def create( # type: ignore
|
|
21
21
|
cls,
|
|
22
22
|
*children,
|
|
23
|
-
style:
|
|
24
|
-
key:
|
|
25
|
-
id:
|
|
26
|
-
class_name:
|
|
27
|
-
autofocus:
|
|
28
|
-
custom_attrs:
|
|
23
|
+
style: Style | None = None,
|
|
24
|
+
key: Any | None = None,
|
|
25
|
+
id: Any | None = None,
|
|
26
|
+
class_name: Any | None = None,
|
|
27
|
+
autofocus: bool | None = None,
|
|
28
|
+
custom_attrs: dict[str, Var | Any] | None = None,
|
|
29
29
|
on_blur: Optional[EventType[()]] = None,
|
|
30
30
|
on_click: Optional[EventType[()]] = None,
|
|
31
31
|
on_context_menu: Optional[EventType[()]] = None,
|
|
@@ -68,13 +68,13 @@ class Default404Page(Component):
|
|
|
68
68
|
def create( # type: ignore
|
|
69
69
|
cls,
|
|
70
70
|
*children,
|
|
71
|
-
status_code:
|
|
72
|
-
style:
|
|
73
|
-
key:
|
|
74
|
-
id:
|
|
75
|
-
class_name:
|
|
76
|
-
autofocus:
|
|
77
|
-
custom_attrs:
|
|
71
|
+
status_code: Var[int] | int | None = None,
|
|
72
|
+
style: Style | None = None,
|
|
73
|
+
key: Any | None = None,
|
|
74
|
+
id: Any | None = None,
|
|
75
|
+
class_name: Any | None = None,
|
|
76
|
+
autofocus: bool | None = None,
|
|
77
|
+
custom_attrs: dict[str, Var | Any] | None = None,
|
|
78
78
|
on_blur: Optional[EventType[()]] = None,
|
|
79
79
|
on_click: Optional[EventType[()]] = None,
|
|
80
80
|
on_context_menu: Optional[EventType[()]] = None,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import Sequence
|
|
6
6
|
|
|
7
7
|
from reflex.components.base.fragment import Fragment
|
|
8
8
|
from reflex.components.tags.tag import Tag
|
|
@@ -18,13 +18,13 @@ class Clipboard(Fragment):
|
|
|
18
18
|
"""Clipboard component."""
|
|
19
19
|
|
|
20
20
|
# The element ids to attach the event listener to. Defaults to all child components or the document.
|
|
21
|
-
targets: Var[
|
|
21
|
+
targets: Var[Sequence[str]]
|
|
22
22
|
|
|
23
23
|
# Called when the user pastes data into the document. Data is a list of tuples of (mime_type, data). Binary types will be base64 encoded as a data uri.
|
|
24
|
-
on_paste: EventHandler[passthrough_event_spec(
|
|
24
|
+
on_paste: EventHandler[passthrough_event_spec(list[tuple[str, str]])]
|
|
25
25
|
|
|
26
26
|
# Save the original event actions for the on_paste event.
|
|
27
|
-
on_paste_event_actions: Var[
|
|
27
|
+
on_paste_event_actions: Var[dict[str, bool | int]]
|
|
28
28
|
|
|
29
29
|
@classmethod
|
|
30
30
|
def create(cls, *children, **props):
|
|
@@ -3,7 +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,
|
|
6
|
+
from typing import Any, Optional, Sequence, overload
|
|
7
7
|
|
|
8
8
|
from reflex.components.base.fragment import Fragment
|
|
9
9
|
from reflex.event import EventType
|
|
@@ -17,16 +17,16 @@ class Clipboard(Fragment):
|
|
|
17
17
|
def create( # type: ignore
|
|
18
18
|
cls,
|
|
19
19
|
*children,
|
|
20
|
-
targets:
|
|
21
|
-
on_paste_event_actions:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
style:
|
|
25
|
-
key:
|
|
26
|
-
id:
|
|
27
|
-
class_name:
|
|
28
|
-
autofocus:
|
|
29
|
-
custom_attrs:
|
|
20
|
+
targets: Sequence[str] | Var[Sequence[str]] | None = None,
|
|
21
|
+
on_paste_event_actions: Var[dict[str, bool | int]]
|
|
22
|
+
| dict[str, bool | int]
|
|
23
|
+
| None = None,
|
|
24
|
+
style: Style | None = None,
|
|
25
|
+
key: Any | None = None,
|
|
26
|
+
id: Any | None = None,
|
|
27
|
+
class_name: Any | None = None,
|
|
28
|
+
autofocus: bool | None = None,
|
|
29
|
+
custom_attrs: dict[str, Var | Any] | None = None,
|
|
30
30
|
on_blur: Optional[EventType[()]] = None,
|
|
31
31
|
on_click: Optional[EventType[()]] = None,
|
|
32
32
|
on_context_menu: Optional[EventType[()]] = None,
|
|
@@ -40,9 +40,7 @@ class Clipboard(Fragment):
|
|
|
40
40
|
on_mouse_out: Optional[EventType[()]] = None,
|
|
41
41
|
on_mouse_over: Optional[EventType[()]] = None,
|
|
42
42
|
on_mouse_up: Optional[EventType[()]] = None,
|
|
43
|
-
on_paste: Optional[
|
|
44
|
-
Union[EventType[()], EventType[list[tuple[str, str]]]]
|
|
45
|
-
] = None,
|
|
43
|
+
on_paste: Optional[EventType[()] | EventType[list[tuple[str, str]]]] = None,
|
|
46
44
|
on_scroll: Optional[EventType[()]] = None,
|
|
47
45
|
on_unmount: Optional[EventType[()]] = None,
|
|
48
46
|
**props,
|
reflex/components/core/cond.py
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict,
|
|
5
|
+
from typing import Any, Dict, overload
|
|
6
6
|
|
|
7
7
|
from reflex.components.base.fragment import Fragment
|
|
8
8
|
from reflex.components.component import BaseComponent, Component, MemoizationLeaf
|
|
9
9
|
from reflex.components.tags import CondTag, Tag
|
|
10
10
|
from reflex.constants import Dirs
|
|
11
11
|
from reflex.style import LIGHT_COLOR_MODE, resolved_color_mode
|
|
12
|
+
from reflex.utils import types
|
|
12
13
|
from reflex.utils.imports import ImportDict, ImportVar
|
|
13
14
|
from reflex.vars import VarData
|
|
14
15
|
from reflex.vars.base import LiteralVar, Var
|
|
@@ -25,17 +26,12 @@ class Cond(MemoizationLeaf):
|
|
|
25
26
|
# The cond to determine which component to render.
|
|
26
27
|
cond: Var[Any]
|
|
27
28
|
|
|
28
|
-
# The component to render if the cond is true.
|
|
29
|
-
comp1: BaseComponent | None = None
|
|
30
|
-
# The component to render if the cond is false.
|
|
31
|
-
comp2: BaseComponent | None = None
|
|
32
|
-
|
|
33
29
|
@classmethod
|
|
34
30
|
def create(
|
|
35
31
|
cls,
|
|
36
32
|
cond: Var,
|
|
37
33
|
comp1: BaseComponent,
|
|
38
|
-
comp2:
|
|
34
|
+
comp2: BaseComponent | None = None,
|
|
39
35
|
) -> Component:
|
|
40
36
|
"""Create a conditional component.
|
|
41
37
|
|
|
@@ -53,19 +49,17 @@ class Cond(MemoizationLeaf):
|
|
|
53
49
|
if comp2 is None or type(comp2).__name__ != "Fragment":
|
|
54
50
|
comp2 = Fragment.create(comp2) if comp2 else Fragment.create()
|
|
55
51
|
return Fragment.create(
|
|
56
|
-
cls(
|
|
57
|
-
cond=cond,
|
|
58
|
-
comp1=comp1,
|
|
59
|
-
comp2=comp2,
|
|
52
|
+
cls._create(
|
|
60
53
|
children=[comp1, comp2],
|
|
54
|
+
cond=cond,
|
|
61
55
|
)
|
|
62
56
|
)
|
|
63
57
|
|
|
64
58
|
def _render(self) -> Tag:
|
|
65
59
|
return CondTag(
|
|
66
60
|
cond=self.cond,
|
|
67
|
-
true_value=self.
|
|
68
|
-
false_value=self.
|
|
61
|
+
true_value=self.children[0].render(),
|
|
62
|
+
false_value=self.children[1].render(),
|
|
69
63
|
)
|
|
70
64
|
|
|
71
65
|
def render(self) -> Dict:
|
|
@@ -85,7 +79,7 @@ class Cond(MemoizationLeaf):
|
|
|
85
79
|
).set(
|
|
86
80
|
props=tag.format_props(),
|
|
87
81
|
),
|
|
88
|
-
cond_state=
|
|
82
|
+
cond_state=str(self.cond),
|
|
89
83
|
)
|
|
90
84
|
|
|
91
85
|
def add_imports(self) -> ImportDict:
|
|
@@ -136,7 +130,7 @@ def cond(condition: Any, c1: Any, c2: Any = None) -> Component | Var:
|
|
|
136
130
|
if isinstance(c1, BaseComponent):
|
|
137
131
|
if c2 is not None and not isinstance(c2, BaseComponent):
|
|
138
132
|
raise ValueError("Both arguments must be components.")
|
|
139
|
-
return Cond.create(cond_var, c1, c2)
|
|
133
|
+
return Cond.create(cond_var.bool(), c1, c2)
|
|
140
134
|
|
|
141
135
|
# Otherwise, create a conditional Var.
|
|
142
136
|
# Check that the second argument is valid.
|
|
@@ -145,20 +139,18 @@ def cond(condition: Any, c1: Any, c2: Any = None) -> Component | Var:
|
|
|
145
139
|
if c2 is None:
|
|
146
140
|
raise ValueError("For conditional vars, the second argument must be set.")
|
|
147
141
|
|
|
148
|
-
def create_var(cond_part: Any) -> Var[Any]:
|
|
149
|
-
return LiteralVar.create(cond_part)
|
|
150
|
-
|
|
151
142
|
# convert the truth and false cond parts into vars so the _var_data can be obtained.
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
c1_var = Var.create(c1)
|
|
144
|
+
c2_var = Var.create(c2)
|
|
145
|
+
|
|
146
|
+
if condition is c1_var:
|
|
147
|
+
c1_var = c1_var.to(types.value_inside_optional(c1_var._var_type))
|
|
154
148
|
|
|
155
149
|
# Create the conditional var.
|
|
156
150
|
return ternary_operation(
|
|
157
|
-
cond_var.bool()
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
c1,
|
|
161
|
-
c2,
|
|
151
|
+
cond_var.bool(),
|
|
152
|
+
c1_var,
|
|
153
|
+
c2_var,
|
|
162
154
|
)
|
|
163
155
|
|
|
164
156
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Any, Type
|
|
5
|
+
from typing import Any, Type
|
|
6
6
|
|
|
7
7
|
from reflex.components.component import Component
|
|
8
8
|
from reflex.constants import EventTriggers
|
|
@@ -37,7 +37,7 @@ class DebounceInput(Component):
|
|
|
37
37
|
force_notify_on_blur: Var[bool]
|
|
38
38
|
|
|
39
39
|
# If provided, create a fully-controlled input
|
|
40
|
-
value: Var[
|
|
40
|
+
value: Var[str | int | float]
|
|
41
41
|
|
|
42
42
|
# The ref to attach to the created input
|
|
43
43
|
input_ref: Var[str]
|
|
@@ -127,7 +127,7 @@ class DebounceInput(Component):
|
|
|
127
127
|
component._get_style = child._get_style
|
|
128
128
|
component.event_triggers.update(child.event_triggers)
|
|
129
129
|
component.children = child.children
|
|
130
|
-
component._rename_props = child._rename_props
|
|
130
|
+
component._rename_props = child._rename_props # pyright: ignore[reportAttributeAccessIssue]
|
|
131
131
|
outer_get_all_custom_code = component._get_all_custom_code
|
|
132
132
|
component._get_all_custom_code = lambda: outer_get_all_custom_code().union(
|
|
133
133
|
child._get_all_custom_code()
|
|
@@ -3,7 +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,
|
|
6
|
+
from typing import Any, Optional, Type, overload
|
|
7
7
|
|
|
8
8
|
from reflex.components.component import Component
|
|
9
9
|
from reflex.event import EventType
|
|
@@ -18,19 +18,19 @@ class DebounceInput(Component):
|
|
|
18
18
|
def create( # type: ignore
|
|
19
19
|
cls,
|
|
20
20
|
*children,
|
|
21
|
-
min_length:
|
|
22
|
-
debounce_timeout:
|
|
23
|
-
force_notify_by_enter:
|
|
24
|
-
force_notify_on_blur:
|
|
25
|
-
value:
|
|
26
|
-
input_ref:
|
|
27
|
-
element:
|
|
28
|
-
style:
|
|
29
|
-
key:
|
|
30
|
-
id:
|
|
31
|
-
class_name:
|
|
32
|
-
autofocus:
|
|
33
|
-
custom_attrs:
|
|
21
|
+
min_length: Var[int] | int | None = None,
|
|
22
|
+
debounce_timeout: Var[int] | int | None = None,
|
|
23
|
+
force_notify_by_enter: Var[bool] | bool | None = None,
|
|
24
|
+
force_notify_on_blur: Var[bool] | bool | None = None,
|
|
25
|
+
value: Var[float | int | str] | float | int | str | None = None,
|
|
26
|
+
input_ref: Var[str] | str | None = None,
|
|
27
|
+
element: Type[Component] | Var[Type[Component]] | None = None,
|
|
28
|
+
style: Style | None = None,
|
|
29
|
+
key: Any | None = None,
|
|
30
|
+
id: Any | None = None,
|
|
31
|
+
class_name: Any | None = None,
|
|
32
|
+
autofocus: bool | None = None,
|
|
33
|
+
custom_attrs: dict[str, Var | Any] | None = None,
|
|
34
34
|
on_blur: Optional[EventType[()]] = None,
|
|
35
35
|
on_change: Optional[EventType[()]] = None,
|
|
36
36
|
on_click: Optional[EventType[()]] = None,
|
|
@@ -8,9 +8,11 @@ from typing import Any, Callable, Iterable
|
|
|
8
8
|
|
|
9
9
|
from reflex.components.base.fragment import Fragment
|
|
10
10
|
from reflex.components.component import Component
|
|
11
|
+
from reflex.components.core.cond import cond
|
|
11
12
|
from reflex.components.tags import IterTag
|
|
12
13
|
from reflex.constants import MemoizationMode
|
|
13
14
|
from reflex.state import ComponentState
|
|
15
|
+
from reflex.utils import types
|
|
14
16
|
from reflex.utils.exceptions import UntypedVarError
|
|
15
17
|
from reflex.vars.base import LiteralVar, Var
|
|
16
18
|
|
|
@@ -85,7 +87,11 @@ class Foreach(Component):
|
|
|
85
87
|
"See https://reflex.dev/docs/library/dynamic-rendering/foreach/"
|
|
86
88
|
)
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
if types.is_optional(iterable._var_type):
|
|
91
|
+
iterable = cond(iterable, iterable, [])
|
|
92
|
+
|
|
93
|
+
component = cls._create(
|
|
94
|
+
children=[],
|
|
89
95
|
iterable=iterable,
|
|
90
96
|
render_fn=render_fn,
|
|
91
97
|
)
|
|
@@ -164,7 +170,6 @@ class Foreach(Component):
|
|
|
164
170
|
iterable_state=str(tag.iterable),
|
|
165
171
|
arg_name=tag.arg_var_name,
|
|
166
172
|
arg_index=tag.get_index_var_arg(),
|
|
167
|
-
iterable_type=tag.iterable._var_type.mro()[0].__name__,
|
|
168
173
|
)
|
|
169
174
|
|
|
170
175
|
|
reflex/components/core/html.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""A html component."""
|
|
2
2
|
|
|
3
|
-
from typing import Dict
|
|
4
|
-
|
|
5
3
|
from reflex.components.el.elements.typography import Div
|
|
6
4
|
from reflex.vars.base import Var
|
|
7
5
|
|
|
@@ -14,7 +12,7 @@ class Html(Div):
|
|
|
14
12
|
"""
|
|
15
13
|
|
|
16
14
|
# The HTML to render.
|
|
17
|
-
dangerouslySetInnerHTML: Var[
|
|
15
|
+
dangerouslySetInnerHTML: Var[dict[str, str]] # noqa: N815
|
|
18
16
|
|
|
19
17
|
@classmethod
|
|
20
18
|
def create(cls, *children, **props):
|