optionalize some Component props
This commit is contained in:
parent
6d3809efcb
commit
1c89f012b6
@ -1,7 +1,7 @@
|
||||
"""A bare component."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Iterator
|
||||
from typing import Any, Iterator, Optional
|
||||
|
||||
from reflex.components.component import Component
|
||||
from reflex.components.tags import Tag
|
||||
@ -12,7 +12,7 @@ from reflex.vars import Var
|
||||
class Bare(Component):
|
||||
"""A component with no tag."""
|
||||
|
||||
contents: Var[str]
|
||||
contents: Optional[Var[str]] = None
|
||||
|
||||
@classmethod
|
||||
def create(cls, contents: Any) -> Component:
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
|
||||
from typing import Union
|
||||
from typing import Union, Optional
|
||||
|
||||
from reflex.components.el.element import Element
|
||||
from reflex.vars import Var as Var
|
||||
@ -9,49 +8,49 @@ class BaseHTML(Element):
|
||||
"""Base class for common attributes."""
|
||||
|
||||
# Provides a hint for generating a keyboard shortcut for the current element.
|
||||
access_key: Var[Union[str, int, bool]]
|
||||
access_key: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
|
||||
auto_capitalize: Var[Union[str, int, bool]]
|
||||
auto_capitalize: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Indicates whether the element's content is editable.
|
||||
content_editable: Var[Union[str, int, bool]]
|
||||
content_editable: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines the ID of a <menu> element which will serve as the element's context menu.
|
||||
context_menu: Var[Union[str, int, bool]]
|
||||
context_menu: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
|
||||
dir: Var[Union[str, int, bool]]
|
||||
dir: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines whether the element can be dragged.
|
||||
draggable: Var[Union[str, int, bool]]
|
||||
draggable: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Hints what media types the media element is able to play.
|
||||
enter_key_hint: Var[Union[str, int, bool]]
|
||||
enter_key_hint: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines whether the element is hidden.
|
||||
hidden: Var[Union[str, int, bool]]
|
||||
hidden: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines the type of the element.
|
||||
input_mode: Var[Union[str, int, bool]]
|
||||
input_mode: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines the name of the element for metadata purposes.
|
||||
item_prop: Var[Union[str, int, bool]]
|
||||
item_prop: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines the language used in the element.
|
||||
lang: Var[Union[str, int, bool]]
|
||||
lang: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines the role of the element.
|
||||
role: Var[Union[str, int, bool]]
|
||||
role: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Assigns a slot in a shadow DOM shadow tree to an element.
|
||||
slot: Var[Union[str, int, bool]]
|
||||
slot: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines whether the element may be checked for spelling errors.
|
||||
spell_check: Var[Union[str, int, bool]]
|
||||
spell_check: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines the position of the current element in the tabbing order.
|
||||
tab_index: Var[Union[str, int, bool]]
|
||||
tab_index: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
||||
# Defines a tooltip for the element.
|
||||
title: Var[Union[str, int, bool]]
|
||||
title: Optional[Var[Union[str, int, bool]]] = None
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, Literal
|
||||
from typing import Any, Dict, Literal, Optional, Union
|
||||
|
||||
from reflex.components import Component
|
||||
from reflex.components.tags import Tag
|
||||
@ -101,7 +101,13 @@ class RadixThemesComponent(Component):
|
||||
"""
|
||||
component = super().create(*children, **props)
|
||||
if component.library is None:
|
||||
<<<<<<< HEAD
|
||||
component.library = RadixThemesComponent.model_fields["library"].default
|
||||
=======
|
||||
component.library = RadixThemesComponent.model_fields[
|
||||
"library"
|
||||
].default
|
||||
>>>>>>> f7035d9b (optionalize some Component props)
|
||||
component.alias = "RadixThemes" + (
|
||||
component.tag or component.__class__.__name__
|
||||
)
|
||||
@ -127,25 +133,25 @@ class Theme(RadixThemesComponent):
|
||||
tag = "Theme"
|
||||
|
||||
# Whether to apply the themes background color to the theme node. Defaults to True.
|
||||
has_background: Var[bool]
|
||||
has_background: Optional[Var[bool]] = None
|
||||
|
||||
# Override light or dark mode theme: "inherit" | "light" | "dark". Defaults to "inherit".
|
||||
appearance: Var[LiteralAppearance]
|
||||
appearance: Optional[Var[LiteralAppearance]] = None
|
||||
|
||||
# The color used for default buttons, typography, backgrounds, etc
|
||||
accent_color: Var[LiteralAccentColor]
|
||||
accent_color: Optional[Var[LiteralAccentColor]] = None
|
||||
|
||||
# The shade of gray, defaults to "auto".
|
||||
gray_color: Var[LiteralGrayColor]
|
||||
gray_color: Optional[Var[LiteralGrayColor]] = None
|
||||
|
||||
# Whether panel backgrounds are translucent: "solid" | "translucent" (default)
|
||||
panel_background: Var[LiteralPanelBackground]
|
||||
panel_background: Optional[Var[LiteralPanelBackground]] = None
|
||||
|
||||
# Element border radius: "none" | "small" | "medium" | "large" | "full". Defaults to "medium".
|
||||
radius: Var[LiteralRadius]
|
||||
radius: Optional[Var[LiteralRadius]] = None
|
||||
|
||||
# Scale of all theme items: "90%" | "95%" | "100%" | "105%" | "110%". Defaults to "100%"
|
||||
scaling: Var[LiteralScaling]
|
||||
scaling: Optional[Var[LiteralScaling]] = None
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
@ -153,6 +159,7 @@ class Theme(RadixThemesComponent):
|
||||
*children,
|
||||
color_mode: LiteralAppearance | None = None,
|
||||
theme_panel: bool = False,
|
||||
accent_color: Union[LiteralAccentColor, Var[LiteralAccentColor]] | None = None,
|
||||
**props,
|
||||
) -> Component:
|
||||
"""Create a new Radix Theme specification.
|
||||
@ -170,6 +177,9 @@ class Theme(RadixThemesComponent):
|
||||
props["appearance"] = color_mode
|
||||
if theme_panel:
|
||||
children = [ThemePanel.create(), *children]
|
||||
if not isinstance(accent_color, Var):
|
||||
accent_color = Var.create(accent_color)
|
||||
props["accent_color"] = accent_color
|
||||
return super().create(*children, **props)
|
||||
|
||||
def _get_imports(self) -> imports.ImportDict:
|
||||
|
@ -6,6 +6,7 @@ from __future__ import annotations
|
||||
|
||||
from reflex import el
|
||||
from reflex.vars import Var
|
||||
from typing import Optional
|
||||
|
||||
from ..base import (
|
||||
LiteralAccentColor,
|
||||
@ -25,25 +26,25 @@ class Heading(el.H1, RadixThemesComponent):
|
||||
tag = "Heading"
|
||||
|
||||
# Change the default rendered element for the one passed as a child, merging their props and behavior.
|
||||
as_child: Var[bool]
|
||||
as_child: Optional[Var[bool]] = None
|
||||
|
||||
# Change the default rendered element into a semantically appropriate alternative (cannot be used with asChild)
|
||||
as_: Var[str]
|
||||
as_: Optional[Var[str]] = None
|
||||
|
||||
# Text size: "1" - "9"
|
||||
size: Var[LiteralTextSize]
|
||||
size: Optional[Var[LiteralTextSize]] = None
|
||||
|
||||
# Thickness of text: "light" | "regular" | "medium" | "bold"
|
||||
weight: Var[LiteralTextWeight]
|
||||
weight: Optional[Var[LiteralTextWeight]] = None
|
||||
|
||||
# Alignment of text in element: "left" | "center" | "right"
|
||||
align: Var[LiteralTextAlign]
|
||||
align: Optional[Var[LiteralTextAlign]] = None
|
||||
|
||||
# Removes the leading trim space: "normal" | "start" | "end" | "both"
|
||||
trim: Var[LiteralTextTrim]
|
||||
trim: Optional[Var[LiteralTextTrim]] = None
|
||||
|
||||
# Overrides the accent color inherited from the Theme.
|
||||
color_scheme: Var[LiteralAccentColor]
|
||||
color_scheme: Optional[Var[LiteralAccentColor]] = None
|
||||
|
||||
# Whether to render the text with higher contrast color
|
||||
high_contrast: Var[bool]
|
||||
high_contrast: Optional[Var[bool]] = None
|
||||
|
Loading…
Reference in New Issue
Block a user