reflex 0.4.6a3__py3-none-any.whl → 0.4.7__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 +1 -0
- reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +1 -1
- reflex/.templates/jinja/custom_components/src.py.jinja2 +8 -8
- reflex/.templates/jinja/web/pages/index.js.jinja2 +0 -4
- reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 +2 -6
- reflex/.templates/web/utils/state.js +6 -1
- reflex/__init__.py +2 -0
- reflex/__init__.pyi +2 -0
- reflex/app.py +12 -16
- reflex/app.pyi +2 -0
- reflex/compiler/compiler.py +10 -11
- reflex/compiler/utils.py +3 -3
- reflex/components/chakra/forms/pininput.py +2 -1
- reflex/components/component.py +71 -131
- reflex/components/core/banner.py +1 -1
- reflex/components/core/upload.py +2 -1
- reflex/components/datadisplay/__init__.py +1 -0
- reflex/components/datadisplay/logo.py +49 -0
- reflex/components/el/elements/forms.py +7 -4
- reflex/components/el/elements/forms.pyi +0 -1
- reflex/components/lucide/icon.py +3 -2
- reflex/components/lucide/icon.pyi +2 -2
- reflex/components/markdown/markdown.py +10 -6
- reflex/components/markdown/markdown.pyi +0 -3
- reflex/components/radix/themes/components/select.py +10 -3
- reflex/config.py +1 -1
- reflex/config.pyi +1 -1
- reflex/constants/base.py +4 -5
- reflex/constants/base.pyi +94 -0
- reflex/constants/compiler.py +8 -0
- reflex/custom_components/custom_components.py +33 -38
- reflex/experimental/__init__.py +14 -0
- reflex/experimental/hooks.py +75 -0
- reflex/page.py +1 -1
- reflex/reflex.py +18 -32
- reflex/style.py +4 -4
- reflex/testing.py +1 -1
- reflex/utils/console.py +6 -4
- reflex/utils/exec.py +17 -1
- reflex/utils/export.py +0 -3
- reflex/utils/prerequisites.py +243 -43
- reflex/utils/processes.py +6 -1
- reflex/utils/telemetry.py +14 -2
- reflex/utils/types.py +3 -2
- reflex/vars.py +6 -6
- reflex/vars.pyi +2 -1
- {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/METADATA +15 -10
- {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/RECORD +51 -65
- {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/WHEEL +1 -1
- reflex/.templates/apps/sidebar/README.md +0 -69
- reflex/.templates/apps/sidebar/assets/favicon.ico +0 -0
- reflex/.templates/apps/sidebar/assets/github.svg +0 -10
- reflex/.templates/apps/sidebar/assets/logo.svg +0 -68
- reflex/.templates/apps/sidebar/assets/paneleft.svg +0 -13
- reflex/.templates/apps/sidebar/assets/reflex_black.svg +0 -37
- reflex/.templates/apps/sidebar/assets/reflex_white.svg +0 -8
- reflex/.templates/apps/sidebar/code/__init__.py +0 -1
- reflex/.templates/apps/sidebar/code/components/__init__.py +0 -0
- reflex/.templates/apps/sidebar/code/components/sidebar.py +0 -152
- reflex/.templates/apps/sidebar/code/pages/__init__.py +0 -3
- reflex/.templates/apps/sidebar/code/pages/dashboard.py +0 -22
- reflex/.templates/apps/sidebar/code/pages/index.py +0 -18
- reflex/.templates/apps/sidebar/code/pages/settings.py +0 -61
- reflex/.templates/apps/sidebar/code/sidebar.py +0 -16
- reflex/.templates/apps/sidebar/code/styles.py +0 -60
- reflex/.templates/apps/sidebar/code/templates/__init__.py +0 -1
- reflex/.templates/apps/sidebar/code/templates/template.py +0 -145
- {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/LICENSE +0 -0
- {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/entry_points.txt +0 -0
reflex/components/component.py
CHANGED
|
@@ -76,15 +76,7 @@ class BaseComponent(Base, ABC):
|
|
|
76
76
|
"""
|
|
77
77
|
|
|
78
78
|
@abstractmethod
|
|
79
|
-
def
|
|
80
|
-
"""Get the hooks required by refs in this component.
|
|
81
|
-
|
|
82
|
-
Returns:
|
|
83
|
-
The hooks for the refs.
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
@abstractmethod
|
|
87
|
-
def get_hooks_internal(self) -> set[str]:
|
|
79
|
+
def _get_all_hooks_internal(self) -> dict[str, None]:
|
|
88
80
|
"""Get the reflex internal hooks for the component and its children.
|
|
89
81
|
|
|
90
82
|
Returns:
|
|
@@ -92,7 +84,7 @@ class BaseComponent(Base, ABC):
|
|
|
92
84
|
"""
|
|
93
85
|
|
|
94
86
|
@abstractmethod
|
|
95
|
-
def
|
|
87
|
+
def _get_all_hooks(self) -> dict[str, None]:
|
|
96
88
|
"""Get the React hooks for this component.
|
|
97
89
|
|
|
98
90
|
Returns:
|
|
@@ -100,7 +92,7 @@ class BaseComponent(Base, ABC):
|
|
|
100
92
|
"""
|
|
101
93
|
|
|
102
94
|
@abstractmethod
|
|
103
|
-
def
|
|
95
|
+
def _get_all_imports(self) -> imports.ImportDict:
|
|
104
96
|
"""Get all the libraries and fields that are used by the component.
|
|
105
97
|
|
|
106
98
|
Returns:
|
|
@@ -108,7 +100,7 @@ class BaseComponent(Base, ABC):
|
|
|
108
100
|
"""
|
|
109
101
|
|
|
110
102
|
@abstractmethod
|
|
111
|
-
def
|
|
103
|
+
def _get_all_dynamic_imports(self) -> set[str]:
|
|
112
104
|
"""Get dynamic imports for the component.
|
|
113
105
|
|
|
114
106
|
Returns:
|
|
@@ -116,7 +108,7 @@ class BaseComponent(Base, ABC):
|
|
|
116
108
|
"""
|
|
117
109
|
|
|
118
110
|
@abstractmethod
|
|
119
|
-
def
|
|
111
|
+
def _get_all_custom_code(self) -> set[str]:
|
|
120
112
|
"""Get custom code for the component.
|
|
121
113
|
|
|
122
114
|
Returns:
|
|
@@ -124,7 +116,7 @@ class BaseComponent(Base, ABC):
|
|
|
124
116
|
"""
|
|
125
117
|
|
|
126
118
|
@abstractmethod
|
|
127
|
-
def
|
|
119
|
+
def _get_all_refs(self) -> set[str]:
|
|
128
120
|
"""Get the refs for the children of the component.
|
|
129
121
|
|
|
130
122
|
Returns:
|
|
@@ -645,6 +637,9 @@ class Component(BaseComponent, ABC):
|
|
|
645
637
|
)
|
|
646
638
|
props[prop] = props.pop(under_prop)
|
|
647
639
|
|
|
640
|
+
# Filter out None props
|
|
641
|
+
props = {key: value for key, value in props.items() if value is not None}
|
|
642
|
+
|
|
648
643
|
# Validate all the children.
|
|
649
644
|
for child in children:
|
|
650
645
|
# Make sure the child is a valid type.
|
|
@@ -674,7 +669,7 @@ class Component(BaseComponent, ABC):
|
|
|
674
669
|
"""
|
|
675
670
|
self.style.update(style)
|
|
676
671
|
|
|
677
|
-
def
|
|
672
|
+
def _add_style_recursive(self, style: ComponentStyle) -> Component:
|
|
678
673
|
"""Add additional style to the component and its children.
|
|
679
674
|
|
|
680
675
|
Args:
|
|
@@ -703,7 +698,7 @@ class Component(BaseComponent, ABC):
|
|
|
703
698
|
# Skip BaseComponent and StatefulComponent children.
|
|
704
699
|
if not isinstance(child, Component):
|
|
705
700
|
continue
|
|
706
|
-
child.
|
|
701
|
+
child._add_style_recursive(style)
|
|
707
702
|
return self
|
|
708
703
|
|
|
709
704
|
def _get_style(self) -> dict:
|
|
@@ -926,7 +921,7 @@ class Component(BaseComponent, ABC):
|
|
|
926
921
|
"""
|
|
927
922
|
return None
|
|
928
923
|
|
|
929
|
-
def
|
|
924
|
+
def _get_all_custom_code(self) -> set[str]:
|
|
930
925
|
"""Get custom code for the component and its children.
|
|
931
926
|
|
|
932
927
|
Returns:
|
|
@@ -942,7 +937,7 @@ class Component(BaseComponent, ABC):
|
|
|
942
937
|
|
|
943
938
|
# Add the custom code for the children.
|
|
944
939
|
for child in self.children:
|
|
945
|
-
code |= child.
|
|
940
|
+
code |= child._get_all_custom_code()
|
|
946
941
|
|
|
947
942
|
# Return the code.
|
|
948
943
|
return code
|
|
@@ -955,7 +950,7 @@ class Component(BaseComponent, ABC):
|
|
|
955
950
|
"""
|
|
956
951
|
return None
|
|
957
952
|
|
|
958
|
-
def
|
|
953
|
+
def _get_all_dynamic_imports(self) -> Set[str]:
|
|
959
954
|
"""Get dynamic imports for the component and its children.
|
|
960
955
|
|
|
961
956
|
Returns:
|
|
@@ -971,11 +966,11 @@ class Component(BaseComponent, ABC):
|
|
|
971
966
|
|
|
972
967
|
# Get the dynamic imports from children
|
|
973
968
|
for child in self.children:
|
|
974
|
-
dynamic_imports |= child.
|
|
969
|
+
dynamic_imports |= child._get_all_dynamic_imports()
|
|
975
970
|
|
|
976
971
|
for prop in self.get_component_props():
|
|
977
972
|
if getattr(self, prop) is not None:
|
|
978
|
-
dynamic_imports |= getattr(self, prop).
|
|
973
|
+
dynamic_imports |= getattr(self, prop)._get_all_dynamic_imports()
|
|
979
974
|
|
|
980
975
|
# Return the dynamic imports
|
|
981
976
|
return dynamic_imports
|
|
@@ -987,7 +982,7 @@ class Component(BaseComponent, ABC):
|
|
|
987
982
|
The imports for the components props of the component.
|
|
988
983
|
"""
|
|
989
984
|
return [
|
|
990
|
-
getattr(self, prop).
|
|
985
|
+
getattr(self, prop)._get_all_imports()
|
|
991
986
|
for prop in self.get_component_props()
|
|
992
987
|
if getattr(self, prop) is not None
|
|
993
988
|
]
|
|
@@ -1029,16 +1024,6 @@ class Component(BaseComponent, ABC):
|
|
|
1029
1024
|
)
|
|
1030
1025
|
return _imports
|
|
1031
1026
|
|
|
1032
|
-
def add_imports(
|
|
1033
|
-
self,
|
|
1034
|
-
) -> Dict[str, Union[str, ImportVar, List[str | ImportVar]]]:
|
|
1035
|
-
"""User defined imports for the component. Need to be overriden in subclass.
|
|
1036
|
-
|
|
1037
|
-
Returns:
|
|
1038
|
-
The user defined imports as a dict.
|
|
1039
|
-
"""
|
|
1040
|
-
return {}
|
|
1041
|
-
|
|
1042
1027
|
def _get_imports(self) -> imports.ImportDict:
|
|
1043
1028
|
"""Get all the libraries and fields that are used by the component.
|
|
1044
1029
|
|
|
@@ -1059,33 +1044,16 @@ class Component(BaseComponent, ABC):
|
|
|
1059
1044
|
var._var_data.imports for var in self._get_vars() if var._var_data
|
|
1060
1045
|
]
|
|
1061
1046
|
|
|
1062
|
-
# If the subclass implements add_imports, merge the imports.
|
|
1063
|
-
def _make_list(
|
|
1064
|
-
value: str | ImportVar | list[str | ImportVar],
|
|
1065
|
-
) -> list[str | ImportVar]:
|
|
1066
|
-
if isinstance(value, (str, ImportVar)):
|
|
1067
|
-
return [value]
|
|
1068
|
-
return value
|
|
1069
|
-
|
|
1070
|
-
added_imports = {
|
|
1071
|
-
package: [
|
|
1072
|
-
ImportVar(tag=tag) if not isinstance(tag, ImportVar) else tag
|
|
1073
|
-
for tag in _make_list(maybe_tags)
|
|
1074
|
-
]
|
|
1075
|
-
for package, maybe_tags in self.add_imports().items()
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
1047
|
return imports.merge_imports(
|
|
1079
1048
|
*self._get_props_imports(),
|
|
1080
1049
|
self._get_dependencies_imports(),
|
|
1081
1050
|
self._get_hooks_imports(),
|
|
1082
1051
|
_imports,
|
|
1083
1052
|
event_imports,
|
|
1084
|
-
added_imports,
|
|
1085
1053
|
*var_imports,
|
|
1086
1054
|
)
|
|
1087
1055
|
|
|
1088
|
-
def
|
|
1056
|
+
def _get_all_imports(self, collapse: bool = False) -> imports.ImportDict:
|
|
1089
1057
|
"""Get all the libraries and fields that are used by the component and its children.
|
|
1090
1058
|
|
|
1091
1059
|
Args:
|
|
@@ -1095,7 +1063,7 @@ class Component(BaseComponent, ABC):
|
|
|
1095
1063
|
The import dict with the required imports.
|
|
1096
1064
|
"""
|
|
1097
1065
|
_imports = imports.merge_imports(
|
|
1098
|
-
self._get_imports(), *[child.
|
|
1066
|
+
self._get_imports(), *[child._get_all_imports() for child in self.children]
|
|
1099
1067
|
)
|
|
1100
1068
|
return imports.collapse_imports(_imports) if collapse else _imports
|
|
1101
1069
|
|
|
@@ -1132,62 +1100,53 @@ class Component(BaseComponent, ABC):
|
|
|
1132
1100
|
if ref is not None:
|
|
1133
1101
|
return f"const {ref} = useRef(null); {str(Var.create_safe(ref).as_ref())} = {ref};"
|
|
1134
1102
|
|
|
1135
|
-
def _get_vars_hooks(self) ->
|
|
1103
|
+
def _get_vars_hooks(self) -> dict[str, None]:
|
|
1136
1104
|
"""Get the hooks required by vars referenced in this component.
|
|
1137
1105
|
|
|
1138
1106
|
Returns:
|
|
1139
1107
|
The hooks for the vars.
|
|
1140
1108
|
"""
|
|
1141
|
-
vars_hooks =
|
|
1109
|
+
vars_hooks = {}
|
|
1142
1110
|
for var in self._get_vars():
|
|
1143
1111
|
if var._var_data:
|
|
1144
1112
|
vars_hooks.update(var._var_data.hooks)
|
|
1145
1113
|
return vars_hooks
|
|
1146
1114
|
|
|
1147
|
-
def _get_events_hooks(self) ->
|
|
1115
|
+
def _get_events_hooks(self) -> dict[str, None]:
|
|
1148
1116
|
"""Get the hooks required by events referenced in this component.
|
|
1149
1117
|
|
|
1150
1118
|
Returns:
|
|
1151
1119
|
The hooks for the events.
|
|
1152
1120
|
"""
|
|
1153
|
-
if self.event_triggers
|
|
1154
|
-
return {Hooks.EVENTS}
|
|
1155
|
-
return set()
|
|
1121
|
+
return {Hooks.EVENTS: None} if self.event_triggers else {}
|
|
1156
1122
|
|
|
1157
|
-
def _get_special_hooks(self) ->
|
|
1123
|
+
def _get_special_hooks(self) -> dict[str, None]:
|
|
1158
1124
|
"""Get the hooks required by special actions referenced in this component.
|
|
1159
1125
|
|
|
1160
1126
|
Returns:
|
|
1161
1127
|
The hooks for special actions.
|
|
1162
1128
|
"""
|
|
1163
|
-
if self.autofocus
|
|
1164
|
-
return {
|
|
1165
|
-
"""
|
|
1166
|
-
// Set focus to the specified element.
|
|
1167
|
-
const focusRef = useRef(null)
|
|
1168
|
-
useEffect(() => {
|
|
1169
|
-
if (focusRef.current) {
|
|
1170
|
-
focusRef.current.focus();
|
|
1171
|
-
}
|
|
1172
|
-
})""",
|
|
1173
|
-
}
|
|
1174
|
-
return set()
|
|
1129
|
+
return {Hooks.AUTOFOCUS: None} if self.autofocus else {}
|
|
1175
1130
|
|
|
1176
|
-
def _get_hooks_internal(self) ->
|
|
1131
|
+
def _get_hooks_internal(self) -> dict[str, None]:
|
|
1177
1132
|
"""Get the React hooks for this component managed by the framework.
|
|
1178
1133
|
|
|
1179
1134
|
Downstream components should NOT override this method to avoid breaking
|
|
1180
1135
|
framework functionality.
|
|
1181
1136
|
|
|
1182
1137
|
Returns:
|
|
1183
|
-
|
|
1138
|
+
The internally managed hooks.
|
|
1184
1139
|
"""
|
|
1185
|
-
return
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1140
|
+
return {
|
|
1141
|
+
**{
|
|
1142
|
+
hook: None
|
|
1143
|
+
for hook in [self._get_ref_hook(), self._get_mount_lifecycle_hook()]
|
|
1144
|
+
if hook is not None
|
|
1145
|
+
},
|
|
1146
|
+
**self._get_vars_hooks(),
|
|
1147
|
+
**self._get_events_hooks(),
|
|
1148
|
+
**self._get_special_hooks(),
|
|
1149
|
+
}
|
|
1191
1150
|
|
|
1192
1151
|
def _get_hooks(self) -> str | None:
|
|
1193
1152
|
"""Get the React hooks for this component.
|
|
@@ -1199,20 +1158,7 @@ class Component(BaseComponent, ABC):
|
|
|
1199
1158
|
"""
|
|
1200
1159
|
return
|
|
1201
1160
|
|
|
1202
|
-
def
|
|
1203
|
-
"""Get the ref hooks for the component and its children.
|
|
1204
|
-
|
|
1205
|
-
Returns:
|
|
1206
|
-
The ref hooks.
|
|
1207
|
-
"""
|
|
1208
|
-
ref_hook = self._get_ref_hook()
|
|
1209
|
-
hooks = set() if ref_hook is None else {ref_hook}
|
|
1210
|
-
|
|
1211
|
-
for child in self.children:
|
|
1212
|
-
hooks |= child.get_ref_hooks()
|
|
1213
|
-
return hooks
|
|
1214
|
-
|
|
1215
|
-
def get_hooks_internal(self) -> set[str]:
|
|
1161
|
+
def _get_all_hooks_internal(self) -> dict[str, None]:
|
|
1216
1162
|
"""Get the reflex internal hooks for the component and its children.
|
|
1217
1163
|
|
|
1218
1164
|
Returns:
|
|
@@ -1223,26 +1169,26 @@ class Component(BaseComponent, ABC):
|
|
|
1223
1169
|
|
|
1224
1170
|
# Add the hook code for the children.
|
|
1225
1171
|
for child in self.children:
|
|
1226
|
-
code
|
|
1172
|
+
code = {**code, **child._get_all_hooks_internal()}
|
|
1227
1173
|
|
|
1228
1174
|
return code
|
|
1229
1175
|
|
|
1230
|
-
def
|
|
1176
|
+
def _get_all_hooks(self) -> dict[str, None]:
|
|
1231
1177
|
"""Get the React hooks for this component and its children.
|
|
1232
1178
|
|
|
1233
1179
|
Returns:
|
|
1234
1180
|
The code that should appear just before returning the rendered component.
|
|
1235
1181
|
"""
|
|
1236
|
-
code =
|
|
1182
|
+
code = {}
|
|
1237
1183
|
|
|
1238
1184
|
# Add the hook code for this component.
|
|
1239
1185
|
hooks = self._get_hooks()
|
|
1240
1186
|
if hooks is not None:
|
|
1241
|
-
code
|
|
1187
|
+
code[hooks] = None
|
|
1242
1188
|
|
|
1243
1189
|
# Add the hook code for the children.
|
|
1244
1190
|
for child in self.children:
|
|
1245
|
-
code
|
|
1191
|
+
code = {**code, **child._get_all_hooks()}
|
|
1246
1192
|
|
|
1247
1193
|
return code
|
|
1248
1194
|
|
|
@@ -1257,7 +1203,7 @@ class Component(BaseComponent, ABC):
|
|
|
1257
1203
|
return None
|
|
1258
1204
|
return format.format_ref(self.id)
|
|
1259
1205
|
|
|
1260
|
-
def
|
|
1206
|
+
def _get_all_refs(self) -> set[str]:
|
|
1261
1207
|
"""Get the refs for the children of the component.
|
|
1262
1208
|
|
|
1263
1209
|
Returns:
|
|
@@ -1268,10 +1214,10 @@ class Component(BaseComponent, ABC):
|
|
|
1268
1214
|
if ref is not None:
|
|
1269
1215
|
refs.add(ref)
|
|
1270
1216
|
for child in self.children:
|
|
1271
|
-
refs |= child.
|
|
1217
|
+
refs |= child._get_all_refs()
|
|
1272
1218
|
return refs
|
|
1273
1219
|
|
|
1274
|
-
def
|
|
1220
|
+
def _get_all_custom_components(
|
|
1275
1221
|
self, seen: set[str] | None = None
|
|
1276
1222
|
) -> Set[CustomComponent]:
|
|
1277
1223
|
"""Get all the custom components used by the component.
|
|
@@ -1291,7 +1237,7 @@ class Component(BaseComponent, ABC):
|
|
|
1291
1237
|
# Skip BaseComponent and StatefulComponent children.
|
|
1292
1238
|
if not isinstance(child, Component):
|
|
1293
1239
|
continue
|
|
1294
|
-
custom_components |= child.
|
|
1240
|
+
custom_components |= child._get_all_custom_components(seen=seen)
|
|
1295
1241
|
return custom_components
|
|
1296
1242
|
|
|
1297
1243
|
@property
|
|
@@ -1315,7 +1261,7 @@ class Component(BaseComponent, ABC):
|
|
|
1315
1261
|
"""
|
|
1316
1262
|
return {}
|
|
1317
1263
|
|
|
1318
|
-
def
|
|
1264
|
+
def _get_all_app_wrap_components(self) -> dict[tuple[int, str], Component]:
|
|
1319
1265
|
"""Get the app wrap components for the component and its children.
|
|
1320
1266
|
|
|
1321
1267
|
Returns:
|
|
@@ -1325,14 +1271,14 @@ class Component(BaseComponent, ABC):
|
|
|
1325
1271
|
components = self._get_app_wrap_components()
|
|
1326
1272
|
|
|
1327
1273
|
for component in tuple(components.values()):
|
|
1328
|
-
components.update(component.
|
|
1274
|
+
components.update(component._get_all_app_wrap_components())
|
|
1329
1275
|
|
|
1330
1276
|
# Add the app wrap components for the children.
|
|
1331
1277
|
for child in self.children:
|
|
1332
1278
|
# Skip BaseComponent and StatefulComponent children.
|
|
1333
1279
|
if not isinstance(child, Component):
|
|
1334
1280
|
continue
|
|
1335
|
-
components.update(child.
|
|
1281
|
+
components.update(child._get_all_app_wrap_components())
|
|
1336
1282
|
|
|
1337
1283
|
# Return the components.
|
|
1338
1284
|
return components
|
|
@@ -1401,8 +1347,8 @@ class CustomComponent(Component):
|
|
|
1401
1347
|
self.component_props[key] = value
|
|
1402
1348
|
value = base_value._replace(
|
|
1403
1349
|
merge_var_data=VarData( # type: ignore
|
|
1404
|
-
imports=value.
|
|
1405
|
-
hooks=value.
|
|
1350
|
+
imports=value._get_all_imports(),
|
|
1351
|
+
hooks=value._get_all_hooks(),
|
|
1406
1352
|
)
|
|
1407
1353
|
)
|
|
1408
1354
|
else:
|
|
@@ -1441,7 +1387,7 @@ class CustomComponent(Component):
|
|
|
1441
1387
|
"""
|
|
1442
1388
|
return set()
|
|
1443
1389
|
|
|
1444
|
-
def
|
|
1390
|
+
def _get_all_custom_components(
|
|
1445
1391
|
self, seen: set[str] | None = None
|
|
1446
1392
|
) -> Set[CustomComponent]:
|
|
1447
1393
|
"""Get all the custom components used by the component.
|
|
@@ -1457,12 +1403,12 @@ class CustomComponent(Component):
|
|
|
1457
1403
|
# Store the seen components in a set to avoid infinite recursion.
|
|
1458
1404
|
if seen is None:
|
|
1459
1405
|
seen = set()
|
|
1460
|
-
custom_components = {self} | super().
|
|
1406
|
+
custom_components = {self} | super()._get_all_custom_components(seen=seen)
|
|
1461
1407
|
|
|
1462
1408
|
# Avoid adding the same component twice.
|
|
1463
1409
|
if self.tag not in seen:
|
|
1464
1410
|
seen.add(self.tag)
|
|
1465
|
-
custom_components |= self.get_component(self).
|
|
1411
|
+
custom_components |= self.get_component(self)._get_all_custom_components(
|
|
1466
1412
|
seen=seen
|
|
1467
1413
|
)
|
|
1468
1414
|
|
|
@@ -1474,7 +1420,9 @@ class CustomComponent(Component):
|
|
|
1474
1420
|
seen.add(child_component.tag)
|
|
1475
1421
|
if isinstance(child_component, CustomComponent):
|
|
1476
1422
|
custom_components |= {child_component}
|
|
1477
|
-
custom_components |= child_component.
|
|
1423
|
+
custom_components |= child_component._get_all_custom_components(
|
|
1424
|
+
seen=seen
|
|
1425
|
+
)
|
|
1478
1426
|
return custom_components
|
|
1479
1427
|
|
|
1480
1428
|
def _render(self) -> Tag:
|
|
@@ -1878,31 +1826,23 @@ class StatefulComponent(BaseComponent):
|
|
|
1878
1826
|
)
|
|
1879
1827
|
return trigger_memo
|
|
1880
1828
|
|
|
1881
|
-
def
|
|
1882
|
-
"""Get the ref hooks for the component and its children.
|
|
1883
|
-
|
|
1884
|
-
Returns:
|
|
1885
|
-
The ref hooks.
|
|
1886
|
-
"""
|
|
1887
|
-
return set()
|
|
1888
|
-
|
|
1889
|
-
def get_hooks_internal(self) -> set[str]:
|
|
1829
|
+
def _get_all_hooks_internal(self) -> dict[str, None]:
|
|
1890
1830
|
"""Get the reflex internal hooks for the component and its children.
|
|
1891
1831
|
|
|
1892
1832
|
Returns:
|
|
1893
1833
|
The code that should appear just before user-defined hooks.
|
|
1894
1834
|
"""
|
|
1895
|
-
return
|
|
1835
|
+
return {}
|
|
1896
1836
|
|
|
1897
|
-
def
|
|
1837
|
+
def _get_all_hooks(self) -> dict[str, None]:
|
|
1898
1838
|
"""Get the React hooks for this component.
|
|
1899
1839
|
|
|
1900
1840
|
Returns:
|
|
1901
1841
|
The code that should appear just before returning the rendered component.
|
|
1902
1842
|
"""
|
|
1903
|
-
return
|
|
1843
|
+
return {}
|
|
1904
1844
|
|
|
1905
|
-
def
|
|
1845
|
+
def _get_all_imports(self) -> imports.ImportDict:
|
|
1906
1846
|
"""Get all the libraries and fields that are used by the component.
|
|
1907
1847
|
|
|
1908
1848
|
Returns:
|
|
@@ -1914,9 +1854,9 @@ class StatefulComponent(BaseComponent):
|
|
|
1914
1854
|
ImportVar(tag=self.tag)
|
|
1915
1855
|
]
|
|
1916
1856
|
}
|
|
1917
|
-
return self.component.
|
|
1857
|
+
return self.component._get_all_imports()
|
|
1918
1858
|
|
|
1919
|
-
def
|
|
1859
|
+
def _get_all_dynamic_imports(self) -> set[str]:
|
|
1920
1860
|
"""Get dynamic imports for the component.
|
|
1921
1861
|
|
|
1922
1862
|
Returns:
|
|
@@ -1924,9 +1864,9 @@ class StatefulComponent(BaseComponent):
|
|
|
1924
1864
|
"""
|
|
1925
1865
|
if self.rendered_as_shared:
|
|
1926
1866
|
return set()
|
|
1927
|
-
return self.component.
|
|
1867
|
+
return self.component._get_all_dynamic_imports()
|
|
1928
1868
|
|
|
1929
|
-
def
|
|
1869
|
+
def _get_all_custom_code(self) -> set[str]:
|
|
1930
1870
|
"""Get custom code for the component.
|
|
1931
1871
|
|
|
1932
1872
|
Returns:
|
|
@@ -1934,9 +1874,9 @@ class StatefulComponent(BaseComponent):
|
|
|
1934
1874
|
"""
|
|
1935
1875
|
if self.rendered_as_shared:
|
|
1936
1876
|
return set()
|
|
1937
|
-
return self.component.
|
|
1877
|
+
return self.component._get_all_custom_code().union({self.code})
|
|
1938
1878
|
|
|
1939
|
-
def
|
|
1879
|
+
def _get_all_refs(self) -> set[str]:
|
|
1940
1880
|
"""Get the refs for the children of the component.
|
|
1941
1881
|
|
|
1942
1882
|
Returns:
|
|
@@ -1944,7 +1884,7 @@ class StatefulComponent(BaseComponent):
|
|
|
1944
1884
|
"""
|
|
1945
1885
|
if self.rendered_as_shared:
|
|
1946
1886
|
return set()
|
|
1947
|
-
return self.component.
|
|
1887
|
+
return self.component._get_all_refs()
|
|
1948
1888
|
|
|
1949
1889
|
def render(self) -> dict:
|
|
1950
1890
|
"""Define how to render the component in React.
|
|
@@ -2002,7 +1942,7 @@ class MemoizationLeaf(Component):
|
|
|
2002
1942
|
The memoization leaf
|
|
2003
1943
|
"""
|
|
2004
1944
|
comp = super().create(*children, **props)
|
|
2005
|
-
if comp.
|
|
1945
|
+
if comp._get_all_hooks() or comp._get_all_hooks_internal():
|
|
2006
1946
|
comp._memoization_mode = cls._memoization_mode.copy(
|
|
2007
1947
|
update={"disposition": MemoizationDisposition.ALWAYS}
|
|
2008
1948
|
)
|
reflex/components/core/banner.py
CHANGED
reflex/components/core/upload.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""A file upload component."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
import os
|
|
@@ -31,7 +32,7 @@ upload_files_context_var_data: VarData = VarData( # type: ignore
|
|
|
31
32
|
},
|
|
32
33
|
},
|
|
33
34
|
hooks={
|
|
34
|
-
"const [filesById, setFilesById] = useContext(UploadFilesContext);",
|
|
35
|
+
"const [filesById, setFilesById] = useContext(UploadFilesContext);": None,
|
|
35
36
|
},
|
|
36
37
|
)
|
|
37
38
|
|
|
@@ -4,6 +4,7 @@ from .code import CodeBlock
|
|
|
4
4
|
from .code import LiteralCodeBlockTheme as LiteralCodeBlockTheme
|
|
5
5
|
from .code import LiteralCodeLanguage as LiteralCodeLanguage
|
|
6
6
|
from .dataeditor import DataEditor, DataEditorTheme
|
|
7
|
+
from .logo import logo
|
|
7
8
|
|
|
8
9
|
code_block = CodeBlock.create
|
|
9
10
|
data_editor = DataEditor.create
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""A Reflex logo component."""
|
|
2
|
+
import reflex as rx
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def logo(**props):
|
|
6
|
+
"""A Reflex logo.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
**props: The props to pass to the component.
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
The logo component.
|
|
13
|
+
"""
|
|
14
|
+
light_mode_logo = """<svg width="56" height="12" viewBox="0 0 56 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
15
|
+
<path d="M0 11.6V0.400024H8.96V4.88002H6.72V2.64002H2.24V4.88002H6.72V7.12002H2.24V11.6H0ZM6.72 11.6V7.12002H8.96V11.6H6.72Z" fill="#110F1F"/>
|
|
16
|
+
<path d="M11.2 11.6V0.400024H17.92V2.64002H13.44V4.88002H17.92V7.12002H13.44V9.36002H17.92V11.6H11.2Z" fill="#110F1F"/>
|
|
17
|
+
<path d="M20.16 11.6V0.400024H26.88V2.64002H22.4V4.88002H26.88V7.12002H22.4V11.6H20.16Z" fill="#110F1F"/>
|
|
18
|
+
<path d="M29.12 11.6V0.400024H31.36V9.36002H35.84V11.6H29.12Z" fill="#110F1F"/>
|
|
19
|
+
<path d="M38.08 11.6V0.400024H44.8V2.64002H40.32V4.88002H44.8V7.12002H40.32V9.36002H44.8V11.6H38.08Z" fill="#110F1F"/>
|
|
20
|
+
<path d="M47.04 4.88002V0.400024H49.28V4.88002H47.04ZM53.76 4.88002V0.400024H56V4.88002H53.76ZM49.28 7.12002V4.88002H53.76V7.12002H49.28ZM47.04 11.6V7.12002H49.28V11.6H47.04ZM53.76 11.6V7.12002H56V11.6H53.76Z" fill="#110F1F"/>
|
|
21
|
+
</svg>"""
|
|
22
|
+
|
|
23
|
+
dark_mode_logo = """<svg width="56" height="12" viewBox="0 0 56 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
24
|
+
<path d="M0 11.5999V0.399902H8.96V4.8799H6.72V2.6399H2.24V4.8799H6.72V7.1199H2.24V11.5999H0ZM6.72 11.5999V7.1199H8.96V11.5999H6.72Z" fill="white"/>
|
|
25
|
+
<path d="M11.2 11.5999V0.399902H17.92V2.6399H13.44V4.8799H17.92V7.1199H13.44V9.3599H17.92V11.5999H11.2Z" fill="white"/>
|
|
26
|
+
<path d="M20.16 11.5999V0.399902H26.88V2.6399H22.4V4.8799H26.88V7.1199H22.4V11.5999H20.16Z" fill="white"/>
|
|
27
|
+
<path d="M29.12 11.5999V0.399902H31.36V9.3599H35.84V11.5999H29.12Z" fill="white"/>
|
|
28
|
+
<path d="M38.08 11.5999V0.399902H44.8V2.6399H40.32V4.8799H44.8V7.1199H40.32V9.3599H44.8V11.5999H38.08Z" fill="white"/>
|
|
29
|
+
<path d="M47.04 4.8799V0.399902H49.28V4.8799H47.04ZM53.76 4.8799V0.399902H56V4.8799H53.76ZM49.28 7.1199V4.8799H53.76V7.1199H49.28ZM47.04 11.5999V7.1199H49.28V11.5999H47.04ZM53.76 11.5999V7.1199H56V11.5999H53.76Z" fill="white"/>
|
|
30
|
+
</svg>"""
|
|
31
|
+
|
|
32
|
+
return rx.center(
|
|
33
|
+
rx.link(
|
|
34
|
+
rx.hstack(
|
|
35
|
+
"Built with ",
|
|
36
|
+
rx.color_mode_cond(
|
|
37
|
+
rx.html(light_mode_logo),
|
|
38
|
+
rx.html(dark_mode_logo),
|
|
39
|
+
),
|
|
40
|
+
text_align="center",
|
|
41
|
+
align="center",
|
|
42
|
+
padding="1em",
|
|
43
|
+
),
|
|
44
|
+
href="https://reflex.dev",
|
|
45
|
+
size="3",
|
|
46
|
+
),
|
|
47
|
+
width=props.pop("width", "100%"),
|
|
48
|
+
**props,
|
|
49
|
+
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
from hashlib import md5
|
|
@@ -162,7 +163,9 @@ class Form(BaseHTML):
|
|
|
162
163
|
props["handle_submit_unique_name"] = ""
|
|
163
164
|
form = super().create(*children, **props)
|
|
164
165
|
form.handle_submit_unique_name = md5(
|
|
165
|
-
str(form.
|
|
166
|
+
str({**form._get_all_hooks_internal(), **form._get_all_hooks()}).encode(
|
|
167
|
+
"utf-8"
|
|
168
|
+
)
|
|
166
169
|
).hexdigest()
|
|
167
170
|
return form
|
|
168
171
|
|
|
@@ -207,7 +210,7 @@ class Form(BaseHTML):
|
|
|
207
210
|
def _get_form_refs(self) -> Dict[str, Any]:
|
|
208
211
|
# Send all the input refs to the handler.
|
|
209
212
|
form_refs = {}
|
|
210
|
-
for ref in self.
|
|
213
|
+
for ref in self._get_all_refs():
|
|
211
214
|
# when ref start with refs_ it's an array of refs, so we need different method
|
|
212
215
|
# to collect data
|
|
213
216
|
if ref.startswith("refs_"):
|
|
@@ -592,13 +595,13 @@ class Textarea(BaseHTML):
|
|
|
592
595
|
"enter_key_submit",
|
|
593
596
|
]
|
|
594
597
|
|
|
595
|
-
def
|
|
598
|
+
def _get_all_custom_code(self) -> Set[str]:
|
|
596
599
|
"""Include the custom code for auto_height and enter_key_submit functionality.
|
|
597
600
|
|
|
598
601
|
Returns:
|
|
599
602
|
The custom code for the component.
|
|
600
603
|
"""
|
|
601
|
-
custom_code = super().
|
|
604
|
+
custom_code = super()._get_all_custom_code()
|
|
602
605
|
if self.auto_height is not None:
|
|
603
606
|
custom_code.add(AUTO_HEIGHT_JS)
|
|
604
607
|
if self.enter_key_submit is not None:
|
|
@@ -2022,7 +2022,6 @@ AUTO_HEIGHT_JS = '\nconst autoHeightOnInput = (e, is_enabled) => {\n if (is_e
|
|
|
2022
2022
|
ENTER_KEY_SUBMIT_JS = "\nconst enterKeySubmitOnKeyDown = (e, is_enabled) => {\n if (is_enabled && e.which === 13 && !e.shiftKey) {\n e.preventDefault();\n if (!e.repeat) {\n if (e.target.form) {\n e.target.form.requestSubmit();\n }\n }\n }\n}\n"
|
|
2023
2023
|
|
|
2024
2024
|
class Textarea(BaseHTML):
|
|
2025
|
-
def get_custom_code(self) -> Set[str]: ...
|
|
2026
2025
|
def get_event_triggers(self) -> Dict[str, Any]: ...
|
|
2027
2026
|
@overload
|
|
2028
2027
|
@classmethod
|
reflex/components/lucide/icon.py
CHANGED
|
@@ -53,6 +53,7 @@ class Icon(LucideIconComponent):
|
|
|
53
53
|
if children:
|
|
54
54
|
if len(children) == 1 and type(children[0]) == str:
|
|
55
55
|
props["tag"] = children[0]
|
|
56
|
+
children = []
|
|
56
57
|
else:
|
|
57
58
|
raise AttributeError(
|
|
58
59
|
f"Passing multiple children to Icon component is not allowed: remove positional arguments {children[1:]} to fix"
|
|
@@ -129,7 +130,7 @@ RENAMED_ICONS_05 = {
|
|
|
129
130
|
"dot_square": "square_dot",
|
|
130
131
|
"download_cloud": "cloud_download",
|
|
131
132
|
"equal_square": "square_equal",
|
|
132
|
-
"form_input": "
|
|
133
|
+
"form_input": "rectangle_ellipsis",
|
|
133
134
|
"function_square": "square_function",
|
|
134
135
|
"gantt_chart_square": "square_gantt_chart",
|
|
135
136
|
"gauge_circle": "circle_gauge",
|
|
@@ -140,7 +141,7 @@ RENAMED_ICONS_05 = {
|
|
|
140
141
|
"ice_cream_2": "ice_cream_bowl",
|
|
141
142
|
"indent": "indent_increase",
|
|
142
143
|
"kanban_square": "square_kanban",
|
|
143
|
-
"kanban_square_dashed": "
|
|
144
|
+
"kanban_square_dashed": "square_dashed_kanban",
|
|
144
145
|
"laptop_2": "laptop_minimal",
|
|
145
146
|
"library_square": "square_library",
|
|
146
147
|
"loader_2": "loader_circle",
|