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.

Files changed (69) hide show
  1. reflex/.templates/apps/blank/code/blank.py +1 -0
  2. reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +1 -1
  3. reflex/.templates/jinja/custom_components/src.py.jinja2 +8 -8
  4. reflex/.templates/jinja/web/pages/index.js.jinja2 +0 -4
  5. reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 +2 -6
  6. reflex/.templates/web/utils/state.js +6 -1
  7. reflex/__init__.py +2 -0
  8. reflex/__init__.pyi +2 -0
  9. reflex/app.py +12 -16
  10. reflex/app.pyi +2 -0
  11. reflex/compiler/compiler.py +10 -11
  12. reflex/compiler/utils.py +3 -3
  13. reflex/components/chakra/forms/pininput.py +2 -1
  14. reflex/components/component.py +71 -131
  15. reflex/components/core/banner.py +1 -1
  16. reflex/components/core/upload.py +2 -1
  17. reflex/components/datadisplay/__init__.py +1 -0
  18. reflex/components/datadisplay/logo.py +49 -0
  19. reflex/components/el/elements/forms.py +7 -4
  20. reflex/components/el/elements/forms.pyi +0 -1
  21. reflex/components/lucide/icon.py +3 -2
  22. reflex/components/lucide/icon.pyi +2 -2
  23. reflex/components/markdown/markdown.py +10 -6
  24. reflex/components/markdown/markdown.pyi +0 -3
  25. reflex/components/radix/themes/components/select.py +10 -3
  26. reflex/config.py +1 -1
  27. reflex/config.pyi +1 -1
  28. reflex/constants/base.py +4 -5
  29. reflex/constants/base.pyi +94 -0
  30. reflex/constants/compiler.py +8 -0
  31. reflex/custom_components/custom_components.py +33 -38
  32. reflex/experimental/__init__.py +14 -0
  33. reflex/experimental/hooks.py +75 -0
  34. reflex/page.py +1 -1
  35. reflex/reflex.py +18 -32
  36. reflex/style.py +4 -4
  37. reflex/testing.py +1 -1
  38. reflex/utils/console.py +6 -4
  39. reflex/utils/exec.py +17 -1
  40. reflex/utils/export.py +0 -3
  41. reflex/utils/prerequisites.py +243 -43
  42. reflex/utils/processes.py +6 -1
  43. reflex/utils/telemetry.py +14 -2
  44. reflex/utils/types.py +3 -2
  45. reflex/vars.py +6 -6
  46. reflex/vars.pyi +2 -1
  47. {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/METADATA +15 -10
  48. {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/RECORD +51 -65
  49. {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/WHEEL +1 -1
  50. reflex/.templates/apps/sidebar/README.md +0 -69
  51. reflex/.templates/apps/sidebar/assets/favicon.ico +0 -0
  52. reflex/.templates/apps/sidebar/assets/github.svg +0 -10
  53. reflex/.templates/apps/sidebar/assets/logo.svg +0 -68
  54. reflex/.templates/apps/sidebar/assets/paneleft.svg +0 -13
  55. reflex/.templates/apps/sidebar/assets/reflex_black.svg +0 -37
  56. reflex/.templates/apps/sidebar/assets/reflex_white.svg +0 -8
  57. reflex/.templates/apps/sidebar/code/__init__.py +0 -1
  58. reflex/.templates/apps/sidebar/code/components/__init__.py +0 -0
  59. reflex/.templates/apps/sidebar/code/components/sidebar.py +0 -152
  60. reflex/.templates/apps/sidebar/code/pages/__init__.py +0 -3
  61. reflex/.templates/apps/sidebar/code/pages/dashboard.py +0 -22
  62. reflex/.templates/apps/sidebar/code/pages/index.py +0 -18
  63. reflex/.templates/apps/sidebar/code/pages/settings.py +0 -61
  64. reflex/.templates/apps/sidebar/code/sidebar.py +0 -16
  65. reflex/.templates/apps/sidebar/code/styles.py +0 -60
  66. reflex/.templates/apps/sidebar/code/templates/__init__.py +0 -1
  67. reflex/.templates/apps/sidebar/code/templates/template.py +0 -145
  68. {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/LICENSE +0 -0
  69. {reflex-0.4.6a3.dist-info → reflex-0.4.7.dist-info}/entry_points.txt +0 -0
@@ -76,15 +76,7 @@ class BaseComponent(Base, ABC):
76
76
  """
77
77
 
78
78
  @abstractmethod
79
- def get_ref_hooks(self) -> set[str]:
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 get_hooks(self) -> set[str]:
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 get_imports(self) -> imports.ImportDict:
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 get_dynamic_imports(self) -> set[str]:
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 get_custom_code(self) -> set[str]:
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 get_refs(self) -> set[str]:
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 add_style(self, style: ComponentStyle) -> Component:
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.add_style(style)
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 get_custom_code(self) -> Set[str]:
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.get_custom_code()
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 get_dynamic_imports(self) -> Set[str]:
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.get_dynamic_imports()
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).get_dynamic_imports()
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).get_imports()
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 get_imports(self, collapse: bool = False) -> imports.ImportDict:
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.get_imports() for child in self.children]
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) -> set[str]:
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 = set()
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) -> set[str]:
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) -> set[str]:
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) -> Set[str]:
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
- Set of internally managed hooks.
1138
+ The internally managed hooks.
1184
1139
  """
1185
- return (
1186
- self._get_vars_hooks()
1187
- | self._get_events_hooks()
1188
- | self._get_special_hooks()
1189
- | set(hook for hook in [self._get_mount_lifecycle_hook()] if hook)
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 get_ref_hooks(self) -> Set[str]:
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 |= child.get_hooks_internal()
1172
+ code = {**code, **child._get_all_hooks_internal()}
1227
1173
 
1228
1174
  return code
1229
1175
 
1230
- def get_hooks(self) -> Set[str]:
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 = set()
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.add(hooks)
1187
+ code[hooks] = None
1242
1188
 
1243
1189
  # Add the hook code for the children.
1244
1190
  for child in self.children:
1245
- code |= child.get_hooks()
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 get_refs(self) -> Set[str]:
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.get_refs()
1217
+ refs |= child._get_all_refs()
1272
1218
  return refs
1273
1219
 
1274
- def get_custom_components(
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.get_custom_components(seen=seen)
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 get_app_wrap_components(self) -> dict[tuple[int, str], Component]:
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.get_app_wrap_components())
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.get_app_wrap_components())
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.get_imports(),
1405
- hooks=value.get_hooks(),
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 get_custom_components(
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().get_custom_components(seen=seen)
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).get_custom_components(
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.get_custom_components(seen=seen)
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 get_ref_hooks(self) -> set[str]:
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 set()
1835
+ return {}
1896
1836
 
1897
- def get_hooks(self) -> set[str]:
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 set()
1843
+ return {}
1904
1844
 
1905
- def get_imports(self) -> imports.ImportDict:
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.get_imports()
1857
+ return self.component._get_all_imports()
1918
1858
 
1919
- def get_dynamic_imports(self) -> set[str]:
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.get_dynamic_imports()
1867
+ return self.component._get_all_dynamic_imports()
1928
1868
 
1929
- def get_custom_code(self) -> set[str]:
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.get_custom_code().union({self.code})
1877
+ return self.component._get_all_custom_code().union({self.code})
1938
1878
 
1939
- def get_refs(self) -> set[str]:
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.get_refs()
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.get_hooks() or comp.get_hooks_internal():
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
  )
@@ -22,7 +22,7 @@ from reflex.vars import Var, VarData
22
22
 
23
23
  connect_error_var_data: VarData = VarData( # type: ignore
24
24
  imports=Imports.EVENTS,
25
- hooks={Hooks.EVENTS},
25
+ hooks={Hooks.EVENTS: None},
26
26
  )
27
27
 
28
28
  connection_error: Var = Var.create_safe(
@@ -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.get_hooks_internal().union(form.get_hooks())).encode("utf-8")
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.get_refs():
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 get_custom_code(self) -> Set[str]:
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().get_custom_code()
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
@@ -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": "rectangle_elipsis",
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": "square_kanban_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",