Fixes from testing on reflex-web
This commit is contained in:
parent
622f0f0dc8
commit
8643ccb758
@ -30,8 +30,8 @@ class Link(ChakraComponent):
|
|||||||
# If true, the link will open in new tab.
|
# If true, the link will open in new tab.
|
||||||
is_external: Var[bool]
|
is_external: Var[bool]
|
||||||
|
|
||||||
def _get_imports(self) -> imports.ImportDict:
|
def _get_imports_list(self) -> list[imports.ImportVar]:
|
||||||
return {**super()._get_imports(), **next_link._get_imports()}
|
return [*super()._get_imports_list(), *next_link._get_imports_list()]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, *children, **props) -> Component:
|
def create(cls, *children, **props) -> Component:
|
||||||
|
@ -1593,32 +1593,29 @@ memo = custom_component
|
|||||||
class NoSSRComponent(Component):
|
class NoSSRComponent(Component):
|
||||||
"""A dynamic component that is not rendered on the server."""
|
"""A dynamic component that is not rendered on the server."""
|
||||||
|
|
||||||
def _get_imports(self) -> imports.ImportDict:
|
def _get_imports_list(self) -> list[ImportVar]:
|
||||||
"""Get the imports for the component.
|
"""Get the imports for the component.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The imports for dynamically importing the component at module load time.
|
The imports for dynamically importing the component at module load time.
|
||||||
"""
|
"""
|
||||||
# Next.js dynamic import mechanism.
|
return [
|
||||||
dynamic_import = {"next/dynamic": [ImportVar(tag="dynamic", is_default=True)]}
|
*super()._get_imports_list(),
|
||||||
|
# Next.js dynamic import mechanism.
|
||||||
|
ImportVar(package="next/dynamic", tag="dynamic", is_default=True),
|
||||||
|
]
|
||||||
|
|
||||||
# The normal imports for this component.
|
@property
|
||||||
_imports = super()._get_imports()
|
def import_var(self) -> ImportVar:
|
||||||
|
"""Will not actually render the tag to import, get it dynamically instead.
|
||||||
|
|
||||||
# Do NOT import the main library/tag statically.
|
Returns:
|
||||||
if self.library is not None:
|
An import var.
|
||||||
_imports[self.library] = [
|
"""
|
||||||
imports.ImportVar(
|
imp = super().import_var
|
||||||
tag=None,
|
imp.tag = None
|
||||||
render=False,
|
imp.render = False
|
||||||
transpile=self._should_transpile(self.library),
|
return imp
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
return imports.merge_imports(
|
|
||||||
dynamic_import,
|
|
||||||
_imports,
|
|
||||||
)
|
|
||||||
|
|
||||||
def _get_dynamic_imports(self) -> str:
|
def _get_dynamic_imports(self) -> str:
|
||||||
opts_fragment = ", { ssr: false });"
|
opts_fragment = ", { ssr: false });"
|
||||||
|
@ -112,7 +112,7 @@ class DebounceInput(Component):
|
|||||||
)._replace(
|
)._replace(
|
||||||
_var_type=Type[Component],
|
_var_type=Type[Component],
|
||||||
merge_var_data=VarData( # type: ignore
|
merge_var_data=VarData( # type: ignore
|
||||||
imports=child._get_imports(),
|
imports=child._get_imports_list(),
|
||||||
hooks=child._get_hooks_internal(),
|
hooks=child._get_hooks_internal(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -268,11 +268,11 @@ class Match(MemoizationLeaf):
|
|||||||
tag.name = "match"
|
tag.name = "match"
|
||||||
return dict(tag)
|
return dict(tag)
|
||||||
|
|
||||||
def _get_imports(self) -> imports.ImportDict:
|
def _get_imports_list(self) -> list[imports.ImportVar]:
|
||||||
return imports.merge_imports(
|
return [
|
||||||
super()._get_imports(),
|
*super()._get_imports_list(),
|
||||||
getattr(self.cond._var_data, "imports", {}),
|
*getattr(self.cond._var_data, "imports", []),
|
||||||
)
|
]
|
||||||
|
|
||||||
def _apply_theme(self, theme: Component):
|
def _apply_theme(self, theme: Component):
|
||||||
"""Apply the theme to this component.
|
"""Apply the theme to this component.
|
||||||
|
@ -180,7 +180,7 @@ class Markdown(Component):
|
|||||||
is_default=True,
|
is_default=True,
|
||||||
),
|
),
|
||||||
ImportVar(
|
ImportVar(
|
||||||
package="remark-katex@6.0.3",
|
package="rehype-katex@6.0.3",
|
||||||
tag=_REHYPE_KATEX._var_name,
|
tag=_REHYPE_KATEX._var_name,
|
||||||
is_default=True,
|
is_default=True,
|
||||||
),
|
),
|
||||||
|
@ -425,12 +425,12 @@ class AccordionRoot(AccordionComponent):
|
|||||||
accordion_theme_root
|
accordion_theme_root
|
||||||
)
|
)
|
||||||
|
|
||||||
def _get_imports(self):
|
def _get_imports_list(self) -> list[imports.ImportVar]:
|
||||||
return imports.merge_imports(
|
return [
|
||||||
super()._get_imports(),
|
*super()._get_imports_list(),
|
||||||
self._var_data.imports if self._var_data else {},
|
*(self._var_data.imports if self._var_data else {}),
|
||||||
{"@emotion/react": [imports.ImportVar(tag="keyframes")]},
|
imports.ImportVar(package="@emotion/react", tag="keyframes"),
|
||||||
)
|
]
|
||||||
|
|
||||||
def get_event_triggers(self) -> Dict[str, Any]:
|
def get_event_triggers(self) -> Dict[str, Any]:
|
||||||
"""Get the events triggers signatures for the component.
|
"""Get the events triggers signatures for the component.
|
||||||
@ -644,12 +644,6 @@ class AccordionContent(AccordionComponent):
|
|||||||
def _apply_theme(self, theme: Component):
|
def _apply_theme(self, theme: Component):
|
||||||
self.style = Style({**self.style})
|
self.style = Style({**self.style})
|
||||||
|
|
||||||
# def _get_imports(self):
|
|
||||||
# return {
|
|
||||||
# **super()._get_imports(),
|
|
||||||
# "@emotion/react": [imports.ImportVar(tag="keyframes")],
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
class Accordion(ComponentNamespace):
|
class Accordion(ComponentNamespace):
|
||||||
"""Accordion component."""
|
"""Accordion component."""
|
||||||
|
@ -59,8 +59,8 @@ class Link(RadixThemesComponent, A, MemoizationLeaf):
|
|||||||
# If True, the link will open in a new tab
|
# If True, the link will open in a new tab
|
||||||
is_external: Var[bool]
|
is_external: Var[bool]
|
||||||
|
|
||||||
def _get_imports(self) -> imports.ImportDict:
|
def _get_imports_list(self) -> list[imports.ImportVar]:
|
||||||
return {**super()._get_imports(), **next_link._get_imports()}
|
return [*super()._get_imports_list(), *next_link._get_imports_list()]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, *children, **props) -> Component:
|
def create(cls, *children, **props) -> Component:
|
||||||
|
@ -22,6 +22,7 @@ from typing import (
|
|||||||
List,
|
List,
|
||||||
Literal,
|
Literal,
|
||||||
Optional,
|
Optional,
|
||||||
|
Sequence,
|
||||||
Tuple,
|
Tuple,
|
||||||
Type,
|
Type,
|
||||||
Union,
|
Union,
|
||||||
@ -129,7 +130,7 @@ class VarData(Base):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
imports: ImportList
|
imports: ImportList
|
||||||
| List[ImportVar | Dict[str, Optional[Union[str, bool]]]]
|
| Sequence[ImportVar | Dict[str, Optional[Union[str, bool]]]]
|
||||||
| ImportDict
|
| ImportDict
|
||||||
| Dict[str, set[ImportVar]]
|
| Dict[str, set[ImportVar]]
|
||||||
| None = None,
|
| None = None,
|
||||||
|
@ -18,6 +18,7 @@ from typing import (
|
|||||||
Iterable,
|
Iterable,
|
||||||
List,
|
List,
|
||||||
Optional,
|
Optional,
|
||||||
|
Sequence,
|
||||||
Set,
|
Set,
|
||||||
Tuple,
|
Tuple,
|
||||||
Type,
|
Type,
|
||||||
@ -41,7 +42,7 @@ class VarData(Base):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
imports: ImportList
|
imports: ImportList
|
||||||
| List[ImportVar | Dict[str, Optional[Union[str, bool]]]]
|
| Sequence[ImportVar | Dict[str, Optional[Union[str, bool]]]]
|
||||||
| ImportDict
|
| ImportDict
|
||||||
| Dict[str, set[ImportVar]]
|
| Dict[str, set[ImportVar]]
|
||||||
| None = None,
|
| None = None,
|
||||||
|
Loading…
Reference in New Issue
Block a user