reflex 0.4.6__py3-none-any.whl → 0.4.6a1__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/components/component.py +27 -0
- reflex/custom_components/custom_components.py +37 -28
- {reflex-0.4.6.dist-info → reflex-0.4.6a1.dist-info}/METADATA +3 -3
- {reflex-0.4.6.dist-info → reflex-0.4.6a1.dist-info}/RECORD +7 -7
- {reflex-0.4.6.dist-info → reflex-0.4.6a1.dist-info}/LICENSE +0 -0
- {reflex-0.4.6.dist-info → reflex-0.4.6a1.dist-info}/WHEEL +0 -0
- {reflex-0.4.6.dist-info → reflex-0.4.6a1.dist-info}/entry_points.txt +0 -0
reflex/components/component.py
CHANGED
|
@@ -1029,6 +1029,16 @@ class Component(BaseComponent, ABC):
|
|
|
1029
1029
|
)
|
|
1030
1030
|
return _imports
|
|
1031
1031
|
|
|
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
|
+
|
|
1032
1042
|
def _get_imports(self) -> imports.ImportDict:
|
|
1033
1043
|
"""Get all the libraries and fields that are used by the component.
|
|
1034
1044
|
|
|
@@ -1049,12 +1059,29 @@ class Component(BaseComponent, ABC):
|
|
|
1049
1059
|
var._var_data.imports for var in self._get_vars() if var._var_data
|
|
1050
1060
|
]
|
|
1051
1061
|
|
|
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
|
+
|
|
1052
1078
|
return imports.merge_imports(
|
|
1053
1079
|
*self._get_props_imports(),
|
|
1054
1080
|
self._get_dependencies_imports(),
|
|
1055
1081
|
self._get_hooks_imports(),
|
|
1056
1082
|
_imports,
|
|
1057
1083
|
event_imports,
|
|
1084
|
+
added_imports,
|
|
1058
1085
|
*var_imports,
|
|
1059
1086
|
)
|
|
1060
1087
|
|
|
@@ -564,7 +564,7 @@ def _ensure_dist_dir(version_to_publish: str, build: bool):
|
|
|
564
564
|
needs_rebuild = (
|
|
565
565
|
console.ask(
|
|
566
566
|
"Distribution files for the version to be published already exist. Do you want to rebuild?",
|
|
567
|
-
choices=["
|
|
567
|
+
choices=["n", "y"],
|
|
568
568
|
default="n",
|
|
569
569
|
)
|
|
570
570
|
== "y"
|
|
@@ -668,10 +668,10 @@ def publish(
|
|
|
668
668
|
if validate_project_info and (
|
|
669
669
|
console.ask(
|
|
670
670
|
"Would you like to interactively review the package information?",
|
|
671
|
-
choices=["
|
|
672
|
-
default="
|
|
671
|
+
choices=["Y", "n"],
|
|
672
|
+
default="Y",
|
|
673
673
|
)
|
|
674
|
-
== "
|
|
674
|
+
== "Y"
|
|
675
675
|
):
|
|
676
676
|
_validate_project_info()
|
|
677
677
|
|
|
@@ -702,7 +702,7 @@ def publish(
|
|
|
702
702
|
if (
|
|
703
703
|
console.ask(
|
|
704
704
|
"Would you like to include your published component on our gallery?",
|
|
705
|
-
choices=["
|
|
705
|
+
choices=["n", "y"],
|
|
706
706
|
default="y",
|
|
707
707
|
)
|
|
708
708
|
== "n"
|
|
@@ -807,6 +807,11 @@ def _collect_details_for_gallery():
|
|
|
807
807
|
"""
|
|
808
808
|
from reflex.reflex import _login
|
|
809
809
|
|
|
810
|
+
console.print("We recommend that you deploy a demo app showcasing the component.")
|
|
811
|
+
console.print("If not already, please deploy it first.")
|
|
812
|
+
if console.ask("Continue?", choices=["y", "n"], default="y") != "y":
|
|
813
|
+
return
|
|
814
|
+
|
|
810
815
|
console.rule("[bold]Authentication with Reflex Services")
|
|
811
816
|
console.print("First let's log in to Reflex backend services.")
|
|
812
817
|
access_token = _login()
|
|
@@ -824,43 +829,34 @@ def _collect_details_for_gallery():
|
|
|
824
829
|
)
|
|
825
830
|
package_name = console.ask("[ Published python package name ]")
|
|
826
831
|
console.print(f"[ Custom component package name ] : {package_name}")
|
|
827
|
-
params["package_name"] = package_name
|
|
828
832
|
|
|
829
833
|
# Check the backend services if the user is allowed to update information of this package is already shared.
|
|
834
|
+
expected_status_code = False
|
|
830
835
|
try:
|
|
831
836
|
console.debug(
|
|
832
|
-
f"Checking if user has permission to
|
|
837
|
+
f"Checking if user has permission to modify information for {package_name} if already exists."
|
|
833
838
|
)
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
# 2. If this package is not shared before, this request records the package name in the backend.
|
|
837
|
-
response = httpx.post(
|
|
838
|
-
POST_CUSTOM_COMPONENTS_GALLERY_ENDPOINT,
|
|
839
|
+
response = httpx.get(
|
|
840
|
+
f"{GET_CUSTOM_COMPONENTS_GALLERY_BY_NAME_ENDPOINT}/{package_name}",
|
|
839
841
|
headers={"Authorization": f"Bearer {access_token}"},
|
|
840
|
-
data=params,
|
|
841
842
|
)
|
|
842
843
|
if response.status_code == httpx.codes.FORBIDDEN:
|
|
843
844
|
console.error(
|
|
844
845
|
f"{package_name} is owned by another user. Unable to update the information for it."
|
|
845
846
|
)
|
|
846
847
|
raise typer.Exit(code=1)
|
|
848
|
+
elif response.status_code == httpx.codes.NOT_FOUND:
|
|
849
|
+
console.debug(f"{package_name} is not found. This is a new share.")
|
|
850
|
+
expected_status_code = True
|
|
851
|
+
|
|
847
852
|
response.raise_for_status()
|
|
853
|
+
console.debug(f"{package_name} is found. This is an update.")
|
|
848
854
|
except httpx.HTTPError as he:
|
|
849
|
-
|
|
850
|
-
|
|
855
|
+
if not expected_status_code:
|
|
856
|
+
console.error(f"Unable to complete request due to {he}.")
|
|
857
|
+
raise typer.Exit(code=1) from he
|
|
851
858
|
|
|
852
|
-
|
|
853
|
-
console.ask("[ Friendly display name for your component ] (enter to skip)")
|
|
854
|
-
or None
|
|
855
|
-
)
|
|
856
|
-
if display_name:
|
|
857
|
-
params["display_name"] = display_name
|
|
858
|
-
|
|
859
|
-
files = []
|
|
860
|
-
if (image_file_and_extension := _get_file_from_prompt_in_loop()) is not None:
|
|
861
|
-
files.append(
|
|
862
|
-
("files", (image_file_and_extension[1], image_file_and_extension[0]))
|
|
863
|
-
)
|
|
859
|
+
params["package_name"] = package_name
|
|
864
860
|
|
|
865
861
|
demo_url = None
|
|
866
862
|
while True:
|
|
@@ -875,6 +871,19 @@ def _collect_details_for_gallery():
|
|
|
875
871
|
if demo_url:
|
|
876
872
|
params["demo_url"] = demo_url
|
|
877
873
|
|
|
874
|
+
display_name = (
|
|
875
|
+
console.ask("[ Friendly display name for your component ] (enter to skip)")
|
|
876
|
+
or None
|
|
877
|
+
)
|
|
878
|
+
if display_name:
|
|
879
|
+
params["display_name"] = display_name
|
|
880
|
+
|
|
881
|
+
files = []
|
|
882
|
+
if (image_file_and_extension := _get_file_from_prompt_in_loop()) is not None:
|
|
883
|
+
files.append(
|
|
884
|
+
("files", (image_file_and_extension[1], image_file_and_extension[0]))
|
|
885
|
+
)
|
|
886
|
+
|
|
878
887
|
# Now send the post request to Reflex backend services.
|
|
879
888
|
try:
|
|
880
889
|
console.debug(f"Sending custom component data: {params}")
|
|
@@ -910,7 +919,7 @@ def _get_file_from_prompt_in_loop() -> Tuple[bytes, str] | None:
|
|
|
910
919
|
image_file = file_extension = None
|
|
911
920
|
while image_file is None:
|
|
912
921
|
image_filepath = console.ask(
|
|
913
|
-
f"
|
|
922
|
+
f"Local path to a preview gif or image (enter to skip)"
|
|
914
923
|
)
|
|
915
924
|
if not image_filepath:
|
|
916
925
|
break
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: reflex
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.6a1
|
|
4
4
|
Summary: Web apps in pure Python.
|
|
5
5
|
Home-page: https://reflex.dev
|
|
6
6
|
License: Apache-2.0
|
|
@@ -40,8 +40,8 @@ Requires-Dist: starlette-admin (>=0.11.0,<1.0)
|
|
|
40
40
|
Requires-Dist: tomlkit (>=0.12.4,<1.0)
|
|
41
41
|
Requires-Dist: twine (>=4.0.0,<6.0)
|
|
42
42
|
Requires-Dist: typer (>=0.4.2,<1.0)
|
|
43
|
-
Requires-Dist: uvicorn (>=0.20.0,<
|
|
44
|
-
Requires-Dist: uvicorn (>=0.24.0,<
|
|
43
|
+
Requires-Dist: uvicorn (>=0.20.0,<1.0) ; python_version < "3.12"
|
|
44
|
+
Requires-Dist: uvicorn (>=0.24.0,<1.0) ; python_version >= "3.12"
|
|
45
45
|
Requires-Dist: watchdog (>=2.3.1,<5.0)
|
|
46
46
|
Requires-Dist: watchfiles (>=0.19.0,<1.0)
|
|
47
47
|
Requires-Dist: wheel (>=0.42.0,<1.0)
|
|
@@ -250,7 +250,7 @@ reflex/components/chakra/typography/span.py,sha256=2DbW5DB27ijtTeugSDUVp3nQ64mrG
|
|
|
250
250
|
reflex/components/chakra/typography/span.pyi,sha256=fOYu3o8OaSDwaWiu-7CrEm8w9azlxHhiZcKqcFxRe6o,3443
|
|
251
251
|
reflex/components/chakra/typography/text.py,sha256=9YXBdK5UYqgDam3ITeRSnd8bu9ht3zydt0pkmJAECsk,472
|
|
252
252
|
reflex/components/chakra/typography/text.pyi,sha256=QwD1kqrIpXwu-RaZpnoGbsMHb4D3t9CfHjgbS7ds9G8,3667
|
|
253
|
-
reflex/components/component.py,sha256=
|
|
253
|
+
reflex/components/component.py,sha256=ZMVHpkh6ajAqpX5OCtKtQgy3M_Y8AiXn4h3DslLCbCE,66152
|
|
254
254
|
reflex/components/core/__init__.py,sha256=mMSd2IZqBgGf7zkjuPeA-oIiIXu_O08fk9x15D8hBSU,844
|
|
255
255
|
reflex/components/core/banner.py,sha256=kc9vSySgXzFxB_XaeWlw51UC4LaujrSjRSmgQI4z0yI,5937
|
|
256
256
|
reflex/components/core/banner.pyi,sha256=PPS1GJLp5uyD1h6mI0Fs-IKf9w4l7qG50rmkSA_HVno,17164
|
|
@@ -486,7 +486,7 @@ reflex/constants/installer.py,sha256=wzoO_TaXF6N54CKmqpSSzT9QGIPalYn245AtUIIlEY0
|
|
|
486
486
|
reflex/constants/route.py,sha256=9ydQEdlz3YwGmGMHVGz7zA-INoOLtz_xUU2S-WmhZZM,1940
|
|
487
487
|
reflex/constants/style.py,sha256=gSzu0sQEQjW81PekxJnwRs7SXQQVco-LxtVjCi0IQZc,636
|
|
488
488
|
reflex/custom_components/__init__.py,sha256=R4zsvOi4dfPmHc18KEphohXnQFBPnUCb50cMR5hSLDE,36
|
|
489
|
-
reflex/custom_components/custom_components.py,sha256=
|
|
489
|
+
reflex/custom_components/custom_components.py,sha256=NagOWQSj2Na6D6bNIq4SXKpV1LAaK8zUHCALcAO4P-4,32344
|
|
490
490
|
reflex/event.py,sha256=tQH1fLdBrTRI150VxiK6SbUBByPQxMNDylaSBYVliYM,26634
|
|
491
491
|
reflex/middleware/__init__.py,sha256=x7xTeDuc73Hjj43k1J63naC9x8vzFxl4sq7cCFBX7sk,111
|
|
492
492
|
reflex/middleware/hydrate_middleware.py,sha256=iXgB_VID2moU9gNpc79TJHGGhQgDH6miT32T_0Ow5tU,1484
|
|
@@ -516,8 +516,8 @@ reflex/utils/types.py,sha256=-OT6RLGOfKnzlArNua7Kld6DLFeUFAasHS5B2RjLqsE,13585
|
|
|
516
516
|
reflex/utils/watch.py,sha256=HzGrHQIZ_62Di0BO46kd2AZktNA3A6nFIBuf8c6ip30,2609
|
|
517
517
|
reflex/vars.py,sha256=LNQkoL58s5Ea4nB8H8N6ZUe24xzuC_4lNpqnDUi50p8,67145
|
|
518
518
|
reflex/vars.pyi,sha256=4sZo25A0nZ5nLhZ_uUnnz8enzBddhBvGmuHZAM2JhU4,5575
|
|
519
|
-
reflex-0.4.
|
|
520
|
-
reflex-0.4.
|
|
521
|
-
reflex-0.4.
|
|
522
|
-
reflex-0.4.
|
|
523
|
-
reflex-0.4.
|
|
519
|
+
reflex-0.4.6a1.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
|
|
520
|
+
reflex-0.4.6a1.dist-info/METADATA,sha256=8O7ctauXWuSYbTRnrfJlWL-kzlNJlf_YbH2QUT_MQ3o,11361
|
|
521
|
+
reflex-0.4.6a1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
522
|
+
reflex-0.4.6a1.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
|
|
523
|
+
reflex-0.4.6a1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|