reflex 0.5.2a1__py3-none-any.whl → 0.5.3a1__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/postcss.config.js +1 -0
- reflex/.templates/web/styles/tailwind.css +4 -1
- reflex/__init__.py +298 -204
- reflex/__init__.pyi +196 -157
- reflex/app.py +13 -2
- reflex/components/__init__.py +31 -17
- reflex/components/__init__.pyi +26 -0
- reflex/components/base/__init__.py +25 -9
- reflex/components/base/__init__.pyi +26 -0
- reflex/components/base/fragment.py +3 -0
- reflex/components/base/fragment.pyi +2 -0
- reflex/components/base/head.py +3 -0
- reflex/components/base/head.pyi +2 -0
- reflex/components/base/script.py +3 -0
- reflex/components/base/script.pyi +2 -0
- reflex/components/core/__init__.py +51 -37
- reflex/components/core/__init__.pyi +39 -0
- reflex/components/core/banner.py +7 -1
- reflex/components/core/banner.pyi +6 -1
- reflex/components/core/debounce.py +3 -0
- reflex/components/core/debounce.pyi +2 -0
- reflex/components/core/foreach.py +3 -0
- reflex/components/core/html.py +3 -0
- reflex/components/core/html.pyi +2 -0
- reflex/components/core/match.py +3 -0
- reflex/components/core/responsive.py +1 -1
- reflex/components/core/upload.py +5 -2
- reflex/components/core/upload.pyi +4 -2
- reflex/components/datadisplay/__init__.py +17 -8
- reflex/components/datadisplay/__init__.pyi +14 -0
- reflex/components/datadisplay/code.py +3 -0
- reflex/components/datadisplay/code.pyi +2 -0
- reflex/components/datadisplay/dataeditor.py +4 -0
- reflex/components/datadisplay/dataeditor.pyi +3 -0
- reflex/components/el/__init__.py +15 -1
- reflex/components/el/__init__.pyi +227 -0
- reflex/components/el/elements/__init__.py +129 -220
- reflex/components/el/elements/__init__.pyi +341 -0
- reflex/components/el/elements/forms.py +15 -0
- reflex/components/el/elements/forms.pyi +14 -0
- reflex/components/el/elements/inline.py +30 -0
- reflex/components/el/elements/inline.pyi +29 -0
- reflex/components/el/elements/media.py +16 -0
- reflex/components/el/elements/media.pyi +15 -0
- reflex/components/el/elements/metadata.py +7 -0
- reflex/components/el/elements/metadata.pyi +6 -0
- reflex/components/el/elements/other.py +9 -0
- reflex/components/el/elements/other.pyi +8 -0
- reflex/components/el/elements/scripts.py +5 -0
- reflex/components/el/elements/scripts.pyi +4 -0
- reflex/components/el/elements/sectioning.py +17 -0
- reflex/components/el/elements/sectioning.pyi +16 -0
- reflex/components/el/elements/tables.py +12 -0
- reflex/components/el/elements/tables.pyi +11 -0
- reflex/components/el/elements/typography.py +16 -0
- reflex/components/el/elements/typography.pyi +15 -0
- reflex/components/moment/__init__.py +1 -1
- reflex/components/plotly/plotly.py +184 -6
- reflex/components/plotly/plotly.pyi +62 -4
- reflex/components/radix/__init__.py +14 -2
- reflex/components/radix/__init__.pyi +73 -0
- reflex/components/radix/primitives/__init__.py +13 -5
- reflex/components/radix/primitives/__init__.pyi +11 -0
- reflex/components/radix/themes/__init__.py +20 -6
- reflex/components/radix/themes/__init__.pyi +13 -0
- reflex/components/radix/themes/base.py +26 -20
- reflex/components/radix/themes/base.pyi +4 -1
- reflex/components/radix/themes/color_mode.py +3 -1
- reflex/components/radix/themes/color_mode.pyi +3 -1
- reflex/components/radix/themes/components/__init__.py +11 -79
- reflex/components/radix/themes/components/__init__.pyi +44 -0
- reflex/components/radix/themes/components/alert_dialog.py +2 -2
- reflex/components/radix/themes/components/alert_dialog.pyi +2 -2
- reflex/components/radix/themes/components/badge.py +2 -2
- reflex/components/radix/themes/components/badge.pyi +2 -2
- reflex/components/radix/themes/components/button.py +2 -2
- reflex/components/radix/themes/components/button.pyi +2 -2
- reflex/components/radix/themes/components/callout.py +4 -4
- reflex/components/radix/themes/components/callout.pyi +4 -4
- reflex/components/radix/themes/components/card.py +2 -2
- reflex/components/radix/themes/components/card.pyi +2 -2
- reflex/components/radix/themes/components/dialog.py +2 -2
- reflex/components/radix/themes/components/dialog.pyi +2 -2
- reflex/components/radix/themes/components/hover_card.py +2 -2
- reflex/components/radix/themes/components/hover_card.pyi +2 -2
- reflex/components/radix/themes/components/icon_button.py +2 -2
- reflex/components/radix/themes/components/icon_button.pyi +2 -2
- reflex/components/radix/themes/components/inset.py +2 -2
- reflex/components/radix/themes/components/inset.pyi +2 -2
- reflex/components/radix/themes/components/popover.py +2 -2
- reflex/components/radix/themes/components/popover.pyi +2 -2
- reflex/components/radix/themes/components/table.py +8 -8
- reflex/components/radix/themes/components/table.pyi +8 -8
- reflex/components/radix/themes/components/text_area.py +11 -2
- reflex/components/radix/themes/components/text_area.pyi +18 -3
- reflex/components/radix/themes/components/text_field.py +3 -3
- reflex/components/radix/themes/components/text_field.pyi +3 -3
- reflex/components/radix/themes/layout/__init__.py +12 -38
- reflex/components/radix/themes/layout/__init__.pyi +21 -0
- reflex/components/radix/themes/layout/box.py +5 -2
- reflex/components/radix/themes/layout/box.pyi +4 -2
- reflex/components/radix/themes/layout/center.py +3 -0
- reflex/components/radix/themes/layout/center.pyi +2 -0
- reflex/components/radix/themes/layout/container.py +5 -2
- reflex/components/radix/themes/layout/container.pyi +4 -2
- reflex/components/radix/themes/layout/flex.py +5 -2
- reflex/components/radix/themes/layout/flex.pyi +4 -2
- reflex/components/radix/themes/layout/grid.py +5 -2
- reflex/components/radix/themes/layout/grid.pyi +4 -2
- reflex/components/radix/themes/layout/list.py +14 -0
- reflex/components/radix/themes/layout/list.pyi +3 -0
- reflex/components/radix/themes/layout/section.py +7 -4
- reflex/components/radix/themes/layout/section.pyi +5 -3
- reflex/components/radix/themes/layout/spacer.py +3 -0
- reflex/components/radix/themes/layout/spacer.pyi +2 -0
- reflex/components/radix/themes/layout/stack.py +5 -0
- reflex/components/radix/themes/layout/stack.pyi +4 -0
- reflex/components/radix/themes/typography/__init__.py +11 -16
- reflex/components/radix/themes/typography/__init__.pyi +12 -0
- reflex/components/radix/themes/typography/blockquote.py +5 -2
- reflex/components/radix/themes/typography/blockquote.pyi +4 -2
- reflex/components/radix/themes/typography/code.py +5 -2
- reflex/components/radix/themes/typography/code.pyi +4 -2
- reflex/components/radix/themes/typography/heading.py +5 -2
- reflex/components/radix/themes/typography/heading.pyi +4 -2
- reflex/components/radix/themes/typography/link.py +3 -0
- reflex/components/radix/themes/typography/link.pyi +2 -0
- reflex/components/radix/themes/typography/text.py +6 -6
- reflex/components/radix/themes/typography/text.pyi +6 -6
- reflex/components/recharts/__init__.py +114 -104
- reflex/components/recharts/__init__.pyi +106 -0
- reflex/components/recharts/cartesian.py +17 -0
- reflex/components/recharts/cartesian.pyi +16 -0
- reflex/components/recharts/charts.py +12 -0
- reflex/components/recharts/charts.pyi +11 -0
- reflex/components/recharts/general.py +7 -0
- reflex/components/recharts/general.pyi +6 -0
- reflex/components/recharts/polar.py +11 -0
- reflex/components/recharts/polar.pyi +9 -0
- reflex/config.py +3 -0
- reflex/constants/__init__.py +0 -2
- reflex/constants/base.py +2 -0
- reflex/constants/base.pyi +5 -0
- reflex/constants/installer.py +2 -1
- reflex/experimental/__init__.py +2 -0
- reflex/experimental/assets.py +56 -0
- reflex/experimental/client_state.py +4 -2
- reflex/experimental/hooks.py +8 -6
- reflex/experimental/layout.py +3 -1
- reflex/state.py +54 -4
- reflex/utils/exec.py +8 -0
- reflex/utils/lazy_loader.py +33 -0
- reflex/utils/prerequisites.py +1 -14
- reflex/utils/pyi_generator.py +71 -20
- reflex/utils/serializers.py +3 -3
- reflex/vars.py +79 -5
- reflex/vars.pyi +16 -0
- {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/METADATA +2 -1
- {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/RECORD +162 -148
- reflex/config.pyi +0 -112
- {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/LICENSE +0 -0
- {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/WHEEL +0 -0
- {reflex-0.5.2a1.dist-info → reflex-0.5.3a1.dist-info}/entry_points.txt +0 -0
reflex/__init__.py
CHANGED
|
@@ -1,141 +1,281 @@
|
|
|
1
1
|
"""Import all classes and functions the end user will need to make an app.
|
|
2
2
|
|
|
3
3
|
Anything imported here will be available in the default Reflex import as `rx.*`.
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
Dynamic Imports
|
|
6
|
+
---------------
|
|
7
|
+
Reflex utilizes dynamic imports, or lazy loading, to reduce startup/import times.
|
|
8
|
+
With this approach, imports are delayed until they are actually needed. We use
|
|
9
|
+
the `lazy_loader` library(https://github.com/scientific-python/lazy_loader) to achieve this.
|
|
10
|
+
|
|
11
|
+
How it works
|
|
12
|
+
--------------
|
|
13
|
+
`lazy_loader.attach` takes two optional arguments: `submodules` and `submod_attrs`.
|
|
14
|
+
- `submodules` typically points to directories or files to be accessed.
|
|
15
|
+
- `submod_attrs` defines a mapping of directory or file names as keys with a list
|
|
16
|
+
of attributes or modules to access.
|
|
17
|
+
|
|
18
|
+
Example directory structure:
|
|
19
|
+
|
|
20
|
+
reflex/
|
|
21
|
+
|_ components/
|
|
22
|
+
|_ radix/
|
|
23
|
+
|_ themes/
|
|
24
|
+
|_ components/
|
|
25
|
+
|_ box.py
|
|
26
|
+
|
|
27
|
+
To add `box` under the `rx` namespace (`rx.box`), add the relative path to `submod_attrs` in
|
|
28
|
+
`reflex/__init__.py` (this file):
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
lazy_loader.attach(
|
|
32
|
+
submodules={"components"},
|
|
33
|
+
submod_attrs={
|
|
34
|
+
"components.radix.themes.components.box": ["box"]
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This implies that `box` will be imported from `reflex/components/radix/themes/components/box.py`.
|
|
40
|
+
|
|
41
|
+
To add box under the `rx.radix` namespace (`rx.radix.box`), add the relative path to the
|
|
42
|
+
submod_attrs argument in `reflex/components/radix/__init__.py`:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
lazy_loader.attach(
|
|
46
|
+
submodules = {"themes"},
|
|
47
|
+
submod_attrs = {
|
|
48
|
+
"themes.components.box": ["box"]
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Note: It is important to specify the immediate submodules of a directory in the submodules
|
|
54
|
+
argument to ensure they are registered at runtime. For example, 'components' for reflex,
|
|
55
|
+
'radix' for components, 'themes' for radix, etc.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
Pyi_generator
|
|
59
|
+
--------------
|
|
60
|
+
To generate `.pyi` files for `__init__.py` files, we read the `_SUBMODULES` and `_SUBMOD_ATTRS`
|
|
61
|
+
attributes to generate the import statements. It is highly recommended to define these with
|
|
62
|
+
the provided annotations to facilitate their generation.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
Aliases
|
|
66
|
+
------------
|
|
67
|
+
This is a special case to specify an alias for a component.
|
|
68
|
+
As an example, we use this typically for `rx.list` where defining `list` attribute in the list.py
|
|
69
|
+
overshadows python's list object which messes up the pyi generation for `list.pyi`. As a result, aliases
|
|
70
|
+
should be used for similar cases like this. Note that this logic is employed to fix the pyi generation and alias
|
|
71
|
+
should still be defined or accessible. Check out the __getattr__ logic in `reflex/components/radix/themes/layouts/list.py`
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
lazy_loader.attach(
|
|
75
|
+
submodules={"components"},
|
|
76
|
+
submod_attrs={
|
|
77
|
+
"components.radix.themes.layouts": [("list_ns", "list")]
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
In the example above, you will be able to do `rx.list`
|
|
6
83
|
"""
|
|
7
84
|
|
|
8
85
|
from __future__ import annotations
|
|
9
86
|
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
from
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
]
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
|
|
87
|
+
from reflex.utils import lazy_loader
|
|
88
|
+
|
|
89
|
+
# import this here explicitly to avoid returning the page module since page attr has the
|
|
90
|
+
# same name as page module(page.py)
|
|
91
|
+
from .page import page as page
|
|
92
|
+
|
|
93
|
+
RADIX_THEMES_MAPPING: dict = {
|
|
94
|
+
"components.radix.themes.base": ["color_mode", "theme", "theme_panel"],
|
|
95
|
+
"components.radix.themes.color_mode": ["color_mode"],
|
|
96
|
+
}
|
|
97
|
+
RADIX_THEMES_COMPONENTS_MAPPING: dict = {
|
|
98
|
+
**{
|
|
99
|
+
f"components.radix.themes.components.{mod}": [mod]
|
|
100
|
+
for mod in [
|
|
101
|
+
"alert_dialog",
|
|
102
|
+
"aspect_ratio",
|
|
103
|
+
"avatar",
|
|
104
|
+
"badge",
|
|
105
|
+
"button",
|
|
106
|
+
"callout",
|
|
107
|
+
"card",
|
|
108
|
+
"checkbox",
|
|
109
|
+
"context_menu",
|
|
110
|
+
"data_list",
|
|
111
|
+
"dialog",
|
|
112
|
+
"hover_card",
|
|
113
|
+
"icon_button",
|
|
114
|
+
"input",
|
|
115
|
+
"inset",
|
|
116
|
+
"popover",
|
|
117
|
+
"scroll_area",
|
|
118
|
+
"select",
|
|
119
|
+
"skeleton",
|
|
120
|
+
"slider",
|
|
121
|
+
"spinner",
|
|
122
|
+
"switch",
|
|
123
|
+
"table",
|
|
124
|
+
"tabs",
|
|
125
|
+
"text_area",
|
|
126
|
+
"tooltip",
|
|
127
|
+
"segmented_control",
|
|
128
|
+
"radio_cards",
|
|
129
|
+
"checkbox_cards",
|
|
130
|
+
"checkbox_group",
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"components.radix.themes.components.text_field": ["text_field", "input"],
|
|
134
|
+
"components.radix.themes.components.radio_group": ["radio", "radio_group"],
|
|
135
|
+
"components.radix.themes.components.dropdown_menu": ["menu", "dropdown_menu"],
|
|
136
|
+
"components.radix.themes.components.separator": ["divider", "separator"],
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
RADIX_THEMES_LAYOUT_MAPPING: dict = {
|
|
140
|
+
"components.radix.themes.layout.box": [
|
|
141
|
+
"box",
|
|
142
|
+
],
|
|
143
|
+
"components.radix.themes.layout.center": [
|
|
144
|
+
"center",
|
|
145
|
+
],
|
|
146
|
+
"components.radix.themes.layout.container": [
|
|
147
|
+
"container",
|
|
148
|
+
],
|
|
149
|
+
"components.radix.themes.layout.flex": [
|
|
150
|
+
"flex",
|
|
151
|
+
],
|
|
152
|
+
"components.radix.themes.layout.grid": [
|
|
153
|
+
"grid",
|
|
154
|
+
],
|
|
155
|
+
"components.radix.themes.layout.section": [
|
|
156
|
+
"section",
|
|
157
|
+
],
|
|
158
|
+
"components.radix.themes.layout.spacer": [
|
|
159
|
+
"spacer",
|
|
160
|
+
],
|
|
161
|
+
"components.radix.themes.layout.stack": [
|
|
162
|
+
"stack",
|
|
163
|
+
"hstack",
|
|
164
|
+
"vstack",
|
|
165
|
+
],
|
|
166
|
+
"components.radix.themes.layout.list": [
|
|
167
|
+
("list_ns", "list"),
|
|
168
|
+
"list_item",
|
|
169
|
+
"ordered_list",
|
|
170
|
+
"unordered_list",
|
|
171
|
+
],
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
RADIX_THEMES_TYPOGRAPHY_MAPPING: dict = {
|
|
175
|
+
"components.radix.themes.typography.blockquote": [
|
|
176
|
+
"blockquote",
|
|
177
|
+
],
|
|
178
|
+
"components.radix.themes.typography.code": [
|
|
179
|
+
"code",
|
|
180
|
+
],
|
|
181
|
+
"components.radix.themes.typography.heading": [
|
|
182
|
+
"heading",
|
|
183
|
+
],
|
|
184
|
+
"components.radix.themes.typography.link": [
|
|
185
|
+
"link",
|
|
186
|
+
],
|
|
187
|
+
"components.radix.themes.typography.text": [
|
|
188
|
+
"text",
|
|
189
|
+
],
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
RADIX_PRIMITIVES_MAPPING: dict = {
|
|
193
|
+
"components.radix.primitives.accordion": [
|
|
194
|
+
"accordion",
|
|
195
|
+
],
|
|
196
|
+
"components.radix.primitives.drawer": [
|
|
197
|
+
"drawer",
|
|
198
|
+
],
|
|
199
|
+
"components.radix.primitives.form": [
|
|
200
|
+
"form",
|
|
201
|
+
],
|
|
202
|
+
"components.radix.primitives.progress": ["progress"],
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
COMPONENTS_CORE_MAPPING: dict = {
|
|
206
|
+
"components.core.banner": [
|
|
207
|
+
"connection_banner",
|
|
208
|
+
"connection_modal",
|
|
209
|
+
],
|
|
210
|
+
"components.core.cond": ["cond", "color_mode_cond"],
|
|
211
|
+
"components.core.foreach": ["foreach"],
|
|
212
|
+
"components.core.debounce": ["debounce_input"],
|
|
213
|
+
"components.core.html": ["html"],
|
|
214
|
+
"components.core.match": ["match"],
|
|
215
|
+
"components.core.colors": ["color"],
|
|
216
|
+
"components.core.responsive": [
|
|
217
|
+
"desktop_only",
|
|
218
|
+
"mobile_and_tablet",
|
|
219
|
+
"mobile_only",
|
|
220
|
+
"tablet_and_desktop",
|
|
221
|
+
"tablet_only",
|
|
222
|
+
],
|
|
223
|
+
"components.core.upload": [
|
|
224
|
+
"cancel_upload",
|
|
225
|
+
"clear_selected_files",
|
|
226
|
+
"get_upload_dir",
|
|
227
|
+
"get_upload_url",
|
|
228
|
+
"selected_files",
|
|
229
|
+
"upload",
|
|
230
|
+
],
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
COMPONENTS_BASE_MAPPING: dict = {
|
|
234
|
+
"components.base.fragment": ["fragment", "Fragment"],
|
|
235
|
+
"components.base.script": ["script", "Script"],
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
RADIX_MAPPING: dict = {
|
|
239
|
+
**RADIX_THEMES_MAPPING,
|
|
240
|
+
**RADIX_THEMES_COMPONENTS_MAPPING,
|
|
241
|
+
**RADIX_THEMES_TYPOGRAPHY_MAPPING,
|
|
242
|
+
**RADIX_THEMES_LAYOUT_MAPPING,
|
|
243
|
+
**RADIX_PRIMITIVES_MAPPING,
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
_MAPPING: dict = {
|
|
247
|
+
"experimental": ["_x"],
|
|
248
|
+
"admin": ["AdminDash"],
|
|
249
|
+
"app": ["App", "UploadFile"],
|
|
250
|
+
"base": ["Base"],
|
|
251
|
+
"components.component": ["Component", "NoSSRComponent", "memo"],
|
|
252
|
+
"components.el.elements.media": ["image"],
|
|
253
|
+
"components.lucide": ["icon"],
|
|
254
|
+
**COMPONENTS_BASE_MAPPING,
|
|
255
|
+
"components.suneditor": [
|
|
256
|
+
"editor",
|
|
257
|
+
"EditorButtonList",
|
|
258
|
+
"EditorOptions",
|
|
259
|
+
],
|
|
260
|
+
"components": ["el", "chakra", "radix", "lucide", "recharts", "next"],
|
|
261
|
+
"components.markdown": ["markdown"],
|
|
262
|
+
**RADIX_MAPPING,
|
|
263
|
+
"components.plotly": ["plotly"],
|
|
264
|
+
"components.react_player": ["audio", "video"],
|
|
265
|
+
**COMPONENTS_CORE_MAPPING,
|
|
266
|
+
"components.datadisplay.code": [
|
|
267
|
+
"code_block",
|
|
268
|
+
],
|
|
269
|
+
"components.datadisplay.dataeditor": [
|
|
270
|
+
"data_editor",
|
|
271
|
+
"data_editor_theme",
|
|
272
|
+
],
|
|
273
|
+
"components.datadisplay.logo": ["logo"],
|
|
274
|
+
"components.gridjs": ["data_table"],
|
|
275
|
+
"components.moment": ["MomentDelta", "moment"],
|
|
276
|
+
"config": ["Config", "DBConfig"],
|
|
277
|
+
"constants": ["Env"],
|
|
278
|
+
"event": [
|
|
139
279
|
"EventChain",
|
|
140
280
|
"EventHandler",
|
|
141
281
|
"background",
|
|
@@ -155,84 +295,38 @@ _MAPPING = {
|
|
|
155
295
|
"upload_files",
|
|
156
296
|
"window_alert",
|
|
157
297
|
],
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"reflex.route": ["route"],
|
|
162
|
-
"reflex.state": [
|
|
163
|
-
"state",
|
|
298
|
+
"middleware": ["middleware", "Middleware"],
|
|
299
|
+
"model": ["session", "Model"],
|
|
300
|
+
"state": [
|
|
164
301
|
"var",
|
|
165
302
|
"Cookie",
|
|
166
303
|
"LocalStorage",
|
|
167
304
|
"ComponentState",
|
|
168
305
|
"State",
|
|
169
306
|
],
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"
|
|
174
|
-
"reflex.vars": ["vars", "cached_var", "Var"],
|
|
307
|
+
"style": ["Style", "toggle_color_mode"],
|
|
308
|
+
"utils.imports": ["ImportVar"],
|
|
309
|
+
"utils.serializers": ["serializer"],
|
|
310
|
+
"vars": ["cached_var", "Var"],
|
|
175
311
|
}
|
|
176
312
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
""
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
""
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
# _MAPPING = {value: key for key, values in _MAPPING.items() for value in values}
|
|
200
|
-
_MAPPING = _reverse_mapping(_MAPPING)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
def _removeprefix(text, prefix):
|
|
204
|
-
return text[text.startswith(prefix) and len(prefix) :]
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
__all__ = (_removeprefix(mod, "reflex.") for mod in _MAPPING)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
def __getattr__(name: str) -> Type:
|
|
211
|
-
"""Lazy load all modules.
|
|
212
|
-
|
|
213
|
-
Args:
|
|
214
|
-
name: name of the module to load.
|
|
215
|
-
|
|
216
|
-
Returns:
|
|
217
|
-
The module or the attribute of the module.
|
|
218
|
-
|
|
219
|
-
Raises:
|
|
220
|
-
AttributeError: If the module or the attribute does not exist.
|
|
221
|
-
"""
|
|
222
|
-
try:
|
|
223
|
-
# Check for import of a module that is not in the mapping.
|
|
224
|
-
if name not in _MAPPING:
|
|
225
|
-
# If the name does not start with reflex, add it.
|
|
226
|
-
if not name.startswith("reflex") and name != "__all__":
|
|
227
|
-
name = f"reflex.{name}"
|
|
228
|
-
return importlib.import_module(name)
|
|
229
|
-
|
|
230
|
-
# Import the module.
|
|
231
|
-
module = importlib.import_module(_MAPPING[name])
|
|
232
|
-
|
|
233
|
-
# Get the attribute from the module if the name is not the module itself.
|
|
234
|
-
return (
|
|
235
|
-
getattr(module, name) if name != _MAPPING[name].rsplit(".")[-1] else module
|
|
236
|
-
)
|
|
237
|
-
except ModuleNotFoundError:
|
|
238
|
-
raise AttributeError(f"module 'reflex' has no attribute {name}") from None
|
|
313
|
+
_SUBMODULES: set[str] = {
|
|
314
|
+
"components",
|
|
315
|
+
"event",
|
|
316
|
+
"app",
|
|
317
|
+
"style",
|
|
318
|
+
"admin",
|
|
319
|
+
"base",
|
|
320
|
+
"model",
|
|
321
|
+
"testing",
|
|
322
|
+
"utils",
|
|
323
|
+
"vars",
|
|
324
|
+
"config",
|
|
325
|
+
"compiler",
|
|
326
|
+
}
|
|
327
|
+
_SUBMOD_ATTRS: dict = _MAPPING
|
|
328
|
+
__getattr__, __dir__, __all__ = lazy_loader.attach(
|
|
329
|
+
__name__,
|
|
330
|
+
submodules=_SUBMODULES,
|
|
331
|
+
submod_attrs=_SUBMOD_ATTRS,
|
|
332
|
+
)
|