Update input to use textfield.input (#2599)
This commit is contained in:
parent
5328f624d4
commit
db90006512
@ -3,11 +3,9 @@
|
|||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
from typing import Any, Dict, Literal
|
from typing import Any, Dict, Literal
|
||||||
|
|
||||||
import reflex as rx
|
|
||||||
from reflex.components import el
|
from reflex.components import el
|
||||||
from reflex.components.component import Component
|
from reflex.components.component import Component
|
||||||
from reflex.components.core.debounce import DebounceInput
|
from reflex.components.core.debounce import DebounceInput
|
||||||
from reflex.components.lucide.icon import Icon
|
|
||||||
from reflex.constants import EventTriggers
|
from reflex.constants import EventTriggers
|
||||||
from reflex.vars import Var
|
from reflex.vars import Var
|
||||||
|
|
||||||
@ -88,9 +86,6 @@ class TextFieldSlot(RadixThemesComponent):
|
|||||||
class Input(RadixThemesComponent):
|
class Input(RadixThemesComponent):
|
||||||
"""High level wrapper for the Input component."""
|
"""High level wrapper for the Input component."""
|
||||||
|
|
||||||
# The icon to render before the input.
|
|
||||||
icon: Var[str]
|
|
||||||
|
|
||||||
# Text field size "1" - "3"
|
# Text field size "1" - "3"
|
||||||
size: Var[LiteralTextFieldSize]
|
size: Var[LiteralTextFieldSize]
|
||||||
|
|
||||||
@ -124,9 +119,15 @@ class Input(RadixThemesComponent):
|
|||||||
# Placeholder text in the input
|
# Placeholder text in the input
|
||||||
placeholder: Var[str]
|
placeholder: Var[str]
|
||||||
|
|
||||||
|
# Indicates whether the input is read-only
|
||||||
|
read_only: Var[bool]
|
||||||
|
|
||||||
# Indicates that the input is required
|
# Indicates that the input is required
|
||||||
required: Var[bool]
|
required: Var[bool]
|
||||||
|
|
||||||
|
# Specifies the type of input
|
||||||
|
type: Var[str]
|
||||||
|
|
||||||
# Value of the input
|
# Value of the input
|
||||||
value: Var[str]
|
value: Var[str]
|
||||||
|
|
||||||
@ -140,34 +141,7 @@ class Input(RadixThemesComponent):
|
|||||||
Returns:
|
Returns:
|
||||||
The component.
|
The component.
|
||||||
"""
|
"""
|
||||||
input_props = {
|
return TextFieldInput.create(**props)
|
||||||
prop: props.pop(prop)
|
|
||||||
for prop in [
|
|
||||||
"auto_complete",
|
|
||||||
"default_value",
|
|
||||||
"disabled",
|
|
||||||
"max_length",
|
|
||||||
"min_length",
|
|
||||||
"name",
|
|
||||||
"placeholder",
|
|
||||||
"required",
|
|
||||||
"value",
|
|
||||||
"on_change",
|
|
||||||
"on_focus",
|
|
||||||
"on_blur",
|
|
||||||
"on_key_down",
|
|
||||||
"on_key_up",
|
|
||||||
]
|
|
||||||
if prop in props
|
|
||||||
}
|
|
||||||
|
|
||||||
icon = props.pop("icon", None)
|
|
||||||
|
|
||||||
return TextFieldRoot.create(
|
|
||||||
TextFieldSlot.create(Icon.create(tag=icon)) if icon else rx.fragment(),
|
|
||||||
TextFieldInput.create(**input_props),
|
|
||||||
**props,
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_event_triggers(self) -> Dict[str, Any]:
|
def get_event_triggers(self) -> Dict[str, Any]:
|
||||||
"""Get the event triggers that pass the component's value to the handler.
|
"""Get the event triggers that pass the component's value to the handler.
|
||||||
|
@ -9,11 +9,9 @@ from reflex.event import EventChain, EventHandler, EventSpec
|
|||||||
from reflex.style import Style
|
from reflex.style import Style
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
from typing import Any, Dict, Literal
|
from typing import Any, Dict, Literal
|
||||||
import reflex as rx
|
|
||||||
from reflex.components import el
|
from reflex.components import el
|
||||||
from reflex.components.component import Component
|
from reflex.components.component import Component
|
||||||
from reflex.components.core.debounce import DebounceInput
|
from reflex.components.core.debounce import DebounceInput
|
||||||
from reflex.components.lucide.icon import Icon
|
|
||||||
from reflex.constants import EventTriggers
|
from reflex.constants import EventTriggers
|
||||||
from reflex.vars import Var
|
from reflex.vars import Var
|
||||||
from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent
|
from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent
|
||||||
@ -712,7 +710,6 @@ class Input(RadixThemesComponent):
|
|||||||
def create( # type: ignore
|
def create( # type: ignore
|
||||||
cls,
|
cls,
|
||||||
*children,
|
*children,
|
||||||
icon: Optional[Union[Var[str], str]] = None,
|
|
||||||
size: Optional[
|
size: Optional[
|
||||||
Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
|
Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
|
||||||
] = None,
|
] = None,
|
||||||
@ -797,7 +794,9 @@ class Input(RadixThemesComponent):
|
|||||||
min_length: Optional[Union[Var[str], str]] = None,
|
min_length: Optional[Union[Var[str], str]] = None,
|
||||||
name: Optional[Union[Var[str], str]] = None,
|
name: Optional[Union[Var[str], str]] = None,
|
||||||
placeholder: Optional[Union[Var[str], str]] = None,
|
placeholder: Optional[Union[Var[str], str]] = None,
|
||||||
|
read_only: Optional[Union[Var[bool], bool]] = None,
|
||||||
required: Optional[Union[Var[bool], bool]] = None,
|
required: Optional[Union[Var[bool], bool]] = None,
|
||||||
|
type: Optional[Union[Var[str], str]] = None,
|
||||||
value: Optional[Union[Var[str], str]] = None,
|
value: Optional[Union[Var[str], str]] = None,
|
||||||
style: Optional[Style] = None,
|
style: Optional[Style] = None,
|
||||||
key: Optional[Any] = None,
|
key: Optional[Any] = None,
|
||||||
@ -864,7 +863,6 @@ class Input(RadixThemesComponent):
|
|||||||
"""Create an Input component.
|
"""Create an Input component.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
icon: The icon to render before the input.
|
|
||||||
size: Text field size "1" - "3"
|
size: Text field size "1" - "3"
|
||||||
variant: Variant of text field: "classic" | "surface" | "soft"
|
variant: Variant of text field: "classic" | "surface" | "soft"
|
||||||
color_scheme: Override theme color for text field
|
color_scheme: Override theme color for text field
|
||||||
@ -876,7 +874,9 @@ class Input(RadixThemesComponent):
|
|||||||
min_length: Specifies the minimum number of characters required in the input
|
min_length: Specifies the minimum number of characters required in the input
|
||||||
name: Name of the input, used when sending form data
|
name: Name of the input, used when sending form data
|
||||||
placeholder: Placeholder text in the input
|
placeholder: Placeholder text in the input
|
||||||
|
read_only: Indicates whether the input is read-only
|
||||||
required: Indicates that the input is required
|
required: Indicates that the input is required
|
||||||
|
type: Specifies the type of input
|
||||||
value: Value of the input
|
value: Value of the input
|
||||||
style: The style of the component.
|
style: The style of the component.
|
||||||
key: A unique key for the component.
|
key: A unique key for the component.
|
||||||
@ -900,7 +900,6 @@ class TextField(SimpleNamespace):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def __call__(
|
def __call__(
|
||||||
*children,
|
*children,
|
||||||
icon: Optional[Union[Var[str], str]] = None,
|
|
||||||
size: Optional[
|
size: Optional[
|
||||||
Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
|
Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
|
||||||
] = None,
|
] = None,
|
||||||
@ -985,7 +984,9 @@ class TextField(SimpleNamespace):
|
|||||||
min_length: Optional[Union[Var[str], str]] = None,
|
min_length: Optional[Union[Var[str], str]] = None,
|
||||||
name: Optional[Union[Var[str], str]] = None,
|
name: Optional[Union[Var[str], str]] = None,
|
||||||
placeholder: Optional[Union[Var[str], str]] = None,
|
placeholder: Optional[Union[Var[str], str]] = None,
|
||||||
|
read_only: Optional[Union[Var[bool], bool]] = None,
|
||||||
required: Optional[Union[Var[bool], bool]] = None,
|
required: Optional[Union[Var[bool], bool]] = None,
|
||||||
|
type: Optional[Union[Var[str], str]] = None,
|
||||||
value: Optional[Union[Var[str], str]] = None,
|
value: Optional[Union[Var[str], str]] = None,
|
||||||
style: Optional[Style] = None,
|
style: Optional[Style] = None,
|
||||||
key: Optional[Any] = None,
|
key: Optional[Any] = None,
|
||||||
@ -1052,7 +1053,6 @@ class TextField(SimpleNamespace):
|
|||||||
"""Create an Input component.
|
"""Create an Input component.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
icon: The icon to render before the input.
|
|
||||||
size: Text field size "1" - "3"
|
size: Text field size "1" - "3"
|
||||||
variant: Variant of text field: "classic" | "surface" | "soft"
|
variant: Variant of text field: "classic" | "surface" | "soft"
|
||||||
color_scheme: Override theme color for text field
|
color_scheme: Override theme color for text field
|
||||||
@ -1064,7 +1064,9 @@ class TextField(SimpleNamespace):
|
|||||||
min_length: Specifies the minimum number of characters required in the input
|
min_length: Specifies the minimum number of characters required in the input
|
||||||
name: Name of the input, used when sending form data
|
name: Name of the input, used when sending form data
|
||||||
placeholder: Placeholder text in the input
|
placeholder: Placeholder text in the input
|
||||||
|
read_only: Indicates whether the input is read-only
|
||||||
required: Indicates that the input is required
|
required: Indicates that the input is required
|
||||||
|
type: Specifies the type of input
|
||||||
value: Value of the input
|
value: Value of the input
|
||||||
style: The style of the component.
|
style: The style of the component.
|
||||||
key: A unique key for the component.
|
key: A unique key for the component.
|
||||||
|
Loading…
Reference in New Issue
Block a user